require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_SYS_BUF_H_)) {
    eval 'sub _SYS_BUF_H_ () {1;}' unless defined(&_SYS_BUF_H_);
    require 'sys/queue.ph';
    eval 'sub NOLIST () {(0x87654321);}' unless defined(&NOLIST);
    eval 'sub BUFQ_ALLOC {
        my($_type) = @_;
	    eval q( &bufq_default_alloc());
    }' unless defined(&BUFQ_ALLOC);
    eval 'sub BUFQ_FREE {
        my($_bufq) = @_;
	    eval q(($_bufq)-> &bufq_free($_bufq));
    }' unless defined(&BUFQ_FREE);
    eval 'sub BUFQ_ADD {
        my($_bufq, $_bp) = @_;
	    eval q(($_bufq)-> &bufq_add($_bufq, $_bp));
    }' unless defined(&BUFQ_ADD);
    eval 'sub BUFQ_GET {
        my($_bufq) = @_;
	    eval q(($_bufq)-> &bufq_get($_bufq));
    }' unless defined(&BUFQ_GET);
    eval 'sub b_cylinder () { &b_resid;}' unless defined(&b_cylinder);
    eval 'sub b_active () { &b_bcount;}' unless defined(&b_active);
    eval 'sub b_data () { ($b_un->{b_addr});}' unless defined(&b_data);
    eval 'sub b_errcnt () { &b_resid;}' unless defined(&b_errcnt);
    eval 'sub B_AGE () {0x1;}' unless defined(&B_AGE);
    eval 'sub B_NEEDCOMMIT () {0x2;}' unless defined(&B_NEEDCOMMIT);
    eval 'sub B_ASYNC () {0x4;}' unless defined(&B_ASYNC);
    eval 'sub B_BAD () {0x8;}' unless defined(&B_BAD);
    eval 'sub B_BUSY () {0x10;}' unless defined(&B_BUSY);
    eval 'sub B_CACHE () {0x20;}' unless defined(&B_CACHE);
    eval 'sub B_CALL () {0x40;}' unless defined(&B_CALL);
    eval 'sub B_DELWRI () {0x80;}' unless defined(&B_DELWRI);
    eval 'sub B_DONE () {0x200;}' unless defined(&B_DONE);
    eval 'sub B_EINTR () {0x400;}' unless defined(&B_EINTR);
    eval 'sub B_ERROR () {0x800;}' unless defined(&B_ERROR);
    eval 'sub B_INVAL () {0x2000;}' unless defined(&B_INVAL);
    eval 'sub B_NOCACHE () {0x8000;}' unless defined(&B_NOCACHE);
    eval 'sub B_PHYS () {0x40000;}' unless defined(&B_PHYS);
    eval 'sub B_RAW () {0x80000;}' unless defined(&B_RAW);
    eval 'sub B_READ () {0x100000;}' unless defined(&B_READ);
    eval 'sub B_WANTED () {0x800000;}' unless defined(&B_WANTED);
    eval 'sub B_WRITE () {0x;}' unless defined(&B_WRITE);
    eval 'sub B_WRITEINPROG () {0x1000000;}' unless defined(&B_WRITEINPROG);
    eval 'sub B_XXX () {0x2000000;}' unless defined(&B_XXX);
    eval 'sub B_DEFERRED () {0x4000000;}' unless defined(&B_DEFERRED);
    eval 'sub B_SCANNED () {0x8000000;}' unless defined(&B_SCANNED);
    eval 'sub B_PDAEMON () {0x10000000;}' unless defined(&B_PDAEMON);
    eval 'sub B_BITS () {"\\010\\001AGE\\002NEEDCOMMIT\\003ASYNC\\004BAD\\005BUSY\\006CACHE" "\\007CALL\\010DELWRI\\012DONE\\013EINTR\\014ERROR" "\\016INVAL\\020NOCACHE\\023PHYS\\024RAW\\025READ" "\\030WANTED\\031WRITEINPROG\\032XXX\\033DEFERRED" "\\034SCANNED\\035PDAEMON";}' unless defined(&B_BITS);
    eval 'sub clrbuf {
        my($bp) = @_;
	    eval q({  &bzero(-> &b_data, ($bp)-> &b_bcount); ($bp)-> &b_resid = 0; });
    }' unless defined(&clrbuf);
    eval 'sub B_CLRBUF () {0x1;}' unless defined(&B_CLRBUF);
    eval 'sub B_SYNC () {0x2;}' unless defined(&B_SYNC);
    if(defined(&_KERNEL)) {
	if(defined(&DEBUG)) {
	}
	eval 'sub buf_start {
	    my($bp) = @_;
    	    eval q({  &if ( ($bioops->{io_start})) (* ($bioops->{io_start}))($bp); });
	}' unless defined(&buf_start);
	eval 'sub buf_complete {
	    my($bp) = @_;
    	    eval q({  &if ( ($bioops->{io_complete})) (* ($bioops->{io_complete}))($bp); });
	}' unless defined(&buf_complete);
	eval 'sub buf_deallocate {
	    my($bp) = @_;
    	    eval q({  &if ( ($bioops->{io_deallocate})) (* ($bioops->{io_deallocate}))($bp); });
	}' unless defined(&buf_deallocate);
	eval 'sub buf_movedeps {
	    my($bp,$bp2) = @_;
    	    eval q({  &if ( ($bioops->{io_movedeps})) (* ($bioops->{io_movedeps}))($bp, $bp2); });
	}' unless defined(&buf_movedeps);
	eval 'sub buf_countdeps {
	    my($bp,$i,$islocked) = @_;
    	    eval q({  &if ( ($b$ioops->{io_countdeps})) ((* ($b$ioops->{io_countdeps}))($bp, $i, $islocked));  &else (0); });
	}' unless defined(&buf_countdeps);
    }
}
1;
