require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_AMD64_SEGMENTS_H_)) {
    eval 'sub _AMD64_SEGMENTS_H_ () {1;}' unless defined(&_AMD64_SEGMENTS_H_);
    eval 'sub ISPL {
        my($s) = @_;
	    eval q((($s) &  &SEL_RPL));
    }' unless defined(&ISPL);
    eval 'sub SEL_KPL () {0;}' unless defined(&SEL_KPL);
    eval 'sub SEL_UPL () {3;}' unless defined(&SEL_UPL);
    eval 'sub SEL_RPL () {3;}' unless defined(&SEL_RPL);
    eval 'sub ISLDT {
        my($s) = @_;
	    eval q((($s) &  &SEL_LDT));
    }' unless defined(&ISLDT);
    eval 'sub SEL_LDT () {4;}' unless defined(&SEL_LDT);
    eval 'sub SYSSEL_START () {( &NGDT_MEM << 3);}' unless defined(&SYSSEL_START);
    eval 'sub DYNSEL_START () {( &SYSSEL_START + ( &NGDT_SYS << 4));}' unless defined(&DYNSEL_START);
    eval 'sub IDXSEL {
        my($s) = @_;
	    eval q(((($s) >> 3) & 0x1fff));
    }' unless defined(&IDXSEL);
    eval 'sub IDXDYNSEL {
        my($s) = @_;
	    eval q((((($s) & ~ &SEL_RPL) -  &DYNSEL_START) >> 4));
    }' unless defined(&IDXDYNSEL);
    eval 'sub GSEL {
        my($s,$r) = @_;
	    eval q(((($s) << 3) | $r));
    }' unless defined(&GSEL);
    eval 'sub GSYSSEL {
        my($s,$r) = @_;
	    eval q((((($s) << 4) +  &SYSSEL_START) | $r));
    }' unless defined(&GSYSSEL);
    eval 'sub GDYNSEL {
        my($s,$r) = @_;
	    eval q((((($s) << 4) +  &DYNSEL_START) | $r |  &SEL_KPL));
    }' unless defined(&GDYNSEL);
    eval 'sub LSEL {
        my($s,$r) = @_;
	    eval q((($s) | $r |  &SEL_LDT));
    }' unless defined(&LSEL);
    eval 'sub USERMODE {
        my($c, $f) = @_;
	    eval q(( &ISPL($c) ==  &SEL_UPL));
    }' unless defined(&USERMODE);
    eval 'sub KERNELMODE {
        my($c, $f) = @_;
	    eval q(( &ISPL($c) ==  &SEL_KPL));
    }' unless defined(&KERNELMODE);
    unless(defined(&_LOCORE)) {
	if(defined(&_KERNEL)) {
	    if(0) {
	    }
	}
    }
    eval 'sub SDT_SYSNULL () {0;}' unless defined(&SDT_SYSNULL);
    eval 'sub SDT_SYS286TSS () {1;}' unless defined(&SDT_SYS286TSS);
    eval 'sub SDT_SYSLDT () {2;}' unless defined(&SDT_SYSLDT);
    eval 'sub SDT_SYS286BSY () {3;}' unless defined(&SDT_SYS286BSY);
    eval 'sub SDT_SYS286CGT () {4;}' unless defined(&SDT_SYS286CGT);
    eval 'sub SDT_SYSTASKGT () {5;}' unless defined(&SDT_SYSTASKGT);
    eval 'sub SDT_SYS286IGT () {6;}' unless defined(&SDT_SYS286IGT);
    eval 'sub SDT_SYS286TGT () {7;}' unless defined(&SDT_SYS286TGT);
    eval 'sub SDT_SYSNULL2 () {8;}' unless defined(&SDT_SYSNULL2);
    eval 'sub SDT_SYS386TSS () {9;}' unless defined(&SDT_SYS386TSS);
    eval 'sub SDT_SYSNULL3 () {10;}' unless defined(&SDT_SYSNULL3);
    eval 'sub SDT_SYS386BSY () {11;}' unless defined(&SDT_SYS386BSY);
    eval 'sub SDT_SYS386CGT () {12;}' unless defined(&SDT_SYS386CGT);
    eval 'sub SDT_SYSNULL4 () {13;}' unless defined(&SDT_SYSNULL4);
    eval 'sub SDT_SYS386IGT () {14;}' unless defined(&SDT_SYS386IGT);
    eval 'sub SDT_SYS386TGT () {15;}' unless defined(&SDT_SYS386TGT);
    eval 'sub SDT_MEMRO () {16;}' unless defined(&SDT_MEMRO);
    eval 'sub SDT_MEMROA () {17;}' unless defined(&SDT_MEMROA);
    eval 'sub SDT_MEMRW () {18;}' unless defined(&SDT_MEMRW);
    eval 'sub SDT_MEMRWA () {19;}' unless defined(&SDT_MEMRWA);
    eval 'sub SDT_MEMROD () {20;}' unless defined(&SDT_MEMROD);
    eval 'sub SDT_MEMRODA () {21;}' unless defined(&SDT_MEMRODA);
    eval 'sub SDT_MEMRWD () {22;}' unless defined(&SDT_MEMRWD);
    eval 'sub SDT_MEMRWDA () {23;}' unless defined(&SDT_MEMRWDA);
    eval 'sub SDT_MEME () {24;}' unless defined(&SDT_MEME);
    eval 'sub SDT_MEMEA () {25;}' unless defined(&SDT_MEMEA);
    eval 'sub SDT_MEMER () {26;}' unless defined(&SDT_MEMER);
    eval 'sub SDT_MEMERA () {27;}' unless defined(&SDT_MEMERA);
    eval 'sub SDT_MEMEC () {28;}' unless defined(&SDT_MEMEC);
    eval 'sub SDT_MEMEAC () {29;}' unless defined(&SDT_MEMEAC);
    eval 'sub SDT_MEMERC () {30;}' unless defined(&SDT_MEMERC);
    eval 'sub SDT_MEMERAC () {31;}' unless defined(&SDT_MEMERAC);
    eval 'sub ISMEMSDP {
        my($s) = @_;
	    eval q((( ($s->{d_type})) >=  &SDT_MEMRO  && ( ($s->{d_type})) <=  &SDT_MEMERAC));
    }' unless defined(&ISMEMSDP);
    eval 'sub IS286GDP {
        my($s) = @_;
	    eval q((( ($s->{d_type})) >=  &SDT_SYS286CGT  && ( ($s->{d_type})) <  &SDT_SYS286TGT));
    }' unless defined(&IS286GDP);
    eval 'sub IS386GDP {
        my($s) = @_;
	    eval q((( ($s->{d_type})) >=  &SDT_SYS386CGT  && ( ($s->{d_type})) <  &SDT_SYS386TGT));
    }' unless defined(&IS386GDP);
    eval 'sub ISGDP {
        my($s) = @_;
	    eval q(( &IS286GDP($s) ||  &IS386GDP($s)));
    }' unless defined(&ISGDP);
    eval 'sub ISSDP {
        my($s) = @_;
	    eval q(( &ISMEMSDP($s) || ! &ISGDP($s)));
    }' unless defined(&ISSDP);
    eval 'sub ISSYSSDP {
        my($s) = @_;
	    eval q((! &ISMEMSDP($s)  && ! &ISGDP($s)));
    }' unless defined(&ISSYSSDP);
    eval 'sub SEGEX_EXT () {0x1;}' unless defined(&SEGEX_EXT);
    eval 'sub SEGEX_IDT () {0x2;}' unless defined(&SEGEX_IDT);
    eval 'sub SEGEX_TI () {0x4;}' unless defined(&SEGEX_TI);
    eval 'sub NIDT () {256;}' unless defined(&NIDT);
    eval 'sub NRSVIDT () {32;}' unless defined(&NRSVIDT);
    eval 'sub GNULL_SEL () {0;}' unless defined(&GNULL_SEL);
    eval 'sub GCODE_SEL () {1;}' unless defined(&GCODE_SEL);
    eval 'sub GDATA_SEL () {2;}' unless defined(&GDATA_SEL);
    eval 'sub GUCODE_SEL () {3;}' unless defined(&GUCODE_SEL);
    eval 'sub GUDATA_SEL () {4;}' unless defined(&GUDATA_SEL);
    eval 'sub GAPM32CODE_SEL () {5;}' unless defined(&GAPM32CODE_SEL);
    eval 'sub GAPM16CODE_SEL () {6;}' unless defined(&GAPM16CODE_SEL);
    eval 'sub GAPMDATA_SEL () {7;}' unless defined(&GAPMDATA_SEL);
    eval 'sub GBIOSCODE_SEL () {8;}' unless defined(&GBIOSCODE_SEL);
    eval 'sub GBIOSDATA_SEL () {9;}' unless defined(&GBIOSDATA_SEL);
    eval 'sub GPNPBIOSCODE_SEL () {10;}' unless defined(&GPNPBIOSCODE_SEL);
    eval 'sub GPNPBIOSDATA_SEL () {11;}' unless defined(&GPNPBIOSDATA_SEL);
    eval 'sub GPNPBIOSSCRATCH_SEL () {12;}' unless defined(&GPNPBIOSSCRATCH_SEL);
    eval 'sub GPNPBIOSTRAMP_SEL () {13;}' unless defined(&GPNPBIOSTRAMP_SEL);
    eval 'sub GUCODE32_SEL () {14;}' unless defined(&GUCODE32_SEL);
    eval 'sub GUDATA32_SEL () {15;}' unless defined(&GUDATA32_SEL);
    eval 'sub NGDT_MEM () {16;}' unless defined(&NGDT_MEM);
    eval 'sub GLDT_SEL () {0;}' unless defined(&GLDT_SEL);
    eval 'sub NGDT_SYS () {1;}' unless defined(&NGDT_SYS);
    eval 'sub GDT_SYS_OFFSET () {( &NGDT_MEM << 3);}' unless defined(&GDT_SYS_OFFSET);
    eval 'sub GDT_ADDR_MEM {
        my($s,$i) = @_;
	    eval q(((($s) + (($i) << 3))));
    }' unless defined(&GDT_ADDR_MEM);
    eval 'sub GDT_ADDR_SYS {
        my($s,$i) = @_;
	    eval q(((($s) + ((($i) << 4) +  &SYSSEL_START))));
    }' unless defined(&GDT_ADDR_SYS);
    eval 'sub LSYS5CALLS_SEL () {0;}' unless defined(&LSYS5CALLS_SEL);
    eval 'sub LUCODE32_SEL () {8;}' unless defined(&LUCODE32_SEL);
    eval 'sub LUDATA_SEL () {16;}' unless defined(&LUDATA_SEL);
    eval 'sub LUCODE_SEL () {24;}' unless defined(&LUCODE_SEL);
    eval 'sub LSOL26CALLS_SEL () {32;}' unless defined(&LSOL26CALLS_SEL);
    eval 'sub LUDATA32_SEL () {56;}' unless defined(&LUDATA32_SEL);
    eval 'sub LBSDICALLS_SEL () {128;}' unless defined(&LBSDICALLS_SEL);
    eval 'sub LDT_SIZE () {144;}' unless defined(&LDT_SIZE);
    eval 'sub LSYSRETBASE_SEL () { &LUCODE32_SEL;}' unless defined(&LSYSRETBASE_SEL);
    eval 'sub VALID_USER_DSEL32 {
        my($s) = @_;
	    eval q((($s) ==  &GSEL( &GUDATA32_SEL,  &SEL_UPL) || ($s) ==  &LSEL( &LUDATA32_SEL,  &SEL_UPL)));
    }' unless defined(&VALID_USER_DSEL32);
    eval 'sub VALID_USER_CSEL32 {
        my($s) = @_;
	    eval q((($s) ==  &GSEL( &GUCODE32_SEL,  &SEL_UPL) || ($s) ==  &LSEL( &LUCODE32_SEL,  &SEL_UPL)));
    }' unless defined(&VALID_USER_CSEL32);
    eval 'sub VALID_USER_CSEL {
        my($s) = @_;
	    eval q((($s) ==  &GSEL( &GUCODE_SEL,  &SEL_UPL) || ($s) ==  &LSEL( &LUCODE_SEL,  &SEL_UPL)));
    }' unless defined(&VALID_USER_CSEL);
    eval 'sub VALID_USER_DSEL {
        my($s) = @_;
	    eval q((($s) ==  &GSEL( &GUDATA_SEL,  &SEL_UPL) || ($s) ==  &LSEL( &LUDATA_SEL,  &SEL_UPL)));
    }' unless defined(&VALID_USER_DSEL);
}
1;
