require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_DEV_I2C_I2CVAR_H_)) {
    eval 'sub _DEV_I2C_I2CVAR_H_ () {1;}' unless defined(&_DEV_I2C_I2CVAR_H_);
    require 'dev/i2c/i2c_io.ph';
    eval 'sub I2C_F_WRITE () {0x;}' unless defined(&I2C_F_WRITE);
    eval 'sub I2C_F_READ () {0x1;}' unless defined(&I2C_F_READ);
    eval 'sub I2C_F_LAST () {0x2;}' unless defined(&I2C_F_LAST);
    eval 'sub I2C_F_STOP () {0x4;}' unless defined(&I2C_F_STOP);
    eval 'sub I2C_F_POLL () {0x8;}' unless defined(&I2C_F_POLL);
    if(defined(&_I2C_PRIVATE)) {
	eval 'sub iic_send_start {
	    my($ic, $flags) = @_;
    	    eval q((*($ic)-> &ic_send_start)(($ic)-> &ic_cookie, ($flags)));
	}' unless defined(&iic_send_start);
	eval 'sub iic_send_stop {
	    my($ic, $flags) = @_;
    	    eval q((*($ic)-> &ic_send_stop)(($ic)-> &ic_cookie, ($flags)));
	}' unless defined(&iic_send_stop);
	eval 'sub iic_initiate_xfer {
	    my($ic, $addr, $flags) = @_;
    	    eval q((*($ic)-> &ic_initiate_xfer)(($ic)-> &ic_cookie, ($addr), ($flags)));
	}' unless defined(&iic_initiate_xfer);
	eval 'sub iic_read_byte {
	    my($ic, $bytep, $flags) = @_;
    	    eval q((*($ic)-> &ic_read_byte)(($ic)-> &ic_cookie, ($bytep), ($flags)));
	}' unless defined(&iic_read_byte);
	eval 'sub iic_write_byte {
	    my($ic, $byte, $flags) = @_;
    	    eval q((*($ic)-> &ic_write_byte)(($ic)-> &ic_cookie, ($byte), ($flags)));
	}' unless defined(&iic_write_byte);
    }
    eval 'sub iic_acquire_bus {
        my($ic, $flags) = @_;
	    eval q((*($ic)-> &ic_acquire_bus)(($ic)-> &ic_cookie, ($flags)));
    }' unless defined(&iic_acquire_bus);
    eval 'sub iic_release_bus {
        my($ic, $flags) = @_;
	    eval q((*($ic)-> &ic_release_bus)(($ic)-> &ic_cookie, ($flags)));
    }' unless defined(&iic_release_bus);
}
1;
