require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_FILE_H_)) {
    eval 'sub _SYS_FILE_H_ () {1;}' unless defined(&_SYS_FILE_H_);
    require 'sys/fcntl.ph';
    require 'sys/unistd.ph';
    if(defined(&_KERNEL) || defined(&_KMEMUSER)) {
	require 'sys/queue.ph';
	require 'sys/mutex.ph';
	require 'sys/condvar.ph';
	eval 'sub f_vnode () { ($f_undata->{fd_vp});}' unless defined(&f_vnode);
	eval 'sub f_socket () { ($f_undata->{fd_so});}' unless defined(&f_socket);
	eval 'sub f_pipe () { ($f_undata->{fd_pipe});}' unless defined(&f_pipe);
	eval 'sub f_kqueue () { ($f_undata->{fd_kq});}' unless defined(&f_kqueue);
	eval 'sub f_data () { ($f_undata->{fd_data});}' unless defined(&f_data);
	eval 'sub f_mqueue () { ($f_undata->{fd_mq});}' unless defined(&f_mqueue);
	eval 'sub f_ksem () { ($f_undata->{fd_ks});}' unless defined(&f_ksem);
	eval 'sub f_eventfd () { ($f_undata->{fd_eventfd});}' unless defined(&f_eventfd);
	eval 'sub f_timerfd () { ($f_undata->{fd_timerfd});}' unless defined(&f_timerfd);
	eval 'sub f_rndctx () { ($f_undata->{fd_rndctx});}' unless defined(&f_rndctx);
	eval 'sub f_audioctx () { ($f_undata->{fd_audioctx});}' unless defined(&f_audioctx);
	eval 'sub f_pad () { ($f_undata->{fd_pad});}' unless defined(&f_pad);
	eval 'sub f_devunit () { ($f_undata->{fd_devunit});}' unless defined(&f_devunit);
	eval 'sub f_bpf () { ($f_undata->{fd_bpf});}' unless defined(&f_bpf);
	eval 'sub f_fcrypt () { ($f_undata->{fd_fcrypt});}' unless defined(&f_fcrypt);
	eval 'sub f_iscsi () { ($f_undata->{fd_iscsi});}' unless defined(&f_iscsi);
    }
    eval 'sub DTYPE_VNODE () {1;}' unless defined(&DTYPE_VNODE);
    eval 'sub DTYPE_SOCKET () {2;}' unless defined(&DTYPE_SOCKET);
    eval 'sub DTYPE_PIPE () {3;}' unless defined(&DTYPE_PIPE);
    eval 'sub DTYPE_KQUEUE () {4;}' unless defined(&DTYPE_KQUEUE);
    eval 'sub DTYPE_MISC () {5;}' unless defined(&DTYPE_MISC);
    eval 'sub DTYPE_CRYPTO () {6;}' unless defined(&DTYPE_CRYPTO);
    eval 'sub DTYPE_MQUEUE () {7;}' unless defined(&DTYPE_MQUEUE);
    eval 'sub DTYPE_SEM () {8;}' unless defined(&DTYPE_SEM);
    eval 'sub DTYPE_EVENTFD () {9;}' unless defined(&DTYPE_EVENTFD);
    eval 'sub DTYPE_TIMERFD () {10;}' unless defined(&DTYPE_TIMERFD);
    eval 'sub DTYPE_NAMES () {"0", "file", "socket", "pipe", "kqueue", "misc", "crypto", "mqueue", "semaphore", "eventfd", "timerfd";}' unless defined(&DTYPE_NAMES);
    if(defined(&_KERNEL)) {
	eval 'sub FOF_UPDATE_OFFSET () {0x1;}' unless defined(&FOF_UPDATE_OFFSET);
	eval 'sub FOF_IOV_SYSSPACE () {0x100;}' unless defined(&FOF_IOV_SYSSPACE);
    }
}
1;
