require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_RWLOCK_H_)) {
    eval 'sub _SYS_RWLOCK_H_ () {1;}' unless defined(&_SYS_RWLOCK_H_);
    if(!defined(&_KERNEL)) {
	require 'sys/types.ph';
	require 'sys/inttypes.ph';
    }
    eval("sub RW_READER () { 0; }") unless defined(&RW_READER);
    eval("sub RW_WRITER () { 1; }") unless defined(&RW_WRITER);
    if(defined(&__RWLOCK_PRIVATE)) {
	require 'sys/stdbool.ph';
	eval 'sub RW_HAS_WAITERS () {0x1;}' unless defined(&RW_HAS_WAITERS);
	eval 'sub RW_WRITE_WANTED () {0x2;}' unless defined(&RW_WRITE_WANTED);
	eval 'sub RW_WRITE_LOCKED () {0x4;}' unless defined(&RW_WRITE_LOCKED);
	eval 'sub RW_NODEBUG () {0x10;}' unless defined(&RW_NODEBUG);
	eval 'sub RW_READ_COUNT_SHIFT () {5;}' unless defined(&RW_READ_COUNT_SHIFT);
	eval 'sub RW_READ_INCR () {(1 <<  &RW_READ_COUNT_SHIFT);}' unless defined(&RW_READ_INCR);
	eval 'sub RW_THREAD () {(( &uintptr_t)- &RW_READ_INCR);}' unless defined(&RW_THREAD);
	eval 'sub RW_OWNER {
	    my($rw) = @_;
    	    eval q((($rw)-> &rw_owner &  &RW_THREAD));
	}' unless defined(&RW_OWNER);
	eval 'sub RW_COUNT {
	    my($rw) = @_;
    	    eval q((($rw)-> &rw_owner &  &RW_THREAD));
	}' unless defined(&RW_COUNT);
	eval 'sub RW_FLAGS {
	    my($rw) = @_;
    	    eval q((($rw)-> &rw_owner & ~ &RW_THREAD));
	}' unless defined(&RW_FLAGS);
    }
    if(defined(&_KERNEL)) {
    }
}
1;
