require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_RF__RF_DISKQUEUE_H_)) {
    eval 'sub _RF__RF_DISKQUEUE_H_ () {1;}' unless defined(&_RF__RF_DISKQUEUE_H_);
    require 'rf_threadstuff.ph';
    require 'rf_acctrace.ph';
    require 'rf_alloclist.ph';
    require 'rf_types.ph';
    require 'rf_etimer.ph';
    if(defined( &__NetBSD__)) {
	require 'rf_netbsd.ph';
    }
 elsif(defined( &__OpenBSD__)) {
	require 'rf_openbsd.ph';
    }
    eval 'sub RF_IO_NORMAL_PRIORITY () {1;}' unless defined(&RF_IO_NORMAL_PRIORITY);
    eval 'sub RF_IO_LOW_PRIORITY () {0;}' unless defined(&RF_IO_LOW_PRIORITY);
    eval 'sub RF_LOCK_DISK_QUEUE () {0x1;}' unless defined(&RF_LOCK_DISK_QUEUE);
    eval 'sub RF_UNLOCK_DISK_QUEUE () {0x2;}' unless defined(&RF_UNLOCK_DISK_QUEUE);
    eval 'sub RF_DQ_LOCKED () {0x2;}' unless defined(&RF_DQ_LOCKED);
    eval 'sub RF_QUEUE_LOCKED {
        my($_q) = @_;
	    eval q((($_q)-> &flags &  &RF_DQ_LOCKED));
    }' unless defined(&RF_QUEUE_LOCKED);
    eval 'sub RF_QUEUE_EMPTY {
        my($_q) = @_;
	    eval q(((($_q)-> &numOutstanding == 0)  && (($_q)-> &nextLockingOp ==  &NULL)  && ! &RF_QUEUE_LOCKED($_q)));
    }' unless defined(&RF_QUEUE_EMPTY);
    eval 'sub RF_QUEUE_FULL {
        my($_q) = @_;
	    eval q((($_q)-> &numOutstanding == ($_q)-> &maxOutstanding));
    }' unless defined(&RF_QUEUE_FULL);
    eval 'sub RF_LOCK_QUEUE {
        my($_q) = @_;
	    eval q(($_q)-> &flags |=  &RF_DQ_LOCKED);
    }' unless defined(&RF_LOCK_QUEUE);
    eval 'sub RF_UNLOCK_QUEUE {
        my($_q) = @_;
	    eval q(($_q)-> &flags &= ~ &RF_DQ_LOCKED);
    }' unless defined(&RF_UNLOCK_QUEUE);
    eval 'sub RF_LOCK_QUEUE_MUTEX {
        my($_q_,$_wh_) = @_;
	    eval q( &RF_LOCK_MUTEX(($_q_)-> &mutex));
    }' unless defined(&RF_LOCK_QUEUE_MUTEX);
    eval 'sub RF_UNLOCK_QUEUE_MUTEX {
        my($_q_,$_wh_) = @_;
	    eval q( &RF_UNLOCK_MUTEX(($_q_)-> &mutex));
    }' unless defined(&RF_UNLOCK_QUEUE_MUTEX);
    eval 'sub RF_LOCKING_REQ {
        my($_r) = @_;
	    eval q((($_r)-> &flags &  &RF_LOCK_DISK_QUEUE));
    }' unless defined(&RF_LOCKING_REQ);
    eval 'sub RF_UNLOCKING_REQ {
        my($_r) = @_;
	    eval q((($_r)-> &flags &  &RF_UNLOCK_DISK_QUEUE));
    }' unless defined(&RF_UNLOCKING_REQ);
    eval 'sub RF_OK_TO_DISPATCH {
        my($_q_,$_r_) = @_;
	    eval q(( &RF_QUEUE_EMPTY($_q_) || ( ! &RF_QUEUE_FULL($_q_)  && (($_r_)-> &priority >= ($_q_)-> &curPriority))));
    }' unless defined(&RF_OK_TO_DISPATCH);
}
1;
