require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_RESOURCEVAR_H_)) {
    eval 'sub _SYS_RESOURCEVAR_H_ () {1;}' unless defined(&_SYS_RESOURCEVAR_H_);
    if(!defined(&_KERNEL)  && !defined(&_KMEMUSER)) {
	die("not supposed to be exposed to userland");
    }
    require 'sys/mutex.ph';
    require 'sys/resource.ph';
    eval 'sub pstat_startzero () { &p_ru;}' unless defined(&pstat_startzero);
    eval 'sub pstat_endzero () { &pstat_startcopy;}' unless defined(&pstat_endzero);
    eval 'sub pstat_startcopy () { &p_timer;}' unless defined(&pstat_startcopy);
    eval 'sub pstat_endcopy () { &p_start;}' unless defined(&pstat_endcopy);
    if(defined(&_KERNEL)) {
	eval 'sub ADDUPROF {
	    my($l) = @_;
    	    eval q( &do { \'struct proc\' * &_p = ($l)-> &l_proc;  &addupc_task(($l),  ($_p->{p_stats}->{p_prof}->{pr_addr}),  ($_p->{p_stats}->{p_prof}->{pr_ticks}));  ($_p->{p_stats}->{p_prof}->{pr_ticks}) = 0; }  &while ( 0));
	}' unless defined(&ADDUPROF);
    }
}
1;
