require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_SYS_SOCKET_H_)) {
    eval 'sub _SYS_SOCKET_H_ () {1;}' unless defined(&_SYS_SOCKET_H_);
    require 'machine/param.ph';
    eval 'sub SOCK_STREAM () {1;}' unless defined(&SOCK_STREAM);
    eval 'sub SOCK_DGRAM () {2;}' unless defined(&SOCK_DGRAM);
    eval 'sub SOCK_RAW () {3;}' unless defined(&SOCK_RAW);
    eval 'sub SOCK_RDM () {4;}' unless defined(&SOCK_RDM);
    eval 'sub SOCK_SEQPACKET () {5;}' unless defined(&SOCK_SEQPACKET);
    eval 'sub SO_DEBUG () {0x1;}' unless defined(&SO_DEBUG);
    eval 'sub SO_ACCEPTCONN () {0x2;}' unless defined(&SO_ACCEPTCONN);
    eval 'sub SO_REUSEADDR () {0x4;}' unless defined(&SO_REUSEADDR);
    eval 'sub SO_KEEPALIVE () {0x8;}' unless defined(&SO_KEEPALIVE);
    eval 'sub SO_DONTROUTE () {0x10;}' unless defined(&SO_DONTROUTE);
    eval 'sub SO_BROADCAST () {0x20;}' unless defined(&SO_BROADCAST);
    eval 'sub SO_USELOOPBACK () {0x40;}' unless defined(&SO_USELOOPBACK);
    eval 'sub SO_LINGER () {0x80;}' unless defined(&SO_LINGER);
    eval 'sub SO_OOBINLINE () {0x100;}' unless defined(&SO_OOBINLINE);
    eval 'sub SO_REUSEPORT () {0x200;}' unless defined(&SO_REUSEPORT);
    eval 'sub SO_JUMBO () {0x400;}' unless defined(&SO_JUMBO);
    eval 'sub SO_SNDBUF () {0x1001;}' unless defined(&SO_SNDBUF);
    eval 'sub SO_RCVBUF () {0x1002;}' unless defined(&SO_RCVBUF);
    eval 'sub SO_SNDLOWAT () {0x1003;}' unless defined(&SO_SNDLOWAT);
    eval 'sub SO_RCVLOWAT () {0x1004;}' unless defined(&SO_RCVLOWAT);
    eval 'sub SO_SNDTIMEO () {0x1005;}' unless defined(&SO_SNDTIMEO);
    eval 'sub SO_RCVTIMEO () {0x1006;}' unless defined(&SO_RCVTIMEO);
    eval 'sub SO_ERROR () {0x1007;}' unless defined(&SO_ERROR);
    eval 'sub SO_TYPE () {0x1008;}' unless defined(&SO_TYPE);
    eval 'sub SO_NETPROC () {0x1020;}' unless defined(&SO_NETPROC);
    eval 'sub SOL_SOCKET () {0xffff;}' unless defined(&SOL_SOCKET);
    eval 'sub AF_UNSPEC () {0;}' unless defined(&AF_UNSPEC);
    eval 'sub AF_LOCAL () {1;}' unless defined(&AF_LOCAL);
    eval 'sub AF_UNIX () { &AF_LOCAL;}' unless defined(&AF_UNIX);
    eval 'sub AF_INET () {2;}' unless defined(&AF_INET);
    eval 'sub AF_IMPLINK () {3;}' unless defined(&AF_IMPLINK);
    eval 'sub AF_PUP () {4;}' unless defined(&AF_PUP);
    eval 'sub AF_CHAOS () {5;}' unless defined(&AF_CHAOS);
    eval 'sub AF_NS () {6;}' unless defined(&AF_NS);
    eval 'sub AF_ISO () {7;}' unless defined(&AF_ISO);
    eval 'sub AF_OSI () { &AF_ISO;}' unless defined(&AF_OSI);
    eval 'sub AF_ECMA () {8;}' unless defined(&AF_ECMA);
    eval 'sub AF_DATAKIT () {9;}' unless defined(&AF_DATAKIT);
    eval 'sub AF_CCITT () {10;}' unless defined(&AF_CCITT);
    eval 'sub AF_SNA () {11;}' unless defined(&AF_SNA);
    eval 'sub AF_DECnet () {12;}' unless defined(&AF_DECnet);
    eval 'sub AF_DLI () {13;}' unless defined(&AF_DLI);
    eval 'sub AF_LAT () {14;}' unless defined(&AF_LAT);
    eval 'sub AF_HYLINK () {15;}' unless defined(&AF_HYLINK);
    eval 'sub AF_APPLETALK () {16;}' unless defined(&AF_APPLETALK);
    eval 'sub AF_ROUTE () {17;}' unless defined(&AF_ROUTE);
    eval 'sub AF_LINK () {18;}' unless defined(&AF_LINK);
    eval 'sub pseudo_AF_XTP () {19;}' unless defined(&pseudo_AF_XTP);
    eval 'sub AF_COIP () {20;}' unless defined(&AF_COIP);
    eval 'sub AF_CNT () {21;}' unless defined(&AF_CNT);
    eval 'sub pseudo_AF_RTIP () {22;}' unless defined(&pseudo_AF_RTIP);
    eval 'sub AF_IPX () {23;}' unless defined(&AF_IPX);
    eval 'sub AF_INET6 () {24;}' unless defined(&AF_INET6);
    eval 'sub pseudo_AF_PIP () {25;}' unless defined(&pseudo_AF_PIP);
    eval 'sub AF_ISDN () {26;}' unless defined(&AF_ISDN);
    eval 'sub AF_E164 () { &AF_ISDN;}' unless defined(&AF_E164);
    eval 'sub AF_NATM () {27;}' unless defined(&AF_NATM);
    eval 'sub AF_ENCAP () {28;}' unless defined(&AF_ENCAP);
    eval 'sub AF_SIP () {29;}' unless defined(&AF_SIP);
    eval 'sub AF_KEY () {30;}' unless defined(&AF_KEY);
    eval 'sub pseudo_AF_HDRCMPLT () {31;}' unless defined(&pseudo_AF_HDRCMPLT);
    eval 'sub AF_BLUETOOTH () {32;}' unless defined(&AF_BLUETOOTH);
    eval 'sub AF_MAX () {33;}' unless defined(&AF_MAX);
    eval 'sub PF_UNSPEC () { &AF_UNSPEC;}' unless defined(&PF_UNSPEC);
    eval 'sub PF_LOCAL () { &AF_LOCAL;}' unless defined(&PF_LOCAL);
    eval 'sub PF_UNIX () { &PF_LOCAL;}' unless defined(&PF_UNIX);
    eval 'sub PF_INET () { &AF_INET;}' unless defined(&PF_INET);
    eval 'sub PF_IMPLINK () { &AF_IMPLINK;}' unless defined(&PF_IMPLINK);
    eval 'sub PF_PUP () { &AF_PUP;}' unless defined(&PF_PUP);
    eval 'sub PF_CHAOS () { &AF_CHAOS;}' unless defined(&PF_CHAOS);
    eval 'sub PF_NS () { &AF_NS;}' unless defined(&PF_NS);
    eval 'sub PF_ISO () { &AF_ISO;}' unless defined(&PF_ISO);
    eval 'sub PF_OSI () { &AF_ISO;}' unless defined(&PF_OSI);
    eval 'sub PF_ECMA () { &AF_ECMA;}' unless defined(&PF_ECMA);
    eval 'sub PF_DATAKIT () { &AF_DATAKIT;}' unless defined(&PF_DATAKIT);
    eval 'sub PF_CCITT () { &AF_CCITT;}' unless defined(&PF_CCITT);
    eval 'sub PF_SNA () { &AF_SNA;}' unless defined(&PF_SNA);
    eval 'sub PF_DECnet () { &AF_DECnet;}' unless defined(&PF_DECnet);
    eval 'sub PF_DLI () { &AF_DLI;}' unless defined(&PF_DLI);
    eval 'sub PF_LAT () { &AF_LAT;}' unless defined(&PF_LAT);
    eval 'sub PF_HYLINK () { &AF_HYLINK;}' unless defined(&PF_HYLINK);
    eval 'sub PF_APPLETALK () { &AF_APPLETALK;}' unless defined(&PF_APPLETALK);
    eval 'sub PF_ROUTE () { &AF_ROUTE;}' unless defined(&PF_ROUTE);
    eval 'sub PF_LINK () { &AF_LINK;}' unless defined(&PF_LINK);
    eval 'sub PF_XTP () { &pseudo_AF_XTP;}' unless defined(&PF_XTP);
    eval 'sub PF_COIP () { &AF_COIP;}' unless defined(&PF_COIP);
    eval 'sub PF_CNT () { &AF_CNT;}' unless defined(&PF_CNT);
    eval 'sub PF_IPX () { &AF_IPX;}' unless defined(&PF_IPX);
    eval 'sub PF_INET6 () { &AF_INET6;}' unless defined(&PF_INET6);
    eval 'sub PF_RTIP () { &pseudo_AF_RTIP;}' unless defined(&PF_RTIP);
    eval 'sub PF_PIP () { &pseudo_AF_PIP;}' unless defined(&PF_PIP);
    eval 'sub PF_ISDN () { &AF_ISDN;}' unless defined(&PF_ISDN);
    eval 'sub PF_NATM () { &AF_NATM;}' unless defined(&PF_NATM);
    eval 'sub PF_ENCAP () { &AF_ENCAP;}' unless defined(&PF_ENCAP);
    eval 'sub PF_SIP () { &AF_SIP;}' unless defined(&PF_SIP);
    eval 'sub PF_KEY () { &AF_KEY;}' unless defined(&PF_KEY);
    eval 'sub PF_BPF () { &pseudo_AF_HDRCMPLT;}' unless defined(&PF_BPF);
    eval 'sub PF_BLUETOOTH () { &AF_BLUETOOTH;}' unless defined(&PF_BLUETOOTH);
    eval 'sub PF_MAX () { &AF_MAX;}' unless defined(&PF_MAX);
    eval 'sub SHUT_RD () {0;}' unless defined(&SHUT_RD);
    eval 'sub SHUT_WR () {1;}' unless defined(&SHUT_WR);
    eval 'sub SHUT_RDWR () {2;}' unless defined(&SHUT_RDWR);
    eval 'sub SOCKCREDSIZE {
        my($ngrps) = @_;
	    eval q(($sizeof{\'struct sockcred\'} + ($sizeof{ &gid_t} * (($ngrps) - 1))));
    }' unless defined(&SOCKCREDSIZE);
    eval 'sub NET_MAXID () { &AF_MAX;}' unless defined(&NET_MAXID);
    eval 'sub CTL_NET_NAMES () {{ { 0, 0}, { "unix",  &CTLTYPE_NODE }, { "inet",  &CTLTYPE_NODE }, { "implink",  &CTLTYPE_NODE }, { "pup",  &CTLTYPE_NODE }, { "chaos",  &CTLTYPE_NODE }, { "xerox_ns",  &CTLTYPE_NODE }, { "iso",  &CTLTYPE_NODE }, { "emca",  &CTLTYPE_NODE }, { "datakit",  &CTLTYPE_NODE }, { "ccitt",  &CTLTYPE_NODE }, { "ibm_sna",  &CTLTYPE_NODE }, { "decnet",  &CTLTYPE_NODE }, { "dec_dli",  &CTLTYPE_NODE }, { "lat",  &CTLTYPE_NODE }, { "hylink",  &CTLTYPE_NODE }, { "appletalk",  &CTLTYPE_NODE }, { "route",  &CTLTYPE_NODE }, { "link_layer",  &CTLTYPE_NODE }, { "xtp",  &CTLTYPE_NODE }, { "coip",  &CTLTYPE_NODE }, { "cnt",  &CTLTYPE_NODE }, { "rtip",  &CTLTYPE_NODE }, { "ipx",  &CTLTYPE_NODE }, { "inet6",  &CTLTYPE_NODE }, { "pip",  &CTLTYPE_NODE }, { "isdn",  &CTLTYPE_NODE }, { "natm",  &CTLTYPE_NODE }, { "encap",  &CTLTYPE_NODE }, { "sip",  &CTLTYPE_NODE }, { "key",  &CTLTYPE_NODE }, { "bpf",  &CTLTYPE_NODE }, };}' unless defined(&CTL_NET_NAMES);
    eval 'sub NET_RT_DUMP () {1;}' unless defined(&NET_RT_DUMP);
    eval 'sub NET_RT_FLAGS () {2;}' unless defined(&NET_RT_FLAGS);
    eval 'sub NET_RT_IFLIST () {3;}' unless defined(&NET_RT_IFLIST);
    eval 'sub NET_RT_STATS () {4;}' unless defined(&NET_RT_STATS);
    eval 'sub NET_RT_MAXID () {5;}' unless defined(&NET_RT_MAXID);
    eval 'sub CTL_NET_RT_NAMES () {{ { 0, 0}, { "dump",  &CTLTYPE_STRUCT }, { "flags",  &CTLTYPE_STRUCT }, { "iflist",  &CTLTYPE_STRUCT }, { "stats",  &CTLTYPE_STRUCT }, };}' unless defined(&CTL_NET_RT_NAMES);
    eval 'sub NET_KEY_SADB_DUMP () {1;}' unless defined(&NET_KEY_SADB_DUMP);
    eval 'sub NET_KEY_SPD_DUMP () {2;}' unless defined(&NET_KEY_SPD_DUMP);
    eval 'sub NET_KEY_MAXID () {3;}' unless defined(&NET_KEY_MAXID);
    eval 'sub CTL_NET_KEY_NAMES () {{ { 0, 0}, { "sadb_dump",  &CTLTYPE_STRUCT }, { "spd_dump",  &CTLTYPE_STRUCT }, };}' unless defined(&CTL_NET_KEY_NAMES);
    eval 'sub NET_BPF_BUFSIZE () {1;}' unless defined(&NET_BPF_BUFSIZE);
    eval 'sub NET_BPF_MAXBUFSIZE () {2;}' unless defined(&NET_BPF_MAXBUFSIZE);
    eval 'sub NET_BPF_MAXID () {3;}' unless defined(&NET_BPF_MAXID);
    eval 'sub CTL_NET_BPF_NAMES () {{ { 0, 0}, { "bufsize",  &CTLTYPE_INT }, { "maxbufsize",  &CTLTYPE_INT }, };}' unless defined(&CTL_NET_BPF_NAMES);
    eval 'sub SOMAXCONN () {128;}' unless defined(&SOMAXCONN);
    eval 'sub MSG_OOB () {0x1;}' unless defined(&MSG_OOB);
    eval 'sub MSG_PEEK () {0x2;}' unless defined(&MSG_PEEK);
    eval 'sub MSG_DONTROUTE () {0x4;}' unless defined(&MSG_DONTROUTE);
    eval 'sub MSG_EOR () {0x8;}' unless defined(&MSG_EOR);
    eval 'sub MSG_TRUNC () {0x10;}' unless defined(&MSG_TRUNC);
    eval 'sub MSG_CTRUNC () {0x20;}' unless defined(&MSG_CTRUNC);
    eval 'sub MSG_WAITALL () {0x40;}' unless defined(&MSG_WAITALL);
    eval 'sub MSG_DONTWAIT () {0x80;}' unless defined(&MSG_DONTWAIT);
    eval 'sub MSG_BCAST () {0x100;}' unless defined(&MSG_BCAST);
    eval 'sub MSG_MCAST () {0x200;}' unless defined(&MSG_MCAST);
    eval 'sub CMSG_DATA {
        my($cmsg) = @_;
	    eval q((($cmsg) +  &__CMSG_ALIGN($sizeof{\'struct cmsghdr\'})));
    }' unless defined(&CMSG_DATA);
    eval 'sub CMSG_NXTHDR {
        my($mhdr, $cmsg) = @_;
	    eval q((( +  &__CMSG_ALIGN(-> &cmsg_len) +  &__CMSG_ALIGN > (($mhdr)-> &msg_control) + ($mhdr)-> &msg_controllen) ?  &NULL : (($cmsg) +  &__CMSG_ALIGN(($cmsg)-> &cmsg_len))));
    }' unless defined(&CMSG_NXTHDR);
    eval 'sub CMSG_FIRSTHDR {
        my($mhdr) = @_;
	    eval q((($mhdr)-> &msg_controllen >= $sizeof{\'struct cmsghdr\'} ? ($mhdr)-> &msg_control :  &NULL));
    }' unless defined(&CMSG_FIRSTHDR);
    eval 'sub __CMSG_ALIGN {
        my($len) = @_;
	    eval q( &ALIGN($len));
    }' unless defined(&__CMSG_ALIGN);
    if(defined(&_KERNEL)) {
	eval 'sub CMSG_ALIGN {
	    my($n) = @_;
    	    eval q( &__CMSG_ALIGN($n));
	}' unless defined(&CMSG_ALIGN);
    }
    eval 'sub CMSG_LEN {
        my($len) = @_;
	    eval q(( &__CMSG_ALIGN($sizeof{\'struct cmsghdr\'}) + ($len)));
    }' unless defined(&CMSG_LEN);
    eval 'sub CMSG_SPACE {
        my($len) = @_;
	    eval q(( &__CMSG_ALIGN($sizeof{\'struct cmsghdr\'}) +  &__CMSG_ALIGN($len)));
    }' unless defined(&CMSG_SPACE);
    eval 'sub SCM_RIGHTS () {0x1;}' unless defined(&SCM_RIGHTS);
    eval 'sub SCM_CREDS () {0x2;}' unless defined(&SCM_CREDS);
    eval 'sub SA_LEN {
        my($x) = @_;
	    eval q((($x)-> &sa_len));
    }' unless defined(&SA_LEN);
    unless(defined(&_KERNEL)) {
	require 'sys/cdefs.ph';
    } else {
	if(defined( &COMPAT_43) || defined( &COMPAT_SUNOS) || defined( &COMPAT_LINUX) || defined( &COMPAT_HPUX) || defined( &COMPAT_FREEBSD) || defined( &COMPAT_BSDOS) || defined( &COMPAT_OSF1)) {
	    eval 'sub COMPAT_OLDSOCK () {1;}' unless defined(&COMPAT_OLDSOCK);
	    eval 'sub MSG_COMPAT () {0x8000;}' unless defined(&MSG_COMPAT);
	}
    }
}
1;
