require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_EVENT_H_)) {
    eval 'sub _SYS_EVENT_H_ () {1;}' unless defined(&_SYS_EVENT_H_);
    require 'sys/featuretest.ph';
    require 'sys/types.ph';
    require 'sys/inttypes.ph';
    require 'sys/null.ph';
    eval 'sub EVFILT_READ () {0;}' unless defined(&EVFILT_READ);
    eval 'sub EVFILT_WRITE () {1;}' unless defined(&EVFILT_WRITE);
    eval 'sub EVFILT_AIO () {2;}' unless defined(&EVFILT_AIO);
    eval 'sub EVFILT_VNODE () {3;}' unless defined(&EVFILT_VNODE);
    eval 'sub EVFILT_PROC () {4;}' unless defined(&EVFILT_PROC);
    eval 'sub EVFILT_SIGNAL () {5;}' unless defined(&EVFILT_SIGNAL);
    eval 'sub EVFILT_TIMER () {6;}' unless defined(&EVFILT_TIMER);
    eval 'sub EVFILT_FS () {7;}' unless defined(&EVFILT_FS);
    eval 'sub EVFILT_USER () {8;}' unless defined(&EVFILT_USER);
    eval 'sub EVFILT_EMPTY () {9;}' unless defined(&EVFILT_EMPTY);
    eval 'sub EVFILT_SYSCOUNT () {10;}' unless defined(&EVFILT_SYSCOUNT);
    if(defined(&EVFILT_NAMES)) {
    }
    eval 'sub _EV_SET {
        my($_kevp,$_ident,$_filter,$_flags,$_fflags,$_data,$_udata) = @_;
	    eval q({  ($_kevp->{ident}) = $_ident;  ($_kevp->{filter}) = $_filter;  ($_kevp->{flags}) = $_flags;  ($_kevp->{fflags}) = $_fflags;  ($_kevp->{data}) = $_data;  ($_kevp->{udata}) = $_udata; });
    }' unless defined(&_EV_SET);
    eval 'sub EV_SET {
        my($kevp, $ident, $filter, $flags, $fflags, $data, $udata) = @_;
	    eval q( &_EV_SET(($kevp),  &__CAST( &uintptr_t, ($ident)), ($filter), ($flags), ($fflags), ($data),  &__CAST( &void *, ($udata))));
    }' unless defined(&EV_SET);
    eval 'sub EV_ADD () {0x1;}' unless defined(&EV_ADD);
    eval 'sub EV_DELETE () {0x2;}' unless defined(&EV_DELETE);
    eval 'sub EV_ENABLE () {0x4;}' unless defined(&EV_ENABLE);
    eval 'sub EV_DISABLE () {0x8;}' unless defined(&EV_DISABLE);
    eval 'sub EV_ONESHOT () {0x10;}' unless defined(&EV_ONESHOT);
    eval 'sub EV_CLEAR () {0x20;}' unless defined(&EV_CLEAR);
    eval 'sub EV_RECEIPT () {0x40;}' unless defined(&EV_RECEIPT);
    eval 'sub EV_DISPATCH () {0x80;}' unless defined(&EV_DISPATCH);
    eval 'sub EV_SYSFLAGS () {0xf000;}' unless defined(&EV_SYSFLAGS);
    eval 'sub EV_FLAG1 () {0x2000;}' unless defined(&EV_FLAG1);
    eval 'sub EV_EOF () {0x8000;}' unless defined(&EV_EOF);
    eval 'sub EV_ERROR () {0x4000;}' unless defined(&EV_ERROR);
    eval 'sub NOTE_FFNOP () {0x;}' unless defined(&NOTE_FFNOP);
    eval 'sub NOTE_FFAND () {0x40000000;}' unless defined(&NOTE_FFAND);
    eval 'sub NOTE_FFOR () {0x80000000;}' unless defined(&NOTE_FFOR);
    eval 'sub NOTE_FFCOPY () {0xc0000000;}' unless defined(&NOTE_FFCOPY);
    eval 'sub NOTE_FFCTRLMASK () {0xc0000000;}' unless defined(&NOTE_FFCTRLMASK);
    eval 'sub NOTE_FFLAGSMASK () {0xffffff;}' unless defined(&NOTE_FFLAGSMASK);
    eval 'sub NOTE_TRIGGER () {0x1000000;}' unless defined(&NOTE_TRIGGER);
    if(defined(&_KERNEL)) {
	eval 'sub NOTE_SUBMIT () {0x1000000;}' unless defined(&NOTE_SUBMIT);
    }
    eval 'sub NOTE_LOWAT () {0x1;}' unless defined(&NOTE_LOWAT);
    eval 'sub NOTE_DELETE () {0x1;}' unless defined(&NOTE_DELETE);
    eval 'sub NOTE_WRITE () {0x2;}' unless defined(&NOTE_WRITE);
    eval 'sub NOTE_EXTEND () {0x4;}' unless defined(&NOTE_EXTEND);
    eval 'sub NOTE_ATTRIB () {0x8;}' unless defined(&NOTE_ATTRIB);
    eval 'sub NOTE_LINK () {0x10;}' unless defined(&NOTE_LINK);
    eval 'sub NOTE_RENAME () {0x20;}' unless defined(&NOTE_RENAME);
    eval 'sub NOTE_REVOKE () {0x40;}' unless defined(&NOTE_REVOKE);
    eval 'sub NOTE_OPEN () {0x80;}' unless defined(&NOTE_OPEN);
    eval 'sub NOTE_CLOSE () {0x100;}' unless defined(&NOTE_CLOSE);
    eval 'sub NOTE_CLOSE_WRITE () {0x200;}' unless defined(&NOTE_CLOSE_WRITE);
    eval 'sub NOTE_READ () {0x400;}' unless defined(&NOTE_READ);
    eval 'sub NOTE_EXIT () {0x80000000;}' unless defined(&NOTE_EXIT);
    eval 'sub NOTE_FORK () {0x40000000;}' unless defined(&NOTE_FORK);
    eval 'sub NOTE_EXEC () {0x20000000;}' unless defined(&NOTE_EXEC);
    eval 'sub NOTE_PCTRLMASK () {0xf0000000;}' unless defined(&NOTE_PCTRLMASK);
    eval 'sub NOTE_PDATAMASK () {0xfffff;}' unless defined(&NOTE_PDATAMASK);
    eval 'sub NOTE_TRACK () {0x1;}' unless defined(&NOTE_TRACK);
    eval 'sub NOTE_TRACKERR () {0x2;}' unless defined(&NOTE_TRACKERR);
    eval 'sub NOTE_CHILD () {0x4;}' unless defined(&NOTE_CHILD);
    eval 'sub NOTE_MSECONDS () {0x;}' unless defined(&NOTE_MSECONDS);
    eval 'sub NOTE_SECONDS () {0x1;}' unless defined(&NOTE_SECONDS);
    eval 'sub NOTE_USECONDS () {0x2;}' unless defined(&NOTE_USECONDS);
    eval 'sub NOTE_NSECONDS () {0x3;}' unless defined(&NOTE_NSECONDS);
    eval 'sub NOTE_ABSTIME () {0x10;}' unless defined(&NOTE_ABSTIME);
    if(defined(&_KERNEL)) {
	eval 'sub NOTE_TIMER_UNITMASK () {0x3;}' unless defined(&NOTE_TIMER_UNITMASK);
    }
    require 'sys/queue.ph';
    require 'sys/ioctl.ph';
    eval 'sub KFILTER_BYFILTER () { &_IOWR(ord(\'k\'), 0, \'struct kfilter_mapping\');}' unless defined(&KFILTER_BYFILTER);
    eval 'sub KFILTER_BYNAME () { &_IOWR(ord(\'k\'), 1, \'struct kfilter_mapping\');}' unless defined(&KFILTER_BYNAME);
    if(defined(&_KERNEL)) {
	eval 'sub KNOTE {
	    my($list, $hint) = @_;
    	    eval q( &if (! &SLIST_EMPTY($list))  &knote($list, $hint));
	}' unless defined(&KNOTE);
	eval 'sub NOTE_SIGNAL () {0x8000000;}' unless defined(&NOTE_SIGNAL);
	eval 'sub EVENT_REGISTER () {1;}' unless defined(&EVENT_REGISTER);
	eval 'sub EVENT_PROCESS () {2;}' unless defined(&EVENT_PROCESS);
	eval 'sub FILTEROP_ISFD () { &__BIT(0);}' unless defined(&FILTEROP_ISFD);
	eval 'sub FILTEROP_MPSAFE () { &__BIT(1);}' unless defined(&FILTEROP_MPSAFE);
	eval 'sub KN_ACTIVE () {0x1;}' unless defined(&KN_ACTIVE);
	eval 'sub KN_QUEUED () {0x2;}' unless defined(&KN_QUEUED);
	eval 'sub KN_DISABLED () {0x4;}' unless defined(&KN_DISABLED);
	eval 'sub KN_DETACHED () {0x8;}' unless defined(&KN_DETACHED);
	eval 'sub KN_MARKER () {0x10;}' unless defined(&KN_MARKER);
	eval 'sub KN_BUSY () {0x20;}' unless defined(&KN_BUSY);
	eval 'sub KN_WILLDETACH () {0x40;}' unless defined(&KN_WILLDETACH);
	eval 'sub __KN_FLAG_BITS () {"\\20" "\\1ACTIVE" "\\2QUEUED" "\\3DISABLED" "\\4DETACHED" "\\5MARKER" "\\6BUSY" "\\7WILLDETACH";}' unless defined(&__KN_FLAG_BITS);
	eval 'sub kn_id () { ($kn_kevent->{ident});}' unless defined(&kn_id);
	eval 'sub kn_filter () { ($kn_kevent->{filter});}' unless defined(&kn_filter);
	eval 'sub kn_flags () { ($kn_kevent->{flags});}' unless defined(&kn_flags);
	eval 'sub kn_fflags () { ($kn_kevent->{fflags});}' unless defined(&kn_fflags);
	eval 'sub kn_data () { ($kn_kevent->{data});}' unless defined(&kn_data);
	require 'sys/systm.ph';
    } else {
	require 'sys/cdefs.ph';
	if(defined(&_NETBSD_SOURCE)) {
	    unless(defined(&__LIBC12_SOURCE__)) {
	    }
	}
    }
}
1;
