require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SPARC64_PSL_)) {
    eval 'sub _SPARC64_PSL_ () {1;}' unless defined(&_SPARC64_PSL_);
    eval 'sub PIL_SCSI () {3;}' unless defined(&PIL_SCSI);
    eval 'sub PIL_FDSOFT () {4;}' unless defined(&PIL_FDSOFT);
    eval 'sub PIL_AUSOFT () {4;}' unless defined(&PIL_AUSOFT);
    eval 'sub PIL_BIO () {5;}' unless defined(&PIL_BIO);
    eval 'sub PIL_VIDEO () {5;}' unless defined(&PIL_VIDEO);
    eval 'sub PIL_TTY () {6;}' unless defined(&PIL_TTY);
    eval 'sub PIL_LPT () {6;}' unless defined(&PIL_LPT);
    eval 'sub PIL_NET () {6;}' unless defined(&PIL_NET);
    eval 'sub PIL_VM () {7;}' unless defined(&PIL_VM);
    eval 'sub PIL_AUD () {8;}' unless defined(&PIL_AUD);
    eval 'sub PIL_CLOCK () {10;}' unless defined(&PIL_CLOCK);
    eval 'sub PIL_FD () {11;}' unless defined(&PIL_FD);
    eval 'sub PIL_SER () {12;}' unless defined(&PIL_SER);
    eval 'sub PIL_STATCLOCK () {14;}' unless defined(&PIL_STATCLOCK);
    eval 'sub PIL_HIGH () {15;}' unless defined(&PIL_HIGH);
    eval 'sub PIL_SCHED () { &PIL_STATCLOCK;}' unless defined(&PIL_SCHED);
    eval 'sub PIL_LOCK () { &PIL_HIGH;}' unless defined(&PIL_LOCK);
    eval 'sub ICC_C () {0x1;}' unless defined(&ICC_C);
    eval 'sub ICC_V () {0x2;}' unless defined(&ICC_V);
    eval 'sub ICC_Z () {0x4;}' unless defined(&ICC_Z);
    eval 'sub ICC_N () {0x8;}' unless defined(&ICC_N);
    eval 'sub XCC_SHIFT () {4;}' unless defined(&XCC_SHIFT);
    eval 'sub XCC_C () {( &ICC_C<< &XCC_SHIFT);}' unless defined(&XCC_C);
    eval 'sub XCC_V () {( &ICC_V<< &XCC_SHIFT);}' unless defined(&XCC_V);
    eval 'sub XCC_Z () {( &ICC_Z<< &XCC_SHIFT);}' unless defined(&XCC_Z);
    eval 'sub XCC_N () {( &ICC_N<< &XCC_SHIFT);}' unless defined(&XCC_N);
    eval 'sub PSTATE_IG () {0x800;}' unless defined(&PSTATE_IG);
    eval 'sub PSTATE_MG () {0x400;}' unless defined(&PSTATE_MG);
    eval 'sub PSTATE_CLE () {0x200;}' unless defined(&PSTATE_CLE);
    eval 'sub PSTATE_TLE () {0x100;}' unless defined(&PSTATE_TLE);
    eval 'sub PSTATE_MM () {0xc0;}' unless defined(&PSTATE_MM);
    eval 'sub PSTATE_MM_TSO () {0x;}' unless defined(&PSTATE_MM_TSO);
    eval 'sub PSTATE_MM_PSO () {0x40;}' unless defined(&PSTATE_MM_PSO);
    eval 'sub PSTATE_MM_RMO () {0x80;}' unless defined(&PSTATE_MM_RMO);
    eval 'sub PSTATE_RED () {0x20;}' unless defined(&PSTATE_RED);
    eval 'sub PSTATE_PEF () {0x10;}' unless defined(&PSTATE_PEF);
    eval 'sub PSTATE_AM () {0x8;}' unless defined(&PSTATE_AM);
    eval 'sub PSTATE_PRIV () {0x4;}' unless defined(&PSTATE_PRIV);
    eval 'sub PSTATE_IE () {0x2;}' unless defined(&PSTATE_IE);
    eval 'sub PSTATE_AG () {0x1;}' unless defined(&PSTATE_AG);
    eval 'sub PSTATE_BITS () {"\\20\\14IG\\13MG\\12CLE\\11TLE\\10\\7MM\\6RED\\5PEF\\4AM\\3PRIV\\2IE\\1AG";}' unless defined(&PSTATE_BITS);
    eval 'sub PSTATE_PROM () {( &PSTATE_MM_TSO| &PSTATE_PRIV);}' unless defined(&PSTATE_PROM);
    eval 'sub PSTATE_NUCLEUS () {( &PSTATE_MM_TSO| &PSTATE_PRIV| &PSTATE_AG);}' unless defined(&PSTATE_NUCLEUS);
    eval 'sub PSTATE_KERN () {( &PSTATE_MM_TSO| &PSTATE_PRIV);}' unless defined(&PSTATE_KERN);
    eval 'sub PSTATE_INTR () {( &PSTATE_KERN| &PSTATE_IE);}' unless defined(&PSTATE_INTR);
    eval 'sub PSTATE_USER32 () {( &PSTATE_MM_TSO| &PSTATE_AM| &PSTATE_IE);}' unless defined(&PSTATE_USER32);
    eval 'sub PSTATE_USER () {( &PSTATE_MM_RMO| &PSTATE_IE);}' unless defined(&PSTATE_USER);
    eval 'sub TSTATE_CWP () {0x1f;}' unless defined(&TSTATE_CWP);
    eval 'sub TSTATE_PSTATE () {0x6ff00;}' unless defined(&TSTATE_PSTATE);
    eval 'sub TSTATE_PSTATE_SHIFT () {8;}' unless defined(&TSTATE_PSTATE_SHIFT);
    eval 'sub TSTATE_ASI () {0xff000000;}' unless defined(&TSTATE_ASI);
    eval 'sub TSTATE_ASI_SHIFT () {24;}' unless defined(&TSTATE_ASI_SHIFT);
    eval 'sub TSTATE_CCR () {0xff00000000;}' unless defined(&TSTATE_CCR);
    eval 'sub TSTATE_CCR_SHIFT () {32;}' unless defined(&TSTATE_CCR_SHIFT);
    eval 'sub PSR_ICC () {0xf00000;}' unless defined(&PSR_ICC);
    eval 'sub PSRCC_TO_TSTATE {
        my($x) = @_;
	    eval q(((( &int64_t)($x) &PSR_ICC)<<( &TSTATE_CCR_SHIFT-19)));
    }' unless defined(&PSRCC_TO_TSTATE);
    eval 'sub TSTATECCR_TO_PSR {
        my($x) = @_;
	    eval q(((($x) &TSTATE_CCR)>>( &TSTATE_CCR_SHIFT-19)));
    }' unless defined(&TSTATECCR_TO_PSR);
    eval 'sub TSTATE_IG () {( &PSTATE_IG<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_IG);
    eval 'sub TSTATE_MG () {( &PSTATE_MG<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_MG);
    eval 'sub TSTATE_CLE () {( &PSTATE_CLE<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_CLE);
    eval 'sub TSTATE_TLE () {( &PSTATE_TLE<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_TLE);
    eval 'sub TSTATE_MM () {( &PSTATE_MM<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_MM);
    eval 'sub TSTATE_MM_TSO () {( &PSTATE_MM_TSO<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_MM_TSO);
    eval 'sub TSTATE_MM_PSO () {( &PSTATE_MM_PSO<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_MM_PSO);
    eval 'sub TSTATE_MM_RMO () {( &PSTATE_MM_RMO<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_MM_RMO);
    eval 'sub TSTATE_RED () {( &PSTATE_RED<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_RED);
    eval 'sub TSTATE_PEF () {( &PSTATE_PEF<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_PEF);
    eval 'sub TSTATE_AM () {( &PSTATE_AM<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_AM);
    eval 'sub TSTATE_PRIV () {( &PSTATE_PRIV<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_PRIV);
    eval 'sub TSTATE_IE () {( &PSTATE_IE<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_IE);
    eval 'sub TSTATE_AG () {( &PSTATE_AG<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_AG);
    eval 'sub TSTATE_BITS () {"\\20\\14IG\\13MG\\12CLE\\11TLE\\10\\7MM\\6RED\\5PEF\\4AM\\3PRIV\\2IE\\1AG";}' unless defined(&TSTATE_BITS);
    eval 'sub TSTATE_KERN () {(( &PSTATE_KERN)<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_KERN);
    eval 'sub TSTATE_USER () {(( &PSTATE_USER)<< &TSTATE_PSTATE_SHIFT);}' unless defined(&TSTATE_USER);
    eval 'sub VER_MANUF () {0xffff000000000000;}' unless defined(&VER_MANUF);
    eval 'sub VER_MANUF_SHIFT () {48;}' unless defined(&VER_MANUF_SHIFT);
    eval 'sub VER_IMPL () {0xffff00000000;}' unless defined(&VER_IMPL);
    eval 'sub VER_IMPL_SHIFT () {32;}' unless defined(&VER_IMPL_SHIFT);
    eval 'sub VER_MASK () {0xff000000;}' unless defined(&VER_MASK);
    eval 'sub VER_MASK_SHIFT () {24;}' unless defined(&VER_MASK_SHIFT);
    eval 'sub VER_MAXTL () {0xff00;}' unless defined(&VER_MAXTL);
    eval 'sub VER_MAXTL_SHIFT () {8;}' unless defined(&VER_MAXTL_SHIFT);
    eval 'sub VER_MAXWIN () {0x1f;}' unless defined(&VER_MAXWIN);
    eval 'sub IMPL_SPARC64 () {0x1;}' unless defined(&IMPL_SPARC64);
    eval 'sub IMPL_SPARC64_II () {0x2;}' unless defined(&IMPL_SPARC64_II);
    eval 'sub IMPL_SPARC64_III () {0x3;}' unless defined(&IMPL_SPARC64_III);
    eval 'sub IMPL_SPARC64_IV () {0x4;}' unless defined(&IMPL_SPARC64_IV);
    eval 'sub IMPL_ZEUS () {0x5;}' unless defined(&IMPL_ZEUS);
    eval 'sub IMPL_OLYMPUS_C () {0x6;}' unless defined(&IMPL_OLYMPUS_C);
    eval 'sub IMPL_JUPITER () {0x7;}' unless defined(&IMPL_JUPITER);
    eval 'sub IMPL_SPITFIRE () {0x10;}' unless defined(&IMPL_SPITFIRE);
    eval 'sub IMPL_BLACKBIRD () {0x11;}' unless defined(&IMPL_BLACKBIRD);
    eval 'sub IMPL_SABRE () {0x12;}' unless defined(&IMPL_SABRE);
    eval 'sub IMPL_HUMMINGBIRD () {0x13;}' unless defined(&IMPL_HUMMINGBIRD);
    eval 'sub IMPL_CHEETAH () {0x14;}' unless defined(&IMPL_CHEETAH);
    eval 'sub IMPL_CHEETAH_PLUS () {0x15;}' unless defined(&IMPL_CHEETAH_PLUS);
    eval 'sub IMPL_JALAPENO () {0x16;}' unless defined(&IMPL_JALAPENO);
    eval 'sub IMPL_JAGUAR () {0x18;}' unless defined(&IMPL_JAGUAR);
    eval 'sub IMPL_PANTHER () {0x19;}' unless defined(&IMPL_PANTHER);
    eval 'sub IMPL_SERRANO () {0x22;}' unless defined(&IMPL_SERRANO);
    eval 'sub KERN_MM () { &PSTATE_MM_TSO;}' unless defined(&KERN_MM);
    eval 'sub USER_MM () { &PSTATE_MM_RMO;}' unless defined(&USER_MM);
    eval 'sub WSTATE_KERN () {027;}' unless defined(&WSTATE_KERN);
    eval 'sub WSTATE_USER () {022;}' unless defined(&WSTATE_USER);
    eval 'sub CWP () {0x1f;}' unless defined(&CWP);
    eval 'sub BLOCK_SIZE () {64;}' unless defined(&BLOCK_SIZE);
    eval 'sub BLOCK_ALIGN () {0x3f;}' unless defined(&BLOCK_ALIGN);
    if(defined( &_KERNEL)  && !defined( &_LOCORE)) {
	unless(defined(&SPLDEBUG)) {
	}
	if(defined(&DIAGNOSTIC)) {
	    eval 'sub splassert {
	        my($__wantipl) = @_;
    		eval q( &do {  &if ( &splassert_ctl > 0) {  &splassert_check($__wantipl,  &__func__); } }  &while (0));
	    }' unless defined(&splassert);
	    eval 'sub splsoftassert {
	        my($wantipl) = @_;
    		eval q( &splassert($wantipl));
	    }' unless defined(&splsoftassert);
	} else {
	    eval 'sub splassert {
	        my($wantipl) = @_;
    		eval q( &do { }  &while (0));
	    }' unless defined(&splassert);
	    eval 'sub splsoftassert {
	        my($wantipl) = @_;
    		eval q( &do { }  &while (0));
	    }' unless defined(&splsoftassert);
	}
	eval 'sub setpstate {
	    my($newpstate) = @_;
    	    eval q({  &sparc_wrpr( &pstate, $newpstate, 0); });
	}' unless defined(&setpstate);
	eval 'sub setcwp {
	    my($newcwp) = @_;
    	    eval q({  &sparc_wrpr( &cwp, $newcwp, 0); });
	}' unless defined(&setcwp);
	eval 'sub intr_disable {
	    eval q({  &u_int64_t  &s;  &s =  &sparc_rdpr( &pstate);  &sparc_wrpr( &pstate,  &s & ~ &PSTATE_IE, 0); ( &s); });
	}' unless defined(&intr_disable);
	eval 'sub intr_restore {
	    my($s) = @_;
    	    eval q({  &sparc_wrpr( &pstate, $s, 0); });
	}' unless defined(&intr_restore);
	eval 'sub stxa_sync {
	    my($va,$asi,$val) = @_;
    	    eval q({  &u_int64_t  &s =  &intr_disable();  &stxa_nc($va, $asi, $val);  &membar( &Sync);  &intr_restore( &s); });
	}' unless defined(&stxa_sync);
	if(defined(&SPLDEBUG)) {
	    eval 'sub SPLPRINT {
	        my($x) = @_;
    		eval q( &if( &printspl) { \'int\'  &i=10000000;  &prom_printf $x ;  &while( &i--); });
	    }' unless defined(&SPLPRINT);
	    eval 'sub SPL {
	        my($name, $newpil) = @_;
    		eval q( &extern  &__inline \'int\' $name &X( &const \'char\' *, \'int\');  &extern  &__inline \'int\' $name &X( &const \'char\' * &file, \'int\'  &line) {  &u_int64_t  &oldpil =  &sparc_rdpr( &pil);  &SPLPRINT((\\"{%s:%d %d=>%d}\\",  &file,  &line,  &oldpil, $newpil));  &sparc_wrpr( &pil, $newpil, 0);  &return ( &oldpil); });
	    }' unless defined(&SPL);
	    eval 'sub SPLHOLD {
	        my($name, $newpil) = @_;
    		eval q( &extern  &__inline \'int\' $name &X( &const \'char\' *, \'int\');  &extern  &__inline \'int\' $name &X( &const \'char\' *  &file, \'int\'  &line) { \'int\'  &oldpil =  &sparc_rdpr( &pil);  &if ( &__predict_false(( &u_int64_t)$newpil <=  &oldpil))  &return ( &oldpil);  &SPLPRINT((\\"{%s:%d %d->!d}\\",  &file,  &line,  &oldpil, $newpil));  &sparc_wrpr( &pil, $newpil, 0);  &return ( &oldpil); });
	    }' unless defined(&SPLHOLD);
	} else {
	    eval 'sub SPLPRINT {
	        my($x) = @_;
    		eval q();
	    }' unless defined(&SPLPRINT);
	    eval 'sub SPL {
	        my($name, $newpil) = @_;
    		eval q( &extern  &__inline \'int\' $name( &void);  &extern  &__inline \'int\' $name() { \'int\'  &oldpil;  &__asm  &__volatile(\\"    rdpr %%pil, %0		\\\\n\\" \\"    wrpr %%g0, %1, %%pil	\\\\n\\" : \\"=&r\\" ( &oldpil) : \\"n\\" ($newpil) : \\"%g0\\");  &__asm  &__volatile(\\"\\" : : : \\"memory\\");  &return ( &oldpil); });
	    }' unless defined(&SPL);
	    eval 'sub SPLHOLD {
	        my($name, $newpil) = @_;
    		eval q( &extern  &__inline \'int\' $name( &void);  &extern  &__inline \'int\' $name() { \'int\'  &oldpil;  &if ($newpil <= 1) {  &__asm  &__volatile(\\"    rdpr	%%pil, %0	\\\\n\\" \\"    brnz,pn	%0, 1f		\\\\n\\" \\"     nop			\\\\n\\" \\"    wrpr	%%g0, %1, %%pil	\\\\n\\" \\"1:				\\\\n\\" : \\"=&r\\" ( &oldpil) : \\"I\\" ($newpil) : \\"%g0\\"); }  &else {  &__asm  &__volatile(\\"    rdpr	%%pil, %0	\\\\n\\" \\"    cmp	%0, %1 - 1	\\\\n\\" \\"    bgu,pn	%%xcc, 1f	\\\\n\\" \\"     nop			\\\\n\\" \\"    wrpr	%%g0, %1, %%pil	\\\\n\\" \\"1:				\\\\n\\" : \\"=&r\\" ( &oldpil) : \\"I\\" ($newpil) : \\"cc\\"); }  &__asm  &__volatile(\\"\\" : : : \\"memory\\");  &return ( &oldpil); });
	    }' unless defined(&SPLHOLD);
	}
	eval 'sub splsoftclock () { &splsoftint;}' unless defined(&splsoftclock);
	eval 'sub splsoftnet () { &splsoftint;}' unless defined(&splsoftnet);
	if(defined(&SPLDEBUG)) {
	    eval 'sub spl0 () {
	        eval q( &spl0X( &__FILE__,  &__LINE__));
	    }' unless defined(&spl0);
	    eval 'sub splsoftint () {
	        eval q( &splsoftintX( &__FILE__,  &__LINE__));
	    }' unless defined(&splsoftint);
	    eval 'sub splausoft () {
	        eval q( &splausoftX( &__FILE__,  &__LINE__));
	    }' unless defined(&splausoft);
	    eval 'sub splfdsoft () {
	        eval q( &splfdsoftX( &__FILE__,  &__LINE__));
	    }' unless defined(&splfdsoft);
	    eval 'sub splbio () {
	        eval q( &splbioX( &__FILE__,  &__LINE__));
	    }' unless defined(&splbio);
	    eval 'sub splnet () {
	        eval q( &splnetX( &__FILE__,  &__LINE__));
	    }' unless defined(&splnet);
	    eval 'sub spltty () {
	        eval q( &splttyX( &__FILE__,  &__LINE__));
	    }' unless defined(&spltty);
	    eval 'sub spllpt () {
	        eval q( &spllptX( &__FILE__,  &__LINE__));
	    }' unless defined(&spllpt);
	    eval 'sub splvm () {
	        eval q( &splvmX( &__FILE__,  &__LINE__));
	    }' unless defined(&splvm);
	    eval 'sub splclock () {
	        eval q( &splclockX( &__FILE__,  &__LINE__));
	    }' unless defined(&splclock);
	    eval 'sub splfd () {
	        eval q( &splfdX( &__FILE__,  &__LINE__));
	    }' unless defined(&splfd);
	    eval 'sub splzs () {
	        eval q( &splzsX( &__FILE__,  &__LINE__));
	    }' unless defined(&splzs);
	    eval 'sub splserial () {
	        eval q( &splzerialX( &__FILE__,  &__LINE__));
	    }' unless defined(&splserial);
	    eval 'sub splaudio () {
	        eval q( &splaudioX( &__FILE__,  &__LINE__));
	    }' unless defined(&splaudio);
	    eval 'sub splstatclock () {
	        eval q( &splstatclockX( &__FILE__,  &__LINE__));
	    }' unless defined(&splstatclock);
	    eval 'sub splsched () {
	        eval q( &splschedX( &__FILE__,  &__LINE__));
	    }' unless defined(&splsched);
	    eval 'sub spllock () {
	        eval q( &spllockX( &__FILE__,  &__LINE__));
	    }' unless defined(&spllock);
	    eval 'sub splhigh () {
	        eval q( &splhighX( &__FILE__,  &__LINE__));
	    }' unless defined(&splhigh);
	    eval 'sub splx {
	        my($x) = @_;
    		eval q( &splxX(($x), &__FILE__,  &__LINE__));
	    }' unless defined(&splx);
	}
	if(defined(&SPLDEBUG)) {
	}
    }
}
1;
