require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_MMAN_H_)) {
    eval 'sub _SYS_MMAN_H_ () {1;}' unless defined(&_SYS_MMAN_H_);
    require 'sys/featuretest.ph';
    require 'machine/ansi.ph';
    if(defined(&_BSD_SIZE_T_)) {
	undef(&_BSD_SIZE_T_) if defined(&_BSD_SIZE_T_);
    }
    require 'sys/ansi.ph';
    unless(defined(&mode_t)) {
	eval 'sub mode_t () { &__mode_t;}' unless defined(&mode_t);
    }
    unless(defined(&off_t)) {
	eval 'sub off_t () { &__off_t;}' unless defined(&off_t);
    }
    eval 'sub PROT_NONE () {0x;}' unless defined(&PROT_NONE);
    eval 'sub PROT_READ () {0x1;}' unless defined(&PROT_READ);
    eval 'sub PROT_WRITE () {0x2;}' unless defined(&PROT_WRITE);
    eval 'sub PROT_EXEC () {0x4;}' unless defined(&PROT_EXEC);
    if(defined(&_NETBSD_SOURCE)) {
	eval 'sub PROT_MPROTECT {
	    my($x) = @_;
    	    eval q((($x) << 3));
	}' unless defined(&PROT_MPROTECT);
	eval 'sub PROT_MPROTECT_EXTRACT {
	    my($x) = @_;
    	    eval q(((($x) >> 3) & 0x7));
	}' unless defined(&PROT_MPROTECT_EXTRACT);
    }
    eval 'sub MAP_SHARED () {0x1;}' unless defined(&MAP_SHARED);
    eval 'sub MAP_PRIVATE () {0x2;}' unless defined(&MAP_PRIVATE);
    eval 'sub MAP_REMAPDUP () {0x4;}' unless defined(&MAP_REMAPDUP);
    eval 'sub MAP_FIXED () {0x10;}' unless defined(&MAP_FIXED);
    eval 'sub MAP_RENAME () {0x20;}' unless defined(&MAP_RENAME);
    eval 'sub MAP_NORESERVE () {0x40;}' unless defined(&MAP_NORESERVE);
    eval 'sub MAP_INHERIT () {0x80;}' unless defined(&MAP_INHERIT);
    eval 'sub MAP_HASSEMAPHORE () {0x200;}' unless defined(&MAP_HASSEMAPHORE);
    eval 'sub MAP_TRYFIXED () {0x400;}' unless defined(&MAP_TRYFIXED);
    eval 'sub MAP_WIRED () {0x800;}' unless defined(&MAP_WIRED);
    eval 'sub MAP_FILE () {0x;}' unless defined(&MAP_FILE);
    eval 'sub MAP_ANONYMOUS () {0x1000;}' unless defined(&MAP_ANONYMOUS);
    eval 'sub MAP_ANON () { &MAP_ANONYMOUS;}' unless defined(&MAP_ANON);
    eval 'sub MAP_STACK () {0x2000;}' unless defined(&MAP_STACK);
    eval 'sub MAP_ALIGNED {
        my($n) = @_;
	    eval q(((($n) <<  &MAP_ALIGNMENT_SHIFT)));
    }' unless defined(&MAP_ALIGNED);
    eval 'sub MAP_ALIGNMENT_SHIFT () {24;}' unless defined(&MAP_ALIGNMENT_SHIFT);
    eval 'sub MAP_ALIGNMENT_MASK () { &MAP_ALIGNED(0xff);}' unless defined(&MAP_ALIGNMENT_MASK);
    eval 'sub MAP_ALIGNMENT_64KB () { &MAP_ALIGNED(16);}' unless defined(&MAP_ALIGNMENT_64KB);
    eval 'sub MAP_ALIGNMENT_16MB () { &MAP_ALIGNED(24);}' unless defined(&MAP_ALIGNMENT_16MB);
    eval 'sub MAP_ALIGNMENT_4GB () { &MAP_ALIGNED(32);}' unless defined(&MAP_ALIGNMENT_4GB);
    eval 'sub MAP_ALIGNMENT_1TB () { &MAP_ALIGNED(40);}' unless defined(&MAP_ALIGNMENT_1TB);
    eval 'sub MAP_ALIGNMENT_256TB () { &MAP_ALIGNED(48);}' unless defined(&MAP_ALIGNMENT_256TB);
    eval 'sub MAP_ALIGNMENT_64PB () { &MAP_ALIGNED(56);}' unless defined(&MAP_ALIGNMENT_64PB);
    if(defined(&_NETBSD_SOURCE)) {
	eval 'sub MAP_FMT () {"\\177\\020" "b\\0" "SHARED\\0" "b\\1" "PRIVATE\\0" "b\\2" "COPY\\0" "b\\4" "FIXED\\0" "b\\5" "RENAME\\0" "b\\6" "NORESERVE\\0" "b\\7" "INHERIT\\0" "b\\11" "HASSEMAPHORE\\0" "b\\12" "TRYFIXED\\0" "b\\13" "WIRED\\0" "F\\14\\1\\0" ":\\0" "FILE\\0" ":\\1" "ANONYMOUS\\0" "b\\15" "STACK\\0" "F\\30\\010\\0" ":\\000" "ALIGN=NONE\\0" ":\\012" "ALIGN=1KB\\0" ":\\013" "ALIGN=2KB\\0" ":\\014" "ALIGN=4KB\\0" ":\\015" "ALIGN=8KB\\0" ":\\016" "ALIGN=16KB\\0" ":\\017" "ALIGN=32KB\\0" ":\\020" "ALIGN=64KB\\0" ":\\021" "ALIGN=128KB\\0" ":\\022" "ALIGN=256KB\\0" ":\\023" "ALIGN=512KB\\0" ":\\024" "ALIGN=1MB\\0" ":\\025" "ALIGN=2MB\\0" ":\\026" "ALIGN=4MB\\0" ":\\027" "ALIGN=8MB\\0" ":\\030" "ALIGN=16MB\\0" ":\\034" "ALIGN=256MB\\0" ":\\040" "ALIGN=4GB\\0" ":\\044" "ALIGN=64GB\\0" ":\\050" "ALIGN=1TB\\0" ":\\054" "ALIGN=16TB\\0" ":\\060" "ALIGN=256TB\\0" ":\\064" "ALIGN=4PB\\0" ":\\070" "ALIGN=64PB\\0" ":\\074" "ALIGN=256PB\\0" "*" "ALIGN=2^%ju\\0";}' unless defined(&MAP_FMT);
    }
    eval 'sub MAP_FAILED () {(( &void *) -1);}' unless defined(&MAP_FAILED);
    eval 'sub MS_ASYNC () {0x1;}' unless defined(&MS_ASYNC);
    eval 'sub MS_INVALIDATE () {0x2;}' unless defined(&MS_INVALIDATE);
    eval 'sub MS_SYNC () {0x4;}' unless defined(&MS_SYNC);
    eval 'sub MCL_CURRENT () {0x1;}' unless defined(&MCL_CURRENT);
    eval 'sub MCL_FUTURE () {0x2;}' unless defined(&MCL_FUTURE);
    eval 'sub POSIX_MADV_NORMAL () {0;}' unless defined(&POSIX_MADV_NORMAL);
    eval 'sub POSIX_MADV_RANDOM () {1;}' unless defined(&POSIX_MADV_RANDOM);
    eval 'sub POSIX_MADV_SEQUENTIAL () {2;}' unless defined(&POSIX_MADV_SEQUENTIAL);
    eval 'sub POSIX_MADV_WILLNEED () {3;}' unless defined(&POSIX_MADV_WILLNEED);
    eval 'sub POSIX_MADV_DONTNEED () {4;}' unless defined(&POSIX_MADV_DONTNEED);
    if(defined(&_NETBSD_SOURCE)) {
	eval 'sub MADV_NORMAL () { &POSIX_MADV_NORMAL;}' unless defined(&MADV_NORMAL);
	eval 'sub MADV_RANDOM () { &POSIX_MADV_RANDOM;}' unless defined(&MADV_RANDOM);
	eval 'sub MADV_SEQUENTIAL () { &POSIX_MADV_SEQUENTIAL;}' unless defined(&MADV_SEQUENTIAL);
	eval 'sub MADV_WILLNEED () { &POSIX_MADV_WILLNEED;}' unless defined(&MADV_WILLNEED);
	eval 'sub MADV_DONTNEED () { &POSIX_MADV_DONTNEED;}' unless defined(&MADV_DONTNEED);
	eval 'sub MADV_SPACEAVAIL () {5;}' unless defined(&MADV_SPACEAVAIL);
	eval 'sub MADV_FREE () {6;}' unless defined(&MADV_FREE);
	eval 'sub MAP_INHERIT_SHARE () {0;}' unless defined(&MAP_INHERIT_SHARE);
	eval 'sub MAP_INHERIT_COPY () {1;}' unless defined(&MAP_INHERIT_COPY);
	eval 'sub MAP_INHERIT_NONE () {2;}' unless defined(&MAP_INHERIT_NONE);
	eval 'sub MAP_INHERIT_DONATE_COPY () {3;}' unless defined(&MAP_INHERIT_DONATE_COPY);
	eval 'sub MAP_INHERIT_ZERO () {4;}' unless defined(&MAP_INHERIT_ZERO);
	eval 'sub MAP_INHERIT_DEFAULT () { &MAP_INHERIT_COPY;}' unless defined(&MAP_INHERIT_DEFAULT);
    }
    unless(defined(&_KERNEL)) {
	require 'sys/cdefs.ph';
	unless(defined(&__LIBC12_SOURCE__)) {
	}
	if(defined(&_NETBSD_SOURCE)) {
	}
    }
}
1;
