require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&__SYSTM_H__)) {
    eval 'sub __SYSTM_H__ () {1;}' unless defined(&__SYSTM_H__);
    require 'sys/queue.ph';
    require 'sys/stdarg.ph';
    if(defined(&MULTIPROCESSOR)) {
	eval 'sub curpriority () {( &curcpu()-> ($ci_schedstate->{spc_curpriority}));}' unless defined(&curpriority);
    } else {
    }
    if((defined(&_BYTE_ORDER) ? &_BYTE_ORDER : 0) == (defined(&_BIG_ENDIAN) ? &_BIG_ENDIAN : 0)) {
	eval 'sub SCARG {
	    my($p, $k) = @_;
    	    eval q((($p)-> ($k->{be}->{datum})));
	}' unless defined(&SCARG);
    }
 elsif((defined(&_BYTE_ORDER) ? &_BYTE_ORDER : 0) == (defined(&_LITTLE_ENDIAN) ? &_LITTLE_ENDIAN : 0)) {
	eval 'sub SCARG {
	    my($p, $k) = @_;
    	    eval q((($p)-> ($k->{le}->{datum})));
	}' unless defined(&SCARG);
    } else {
	die("what byte order is this machine?");
    }
    if(defined( &_KERNEL)  && defined( &SYSCALL_DEBUG)) {
    }
    eval 'sub HOOK_REMOVE () {0x1;}' unless defined(&HOOK_REMOVE);
    eval 'sub HOOK_FREE () {0x2;}' unless defined(&HOOK_FREE);
    eval 'sub startuphook_establish {
        my($fn, $arg) = @_;
	    eval q( &hook_establish( &startuphook_list, 1, ($fn), ($arg)));
    }' unless defined(&startuphook_establish);
    eval 'sub startuphook_disestablish {
        my($vhook) = @_;
	    eval q( &hook_disestablish( &startuphook_list, ($vhook)));
    }' unless defined(&startuphook_disestablish);
    eval 'sub dostartuphooks () {
        eval q( &dohooks( &startuphook_list,  &HOOK_REMOVE| &HOOK_FREE));
    }' unless defined(&dostartuphooks);
    eval 'sub shutdownhook_establish {
        my($fn, $arg) = @_;
	    eval q( &hook_establish( &shutdownhook_list, 0, ($fn), ($arg)));
    }' unless defined(&shutdownhook_establish);
    eval 'sub shutdownhook_disestablish {
        my($vhook) = @_;
	    eval q( &hook_disestablish( &shutdownhook_list, ($vhook)));
    }' unless defined(&shutdownhook_disestablish);
    eval 'sub doshutdownhooks () {
        eval q( &dohooks( &shutdownhook_list,  &HOOK_REMOVE));
    }' unless defined(&doshutdownhooks);
    eval 'sub mountroothook_establish {
        my($fn, $arg) = @_;
	    eval q( &hook_establish( &mountroothook_list, 0, ($fn), ($arg)));
    }' unless defined(&mountroothook_establish);
    eval 'sub mountroothook_disestablish {
        my($vhook) = @_;
	    eval q( &hook_disestablish( &mountroothook_list, ($vhook)));
    }' unless defined(&mountroothook_disestablish);
    eval 'sub domountroothooks () {
        eval q( &dohooks( &mountroothook_list,  &HOOK_REMOVE| &HOOK_FREE));
    }' unless defined(&domountroothooks);
    eval 'sub PWR_RESUME () {0;}' unless defined(&PWR_RESUME);
    eval 'sub PWR_SUSPEND () {1;}' unless defined(&PWR_SUSPEND);
    eval 'sub PWR_STANDBY () {2;}' unless defined(&PWR_STANDBY);
    if(defined( &_KERNEL)) {
    }
    if(defined(&GPROF)) {
    }
    require 'lib/libkern/libkern.ph';
    if(defined( &DDB) || defined( &KGDB)) {
    }
    if(defined(&BOOT_CONFIG)) {
    }
    if(defined( &MULTIPROCESSOR)) {
	eval 'sub KERNEL_LOCK_INIT () {
	    eval q( &_kernel_lock_init());
	}' unless defined(&KERNEL_LOCK_INIT);
	eval 'sub KERNEL_LOCK {
	    my($flag) = @_;
    	    eval q( &_kernel_lock(($flag)));
	}' unless defined(&KERNEL_LOCK);
	eval 'sub KERNEL_UNLOCK () {
	    eval q( &_kernel_unlock());
	}' unless defined(&KERNEL_UNLOCK);
	eval 'sub KERNEL_PROC_LOCK {
	    my($p) = @_;
    	    eval q( &_kernel_proc_lock(($p)));
	}' unless defined(&KERNEL_PROC_LOCK);
	eval 'sub KERNEL_PROC_UNLOCK {
	    my($p) = @_;
    	    eval q( &_kernel_proc_unlock(($p)));
	}' unless defined(&KERNEL_PROC_UNLOCK);
    } else {
	eval 'sub KERNEL_LOCK_INIT () {
	    eval q();
	}' unless defined(&KERNEL_LOCK_INIT);
	eval 'sub KERNEL_LOCK {
	    my($flag) = @_;
    	    eval q();
	}' unless defined(&KERNEL_LOCK);
	eval 'sub KERNEL_UNLOCK () {
	    eval q();
	}' unless defined(&KERNEL_UNLOCK);
	eval 'sub KERNEL_PROC_LOCK {
	    my($p) = @_;
    	    eval q();
	}' unless defined(&KERNEL_PROC_LOCK);
	eval 'sub KERNEL_PROC_UNLOCK {
	    my($p) = @_;
    	    eval q();
	}' unless defined(&KERNEL_PROC_UNLOCK);
    }
}
1;
