require '_h2ph_pre.ph';

no warnings 'redefine';

if(defined(&HAVE_CONFIG_H)) {
    require 'config.ph';
} else {
    require 'xfs/xfs_config.ph';
}
unless(defined(&RCSID)) {
    eval 'sub RCSID {
        my($x) = @_;
	    eval q();
    }' unless defined(&RCSID);
}
if(defined(&__osf__)) {
    if(defined(&__GNUC__)) {
	eval 'sub asm () { &__foo_asm;}' unless defined(&asm);
    }
    require 'sys/types.ph';
    require 'sys/errno.ph';
    require 'sys/uio.ph';
    require 'machine/cpu.ph';
    require 'sys/conf.ph';
    require 'sys/sysconfig.ph';
    require 'sys/file.ph';
    require 'sys/malloc.ph';
    require 'sys/poll.ph';
    require 'sys/ioctl.ph';
    require 'sys/fcntl.ph';
    require 'sys/vfs_proto.ph';
    require 'io/common/devdriver.ph';
    require 'vm/vm_page.ph';
    require 'vm/vm_vppage.ph';
    require 'vm/vm_ubc.ph';
    eval 'sub VT_AFS () { &VT_ADDON;}' unless defined(&VT_AFS);
    eval 'sub MOUNT_NNPFS () { &MOUNT_PC;}' unless defined(&MOUNT_NNPFS);
    if(0) {
	eval 'sub componentname () { &nameidata;}' unless defined(&componentname);
    }
    eval 'sub cn_nameptr () { &ni_ptr;}' unless defined(&cn_nameptr);
    eval 'sub cn_namelen () { &ni_namelen;}' unless defined(&cn_namelen);
    eval 'sub cn_hash () { &ni_hash;}' unless defined(&cn_hash);
    eval 'sub cn_cred () { &ni_cred;}' unless defined(&cn_cred);
    eval 'sub cn_nameiop () { &ni_nameiop;}' unless defined(&cn_nameiop);
    eval 'sub cn_flags () { &ni_flags;}' unless defined(&cn_flags);
    eval 'sub mnt_stat () { &m_stat;}' unless defined(&mnt_stat);
    eval 'sub mnt_flag () { &m_flag;}' unless defined(&mnt_flag);
    eval 'sub NDINIT {
        my($ndp, $op, $flags, $segflg, $namep, $p) = @_;
	    eval q(($ndp)-> &ni_nameiop = ($op) | ($flags); ($ndp)-> &ni_segflg = $segflg; ($ndp)-> &ni_dirp = $namep;);
    }' unless defined(&NDINIT);
    eval 'sub LOCKLEAF () {0;}' unless defined(&LOCKLEAF);
    eval 'sub FFLAGS {
        my($mode) = @_;
	    eval q((($mode) -  &FOPEN));
    }' unless defined(&FFLAGS);
    eval 'sub vput {
        my($VP) = @_;
	    eval q( &vrele($VP));
    }' unless defined(&vput);
    eval 'sub xfs_uio_to_proc {
        my($uiop) = @_;
	    eval q(( ($u->{u_procp})));
    }' unless defined(&xfs_uio_to_proc);
    eval 'sub xfs_cnp_to_proc {
        my($cnp) = @_;
	    eval q(( ($u->{u_procp})));
    }' unless defined(&xfs_cnp_to_proc);
    eval 'sub xfs_proc_to_cred {
        my($p) = @_;
	    eval q((($p)-> &p_rcred));
    }' unless defined(&xfs_proc_to_cred);
    eval 'sub xfs_proc_to_euid {
        my($p) = @_;
	    eval q((($p)-> ($p_rcred->{cr_uid})));
    }' unless defined(&xfs_proc_to_euid);
    eval 'sub xfs_curproc () {
        eval q(( ($u->{u_procp})));
    }' unless defined(&xfs_curproc);
    eval 'sub xfs_vop_read () { &VOP_READ;}' unless defined(&xfs_vop_read);
    eval 'sub xfs_vop_write () { &VOP_WRITE;}' unless defined(&xfs_vop_write);
    eval 'sub xfs_vop_getattr {
        my($t, $attr, $cred, $proc, $error) = @_;
	    eval q( &VOP_GETATTR(($t), ($attr), ($cred), ($error)));
    }' unless defined(&xfs_vop_getattr);
    eval 'sub xfs_vop_access {
        my($dvp, $mode, $cred, $proc, $error) = @_;
	    eval q( &VOP_ACCESS(($dvp), ($mode), ($cred), ($error)));
    }' unless defined(&xfs_vop_access);
} else {
    require 'sys/types.ph';
    require 'sys/param.ph';
    require 'sys/time.ph';
    require 'sys/proc.ph';
    require 'sys/filedesc.ph';
    require 'sys/kernel.ph';
    if(defined(&HAVE_SYS_MODULE_H)) {
	require 'sys/module.ph';
    }
    require 'sys/systm.ph';
    require 'sys/fcntl.ph';
    if(defined(&HAVE_SYS_SYSPROTO_H)) {
	require 'sys/sysproto.ph';
    }
    require 'sys/conf.ph';
    require 'sys/mount.ph';
    require 'sys/exec.ph';
    if(defined(&HAVE_SYS_SYSENT_H)) {
	require 'sys/sysent.ph';
    }
    if(defined(&HAVE_SYS_LKM_H)) {
	require 'sys/lkm.ph';
    }
    if(defined(&HAVE_SYS_LOCK_H)) {
	require 'sys/lock.ph';
    }
    if(defined(&HAVE_SYS_MUTEX_H)) {
	require 'sys/mutex.ph';
    }
    require 'sys/vnode.ph';
    require 'sys/errno.ph';
    require 'sys/file.ph';
    require 'sys/namei.ph';
    require 'sys/dirent.ph';
    require 'sys/ucred.ph';
    require 'sys/selinfo.ph';
    require 'sys/uio.ph';
    if(defined(&HAVE_SYS_POLL_H)) {
	require 'sys/poll.ph';
    }
    if(defined(&HAVE_SYS_SIGNALVAR_H)) {
	require 'sys/signalvar.ph';
    }
    if(defined(&HAVE_SYS_INTTYPES_H)) {
	require 'sys/inttypes.ph';
    }
    require 'sys/syscall.ph';
    require 'sys/queue.ph';
    require 'sys/malloc.ph';
    if(defined(&HAVE_SYS_SYSCALLARGS_H)) {
	require 'sys/syscallargs.ph';
    }
    if(defined(&HAVE_SYS_ATTR_H)) {
	require 'sys/attr.ph';
    }
    if(defined(&HAVE_MISCFS_GENFS_GENFS_H)) {
	require 'miscfs/genfs/genfs.ph';
    }
    if(defined(&HAVE_MISCFS_SYNCFS_SYNCFS_H)) {
	require 'miscfs/syncfs/syncfs.ph';
    }
    unless(defined(&HAVE_KERNEL_UVM_ONLY)) {
	if(defined(&HAVE_VM_VM_H)) {
	    require 'vm/vm.ph';
	}
	if(defined(&HAVE_VM_VM_EXTERN_H)) {
	    require 'vm/vm_extern.ph';
	}
	if(defined(&HAVE_VM_VM_ZONE_H)) {
	    require 'vm/vm_zone.ph';
	}
	if(defined(&HAVE_VM_VM_OBJECT_H)) {
	    require 'vm/vm_object.ph';
	}
    }
    if(defined(&HAVE_UVM_UVM_EXTERN_H)) {
	require 'uvm/uvm_extern.ph';
    }
    if(defined(&HAVE_VM_UMA_H)) {
	require 'vm/uma.ph';
    }
    if(defined( &__APPLE__)) {
	require 'machine/machine_routines.ph';
	require 'mach/machine/vm_types.ph';
	require 'sys/ubc.ph';
    }
    eval 'sub xfs_vop_read {
        my($t, $uio, $ioflag, $cred, $error) = @_;
	    eval q(($error) =  &VOP_READ(($t), ($uio), ($ioflag), ($cred)));
    }' unless defined(&xfs_vop_read);
    eval 'sub xfs_vop_write {
        my($t, $uio, $ioflag, $cred, $error) = @_;
	    eval q(($error) =  &VOP_WRITE(($t), ($uio), ($ioflag), ($cred)));
    }' unless defined(&xfs_vop_write);
    eval 'sub xfs_vop_getattr {
        my($t, $attr, $cred, $proc, $error) = @_;
	    eval q(($error) =  &VOP_GETATTR(($t), ($attr), ($cred), ($proc)));
    }' unless defined(&xfs_vop_getattr);
    eval 'sub xfs_vop_access {
        my($dvp, $mode, $cred, $proc, $error) = @_;
	    eval q(($error) =  &VOP_ACCESS(($dvp), ($mode), ($cred), ($proc)));
    }' unless defined(&xfs_vop_access);
}
if(defined(&__FreeBSD_version)) {
    if((defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) < 400000) {
	die("This\ version\ is\ unsupported");
    }
 elsif((defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) < 440001|| ((defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) >= 500000 && (defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) < 500023)) {
    }
 elsif((defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) == 500023) {
	eval 'sub HAVE_FREEBSD_THREAD () {1;}' unless defined(&HAVE_FREEBSD_THREAD);
    }
 elsif((defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) >= 500024) {
	eval 'sub HAVE_FREEBSD_THREAD () {1;}' unless defined(&HAVE_FREEBSD_THREAD);
    }
    eval 'sub syscall_thread_to_thread {
        my($x) = @_;
	    eval q(($x));
    }' unless defined(&syscall_thread_to_thread);
} else {
    if(defined( &__NetBSD__)  && (defined(&__NetBSD_Version__) ? &__NetBSD_Version__ : 0) >= 106130000) {
	eval 'sub syscall_thread_to_thread {
	    my($x) = @_;
    	    eval q((($x)-> &l_proc));
	}' unless defined(&syscall_thread_to_thread);
    } else {
	eval 'sub syscall_thread_to_thread {
	    my($x) = @_;
    	    eval q(($x));
	}' unless defined(&syscall_thread_to_thread);
    }
}
if(defined(&VV_ROOT)) {
    eval 'sub NNPFS_MAKE_VROOT {
        my($v) = @_;
	    eval q((($v)-> &v_vflag |=  &VV_ROOT));
    }' unless defined(&NNPFS_MAKE_VROOT);
} else {
    eval 'sub NNPFS_MAKE_VROOT {
        my($v) = @_;
	    eval q((($v)-> &v_flag |=  &VROOT));
    }' unless defined(&NNPFS_MAKE_VROOT);
}
if(defined( &__NetBSD__)  && (defined(&__NetBSD_Version__) ? &__NetBSD_Version__ : 0) >= 105280000) {
    require 'miscfs/genfs/genfs.ph';
    require 'miscfs/genfs/genfs_node.ph';
}
if(defined( &HAVE_FREEBSD_THREAD)) {
    eval 'sub xfs_uio_to_thread {
        my($uiop) = @_;
	    eval q((($uiop)-> &uio_td));
    }' unless defined(&xfs_uio_to_thread);
    eval 'sub xfs_cnp_to_thread {
        my($cnp) = @_;
	    eval q((($cnp)-> &cn_thread));
    }' unless defined(&xfs_cnp_to_thread);
    eval 'sub xfs_thread_to_cred {
        my($td) = @_;
	    eval q((($td)-> ($td_proc->{p_ucred})));
    }' unless defined(&xfs_thread_to_cred);
    eval 'sub xfs_thread_to_euid {
        my($td) = @_;
	    eval q((($td)-> ($td_proc->{p_ucred}->{cr_uid})));
    }' unless defined(&xfs_thread_to_euid);
} else {
    eval 'sub xfs_uio_to_proc {
        my($uiop) = @_;
	    eval q((($uiop)-> &uio_procp));
    }' unless defined(&xfs_uio_to_proc);
    eval 'sub xfs_cnp_to_proc {
        my($cnp) = @_;
	    eval q((($cnp)-> &cn_proc));
    }' unless defined(&xfs_cnp_to_proc);
    eval 'sub xfs_proc_to_cred {
        my($p) = @_;
	    eval q((($p)-> &p_ucred));
    }' unless defined(&xfs_proc_to_cred);
    eval 'sub xfs_proc_to_euid {
        my($p) = @_;
	    eval q((($p)-> ($p_ucred->{cr_uid})));
    }' unless defined(&xfs_proc_to_euid);
}
if(defined( &__FreeBSD_version)  && (defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) >= 500043) {
}
if(defined( &__FreeBSD__)) {
}
 elsif(defined( &__NetBSD__)  && (defined(&__NetBSD_Version__) ? &__NetBSD_Version__ : 0) >= 106140000) {
} else {
}
if(defined(&__APPLE__)) {
    eval 'sub xfs_curproc () {
        eval q(( &current_proc()));
    }' unless defined(&xfs_curproc);
} else {
    if(defined( &HAVE_FREEBSD_THREAD)) {
	eval 'sub xfs_curthread () {
	    eval q(( &curthread));
	}' unless defined(&xfs_curthread);
    } else {
	eval 'sub xfs_curproc () {
	    eval q(( &curproc));
	}' unless defined(&xfs_curproc);
    }
}
if(defined(&__osf__)) {
    eval 'sub xfs_pushdirty {
        my($vp, $cred, $p) = @_;
	    eval q();
    }' unless defined(&xfs_pushdirty);
} else {
}
if(defined( &HAVE_UINTPTR_T) ) {
    eval 'sub xfs_uintptr_t () { &uintptr_t;}' unless defined(&xfs_uintptr_t);
} else {
    if(defined( &_LP64) || defined( &alpha) || defined( &__alpha__) || defined( &__sparc64__) || defined( &__sparcv9__)) {
	eval 'sub xfs_uintptr_t () {\'unsigned long long\';}' unless defined(&xfs_uintptr_t);
    } else {
	eval 'sub xfs_uintptr_t () {\'unsigned long\';}' unless defined(&xfs_uintptr_t);
    }
}
unless(defined(&SCARG)) {
    if(defined( &__FreeBSD_version)  && (defined(&__FreeBSD_version) ? &__FreeBSD_version : 0) > 500042) {
	eval 'sub SCARG {
	    my($a, $b) = @_;
    	    eval q((($a)->$b));
	}' unless defined(&SCARG);
	eval 'sub syscallarg {
	    my($x) = @_;
    	    eval q($x);
	}' unless defined(&syscallarg);
    } else {
	eval 'sub SCARG {
	    my($a, $b) = @_;
    	    eval q((($a)-> ($b->{d$atum})));
	}' unless defined(&SCARG);
	eval 'sub syscallarg {
	    my($x) = @_;
    	    eval q(\'union union\' { $x  &datum;  &register_t  &pad; });
	}' unless defined(&syscallarg);
    }
}
unless(defined(&syscallarg)) {
    eval 'sub syscallarg {
        my($x) = @_;
	    eval q($x);
    }' unless defined(&syscallarg);
}
unless(defined(&HAVE_REGISTER_T)) {
}
unless(defined(&M_WAITOK)) {
    eval 'sub M_WAITOK () {0;}' unless defined(&M_WAITOK);
}
if(defined( &HAVE_DEF_STRUCT_SETGROUPS_ARGS)) {
    eval 'sub xfs_setgroups_args () { &setgroups_args;}' unless defined(&xfs_setgroups_args);
}
 elsif(defined( &HAVE_DEF_STRUCT_SYS_SETGROUPS_ARGS)) {
    eval 'sub xfs_setgroups_args () { &sys_setgroups_args;}' unless defined(&xfs_setgroups_args);
}
 elsif((defined(&__osf__) ? &__osf__ : 0)) {
}
 elsif(defined( &__APPLE__)) {
} else {
    die("what\ is\ you\ setgroups\ named\ \?");
}
if(defined(&HAVE_KERNEL_VFS_GETVFS)) {
    eval 'sub xfs_vfs_getvfs () { &vfs_getvfs;}' unless defined(&xfs_vfs_getvfs);
} else {
    eval 'sub xfs_vfs_getvfs () { &getvfs;}' unless defined(&xfs_vfs_getvfs);
}
if(defined(&HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE)) {
    eval 'sub xfs_vfs_object_create {
        my($vp,$proc,$ucred) = @_;
	    eval q( &vfs_object_create($vp,$proc,$ucred, &TRUE));
    }' unless defined(&xfs_vfs_object_create);
} else {
    eval 'sub xfs_vfs_object_create {
        my($vp,$proc,$ucred) = @_;
	    eval q( &vfs_object_create($vp,$proc,$ucred));
    }' unless defined(&xfs_vfs_object_create);
}
if(defined( &UVM) || (defined( &__NetBSD__)  && (defined(&__NetBSD_Version__) ? &__NetBSD_Version__ : 0) >= 105280000)) {
    eval 'sub xfs_set_vp_size {
        my($vp, $sz) = @_;
	    eval q( &uvm_vnp_setsize($vp, $sz));
    }' unless defined(&xfs_set_vp_size);
}
 elsif((defined(&HAVE_KERNEL_VNODE_PAGER_SETSIZE) ? &HAVE_KERNEL_VNODE_PAGER_SETSIZE : 0)) {
    eval 'sub xfs_set_vp_size {
        my($vp, $sz) = @_;
	    eval q( &vnode_pager_setsize($vp, $sz));
    }' unless defined(&xfs_set_vp_size);
}
 elsif(defined( &__APPLE__)) {
    eval 'sub xfs_set_vp_size {
        my($vp, $sz) = @_;
	    eval q( &ubc_setsize($vp, $sz));
    }' unless defined(&xfs_set_vp_size);
} else {
    eval 'sub xfs_set_vp_size {
        my($vp, $sz) = @_;
	    eval q();
    }' unless defined(&xfs_set_vp_size);
}
if(defined(&LOCKLEAF)) {
    eval 'sub NNPFS_LOCKLEAF () { &LOCKLEAF;}' unless defined(&NNPFS_LOCKLEAF);
} else {
    eval 'sub NNPFS_LOCKLEAF () {0;}' unless defined(&NNPFS_LOCKLEAF);
}
if(defined(&NEED_VGONEL_PROTO)) {
}
if(defined(&NEED_ISSIGNAL_PROTO)) {
}
if(defined(&NEED_STRNCMP_PROTO)) {
}
if(defined(&NEED_VN_WRITECHK_PROTO)) {
}
if(defined(&NEED_UBC_PUSHDIRTY_PROTO)) {
}
require 'xfs/xfs_syscalls.ph';
unless(defined(&NNPFS_VOP_DEF)) {
    sub NNPFS_VOP_DEF {
	my($n) = @_;
	eval q('struct vop_'$n &_args; 'int'  &xfs_$n('struct vop_'$n &_args *););
    }
}
require 'xfs/xfs_vopdefs.ph';
1;
