require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_M88K_IEEEFP_H_)) {
    eval 'sub _M88K_IEEEFP_H_ () {1;}' unless defined(&_M88K_IEEEFP_H_);
    eval 'sub FP_X_INV () {0x10;}' unless defined(&FP_X_INV);
    eval 'sub FP_X_DZ () {0x8;}' unless defined(&FP_X_DZ);
    eval 'sub FP_X_UFL () {0x4;}' unless defined(&FP_X_UFL);
    eval 'sub FP_X_OFL () {0x2;}' unless defined(&FP_X_OFL);
    eval 'sub FP_X_IMP () {0x1;}' unless defined(&FP_X_IMP);
    eval("sub FP_RN () { 0; }") unless defined(&FP_RN);
    eval("sub FP_RZ () { 1; }") unless defined(&FP_RZ);
    eval("sub FP_RM () { 2; }") unless defined(&FP_RM);
    eval("sub FP_RP () { 3; }") unless defined(&FP_RP);
    if(defined(&_KERNEL)) {
	require 'sys/param.ph';
	require 'sys/proc.ph';
	eval 'sub float_raise {
	    my($bits) = @_;
    	    eval q( ($curproc->{p_md}->{md_tf}->{tf_fpsr}) |= $bits);
	}' unless defined(&float_raise);
	eval 'sub float_set_inexact () {
	    eval q( &float_raise( &FP_X_IMP));
	}' unless defined(&float_set_inexact);
	eval 'sub float_set_invalid () {
	    eval q( &float_raise( &FP_X_INV));
	}' unless defined(&float_set_invalid);
	eval 'sub FPCR_RD_SHIFT () {14;}' unless defined(&FPCR_RD_SHIFT);
	eval 'sub FPCR_RD_MASK () {0x3;}' unless defined(&FPCR_RD_MASK);
	eval 'sub float_get_round {
	    my($fpcr) = @_;
    	    eval q(((($fpcr) >>  &FPCR_RD_SHIFT) &  &FPCR_RD_MASK));
	}' unless defined(&float_get_round);
	eval 'sub fpgetround () {
	    eval q( &float_get_round( ($curproc->{p_md}->{md_tf}->{tf_fpcr})));
	}' unless defined(&fpgetround);
	eval 'sub SOFTFLOAT_MD_CLZ () {1;}' unless defined(&SOFTFLOAT_MD_CLZ);
    }
}
1;
