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/pool.ph';
    require 'sys/queue.ph';
    require 'sys/mutex.ph';
    require 'sys/condvar.ph';
    require 'sys/rbtree.ph';
    if(defined(&_KERNEL)) {
	require 'sys/workqueue.ph';
    }
    eval 'sub NOLIST () {(0x87654321);}' unless defined(&NOLIST);
    if(defined(&_KERNEL)) {
    }
    if(defined(&_KERNEL)) {
    }
    if(defined(&_KERNEL)) {
    }
    eval 'sub b_actq () { ($b_u->{u_actq});}' unless defined(&b_actq);
    eval 'sub b_work () { ($b_u->{u_work});}' unless defined(&b_work);
    eval 'sub b_cylinder () { &b_resid;}' unless defined(&b_cylinder);
    eval 'sub BC_AGE () {0x1;}' unless defined(&BC_AGE);
    eval 'sub BC_BUSY () {0x10;}' unless defined(&BC_BUSY);
    eval 'sub BC_INVAL () {0x2000;}' unless defined(&BC_INVAL);
    eval 'sub BC_NOCACHE () {0x8000;}' unless defined(&BC_NOCACHE);
    eval 'sub BC_WANTED () {0x800000;}' unless defined(&BC_WANTED);
    eval 'sub BC_VFLUSH () {0x4000000;}' unless defined(&BC_VFLUSH);
    eval 'sub BO_DELWRI () {0x80;}' unless defined(&BO_DELWRI);
    eval 'sub BO_DONE () {0x200;}' unless defined(&BO_DONE);
    eval 'sub B_WRITE () {0x;}' unless defined(&B_WRITE);
    eval 'sub B_ASYNC () {0x4;}' unless defined(&B_ASYNC);
    eval 'sub B_COWDONE () {0x400;}' unless defined(&B_COWDONE);
    eval 'sub B_GATHERED () {0x1000;}' unless defined(&B_GATHERED);
    eval 'sub B_LOCKED () {0x4000;}' unless defined(&B_LOCKED);
    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_DEVPRIVATE () {0x2000000;}' unless defined(&B_DEVPRIVATE);
    eval 'sub B_MEDIA_FUA () {0x8000000;}' unless defined(&B_MEDIA_FUA);
    eval 'sub B_MEDIA_DPO () {0x10000000;}' unless defined(&B_MEDIA_DPO);
    eval 'sub BUF_FLAGBITS () {"\\20\\1AGE\\3ASYNC\\4BAD\\5BUSY\\10DELWRI" "\\12DONE\\13COWDONE\\15GATHERED\\16INVAL\\17LOCKED\\20NOCACHE" "\\23PHYS\\24RAW\\25READ\\32DEVPRIVATE\\33VFLUSH\\34MEDIA_FUA\\35MEDIA_DPO";}' unless defined(&BUF_FLAGBITS);
    eval 'sub BUF_ISREAD {
        my($bp) = @_;
	    eval q(((($bp)-> &b_flags &  &B_READ) ==  &B_READ));
    }' unless defined(&BUF_ISREAD);
    eval 'sub BUF_ISWRITE {
        my($bp) = @_;
	    eval q(((($bp)-> &b_flags &  &B_READ) ==  &B_WRITE));
    }' unless defined(&BUF_ISWRITE);
    eval 'sub B_MEDIA_FLAGS () {( &B_MEDIA_FUA| &B_MEDIA_DPO);}' unless defined(&B_MEDIA_FLAGS);
    eval 'sub clrbuf {
        my($bp) = @_;
	    eval q( &do {  &memset(-> &b_data, 0, ($bp)-> &b_bcount); ($bp)-> &b_resid = 0; }  &while ( 0));
    }' unless defined(&clrbuf);
    eval 'sub B_CLRBUF () {0x1;}' unless defined(&B_CLRBUF);
    eval 'sub B_SYNC () {0x2;}' unless defined(&B_SYNC);
    eval 'sub B_METAONLY () {0x4;}' unless defined(&B_METAONLY);
    eval 'sub B_CONTIG () {0x8;}' unless defined(&B_CONTIG);
    eval 'sub B_MODIFY () {0x1;}' unless defined(&B_MODIFY);
    if(defined(&_KERNEL)) {
	eval 'sub BIO_GETPRIO {
	    my($bp) = @_;
    	    eval q((($bp)-> &b_prio));
	}' unless defined(&BIO_GETPRIO);
	eval 'sub BIO_SETPRIO {
	    my($bp, $prio) = @_;
    	    eval q(($bp)-> &b_prio = ($prio));
	}' unless defined(&BIO_SETPRIO);
	eval 'sub BIO_COPYPRIO {
	    my($bp1, $bp2) = @_;
    	    eval q( &BIO_SETPRIO($bp1,  &BIO_GETPRIO($bp2)));
	}' unless defined(&BIO_COPYPRIO);
	eval 'sub BPRIO_NPRIO () {3;}' unless defined(&BPRIO_NPRIO);
	eval 'sub BPRIO_TIMECRITICAL () {2;}' unless defined(&BPRIO_TIMECRITICAL);
	eval 'sub BPRIO_TIMELIMITED () {1;}' unless defined(&BPRIO_TIMELIMITED);
	eval 'sub BPRIO_TIMENONCRITICAL () {0;}' unless defined(&BPRIO_TIMENONCRITICAL);
	eval 'sub BPRIO_DEFAULT () { &BPRIO_TIMELIMITED;}' unless defined(&BPRIO_DEFAULT);
	if(defined(&DDB) || defined(&DEBUGPRINT)) {
	}
    }
}
1;
