diff options
author | steve <steve@FreeBSD.org> | 1998-05-31 04:09:09 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1998-05-31 04:09:09 +0000 |
commit | ef6b569c2680708db69ce3bc73b314146457d0a0 (patch) | |
tree | 4f5a9100e07d16e971817716606b250901c68409 /lib/libc/gen/semctl.c | |
parent | c8c505e6c085ef10f4a357b2c99e9b9496cd3a63 (diff) | |
download | FreeBSD-src-ef6b569c2680708db69ce3bc73b314146457d0a0.zip FreeBSD-src-ef6b569c2680708db69ce3bc73b314146457d0a0.tar.gz |
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
Diffstat (limited to 'lib/libc/gen/semctl.c')
-rw-r--r-- | lib/libc/gen/semctl.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/libc/gen/semctl.c b/lib/libc/gen/semctl.c index b0ed723..96a8626 100644 --- a/lib/libc/gen/semctl.c +++ b/lib/libc/gen/semctl.c @@ -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 { + va_list ap; + union semun semun; + union semun *semun_ptr; +#ifdef __STDC__ + va_start(ap, cmd); +#else + 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)); + return (__semctl(semid, semnum, cmd, semun_ptr)); #else - return (semsys(0, semid, semnum, cmd, &semun)); + return (semsys(0, semid, semnum, cmd, semun_ptr)); #endif } |