require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_LEMAC_VAR_H)) {
    eval 'sub _LEMAC_VAR_H () {1;}' unless defined(&_LEMAC_VAR_H);
    eval 'sub LEMAC_PIO_MODE () {0x;}' unless defined(&LEMAC_PIO_MODE);
    eval 'sub LEMAC_2K_MODE () {0x1;}' unless defined(&LEMAC_2K_MODE);
    eval 'sub LEMAC_WAS_32K_MODE () {0x2;}' unless defined(&LEMAC_WAS_32K_MODE);
    eval 'sub LEMAC_WAS_64K_MODE () {0x3;}' unless defined(&LEMAC_WAS_64K_MODE);
    eval 'sub LEMAC_MODE_MASK () {0x3;}' unless defined(&LEMAC_MODE_MASK);
    eval 'sub LEMAC_ALLMULTI () {0x10;}' unless defined(&LEMAC_ALLMULTI);
    eval 'sub LEMAC_ALIVE () {0x20;}' unless defined(&LEMAC_ALIVE);
    eval 'sub LEMAC_LINKUP () {0x40;}' unless defined(&LEMAC_LINKUP);
    eval 'sub sc_if () { ($sc_arpcom->{ac_if});}' unless defined(&sc_if);
    eval 'sub LEMAC_IFP_TO_SOFTC {
        my($ifp) = @_;
	    eval q(((($ifp)-> &if_softc)));
    }' unless defined(&LEMAC_IFP_TO_SOFTC);
    eval 'sub LEMAC_USE_PIO_MODE {
        my($sc) = @_;
	    eval q(((( ($sc->{sc_flags}) &  &LEMAC_MODE_MASK) ==  &LEMAC_PIO_MODE) || ( ($sc->{sc_if}->{if_flags}) &  &IFF_LINK0)));
    }' unless defined(&LEMAC_USE_PIO_MODE);
    eval 'sub LEMAC_OUTB {
        my($sc, $o, $v) = @_;
	    eval q( &bus_space_write_1(($sc)-> &sc_iot, ($sc)-> &sc_ioh, ($o), ($v)));
    }' unless defined(&LEMAC_OUTB);
    eval 'sub LEMAC_OUTSB {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_write_multi_1(($sc)-> &sc_iot, ($sc)-> &sc_ioh, ($o), ($p), ($l)));
    }' unless defined(&LEMAC_OUTSB);
    eval 'sub LEMAC_INB {
        my($sc, $o) = @_;
	    eval q( &bus_space_read_1(($sc)-> &sc_iot, ($sc)-> &sc_ioh, ($o)));
    }' unless defined(&LEMAC_INB);
    eval 'sub LEMAC_INSB {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_read_multi_1(($sc)-> &sc_iot, ($sc)-> &sc_ioh, ($o), ($p), ($l)));
    }' unless defined(&LEMAC_INSB);
    eval 'sub LEMAC_PUTBUF8 {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_write_region_1(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($p), ($l)));
    }' unless defined(&LEMAC_PUTBUF8);
    eval 'sub LEMAC_PUTBUF16 {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_write_raw_region_2(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($p), ($l) << 1));
    }' unless defined(&LEMAC_PUTBUF16);
    eval 'sub LEMAC_PUTBUF32 {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_write_raw_region_4(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($p), ($l) << 2));
    }' unless defined(&LEMAC_PUTBUF32);
    eval 'sub LEMAC_PUT8 {
        my($sc, $o, $v) = @_;
	    eval q( &bus_space_write_1(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($v)));
    }' unless defined(&LEMAC_PUT8);
    eval 'sub LEMAC_PUT16 {
        my($sc, $o, $v) = @_;
	    eval q( &bus_space_write_2(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o),  &htole16($v)));
    }' unless defined(&LEMAC_PUT16);
    eval 'sub LEMAC_PUT32 {
        my($sc, $o, $v) = @_;
	    eval q( &bus_space_write_4(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o),  &htole32($v)));
    }' unless defined(&LEMAC_PUT32);
    eval 'sub LEMAC_GETBUF8 {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_read_region_1(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($p), ($l)));
    }' unless defined(&LEMAC_GETBUF8);
    eval 'sub LEMAC_GETBUF16 {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_read_raw_region_2(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($p), ($l) << 1));
    }' unless defined(&LEMAC_GETBUF16);
    eval 'sub LEMAC_GETBUF32 {
        my($sc, $o, $l, $p) = @_;
	    eval q( &bus_space_read_raw_region_4(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o), ($p), ($l) << 2));
    }' unless defined(&LEMAC_GETBUF32);
    eval 'sub LEMAC_GET8 {
        my($sc, $o) = @_;
	    eval q( &bus_space_read_1(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o)));
    }' unless defined(&LEMAC_GET8);
    eval 'sub LEMAC_GET16 {
        my($sc, $o) = @_;
	    eval q( &letoh16( &bus_space_read_2(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o))));
    }' unless defined(&LEMAC_GET16);
    eval 'sub LEMAC_GET32 {
        my($sc, $o) = @_;
	    eval q( &letoh32( &bus_space_read_4(($sc)-> &sc_memt, ($sc)-> &sc_memh, ($o))));
    }' unless defined(&LEMAC_GET32);
    eval 'sub LEMAC_INTR_ENABLE {
        my($sc) = @_;
	    eval q( &LEMAC_OUTB($sc,  &LEMAC_REG_IC,  &LEMAC_INB($sc,  &LEMAC_REG_IC) |  &LEMAC_IC_ALL));
    }' unless defined(&LEMAC_INTR_ENABLE);
    eval 'sub LEMAC_INTR_DISABLE {
        my($sc) = @_;
	    eval q( &LEMAC_OUTB($sc,  &LEMAC_REG_IC,  &LEMAC_INB($sc,  &LEMAC_REG_IC) & ~ &LEMAC_IC_ALL));
    }' unless defined(&LEMAC_INTR_DISABLE);
    eval 'sub LEMAC_IS_64K_MODE {
        my($mbase) = @_;
	    eval q(((($mbase) >= 0xa)  && (($mbase) <= 0xf)));
    }' unless defined(&LEMAC_IS_64K_MODE);
    eval 'sub LEMAC_IS_32K_MODE {
        my($mbase) = @_;
	    eval q(((($mbase) >= 0x14)  && (($mbase) <= 0x1f)));
    }' unless defined(&LEMAC_IS_32K_MODE);
    eval 'sub LEMAC_IS_2K_MODE {
        my($mbase) = @_;
	    eval q((($mbase) >= 0x40));
    }' unless defined(&LEMAC_IS_2K_MODE);
    eval 'sub LEMAC_DECODEIRQ {
        my($i) = @_;
	    eval q(((0xfba5 >> (($i) >> 3)) & 0xf));
    }' unless defined(&LEMAC_DECODEIRQ);
    eval 'sub LEMAC_ADDREQUAL {
        my($a1, $a2) = @_;
	    eval q(((( &u_int16_t *)$a1)[0] == (( &u_int16_t *)$a2)[0]  && (( &u_int16_t *)$a1)[1] == (( &u_int16_t *)$a2)[1]  && (( &u_int16_t *)$a1)[2] == (( &u_int16_t *)$a2)[2]));
    }' unless defined(&LEMAC_ADDREQUAL);
    eval 'sub LEMAC_ADDRBRDCST {
        my($a1) = @_;
	    eval q(((( &u_int16_t *)$a1)[0] == 0xffff  && (( &u_int16_t *)$a1)[1] == 0xffff  && (( &u_int16_t *)$a1)[2] == 0xffff));
    }' unless defined(&LEMAC_ADDRBRDCST);
}
1;
