Several sources including Unix98 say that semctl's fourth

parameter is optional except where:
	cmd == {IPC_SET || IPC_STAT || GETALL || SETVAL || SETALL}

PR:		2448
Reviewed by:	bde
Submitted by:	Tim Singletary <tsingle@sunland.gsfc.nasa.gov>
Minor tweaks by: steve
This commit is contained in:
Steve Price 1998-05-31 04:09:09 +00:00
parent 9e8799c9cd
commit 3f58cad638
2 changed files with 27 additions and 8 deletions

View file

@ -1,19 +1,38 @@
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdarg.h>
#include <stdlib.h>
#if __STDC__
int semctl(int semid, int semnum, int cmd, union semun semun)
int semctl(int semid, int semnum, int cmd, ...)
#else
int semctl(semid, int semnum, cmd, semun)
int semctl(semid, semnum, cmd, va_alist)
int semid, semnum;
int cmd;
union semun semun;
va_dcl
#endif
{
#ifdef __NETBSD_SYSCALLS
return (__semctl(semid, semnum, cmd, &semun));
va_list ap;
union semun semun;
union semun *semun_ptr;
#ifdef __STDC__
va_start(ap, cmd);
#else
return (semsys(0, semid, semnum, cmd, &semun));
va_start(ap);
#endif
if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL
|| cmd == SETVAL || cmd == SETALL) {
semun = va_arg(ap, union semun);
semun_ptr = &semun;
} else {
semun_ptr = NULL;
}
va_end(ap);
#ifdef __NETBSD_SYSCALLS
return (__semctl(semid, semnum, cmd, semun_ptr));
#else
return (semsys(0, semid, semnum, cmd, semun_ptr));
#endif
}

View file

@ -1,4 +1,4 @@
/* $Id: sem.h,v 1.12 1997/02/22 09:45:51 peter Exp $ */
/* $Id: sem.h,v 1.13 1997/09/07 05:27:21 bde Exp $ */
/* $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $ */
/*
@ -171,7 +171,7 @@ typedef enum {
__BEGIN_DECLS
int semsys __P((int, ...));
int semctl __P((int, int, int, union semun));
int semctl __P((int, int, int, ...));
int semget __P((key_t, int, int));
int semop __P((int, struct sembuf *,unsigned));
__END_DECLS