require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_SYS_ENDIAN_H_)) {
    eval 'sub _SYS_ENDIAN_H_ () {1;}' unless defined(&_SYS_ENDIAN_H_);
    require 'sys/cdefs.ph';
    eval 'sub _LITTLE_ENDIAN () {1234;}' unless defined(&_LITTLE_ENDIAN);
    eval 'sub _BIG_ENDIAN () {4321;}' unless defined(&_BIG_ENDIAN);
    eval 'sub _PDP_ENDIAN () {3412;}' unless defined(&_PDP_ENDIAN);
    if((defined(&__BSD_VISIBLE) ? &__BSD_VISIBLE : 0)) {
	eval 'sub LITTLE_ENDIAN () { &_LITTLE_ENDIAN;}' unless defined(&LITTLE_ENDIAN);
	eval 'sub BIG_ENDIAN () { &_BIG_ENDIAN;}' unless defined(&BIG_ENDIAN);
	eval 'sub PDP_ENDIAN () { &_PDP_ENDIAN;}' unless defined(&PDP_ENDIAN);
	eval 'sub BYTE_ORDER () { &_BYTE_ORDER;}' unless defined(&BYTE_ORDER);
    }
    if(defined(&__GNUC__)) {
	eval 'sub __swap16gen {
	    my($x) = @_;
    	    eval q( &__statement({  &__uint16_t  &__swap16gen_x = ($x); ( &__uint16_t)(( &__swap16gen_x & 0xff) << 8| ( &__swap16gen_x & 0xff00) >> 8); }));
	}' unless defined(&__swap16gen);
	eval 'sub __swap32gen {
	    my($x) = @_;
    	    eval q( &__statement({  &__uint32_t  &__swap32gen_x = ($x); ( &__uint32_t)(( &__swap32gen_x & 0xff) << 24| ( &__swap32gen_x & 0xff00) << 8| ( &__swap32gen_x & 0xff0000) >> 8| ( &__swap32gen_x & 0xff000000) >> 24); }));
	}' unless defined(&__swap32gen);
	eval 'sub __swap64gen {
	    my($x) = @_;
    	    eval q( &__statement({  &__uint64_t  &__swap64gen_x = ($x); ( &__uint64_t)(( &__swap64gen_x & 0xff) << 56| ( &__swap64gen_x & 0xff00) << 40| ( &__swap64gen_x & 0xff0000) << 24| ( &__swap64gen_x & 0xff000000) << 8| ( &__swap64gen_x & 1095216660480) >> 8| ( &__swap64gen_x & 280375465082880) >> 24| ( &__swap64gen_x & 7.17761190612173e+16) >> 40| ( &__swap64gen_x & 1.83746864796716e+19) >> 56); }));
	}' unless defined(&__swap64gen);
    } else {
	eval 'sub __swap16gen {
	    my($x) = @_;
    	    eval q(( &__uint16_t)((( &__uint16_t)($x) & 0xff) << 8| (( &__uint16_t)($x) & 0xff00) >> 8));
	}' unless defined(&__swap16gen);
	eval 'sub __swap32gen {
	    my($x) = @_;
    	    eval q(( &__uint32_t)((( &__uint32_t)($x) & 0xff) << 24| (( &__uint32_t)($x) & 0xff00) << 8| (( &__uint32_t)($x) & 0xff0000) >> 8| (( &__uint32_t)($x) & 0xff000000) >> 24));
	}' unless defined(&__swap32gen);
	eval 'sub __swap64gen {
	    my($x) = @_;
    	    eval q(( &__uint64_t)(((( &__uint64_t)($x) & 0xff) << 56) | (( &__uint64_t)($x) & 0xff00) << 40| (( &__uint64_t)($x) & 0xff0000) << 24| (( &__uint64_t)($x) & 0xff000000) << 8| (( &__uint64_t)($x) & 1095216660480) >> 8| (( &__uint64_t)($x) & 280375465082880) >> 24| (( &__uint64_t)($x) & 7.17761190612173e+16) >> 40| (( &__uint64_t)($x) & 1.83746864796716e+19) >> 56));
	}' unless defined(&__swap64gen);
    }
    if(defined(&MD_SWAP)) {
	if((defined(&__GNUC__) ? &__GNUC__ : 0)) {
	    eval 'sub __swap16 {
	        my($x) = @_;
    		eval q( &__statement({  &__uint16_t  &__swap16_x = ($x);  &__builtin_constant_p($x) ?  &__swap16gen( &__swap16_x) :  &__swap16md( &__swap16_x); }));
	    }' unless defined(&__swap16);
	    eval 'sub __swap32 {
	        my($x) = @_;
    		eval q( &__statement({  &__uint32_t  &__swap32_x = ($x);  &__builtin_constant_p($x) ?  &__swap32gen( &__swap32_x) :  &__swap32md( &__swap32_x); }));
	    }' unless defined(&__swap32);
	    eval 'sub __swap64 {
	        my($x) = @_;
    		eval q( &__statement({  &__uint64_t  &__swap64_x = ($x);  &__builtin_constant_p($x) ?  &__swap64gen( &__swap64_x) :  &__swap64md( &__swap64_x); }));
	    }' unless defined(&__swap64);
	}
    } else {
	eval 'sub __swap16 () { &__swap16gen;}' unless defined(&__swap16);
	eval 'sub __swap32 () { &__swap32gen;}' unless defined(&__swap32);
	eval 'sub __swap64 () { &__swap64gen;}' unless defined(&__swap64);
    }
    eval 'sub __swap16_multi {
        my($v, $n) = @_;
	    eval q( &do {  &__size_t  &__swap16_multi_n = ($n);  &__uint16_t * &__swap16_multi_v = ($v);  &while ( &__swap16_multi_n) { * &__swap16_multi_v =  &swap16(* &__swap16_multi_v);  &__swap16_multi_v++;  &__swap16_multi_n--; } }  &while (0));
    }' unless defined(&__swap16_multi);
    if((defined(&__BSD_VISIBLE) ? &__BSD_VISIBLE : 0)) {
	eval 'sub swap16 () { &__swap16;}' unless defined(&swap16);
	eval 'sub swap32 () { &__swap32;}' unless defined(&swap32);
	eval 'sub swap64 () { &__swap64;}' unless defined(&swap64);
	eval 'sub swap16_multi () { &__swap16_multi;}' unless defined(&swap16_multi);
    }
    if((defined(&_BYTE_ORDER) ? &_BYTE_ORDER : 0) == (defined(&_LITTLE_ENDIAN) ? &_LITTLE_ENDIAN : 0)) {
	unless(defined(&_QUAD_HIGHWORD)) {
	    eval 'sub _QUAD_HIGHWORD () {1;}' unless defined(&_QUAD_HIGHWORD);
	}
	unless(defined(&_QUAD_LOWWORD)) {
	    eval 'sub _QUAD_LOWWORD () {0;}' unless defined(&_QUAD_LOWWORD);
	}
	if((defined(&__BSD_VISIBLE) ? &__BSD_VISIBLE : 0)) {
	    eval 'sub htobe16 () { &__swap16;}' unless defined(&htobe16);
	    eval 'sub htobe32 () { &__swap32;}' unless defined(&htobe32);
	    eval 'sub htobe64 () { &__swap64;}' unless defined(&htobe64);
	    eval 'sub betoh16 () { &__swap16;}' unless defined(&betoh16);
	    eval 'sub betoh32 () { &__swap32;}' unless defined(&betoh32);
	    eval 'sub betoh64 () { &__swap64;}' unless defined(&betoh64);
	    eval 'sub htole16 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&htole16);
	    eval 'sub htole32 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&htole32);
	    eval 'sub htole64 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&htole64);
	    eval 'sub letoh16 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&letoh16);
	    eval 'sub letoh32 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&letoh32);
	    eval 'sub letoh64 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&letoh64);
	}
	eval 'sub htons {
	    my($x) = @_;
    	    eval q( &__swap16($x));
	}' unless defined(&htons);
	eval 'sub htonl {
	    my($x) = @_;
    	    eval q( &__swap32($x));
	}' unless defined(&htonl);
	eval 'sub ntohs {
	    my($x) = @_;
    	    eval q( &__swap16($x));
	}' unless defined(&ntohs);
	eval 'sub ntohl {
	    my($x) = @_;
    	    eval q( &__swap32($x));
	}' unless defined(&ntohl);
    }
    if((defined(&_BYTE_ORDER) ? &_BYTE_ORDER : 0) == (defined(&_BIG_ENDIAN) ? &_BIG_ENDIAN : 0)) {
	unless(defined(&_QUAD_HIGHWORD)) {
	    eval 'sub _QUAD_HIGHWORD () {0;}' unless defined(&_QUAD_HIGHWORD);
	}
	unless(defined(&_QUAD_LOWWORD)) {
	    eval 'sub _QUAD_LOWWORD () {1;}' unless defined(&_QUAD_LOWWORD);
	}
	if((defined(&__BSD_VISIBLE) ? &__BSD_VISIBLE : 0)) {
	    eval 'sub htole16 () { &__swap16;}' unless defined(&htole16);
	    eval 'sub htole32 () { &__swap32;}' unless defined(&htole32);
	    eval 'sub htole64 () { &__swap64;}' unless defined(&htole64);
	    eval 'sub letoh16 () { &__swap16;}' unless defined(&letoh16);
	    eval 'sub letoh32 () { &__swap32;}' unless defined(&letoh32);
	    eval 'sub letoh64 () { &__swap64;}' unless defined(&letoh64);
	    eval 'sub htobe16 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&htobe16);
	    eval 'sub htobe32 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&htobe32);
	    eval 'sub htobe64 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&htobe64);
	    eval 'sub betoh16 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&betoh16);
	    eval 'sub betoh32 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&betoh32);
	    eval 'sub betoh64 {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&betoh64);
	}
	eval 'sub htons {
	    my($x) = @_;
    	    eval q(($x));
	}' unless defined(&htons);
	eval 'sub htonl {
	    my($x) = @_;
    	    eval q(($x));
	}' unless defined(&htonl);
	eval 'sub ntohs {
	    my($x) = @_;
    	    eval q(($x));
	}' unless defined(&ntohs);
	eval 'sub ntohl {
	    my($x) = @_;
    	    eval q(($x));
	}' unless defined(&ntohl);
    }
    if((defined(&__BSD_VISIBLE) ? &__BSD_VISIBLE : 0)) {
	eval 'sub NTOHL {
	    my($x) = @_;
    	    eval q(($x) =  &ntohl(( &u_int32_t)($x)));
	}' unless defined(&NTOHL);
	eval 'sub NTOHS {
	    my($x) = @_;
    	    eval q(($x) =  &ntohs(( &u_int16_t)($x)));
	}' unless defined(&NTOHS);
	eval 'sub HTONL {
	    my($x) = @_;
    	    eval q(($x) =  &htonl(( &u_int32_t)($x)));
	}' unless defined(&HTONL);
	eval 'sub HTONS {
	    my($x) = @_;
    	    eval q(($x) =  &htons(( &u_int16_t)($x)));
	}' unless defined(&HTONS);
    }
}
1;
