require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_TYPES_H_)) {
    eval 'sub _SYS_TYPES_H_ () {1;}' unless defined(&_SYS_TYPES_H_);
    require 'sys/featuretest.ph';
    require 'machine/types.ph';
    require 'machine/ansi.ph';
    require 'machine/int_types.ph';
    require 'sys/ansi.ph';
    unless(defined(&_BSD_INT8_T_)) {
	eval 'sub _BSD_INT8_T_ () {1;}' unless defined(&_BSD_INT8_T_);
    }
    unless(defined(&_BSD_UINT8_T_)) {
	eval 'sub _BSD_UINT8_T_ () {1;}' unless defined(&_BSD_UINT8_T_);
    }
    unless(defined(&_BSD_INT16_T_)) {
	eval 'sub _BSD_INT16_T_ () {1;}' unless defined(&_BSD_INT16_T_);
    }
    unless(defined(&_BSD_UINT16_T_)) {
	eval 'sub _BSD_UINT16_T_ () {1;}' unless defined(&_BSD_UINT16_T_);
    }
    unless(defined(&_BSD_INT32_T_)) {
	eval 'sub _BSD_INT32_T_ () {1;}' unless defined(&_BSD_INT32_T_);
    }
    unless(defined(&_BSD_UINT32_T_)) {
	eval 'sub _BSD_UINT32_T_ () {1;}' unless defined(&_BSD_UINT32_T_);
    }
    unless(defined(&_BSD_INT64_T_)) {
	eval 'sub _BSD_INT64_T_ () {1;}' unless defined(&_BSD_INT64_T_);
    }
    unless(defined(&_BSD_UINT64_T_)) {
	eval 'sub _BSD_UINT64_T_ () {1;}' unless defined(&_BSD_UINT64_T_);
    }
    require 'machine/endian.ph';
    if(defined(&_NETBSD_SOURCE)) {
    }
    unless(defined(&fsblkcnt_t)) {
	eval 'sub fsblkcnt_t () { &__fsblkcnt_t;}' unless defined(&fsblkcnt_t);
    }
    unless(defined(&fsfilcnt_t)) {
	eval 'sub fsfilcnt_t () { &__fsfilcnt_t;}' unless defined(&fsfilcnt_t);
    }
    if(!defined(&_KERNEL)  && !defined(&_STANDALONE)) {
	unless(defined(&caddr_t)) {
	    eval 'sub caddr_t () { &__caddr_t;}' unless defined(&caddr_t);
	}
    }
    if(defined(&__daddr_t)) {
	undef(&__daddr_t) if defined(&__daddr_t);
    } else {
    }
    unless(defined(&gid_t)) {
	eval 'sub gid_t () { &__gid_t;}' unless defined(&gid_t);
    }
    if(defined(&__ino_t)) {
	undef(&__ino_t) if defined(&__ino_t);
    } else {
    }
    unless(defined(&mode_t)) {
	eval 'sub mode_t () { &__mode_t;}' unless defined(&mode_t);
    }
    unless(defined(&accmode_t)) {
	eval 'sub accmode_t () { &__accmode_t;}' unless defined(&accmode_t);
    }
    unless(defined(&off_t)) {
	eval 'sub off_t () { &__off_t;}' unless defined(&off_t);
    }
    unless(defined(&pid_t)) {
	eval 'sub pid_t () { &__pid_t;}' unless defined(&pid_t);
    }
    unless(defined(&uid_t)) {
	eval 'sub uid_t () { &__uid_t;}' unless defined(&uid_t);
    }
    if(defined(&_KERNEL) || defined(&_STANDALONE)) {
	require 'sys/stdbool.ph';
	unless(defined(&TRUE)) {
	    eval 'sub TRUE () {1;}' unless defined(&TRUE);
	}
	unless(defined(&FALSE)) {
	    eval 'sub FALSE () {0;}' unless defined(&FALSE);
	}
    }
    if(defined(&_KERNEL) || defined(&_LIBC) || defined(&_KMEMUSER)) {
	require 'sys/stdint.ph';
    }
    if(defined(&_NETBSD_SOURCE)) {
	unless(defined(&__OFF_T_SYSCALLS_DECLARED)) {
	    eval 'sub __OFF_T_SYSCALLS_DECLARED () {1;}' unless defined(&__OFF_T_SYSCALLS_DECLARED);
	    unless(defined(&_KERNEL)) {
		require 'sys/cdefs.ph';
	    }
	}
    }
    if(defined(&_NETBSD_SOURCE)) {
	eval 'sub devmajor_t () { &__devmajor_t;}' unless defined(&devmajor_t);
	eval 'sub devminor_t () { &__devminor_t;}' unless defined(&devminor_t);
	eval 'sub NODEVMAJOR () {(-1);}' unless defined(&NODEVMAJOR);
	eval 'sub major {
	    my($x) = @_;
    	    eval q((( &devmajor_t)((( &uint32_t)($x) & 0xfff00) >> 8)));
	}' unless defined(&major);
	eval 'sub minor {
	    my($x) = @_;
    	    eval q((( &devminor_t)(((( &uint32_t)($x) & 0xfff00000) >> 12) | ((( &uint32_t)($x) & 0xff) >> 0))));
	}' unless defined(&minor);
	eval 'sub makedev {
	    my($x,$y) = @_;
    	    eval q((( &dev_t)(((( &dev_t)($x) << 8) & 0xfff00) | ((( &dev_t)($y) << 12) & 0xfff00000) | ((( &dev_t)($y) << 0) & 0xff))));
	}' unless defined(&makedev);
    }
    if(defined(&_BSD_CLOCK_T_)) {
	undef(&_BSD_CLOCK_T_) if defined(&_BSD_CLOCK_T_);
    }
    if(defined(&_BSD_PTRDIFF_T_)) {
	undef(&_BSD_PTRDIFF_T_) if defined(&_BSD_PTRDIFF_T_);
    }
    if(defined(&_BSD_SIZE_T_)) {
	eval 'sub _SIZE_T () {1;}' unless defined(&_SIZE_T);
	undef(&_BSD_SIZE_T_) if defined(&_BSD_SIZE_T_);
    }
    if(defined(&_BSD_SSIZE_T_)) {
	undef(&_BSD_SSIZE_T_) if defined(&_BSD_SSIZE_T_);
    }
    if(defined(&_BSD_TIME_T_)) {
	undef(&_BSD_TIME_T_) if defined(&_BSD_TIME_T_);
    }
    if(defined(&_BSD_CLOCKID_T_)) {
	undef(&_BSD_CLOCKID_T_) if defined(&_BSD_CLOCKID_T_);
    }
    if(defined(&_BSD_TIMER_T_)) {
	undef(&_BSD_TIMER_T_) if defined(&_BSD_TIMER_T_);
    }
    if(defined(&_BSD_SUSECONDS_T_)) {
	undef(&_BSD_SUSECONDS_T_) if defined(&_BSD_SUSECONDS_T_);
    }
    if(defined(&_BSD_USECONDS_T_)) {
	undef(&_BSD_USECONDS_T_) if defined(&_BSD_USECONDS_T_);
    }
    if(defined(&_NETBSD_SOURCE)) {
	require 'sys/fd_set.ph';
	eval 'sub NBBY () {8;}' unless defined(&NBBY);
    }
    if(defined(&__STDC__)  && (defined(&_KERNEL) || defined(&_KMEMUSER))) {
    }
    if(defined(&_KERNEL) || defined(&_STANDALONE)) {
	eval 'sub SET {
	    my($t, $f) = @_;
    	    eval q((($t) |= ($f)));
	}' unless defined(&SET);
	eval 'sub ISSET {
	    my($t, $f) = @_;
    	    eval q((($t) & ($f)));
	}' unless defined(&ISSET);
	eval 'sub CLR {
	    my($t, $f) = @_;
    	    eval q((($t) &= ~($f)));
	}' unless defined(&CLR);
    }
    if(!defined(&_KERNEL)  && !defined(&_STANDALONE)) {
	if(((defined(&_POSIX_C_SOURCE) ? &_POSIX_C_SOURCE : undef) - 0) >= 199506 || ((defined(&_XOPEN_SOURCE) ? &_XOPEN_SOURCE : undef) - 0) >= 500|| defined(&_NETBSD_SOURCE)) {
	    require 'pthread_types.ph';
	}
    }
}
1;
