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/featuretest.ph';
    require 'sys/ipc.ph';
    if(defined(&_KERNEL)) {
	require 'sys/condvar.ph';
	require 'sys/mutex.ph';
    }
    if(defined(&_KERNEL)) {
    }
    eval 'sub MSG_NOERROR () {010000;}' unless defined(&MSG_NOERROR);
    if(defined(&_NETBSD_SOURCE)) {
    }
    if(defined(&_KERNEL)) {
	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);
	eval 'sub MSG_LOCKED () {01000;}' unless defined(&MSG_LOCKED);
	eval 'sub SYSCTL_FILL_MSG {
	    my($src, $dst) = @_;
    	    eval q( &do {  &SYSCTL_FILL_PERM(($src). &msg_perm, ($dst). &msg_perm); ($dst). &msg_qnum = ($src). &msg_qnum; ($dst). &msg_qbytes = ($src). &msg_qbytes; ($dst). &_msg_cbytes = ($src). &_msg_cbytes; ($dst). &msg_lspid = ($src). &msg_lspid; ($dst). &msg_lrpid = ($src). &msg_lrpid; ($dst). &msg_stime = ($src). &msg_stime; ($dst). &msg_rtime = ($src). &msg_rtime; ($dst). &msg_ctime = ($src). &msg_ctime; }  &while ( 0));
	}' unless defined(&SYSCTL_FILL_MSG);
    }
    unless(defined(&_KERNEL)) {
	require 'sys/cdefs.ph';
    } else {
	require 'sys/systm.ph';
    }
}
1;
