require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_MACHINE_IEEEFP_H_)) {
    eval 'sub _MACHINE_IEEEFP_H_ () {1;}' unless defined(&_MACHINE_IEEEFP_H_);
    if(defined(&_KERNEL)) {
	require 'sys/param.ph';
	require 'sys/proc.ph';
	require 'machine/fpu.ph';
	require 'machine/cpu.ph';
	eval 'sub FP_AA_FLAGS () {( &FP_X_INV |  &FP_X_DZ |  &FP_X_OFL |  &FP_X_UFL |  &FP_X_IMP);}' unless defined(&FP_AA_FLAGS);
	eval 'sub float_raise {
	    my($f) = @_;
    	    eval q( &do  ($curproc->{p_md}->{md_flags}) |=  &OPENBSD_FLAG_TO_FP_C($f);  &while(0));
	}' 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 fpgetround () {
	    eval q(( &alpha_read_fpcr() >> 58& 3));
	}' unless defined(&fpgetround);
    }
    eval 'sub FP_X_INV () {0x1;}' unless defined(&FP_X_INV);
    eval 'sub FP_X_DZ () {0x2;}' unless defined(&FP_X_DZ);
    eval 'sub FP_X_OFL () {0x4;}' unless defined(&FP_X_OFL);
    eval 'sub FP_X_UFL () {0x8;}' unless defined(&FP_X_UFL);
    eval 'sub FP_X_IMP () {0x10;}' unless defined(&FP_X_IMP);
    eval 'sub FP_X_IOV () {0x20;}' unless defined(&FP_X_IOV);
    eval("sub FP_RZ () { 0; }") unless defined(&FP_RZ);
    eval("sub FP_RM () { 1; }") unless defined(&FP_RM);
    eval("sub FP_RN () { 2; }") unless defined(&FP_RN);
    eval("sub FP_RP () { 3; }") unless defined(&FP_RP);
}
1;
