require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_I386_ENDIAN_H_)) {
    eval 'sub _I386_ENDIAN_H_ () {1;}' unless defined(&_I386_ENDIAN_H_);
    if(defined(&__GNUC__)) {
	if(defined( &_KERNEL)  && !defined( &I386_CPU)) {
	    eval 'sub __swap32md {
	        local($x) = @_;
    		eval q(({  &u_int32_t  &__swap32md_x = ($x);  &__asm (\\"bswap %1\\" : \\"+r\\" ( &__swap32md_x));  &__swap32md_x; }));
	    }' unless defined(&__swap32md);
	} else {
	    eval 'sub __swap32md {
	        local($x) = @_;
    		eval q(({  &u_int32_t  &__swap32md_x = ($x);  &__asm (\\"rorw $8, %w1; rorl $16, %1; rorw $8, %w1\\" : \\"+r\\" ( &__swap32md_x));  &__swap32md_x; }));
	    }' unless defined(&__swap32md);
	}
	eval 'sub __swap64md {
	    local($x) = @_;
    	    eval q(({  &u_int64_t  &__swap64md_x = ($x); ( &u_int64_t) &__swap32md( &__swap64md_x >> 32) | ( &u_int64_t) &__swap32md( &__swap64md_x & 0xffffffff) << 32; }));
	}' unless defined(&__swap64md);
	eval 'sub __swap16md {
	    local($x) = @_;
    	    eval q(({  &u_int16_t  &__swap16md_x = ($x);  &__asm (\\"rorw $8, %w1\\" : \\"+r\\" ( &__swap16md_x));  &__swap16md_x; }));
	}' unless defined(&__swap16md);
	eval 'sub MD_SWAP () {1;}' unless defined(&MD_SWAP);
    }
    eval 'sub _BYTE_ORDER () { &_LITTLE_ENDIAN;}' unless defined(&_BYTE_ORDER);
    require 'sys/endian.ph';
}
1;
