require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_EXTENT_H_)) {
    eval 'sub _SYS_EXTENT_H_ () {1;}' unless defined(&_SYS_EXTENT_H_);
    require 'sys/queue.ph';
    require 'sys/mutex.ph';
    require 'sys/condvar.ph';
    unless(defined(&_KERNEL)) {
	require 'stdbool.ph';
    }
    eval 'sub ER_ALLOC () {0x1;}' unless defined(&ER_ALLOC);
    eval 'sub EXF_FIXED () { &__BIT(0);}' unless defined(&EXF_FIXED);
    eval 'sub EXF_NOCOALESCE () { &__BIT(1);}' unless defined(&EXF_NOCOALESCE);
    eval 'sub EXF_EARLY () { &__BIT(2);}' unless defined(&EXF_EARLY);
    eval 'sub EXF_BITS () {"\\20\\3EARLY\\2NOCOALESCE\\1FIXED";}' unless defined(&EXF_BITS);
    eval 'sub EX_NOWAIT () {0;}' unless defined(&EX_NOWAIT);
    eval 'sub EX_WAITOK () { &__BIT(0);}' unless defined(&EX_WAITOK);
    eval 'sub EX_FAST () { &__BIT(1);}' unless defined(&EX_FAST);
    eval 'sub EX_CATCH () { &__BIT(2);}' unless defined(&EX_CATCH);
    eval 'sub EX_NOCOALESCE () { &__BIT(3);}' unless defined(&EX_NOCOALESCE);
    eval 'sub EX_MALLOCOK () { &__BIT(4);}' unless defined(&EX_MALLOCOK);
    eval 'sub EX_WAITSPACE () { &__BIT(5);}' unless defined(&EX_WAITSPACE);
    eval 'sub EX_BOUNDZERO () { &__BIT(6);}' unless defined(&EX_BOUNDZERO);
    eval 'sub EX_EARLY () { &__BIT(7);}' unless defined(&EX_EARLY);
    eval 'sub EX_NOALIGN () {1;}' unless defined(&EX_NOALIGN);
    eval 'sub EX_NOBOUNDARY () {0;}' unless defined(&EX_NOBOUNDARY);
    if(defined(&_KERNEL) || defined(&_EXTENT_TESTING)) {
	eval 'sub EXTENT_FIXED_STORAGE_SIZE {
	    my($_nregions) = @_;
    	    eval q(( &ALIGN($sizeof{\'struct extent_fixed\'}) + (( &ALIGN($sizeof{\'struct extent_region\'})) * ($_nregions))));
	}' unless defined(&EXTENT_FIXED_STORAGE_SIZE);
    }
}
1;
