require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_POWERPC_INTR_H_)) {
    eval 'sub _POWERPC_INTR_H_ () {1;}' unless defined(&_POWERPC_INTR_H_);
    eval 'sub IPL_NONE () {0;}' unless defined(&IPL_NONE);
    eval 'sub IPL_BIO () {1;}' unless defined(&IPL_BIO);
    eval 'sub IPL_AUDIO () { &IPL_BIO;}' unless defined(&IPL_AUDIO);
    eval 'sub IPL_NET () {2;}' unless defined(&IPL_NET);
    eval 'sub IPL_TTY () {3;}' unless defined(&IPL_TTY);
    eval 'sub IPL_VM () {4;}' unless defined(&IPL_VM);
    eval 'sub IPL_CLOCK () {5;}' unless defined(&IPL_CLOCK);
    eval 'sub IPL_HIGH () {6;}' unless defined(&IPL_HIGH);
    eval 'sub IPL_NUM () {7;}' unless defined(&IPL_NUM);
    eval 'sub IST_NONE () {0;}' unless defined(&IST_NONE);
    eval 'sub IST_PULSE () {1;}' unless defined(&IST_PULSE);
    eval 'sub IST_EDGE () {2;}' unless defined(&IST_EDGE);
    eval 'sub IST_LEVEL () {3;}' unless defined(&IST_LEVEL);
    if(defined( &_KERNEL)  && !defined( &_LOCORE)) {
	require 'sys/evcount.ph';
	require 'machine/atomic.ph';
	eval 'sub PPC_NIRQ () {66;}' unless defined(&PPC_NIRQ);
	eval 'sub PPC_CLK_IRQ () {64;}' unless defined(&PPC_CLK_IRQ);
	eval 'sub PPC_STAT_IRQ () {65;}' unless defined(&PPC_STAT_IRQ);
	eval 'sub splassert {
	    my($wantipl) = @_;
    	    eval q();
	}' unless defined(&splassert);
	eval 'sub splsoftassert {
	    my($wantipl) = @_;
    	    eval q();
	}' unless defined(&splsoftassert);
	eval 'sub SINTBIT {
	    my($q) = @_;
    	    eval q((31- ($q)));
	}' unless defined(&SINTBIT);
	eval 'sub SINTMASK {
	    my($q) = @_;
    	    eval q((1<<  &SINTBIT($q)));
	}' unless defined(&SINTMASK);
	eval 'sub SPL_CLOCKMASK () { &SINTMASK( &SI_NQUEUES);}' unless defined(&SPL_CLOCKMASK);
	eval 'sub IPL_SOFTCLOCK () {0;}' unless defined(&IPL_SOFTCLOCK);
	eval 'sub IPL_SOFTNET () {1;}' unless defined(&IPL_SOFTNET);
	eval 'sub IPL_SOFTTTY () {2;}' unless defined(&IPL_SOFTTTY);
	eval 'sub SI_SOFTCLOCK () {0;}' unless defined(&SI_SOFTCLOCK);
	eval 'sub SI_SOFTNET () {1;}' unless defined(&SI_SOFTNET);
	eval 'sub SI_SOFTTTY () {2;}' unless defined(&SI_SOFTTTY);
	eval 'sub SINT_ALLMASK () {( &SINTMASK( &SI_SOFTCLOCK) |  &SINTMASK( &SI_SOFTNET) |  &SINTMASK( &SI_SOFTTTY));}' unless defined(&SINT_ALLMASK);
	eval 'sub SI_NQUEUES () {3;}' unless defined(&SI_NQUEUES);
	require 'machine/mutex.ph';
	require 'sys/queue.ph';
	eval 'sub setsoftnet () {
	    eval q( &softintr_schedule( &softnet_intrhand));
	}' unless defined(&setsoftnet);
	eval 'sub SINT_CLOCK () { &SINTMASK( &SI_SOFTCLOCK);}' unless defined(&SINT_CLOCK);
	eval 'sub SINT_NET () { &SINTMASK( &SI_SOFTNET);}' unless defined(&SINT_NET);
	eval 'sub SINT_TTY () { &SINTMASK( &SI_SOFTTTY);}' unless defined(&SINT_TTY);
	eval 'sub splbio () {
	    eval q( &splraise( $imask[ &IPL_BIO]));
	}' unless defined(&splbio);
	eval 'sub splnet () {
	    eval q( &splraise( $imask[ &IPL_NET]));
	}' unless defined(&splnet);
	eval 'sub spltty () {
	    eval q( &splraise( $imask[ &IPL_TTY]));
	}' unless defined(&spltty);
	eval 'sub splaudio () {
	    eval q( &splraise( $imask[ &IPL_AUDIO]));
	}' unless defined(&splaudio);
	eval 'sub splclock () {
	    eval q( &splraise( $imask[ &IPL_CLOCK]));
	}' unless defined(&splclock);
	eval 'sub splvm () {
	    eval q( &splraise( $imask[ &IPL_VM]));
	}' unless defined(&splvm);
	eval 'sub splsched () {
	    eval q( &splhigh());
	}' unless defined(&splsched);
	eval 'sub spllock () {
	    eval q( &splhigh());
	}' unless defined(&spllock);
	eval 'sub splstatclock () {
	    eval q( &splhigh());
	}' unless defined(&splstatclock);
	eval 'sub splsoftclock () {
	    eval q( &splraise( &SINT_CLOCK));
	}' unless defined(&splsoftclock);
	eval 'sub splsoftnet () {
	    eval q( &splraise( &SINT_NET| &SINT_CLOCK));
	}' unless defined(&splsoftnet);
	eval 'sub splsofttty () {
	    eval q( &splraise( &SINT_TTY| &SINT_NET| &SINT_CLOCK));
	}' unless defined(&splsofttty);
	eval 'sub splhigh () {
	    eval q( &splraise(0xffffffff));
	}' unless defined(&splhigh);
	eval 'sub spl0 () {
	    eval q( &spllower(0));
	}' unless defined(&spl0);
	eval 'sub MAX_PRECONF_INTR () {16;}' unless defined(&MAX_PRECONF_INTR);
	eval 'sub PPC_IPI_NOP () {0;}' unless defined(&PPC_IPI_NOP);
	eval 'sub PPC_IPI_DDB () {1;}' unless defined(&PPC_IPI_DDB);
    }
}
1;
