require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_MACHINE_FPU_H_)) {
    eval 'sub _MACHINE_FPU_H_ () {1;}' unless defined(&_MACHINE_FPU_H_);
    eval 'sub _FP_C_DEF {
        my($n) = @_;
	    eval q((1 << ($n)));
    }' unless defined(&_FP_C_DEF);
    eval 'sub FPCR_SUM () { &_FP_C_DEF(63);}' unless defined(&FPCR_SUM);
    eval 'sub FPCR_INED () { &_FP_C_DEF(62);}' unless defined(&FPCR_INED);
    eval 'sub FPCR_UNFD () { &_FP_C_DEF(61);}' unless defined(&FPCR_UNFD);
    eval 'sub FPCR_UNDZ () { &_FP_C_DEF(60);}' unless defined(&FPCR_UNDZ);
    eval 'sub FPCR_DYN {
        my($rm) = @_;
	    eval q((($rm) << 58));
    }' unless defined(&FPCR_DYN);
    eval 'sub FPCR_IOV () { &_FP_C_DEF(57);}' unless defined(&FPCR_IOV);
    eval 'sub FPCR_INE () { &_FP_C_DEF(56);}' unless defined(&FPCR_INE);
    eval 'sub FPCR_UNF () { &_FP_C_DEF(55);}' unless defined(&FPCR_UNF);
    eval 'sub FPCR_OVF () { &_FP_C_DEF(54);}' unless defined(&FPCR_OVF);
    eval 'sub FPCR_DZE () { &_FP_C_DEF(53);}' unless defined(&FPCR_DZE);
    eval 'sub FPCR_INV () { &_FP_C_DEF(52);}' unless defined(&FPCR_INV);
    eval 'sub FPCR_OVFD () { &_FP_C_DEF(51);}' unless defined(&FPCR_OVFD);
    eval 'sub FPCR_DZED () { &_FP_C_DEF(50);}' unless defined(&FPCR_DZED);
    eval 'sub FPCR_INVD () { &_FP_C_DEF(49);}' unless defined(&FPCR_INVD);
    eval 'sub FPCR_DNZ () { &_FP_C_DEF(48);}' unless defined(&FPCR_DNZ);
    eval 'sub FPCR_DNOD () { &_FP_C_DEF(47);}' unless defined(&FPCR_DNOD);
    eval 'sub FPCR_MIRRORED () {( &FPCR_INE |  &FPCR_UNF |  &FPCR_OVF |  &FPCR_DZE |  &FPCR_INV);}' unless defined(&FPCR_MIRRORED);
    eval 'sub FPCR_MIR_START () {52;}' unless defined(&FPCR_MIR_START);
    eval 'sub IEEE_STATUS_DNO () { &_FP_C_DEF(22);}' unless defined(&IEEE_STATUS_DNO);
    eval 'sub IEEE_STATUS_INE () { &_FP_C_DEF(21);}' unless defined(&IEEE_STATUS_INE);
    eval 'sub IEEE_STATUS_UNF () { &_FP_C_DEF(20);}' unless defined(&IEEE_STATUS_UNF);
    eval 'sub IEEE_STATUS_OVF () { &_FP_C_DEF(19);}' unless defined(&IEEE_STATUS_OVF);
    eval 'sub IEEE_STATUS_DZE () { &_FP_C_DEF(18);}' unless defined(&IEEE_STATUS_DZE);
    eval 'sub IEEE_STATUS_INV () { &_FP_C_DEF(17);}' unless defined(&IEEE_STATUS_INV);
    eval 'sub IEEE_TRAP_ENABLE_DNO () { &_FP_C_DEF(6);}' unless defined(&IEEE_TRAP_ENABLE_DNO);
    eval 'sub IEEE_TRAP_ENABLE_INE () { &_FP_C_DEF(5);}' unless defined(&IEEE_TRAP_ENABLE_INE);
    eval 'sub IEEE_TRAP_ENABLE_UNF () { &_FP_C_DEF(4);}' unless defined(&IEEE_TRAP_ENABLE_UNF);
    eval 'sub IEEE_TRAP_ENABLE_OVF () { &_FP_C_DEF(3);}' unless defined(&IEEE_TRAP_ENABLE_OVF);
    eval 'sub IEEE_TRAP_ENABLE_DZE () { &_FP_C_DEF(2);}' unless defined(&IEEE_TRAP_ENABLE_DZE);
    eval 'sub IEEE_TRAP_ENABLE_INV () { &_FP_C_DEF(1);}' unless defined(&IEEE_TRAP_ENABLE_INV);
    eval 'sub IEEE_INHERIT () { &_FP_C_DEF(14);}' unless defined(&IEEE_INHERIT);
    eval 'sub IEEE_MAP_UMZ () { &_FP_C_DEF(13);}' unless defined(&IEEE_MAP_UMZ);
    eval 'sub IEEE_MAP_DMZ () { &_FP_C_DEF(12);}' unless defined(&IEEE_MAP_DMZ);
    eval 'sub FP_C_MIRRORED () {( &IEEE_STATUS_INE |  &IEEE_STATUS_UNF |  &IEEE_STATUS_OVF |  &IEEE_STATUS_DZE |  &IEEE_STATUS_INV);}' unless defined(&FP_C_MIRRORED);
    eval 'sub FP_C_MIR_START () {17;}' unless defined(&FP_C_MIR_START);
    if(defined(&_KERNEL)) {
	eval 'sub FLD_MASK {
	    my($len) = @_;
    	    eval q(((1 << ($len)) - 1));
	}' unless defined(&FLD_MASK);
	eval 'sub FLD_CLEAR {
	    my($obj, $origin, $len) = @_;
    	    eval q((($obj) & ~( &FLD_MASK($len) << ($origin))));
	}' unless defined(&FLD_CLEAR);
	eval 'sub FLD_INSERT {
	    my($obj, $origin, $len, $value) = @_;
    	    eval q(( &FLD_CLEAR($obj, $origin, $len) | ($value) << $origin));
	}' unless defined(&FLD_INSERT);
	eval 'sub FP_C_TO_OPENBSD_MASK {
	    my($fp_c) = @_;
    	    eval q((($fp_c) >> 1& 0x3f));
	}' unless defined(&FP_C_TO_OPENBSD_MASK);
	eval 'sub FP_C_TO_OPENBSD_FLAG {
	    my($fp_c) = @_;
    	    eval q((($fp_c) >> 17& 0x3f));
	}' unless defined(&FP_C_TO_OPENBSD_FLAG);
	eval 'sub OPENBSD_MASK_TO_FP_C {
	    my($m) = @_;
    	    eval q(((($m) & 0x3f) << 1));
	}' unless defined(&OPENBSD_MASK_TO_FP_C);
	eval 'sub OPENBSD_FLAG_TO_FP_C {
	    my($s) = @_;
    	    eval q(((($s) & 0x3f) << 17));
	}' unless defined(&OPENBSD_FLAG_TO_FP_C);
	eval 'sub CLEAR_FP_C_MASK {
	    my($fp_c) = @_;
    	    eval q((($fp_c) & ~(0x3f << 1)));
	}' unless defined(&CLEAR_FP_C_MASK);
	eval 'sub CLEAR_FP_C_FLAG {
	    my($fp_c) = @_;
    	    eval q((($fp_c) & ~(0x3f << 17)));
	}' unless defined(&CLEAR_FP_C_FLAG);
	eval 'sub SET_FP_C_MASK {
	    my($fp_c, $m) = @_;
    	    eval q(( &CLEAR_FP_C_MASK($fp_c) |  &OPENBSD_MASK_TO_FP_C($m)));
	}' unless defined(&SET_FP_C_MASK);
	eval 'sub SET_FP_C_FLAG {
	    my($fp_c, $m) = @_;
    	    eval q(( &CLEAR_FP_C_FLAG($fp_c) |  &OPENBSD_FLAG_TO_FP_C($m)));
	}' unless defined(&SET_FP_C_FLAG);
    }
}
1;
