require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_SYS_EXEC_H_)) {
    eval 'sub _SYS_EXEC_H_ () {1;}' unless defined(&_SYS_EXEC_H_);
    if(defined(&MACHINE_STACK_GROWS_UP)) {
	eval 'sub PS_STRINGS () {(( &USRSTACK));}' unless defined(&PS_STRINGS);
    } else {
	eval 'sub PS_STRINGS () {(( &USRSTACK - $sizeof{\'struct ps_strings\'}));}' unless defined(&PS_STRINGS);
    }
    eval 'sub STACKGAPLEN () {(2*1024);}' unless defined(&STACKGAPLEN);
    if(defined(&MACHINE_STACK_GROWS_UP)) {
	eval 'sub STACKGAPBASE_UNALIGNED () {( &PS_STRINGS + $sizeof{\'struct ps_strings\'});}' unless defined(&STACKGAPBASE_UNALIGNED);
    } else {
	eval 'sub STACKGAPBASE_UNALIGNED () {( &PS_STRINGS -  &STACKGAPLEN);}' unless defined(&STACKGAPBASE_UNALIGNED);
    }
    eval 'sub STACKGAPBASE () {( &ALIGN( &STACKGAPBASE_UNALIGNED));}' unless defined(&STACKGAPBASE);
    eval 'sub VMCMD_RELATIVE () {0x1;}' unless defined(&VMCMD_RELATIVE);
    eval 'sub VMCMD_BASE () {0x2;}' unless defined(&VMCMD_BASE);
    eval 'sub EXEC_DEFAULT_VMCMD_SETSIZE () {8;}' unless defined(&EXEC_DEFAULT_VMCMD_SETSIZE);
    eval 'sub EXEC_INDIR () {0x1;}' unless defined(&EXEC_INDIR);
    eval 'sub EXEC_HASFD () {0x2;}' unless defined(&EXEC_HASFD);
    eval 'sub EXEC_HASARGL () {0x4;}' unless defined(&EXEC_HASARGL);
    eval 'sub EXEC_SKIPARG () {0x8;}' unless defined(&EXEC_SKIPARG);
    eval 'sub EXEC_DESTR () {0x10;}' unless defined(&EXEC_DESTR);
    if(defined(&_KERNEL)) {
	if(defined(&DEBUG)) {
	    eval 'sub NEW_VMCMD {
	        my($evsp,$proc,$len,$addr,$vp,$offset,$prot) = @_;
    		eval q( &new_vmcmd($evsp,$proc,$len,$addr,$vp,$offset,$prot, 0););
	    }' unless defined(&NEW_VMCMD);
	    eval 'sub NEW_VMCMD2 {
	        my($evsp,$proc,$len,$addr,$vp,$offset,$prot,$flags) = @_;
    		eval q( &new_vmcmd($evsp,$proc,$len,$addr,$vp,$offset,$prot,$flags));
	    }' unless defined(&NEW_VMCMD2);
	} else {
	    eval 'sub NEW_VMCMD {
	        my($evsp,$proc,$len,$addr,$vp,$offset,$prot) = @_;
    		eval q( &NEW_VMCMD2($evsp,$proc,$len,$addr,$vp,$offset,$prot,0));
	    }' unless defined(&NEW_VMCMD);
	    eval 'sub NEW_VMCMD2 {
	        my($evsp,$proc,$len,$addr,$vp,$offset,$prot,$flags) = @_;
    		eval q( &do { \'struct exec_vmcmd\' * &vcp;  &if (($evsp)-> &evs_used >= ($evsp)-> &evs_cnt)  &vmcmdset_extend($evsp);  &vcp = ($evsp)-> $evs_cmds[($evsp)-> &evs_used++];  ($vcp->{ev_proc}) = ($proc);  ($vcp->{ev_len}) = ($len);  ($vcp->{ev_addr}) = ($addr);  &if (( ($vcp->{ev_vp}) = ($vp)) !=  &NULLVP)  &VREF($vp);  ($vcp->{ev_offset}) = ($offset);  ($vcp->{ev_prot}) = ($prot);  ($vcp->{ev_flags}) = ($flags); }  &while (0));
	    }' unless defined(&NEW_VMCMD2);
	}
	eval 'sub VMCMDSET_INIT {
	    my($vmc) = @_;
    	    eval q( &do { ($vmc)-> &evs_cnt =  &EXEC_DEFAULT_VMCMD_SETSIZE; ($vmc)-> &evs_cmds = ($vmc)-> &evs_start; ($vmc)-> &evs_used = 0; }  &while (0));
	}' unless defined(&VMCMDSET_INIT);
    }
    require 'sys/exec_aout.ph';
    require 'machine/exec.ph';
}
1;
