require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_SYS_EXTENT_H_)) {
    eval 'sub _SYS_EXTENT_H_ () {1;}' unless defined(&_SYS_EXTENT_H_);
    require 'sys/queue.ph';
    eval 'sub ER_ALLOC () {0x1;}' unless defined(&ER_ALLOC);
    eval 'sub EXF_FIXED () {0x1;}' unless defined(&EXF_FIXED);
    eval 'sub EXF_NOCOALESCE () {0x2;}' unless defined(&EXF_NOCOALESCE);
    eval 'sub EXF_WANTED () {0x4;}' unless defined(&EXF_WANTED);
    eval 'sub EXF_FLWANTED () {0x8;}' unless defined(&EXF_FLWANTED);
    eval 'sub EXF_BITS () {"\\20\\4FLWANTED\\3WANTED\\2NOCOALESCE\\1FIXED";}' unless defined(&EXF_BITS);
    eval 'sub EX_NOWAIT () {0x;}' unless defined(&EX_NOWAIT);
    eval 'sub EX_WAITOK () {0x1;}' unless defined(&EX_WAITOK);
    eval 'sub EX_FAST () {0x2;}' unless defined(&EX_FAST);
    eval 'sub EX_CATCH () {0x4;}' unless defined(&EX_CATCH);
    eval 'sub EX_NOCOALESCE () {0x8;}' unless defined(&EX_NOCOALESCE);
    eval 'sub EX_MALLOCOK () {0x10;}' unless defined(&EX_MALLOCOK);
    eval 'sub EX_WAITSPACE () {0x20;}' unless defined(&EX_WAITSPACE);
    eval 'sub EX_BOUNDZERO () {0x40;}' unless defined(&EX_BOUNDZERO);
    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);
	eval 'sub extent_alloc {
	    my($_ex, $_size, $_alignment, $_skew, $_boundary, 		$_flags, $_result) = @_;
    	    eval q( &extent_alloc_subregion(($_ex), ($_ex)-> &ex_start, ($_ex)-> &ex_end, ($_size), ($_alignment), ($_skew), ($_boundary), ($_flags), ($_result)));
	}' unless defined(&extent_alloc);
    }
}
1;
