require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_SEM_H_)) {
    eval 'sub _SYS_SEM_H_ () {1;}' unless defined(&_SYS_SEM_H_);
    require 'sys/featuretest.ph';
    require 'sys/ipc.ph';
    if(defined(&_KERNEL)) {
    }
    eval 'sub SEM_UNDO () {010000;}' unless defined(&SEM_UNDO);
    eval 'sub GETNCNT () {3;}' unless defined(&GETNCNT);
    eval 'sub GETPID () {4;}' unless defined(&GETPID);
    eval 'sub GETVAL () {5;}' unless defined(&GETVAL);
    eval 'sub GETALL () {6;}' unless defined(&GETALL);
    eval 'sub GETZCNT () {7;}' unless defined(&GETZCNT);
    eval 'sub SETVAL () {8;}' unless defined(&SETVAL);
    eval 'sub SETALL () {9;}' unless defined(&SETALL);
    if(defined(&_KERNEL)) {
	eval 'sub SEMVMX () {32767;}' unless defined(&SEMVMX);
	eval 'sub SEMAEM () {16384;}' unless defined(&SEMAEM);
	eval 'sub SEM_A () {0200;}' unless defined(&SEM_A);
	eval 'sub SEM_R () {0400;}' unless defined(&SEM_R);
    }
    if(defined(&_NETBSD_SOURCE)) {
	eval 'sub SEM_ALLOC () {01000;}' unless defined(&SEM_ALLOC);
    }
    if(defined(&_KERNEL)) {
	eval 'sub SEM_DEST () {02000;}' unless defined(&SEM_DEST);
	unless(defined(&SEMMNI)) {
	    eval 'sub SEMMNI () {10;}' unless defined(&SEMMNI);
	}
	unless(defined(&SEMMNS)) {
	    eval 'sub SEMMNS () {60;}' unless defined(&SEMMNS);
	}
	unless(defined(&SEMUME)) {
	    eval 'sub SEMUME () {10;}' unless defined(&SEMUME);
	}
	unless(defined(&SEMMNU)) {
	    eval 'sub SEMMNU () {30;}' unless defined(&SEMMNU);
	}
	unless(defined(&SEMMAP)) {
	    eval 'sub SEMMAP () {30;}' unless defined(&SEMMAP);
	}
	unless(defined(&SEMMSL)) {
	    eval 'sub SEMMSL () { &SEMMNS;}' unless defined(&SEMMSL);
	}
	unless(defined(&SEMOPM)) {
	    eval 'sub SEMOPM () {100;}' unless defined(&SEMOPM);
	}
	eval 'sub SEMUSZ () {($sizeof{\'struct sem_undo\'}+$sizeof{\'struct sem_undo_entry\'}* &SEMUME);}' unless defined(&SEMUSZ);
	eval 'sub SEM_CONFIG_FREEZE () {0;}' unless defined(&SEM_CONFIG_FREEZE);
	eval 'sub SEM_CONFIG_THAW () {1;}' unless defined(&SEM_CONFIG_THAW);
	eval 'sub SYSCTL_FILL_SEM {
	    my($src, $dst) = @_;
    	    eval q( &do {  &SYSCTL_FILL_PERM(($src). &sem_perm, ($dst). &sem_perm); ($dst). &sem_nsems = ($src). &sem_nsems; ($dst). &sem_otime = ($src). &sem_otime; ($dst). &sem_ctime = ($src). &sem_ctime; }  &while ( 0));
	}' unless defined(&SYSCTL_FILL_SEM);
    }
    unless(defined(&_KERNEL)) {
	require 'sys/cdefs.ph';
	unless(defined(&__LIBC12_SOURCE__)) {
	}
	if(defined(&_NETBSD_SOURCE)) {
	}
    } else {
	eval 'sub get_semctl_arg {
	    my($cmd, $sembuf, $arg) = @_;
    	    eval q((($cmd) ==  &IPC_SET || ($cmd) ==  &IPC_STAT ? ( &void *)$sembuf : ($cmd) ==  &GETALL || ($cmd) ==  &SETVAL || ($cmd) ==  &SETALL ? ( &void *)$arg :  &NULL));
	}' unless defined(&get_semctl_arg);
    }
}
1;
