require '_h2ph_pre.ph';

no warnings qw(redefine misc);

eval 'sub _PATH_KERNFS () {"/kern";}' unless defined(&_PATH_KERNFS);
if(defined(&_KERNEL)) {
    require 'sys/queue.ph';
    require 'sys/tree.ph';
    require 'sys/mutex.ph';
    eval("sub KFSkern () { 0; }") unless defined(&KFSkern);
    eval("sub KFSroot () { 1; }") unless defined(&KFSroot);
    eval("sub KFSnull () { 2; }") unless defined(&KFSnull);
    eval("sub KFStime () { 3; }") unless defined(&KFStime);
    eval("sub KFSboottime () { 4; }") unless defined(&KFSboottime);
    eval("sub KFSint () { 5; }") unless defined(&KFSint);
    eval("sub KFSstring () { 6; }") unless defined(&KFSstring);
    eval("sub KFShostname () { 7; }") unless defined(&KFShostname);
    eval("sub KFSavenrun () { 8; }") unless defined(&KFSavenrun);
    eval("sub KFSdevice () { 9; }") unless defined(&KFSdevice);
    eval("sub KFSmsgbuf () { 10; }") unless defined(&KFSmsgbuf);
    eval("sub KFSsubdir () { 11; }") unless defined(&KFSsubdir);
    eval("sub KFSlasttype () { 12; }") unless defined(&KFSlasttype);
    eval("sub KFSmaxtype () { (1<<6)-1; }") unless defined(&KFSmaxtype);
    eval 'sub UIO_MX () {32;}' unless defined(&UIO_MX);
    eval 'sub KERNFS_FILENO {
        my($kt, $typ, $cookie) = @_;
	    eval q((($kt >=  $kern_targets[0]  && $kt <  $kern_targets[ &static_nkern_targets]) ? 2+ (($kt) -  $kern_targets[0]) : ((($cookie + 1) << 6) | ($typ))));
    }' unless defined(&KERNFS_FILENO);
    eval 'sub KERNFS_TYPE_FILENO {
        my($typ, $cookie) = @_;
	    eval q(((($cookie + 1) << 6) | ($typ)));
    }' unless defined(&KERNFS_TYPE_FILENO);
    eval 'sub VFSTOKERNFS {
        my($mp) = @_;
	    eval q(((($mp)-> &mnt_data)));
    }' unless defined(&VFSTOKERNFS);
    eval 'sub VTOKERN {
        my($vp) = @_;
	    eval q((($vp)-> &v_data));
    }' unless defined(&VTOKERN);
    eval 'sub KERNFSTOV {
        my($kfs) = @_;
	    eval q((($kfs)-> &kfs_vnode));
    }' unless defined(&KERNFSTOV);
    eval 'sub KERNFS_MAXNAMLEN () {255;}' unless defined(&KERNFS_MAXNAMLEN);
    eval("sub KERNFS_XREAD () { 0; }") unless defined(&KERNFS_XREAD);
    eval("sub KERNFS_XWRITE () { 1; }") unless defined(&KERNFS_XWRITE);
    eval("sub KERNFS_FILEOP_CLOSE () { 2; }") unless defined(&KERNFS_FILEOP_CLOSE);
    eval("sub KERNFS_FILEOP_GETATTR () { 3; }") unless defined(&KERNFS_FILEOP_GETATTR);
    eval("sub KERNFS_FILEOP_IOCTL () { 4; }") unless defined(&KERNFS_FILEOP_IOCTL);
    eval("sub KERNFS_FILEOP_OPEN () { 5; }") unless defined(&KERNFS_FILEOP_OPEN);
    eval("sub KERNFS_FILEOP_READ () { 6; }") unless defined(&KERNFS_FILEOP_READ);
    eval("sub KERNFS_FILEOP_WRITE () { 7; }") unless defined(&KERNFS_FILEOP_WRITE);
    eval 'sub kf_vop () { ($_kf_opfn->{_kf_vop});}' unless defined(&kf_vop);
    eval 'sub kf_xread () { ($_kf_opfn->{_kf_xread});}' unless defined(&kf_xread);
    eval 'sub kf_xwrite () { ($_kf_opfn->{_kf_xwrite});}' unless defined(&kf_xwrite);
    eval 'sub KERNFS_ALLOCTYPE {
        my($kf) = @_;
	    eval q( &kernfs_alloctype($sizeof{($kf)} / $sizeof{($kf)[0]}, ($kf)));
    }' unless defined(&KERNFS_ALLOCTYPE);
    eval 'sub KERNFS_ALLOCENTRY {
        my($dkt, $km_flags) = @_;
	    eval q($dkt = ( &kernfs_entry_t *) &kmem_zalloc( $sizeof{\'struct dyn_kern_target\'}, ($km_flags)));
    }' unless defined(&KERNFS_ALLOCENTRY);
    eval 'sub KERNFS_INITENTRY {
        my($dkt, $type, $name, $data, $tag, $vtype, $mode) = @_;
	    eval q( &do { ($dkt)-> ($dkt_kt->{kt_type}) = ($type); ($dkt)-> ($dkt_kt->{kt_namlen}) =  &strlen(($name)); ($dkt)-> ($dkt_kt->{kt_name}) = ($name); ($dkt)-> ($dkt_kt->{kt_data}) = ($data); ($dkt)-> ($dkt_kt->{kt_tag}) = ($tag); ($dkt)-> ($dkt_kt->{kt_vtype}) = ($vtype); ($dkt)-> ($dkt_kt->{kt_mode}) = ($mode); }  &while ( 0));
    }' unless defined(&KERNFS_INITENTRY);
    eval 'sub KERNFS_ENTOPARENTDIR {
        my($dkt) = @_;
	    eval q(($dkt)-> &dkt_kt);
    }' unless defined(&KERNFS_ENTOPARENTDIR);
    if(defined(&IPSEC)) {
    }
}
1;
