require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_IOCCOM_H_)) {
    eval 'sub _SYS_IOCCOM_H_ () {1;}' unless defined(&_SYS_IOCCOM_H_);
    eval 'sub IOCPARM_MASK () {0x1fff;}' unless defined(&IOCPARM_MASK);
    eval 'sub IOCPARM_LEN {
        my($x) = @_;
	    eval q(((($x) >> 16) &  &IOCPARM_MASK));
    }' unless defined(&IOCPARM_LEN);
    eval 'sub IOCBASECMD {
        my($x) = @_;
	    eval q((($x) & ~( &IOCPARM_MASK << 16)));
    }' unless defined(&IOCBASECMD);
    eval 'sub IOCGROUP {
        my($x) = @_;
	    eval q(((($x) >> 8) & 0xff));
    }' unless defined(&IOCGROUP);
    eval 'sub IOCPARM_MAX () { &PAGE_SIZE;}' unless defined(&IOCPARM_MAX);
    eval 'sub IOC_VOID () {0x20000000;}' unless defined(&IOC_VOID);
    eval 'sub IOC_OUT () {0x40000000;}' unless defined(&IOC_OUT);
    eval 'sub IOC_IN () {0x80000000;}' unless defined(&IOC_IN);
    eval 'sub IOC_INOUT () {( &IOC_IN| &IOC_OUT);}' unless defined(&IOC_INOUT);
    eval 'sub IOC_DIRMASK () {0xe0000000;}' unless defined(&IOC_DIRMASK);
    if(defined(&TCPV40HDRS)) {
	eval 'sub _IOC {
	    my($inout,$group,$num,$len) = @_;
    	    eval q((  ( (($group) << 8) | ($num) ) ));
	}' unless defined(&_IOC);
    } else {
	eval 'sub _IOC {
	    my($inout,$group,$num,$len) = @_;
    	    eval q((($inout | (($len &  &IOCPARM_MASK) << 16) | (($group) << 8) | ($num))));
	}' unless defined(&_IOC);
    }
    eval 'sub _IO {
        my($g,$n) = @_;
	    eval q( &_IOC( &IOC_VOID, ($g), ($n), 0));
    }' unless defined(&_IO);
    eval 'sub _IOR {
        my($g,$n,$t) = @_;
	    eval q( &_IOC( &IOC_OUT, ($g), ($n), $sizeof{$t}));
    }' unless defined(&_IOR);
    eval 'sub _IOW {
        my($g,$n,$t) = @_;
	    eval q( &_IOC( &IOC_IN, ($g), ($n), $sizeof{$t}));
    }' unless defined(&_IOW);
    eval 'sub _IOWR {
        my($g,$n,$t) = @_;
	    eval q( &_IOC( &IOC_INOUT, ($g), ($n), $sizeof{$t}));
    }' unless defined(&_IOWR);
    unless(defined(&_KERNEL)) {
	require 'sys/cdefs.ph';
	if(defined(&TCPV40HDRS)) {
	} else {
	}
    }
    eval 'sub ioc {
        my($x,$y) = @_;
	    eval q((($x<<8)|$y));
    }' unless defined(&ioc);
}
1;
