require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_WAPBL_H)) {
    eval 'sub _SYS_WAPBL_H () {1;}' unless defined(&_SYS_WAPBL_H);
    require 'sys/mutex.ph';
    if(defined(&_KERNEL) || defined(&_KMEMUSER)) {
	require 'miscfs/specfs/specdev.ph';
    }
    if(defined(&_KERNEL_OPT)) {
	require './sys/opt_wapbl.ph';
    }
    if(defined(&WAPBL_DEBUG)) {
	unless(defined(&WAPBL_DEBUG_PRINT)) {
	    eval 'sub WAPBL_DEBUG_PRINT () {( &WAPBL_PRINT_REPLAY |  &WAPBL_PRINT_OPEN);}' unless defined(&WAPBL_DEBUG_PRINT);
	}
	if(0) {
	    eval 'sub WAPBL_DEBUG_BUFBYTES () {1;}' unless defined(&WAPBL_DEBUG_BUFBYTES);
	}
    }
    if(defined(&WAPBL_DEBUG_PRINT)) {
	eval("sub WAPBL_PRINT_OPEN () { 0x1; }") unless defined(&WAPBL_PRINT_OPEN);
	eval("sub WAPBL_PRINT_FLUSH () { 0x2; }") unless defined(&WAPBL_PRINT_FLUSH);
	eval("sub WAPBL_PRINT_TRUNCATE () { 0x4; }") unless defined(&WAPBL_PRINT_TRUNCATE);
	eval("sub WAPBL_PRINT_TRANSACTION () { 0x8; }") unless defined(&WAPBL_PRINT_TRANSACTION);
	eval("sub WAPBL_PRINT_BUFFER () { 0x10; }") unless defined(&WAPBL_PRINT_BUFFER);
	eval("sub WAPBL_PRINT_BUFFER2 () { 0x20; }") unless defined(&WAPBL_PRINT_BUFFER2);
	eval("sub WAPBL_PRINT_ALLOC () { 0x40; }") unless defined(&WAPBL_PRINT_ALLOC);
	eval("sub WAPBL_PRINT_INODE () { 0x80; }") unless defined(&WAPBL_PRINT_INODE);
	eval("sub WAPBL_PRINT_WRITE () { 0x100; }") unless defined(&WAPBL_PRINT_WRITE);
	eval("sub WAPBL_PRINT_IO () { 0x200; }") unless defined(&WAPBL_PRINT_IO);
	eval("sub WAPBL_PRINT_REPLAY () { 0x400; }") unless defined(&WAPBL_PRINT_REPLAY);
	eval("sub WAPBL_PRINT_ERROR () { 0x800; }") unless defined(&WAPBL_PRINT_ERROR);
	eval("sub WAPBL_PRINT_DISCARD () { 0x1000; }") unless defined(&WAPBL_PRINT_DISCARD);
	eval("sub WAPBL_PRINT_BIODONE () { 0x2000; }") unless defined(&WAPBL_PRINT_BIODONE);
	eval 'sub WAPBL_PRINTF {
	    my($mask, $a) = @_;
    	    eval q( &if ( &wapbl_debug_print & ($mask))  &printf $a);
	}' unless defined(&WAPBL_PRINTF);
    } else {
	eval 'sub WAPBL_PRINTF {
	    my($mask, $a) = @_;
    	    eval q();
	}' unless defined(&WAPBL_PRINTF);
    }
    require 'sys/queue.ph';
    require 'sys/vnode.ph';
    require 'sys/buf.ph';
    if(defined(&_KERNEL)) {
	if(defined(&WAPBL_DEBUG_BUFBYTES)) {
	}
	if(defined(&WAPBL_DEBUG) || defined(&DDB)) {
	}
	eval 'sub wapbl_vptomp {
	    my($vp) = @_;
    	    eval q({ \'struct mount\' * &mp;  &mp =  &NULL;  &if ($vp !=  &NULL) {  &if ( ($vp->{v_type}) ==  &VBLK)  &mp =  &spec_node_getmountedfs($vp);  &else  &mp =  ($vp->{v_mount}); }  &mp; });
	}' unless defined(&wapbl_vptomp);
	eval 'sub wapbl_vphaswapbl {
	    my($vp) = @_;
    	    eval q({ \'struct mount\' * &mp;  &if ($vp ==  &NULL)  &false;  &mp =  &wapbl_vptomp($vp);  &mp  &&  ($mp->{mnt_wapbl}); });
	}' unless defined(&wapbl_vphaswapbl);
    }
    if(defined(&WAPBL_INTERNAL)) {
	eval 'sub wapbl_replay_isopen {
	    my($wr) = @_;
    	    eval q((($wr)-> &wr_scratch != 0));
	}' unless defined(&wapbl_replay_isopen);
    } else {
    }
}
1;
