require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&FATNUM)) {
    sub FATNUM () {	0xf;}
}
unless(defined(&FATMIRROR)) {
    sub FATMIRROR () {	0x80;}
}
unless(defined(&FSVERS)) {
    sub FSVERS () {	0;}
}
require 'machine/endian.ph';
if(((defined(&BYTE_ORDER) ? &BYTE_ORDER : undef) == (defined(&LITTLE_ENDIAN) ? &LITTLE_ENDIAN : undef))  && !defined( &__STRICT_ALIGNMENT)) {
    eval 'sub getushort {
        my($x) = @_;
	    eval q(*(( &u_int16_t *)($x)));
    }' unless defined(&getushort);
    eval 'sub getulong {
        my($x) = @_;
	    eval q(*(( &u_int32_t *)($x)));
    }' unless defined(&getulong);
    eval 'sub putushort {
        my($p, $v) = @_;
	    eval q((*(( &u_int16_t *)($p)) = ($v)));
    }' unless defined(&putushort);
    eval 'sub putulong {
        my($p, $v) = @_;
	    eval q((*(( &u_int32_t *)($p)) = ($v)));
    }' unless defined(&putulong);
} else {
    eval 'sub getushort {
        my($x) = @_;
	    eval q(((( &u_int8_t *)($x))[0] + ((( &u_int8_t *)($x))[1] << 8)));
    }' unless defined(&getushort);
    eval 'sub getulong {
        my($x) = @_;
	    eval q(((( &u_int8_t *)($x))[0] + ((( &u_int8_t *)($x))[1] << 8) + ((( &u_int8_t *)($x))[2] << 16) + ((( &u_int8_t *)($x))[3] << 24)));
    }' unless defined(&getulong);
    eval 'sub putushort {
        my($p, $v) = @_;
	    eval q(((( &u_int8_t *)($p))[0] = ($v), (( &u_int8_t *)($p))[1] = ($v) >> 8));
    }' unless defined(&putushort);
    eval 'sub putulong {
        my($p, $v) = @_;
	    eval q(((( &u_int8_t *)($p))[0] = ($v), (( &u_int8_t *)($p))[1] = ($v) >> 8, (( &u_int8_t *)($p))[2] = ($v) >> 16, (( &u_int8_t *)($p))[3] = ($v) >> 24));
    }' unless defined(&putulong);
}
1;
