require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_VNODE_IMPL_H_)) {
    eval 'sub _SYS_VNODE_IMPL_H_ () {1;}' unless defined(&_SYS_VNODE_IMPL_H_);
    if(defined(&_KERNEL) || defined(&_KMEMUSER)) {
	require 'sys/vnode.ph';
	eval("sub VS_ACTIVE () { 0; }") unless defined(&VS_ACTIVE);
	eval("sub VS_MARKER () { 1; }") unless defined(&VS_MARKER);
	eval("sub VS_LOADING () { 2; }") unless defined(&VS_LOADING);
	eval("sub VS_LOADED () { 3; }") unless defined(&VS_LOADED);
	eval("sub VS_BLOCKED () { 4; }") unless defined(&VS_BLOCKED);
	eval("sub VS_RECLAIMING () { 5; }") unless defined(&VS_RECLAIMING);
	eval("sub VS_RECLAIMED () { 6; }") unless defined(&VS_RECLAIMED);
	eval 'sub VIMPL_TO_VNODE {
	    my($vip) = @_;
    	    eval q((($vip)-> &vi_vnode));
	}' unless defined(&VIMPL_TO_VNODE);
	eval 'sub VNODE_TO_VIMPL {
	    my($vp) = @_;
    	    eval q( &container_of(($vp), \'struct vnode_impl\',  &vi_vnode));
	}' unless defined(&VNODE_TO_VIMPL);
	if(defined(&DIAGNOSTIC) ) {
	    eval 'sub VSTATE_ASSERT {
	        my($vp, $state) = @_;
    		eval q( &_vstate_assert(($vp), ($state),  &__func__,  &__LINE__,  &true));
	    }' unless defined(&VSTATE_ASSERT);
	    eval 'sub VSTATE_ASSERT_UNLOCKED {
	        my($vp, $state) = @_;
    		eval q( &_vstate_assert(($vp), ($state),  &__func__,  &__LINE__,  &false));
	    }' unless defined(&VSTATE_ASSERT_UNLOCKED);
	} else {
	    eval 'sub VSTATE_ASSERT {
	        my($vp, $state) = @_;
    		eval q();
	    }' unless defined(&VSTATE_ASSERT);
	    eval 'sub VSTATE_ASSERT_UNLOCKED {
	        my($vp, $state) = @_;
    		eval q();
	    }' unless defined(&VSTATE_ASSERT_UNLOCKED);
	}
    }
}
1;
