require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_BUF_H_)) {
    eval 'sub _SYS_BUF_H_ () {1;}' unless defined(&_SYS_BUF_H_);
    require 'sys/queue.ph';
    require 'sys/tree.ph';
    require 'sys/mutex.ph';
    require 'sys/workq.ph';
    eval 'sub NOLIST () {(0x87654321);}' unless defined(&NOLIST);
    eval 'sub BUFQ_DISKSORT () {0;}' unless defined(&BUFQ_DISKSORT);
    eval 'sub BUFQ_FIFO () {1;}' unless defined(&BUFQ_FIFO);
    eval 'sub BUFQ_DEFAULT () { &BUFQ_DISKSORT;}' unless defined(&BUFQ_DEFAULT);
    eval 'sub BUFQ_HOWMANY () {2;}' unless defined(&BUFQ_HOWMANY);
    eval 'sub b_actf () { ($b_bufq->{bufq_data_disksort}->{bqd_actf});}' unless defined(&b_actf);
    eval 'sub b_actb () { ($b_bufq->{bufq_data_disksort}->{bqd_actb});}' unless defined(&b_actb);
    eval 'sub b_cylinder () { &b_resid;}' unless defined(&b_cylinder);
    eval 'sub b_active () { &b_bcount;}' unless defined(&b_active);
    eval 'sub b_errcnt () { &b_resid;}' unless defined(&b_errcnt);
    eval 'sub B_WRITE () {0x;}' unless defined(&B_WRITE);
    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 () {0x100;}' unless defined(&B_DONE);
    eval 'sub B_EINTR () {0x200;}' unless defined(&B_EINTR);
    eval 'sub B_ERROR () {0x400;}' unless defined(&B_ERROR);
    eval 'sub B_INVAL () {0x800;}' unless defined(&B_INVAL);
    eval 'sub B_NOCACHE () {0x1000;}' unless defined(&B_NOCACHE);
    eval 'sub B_PHYS () {0x2000;}' unless defined(&B_PHYS);
    eval 'sub B_RAW () {0x4000;}' unless defined(&B_RAW);
    eval 'sub B_READ () {0x8000;}' unless defined(&B_READ);
    eval 'sub B_WANTED () {0x10000;}' unless defined(&B_WANTED);
    eval 'sub B_WRITEINPROG () {0x20000;}' unless defined(&B_WRITEINPROG);
    eval 'sub B_XXX () {0x40000;}' unless defined(&B_XXX);
    eval 'sub B_DEFERRED () {0x80000;}' unless defined(&B_DEFERRED);
    eval 'sub B_SCANNED () {0x100000;}' unless defined(&B_SCANNED);
    eval 'sub B_PDAEMON () {0x200000;}' unless defined(&B_PDAEMON);
    eval 'sub B_RELEASED () {0x400000;}' unless defined(&B_RELEASED);
    eval 'sub B_NOTMAPPED () {0x800000;}' unless defined(&B_NOTMAPPED);
    eval 'sub B_BITS () {"\\20\\001AGE\\002NEEDCOMMIT\\003ASYNC\\004BAD\\005BUSY" "\\006CACHE\\007CALL\\010DELWRI\\011DONE\\012EINTR\\013ERROR" "\\014INVAL\\015NOCACHE\\016PHYS\\017RAW\\020READ" "\\021WANTED\\022WRITEINPROG\\023XXX(FORMAT)\\024DEFERRED" "\\025SCANNED\\026DAEMON\\027RELEASED\\030NOTMAPPED";}' 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;
