require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_MSG_H_)) {
    eval 'sub _SYS_MSG_H_ () {1;}' unless defined(&_SYS_MSG_H_);
    require 'sys/ipc.ph';
    require 'sys/queue.ph';
    eval 'sub MSG_NOERROR () {010000;}' unless defined(&MSG_NOERROR);
    if(defined(&_KERNEL)) {
	eval 'sub MSGQ_READERS () {0x1;}' unless defined(&MSGQ_READERS);
	eval 'sub MSGQ_WRITERS () {0x2;}' unless defined(&MSGQ_WRITERS);
	eval 'sub MSGQ_DYING () {0x4;}' unless defined(&MSGQ_DYING);
	eval 'sub QREF {
	    my($q) = @_;
    	    eval q(($q)-> &que_references++);
	}' unless defined(&QREF);
	eval 'sub QRELE {
	    my($q) = @_;
    	    eval q( &do {  &if (--($q)-> &que_references == 0 && ($q)-> &que_flags &  &MSGQ_DYING)  &wakeup_one(($q)-> &que_references); }  &while (0));
	}' unless defined(&QRELE);
    }
    if(defined(&_KERNEL)) {
	if(defined(&SYSVMSG)) {
	}
	unless(defined(&MSGSSZ)) {
	    eval 'sub MSGSSZ () {8;}' unless defined(&MSGSSZ);
	}
	unless(defined(&MSGSEG)) {
	    eval 'sub MSGSEG () {2048;}' unless defined(&MSGSEG);
	}
	undef(&MSGMAX) if defined(&MSGMAX);
	eval 'sub MSGMAX () {( &MSGSSZ* &MSGSEG);}' unless defined(&MSGMAX);
	unless(defined(&MSGMNB)) {
	    eval 'sub MSGMNB () {2048;}' unless defined(&MSGMNB);
	}
	unless(defined(&MSGMNI)) {
	    eval 'sub MSGMNI () {40;}' unless defined(&MSGMNI);
	}
	unless(defined(&MSGTQL)) {
	    eval 'sub MSGTQL () {40;}' unless defined(&MSGTQL);
	}
	eval 'sub MSQID {
	    my($ix,$ds) = @_;
    	    eval q((($ix) & 0xffff | ((($ds). ($msg_perm->{seq}) << 16) & 0xffff0000)));
	}' unless defined(&MSQID);
	eval 'sub MSQID_IX {
	    my($id) = @_;
    	    eval q((($id) & 0xffff));
	}' unless defined(&MSQID_IX);
	eval 'sub MSQID_SEQ {
	    my($id) = @_;
    	    eval q(((($id) >> 16) & 0xffff));
	}' unless defined(&MSQID_SEQ);
    }
    if(defined(&_KERNEL)) {
	eval 'sub MSG_LOCKED () {01000;}' unless defined(&MSG_LOCKED);
    }
    unless(defined(&_KERNEL)) {
	require 'sys/cdefs.ph';
    } else {
    }
}
1;
