diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-06-10 08:46:23 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-06-10 08:46:23 +0000 |
commit | 00ac48fa029432909e9fc923a68c3413417e0bce (patch) | |
tree | 7cbcb788242d1360a8334191b5960503694bd94e /lib/libc/sys | |
parent | 7dd3b82a25781e074b4f105df1abcb9ecdf72ab2 (diff) |
XPG says 4th arg is optional
Diffstat (limited to 'lib/libc/sys')
-rw-r--r-- | lib/libc/sys/semctl.2 | 32 | ||||
-rw-r--r-- | lib/libc/sys/semctl.c | 33 |
2 files changed, 43 insertions, 22 deletions
diff --git a/lib/libc/sys/semctl.2 b/lib/libc/sys/semctl.2 index 610afb196bd..109595cfe79 100644 --- a/lib/libc/sys/semctl.2 +++ b/lib/libc/sys/semctl.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: semctl.2,v 1.4 1997/11/24 02:07:31 deraadt Exp $ +.\" $OpenBSD: semctl.2,v 1.5 1998/06/10 08:46:20 deraadt Exp $ .\" $NetBSD: semctl.2,v 1.2 1997/03/27 08:20:40 mikel Exp $ .\" .\" Copyright (c) 1995 Frank van der Linden @@ -56,9 +56,9 @@ The operation to be performed is specified in .Fa arg is a union of the following fields: .Bd -literal - int val; /* value for SETVAL */ - struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */ - u_short *array; /* array for GETALL & SETALL */ + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */ + u_short *array; /* array for GETALL & SETALL */ .Ed The @@ -70,11 +70,11 @@ as follows in .Aq Pa sys/sem.h : .Bd -literal struct semid_ds { - struct ipc_perm sem_perm; /* operation permissions */ - struct sem *sem_base; /* semaphore set */ - u_short sem_nsems; /* number of sems in set */ - time_t sem_otime; /* last operation time */ - time_t sem_ctime; /* last change time */ + struct ipc_perm sem_perm; /* operation permissions */ + struct sem *sem_base; /* semaphore set */ + u_short sem_nsems; /* number of sems in set */ + time_t sem_otime; /* last operation time */ + time_t sem_ctime; /* last change time */ }; .Ed @@ -91,13 +91,13 @@ structure is defined in and looks like this: .Bd -literal struct ipc_perm { - ushort cuid; /* creator user id */ - ushort cgid; /* creator group id */ - ushort uid; /* user id */ - ushort gid; /* group id */ - ushort mode; /* r/w permission (see chmod(2)) */ - ushort seq; /* sequence # (to generate unique msg/sem/shm id) */ - key_t key; /* user specified msg/sem/shm key */ + ushort cuid; /* creator user id */ + ushort cgid; /* creator group id */ + ushort uid; /* user id */ + ushort gid; /* group id */ + ushort mode; /* r/w permission (see chmod(2)) */ + ushort seq; /* sequence # (to generate unique msg/sem/shm id) */ + key_t key; /* user specified msg/sem/shm key */ }; .Ed diff --git a/lib/libc/sys/semctl.c b/lib/libc/sys/semctl.c index 49d1c0a0da9..7a933897d66 100644 --- a/lib/libc/sys/semctl.c +++ b/lib/libc/sys/semctl.c @@ -30,21 +30,42 @@ */ #if defined(SYSLIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: semctl.c,v 1.4 1997/07/25 20:30:14 mickey Exp $"; +static char rcsid[] = "$OpenBSD: semctl.c,v 1.5 1998/06/10 08:46:22 deraadt Exp $"; #endif /* SYSLIBC_SCCS and not lint */ #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include <stdlib.h> -#ifdef __STDC__ -int semctl(int semid, int semnum, int cmd, union semun semun) +#if __STDC__ +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 { - return (__semctl(semid, semnum, cmd, &semun)); + va_list ap; + union semun semun; + union semun *semun_ptr = NULL; +#if __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; + } + va_end(ap); + + return (__semctl(semid, semnum, cmd, semun_ptr)); } |