diff options
-rw-r--r-- | lib/libc/sys/semctl.2 | 32 | ||||
-rw-r--r-- | lib/libc/sys/semctl.c | 33 | ||||
-rw-r--r-- | sys/sys/sem.h | 4 |
3 files changed, 45 insertions, 24 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)); } diff --git a/sys/sys/sem.h b/sys/sys/sem.h index 0ca69f7ab91..448506ce17a 100644 --- a/sys/sys/sem.h +++ b/sys/sys/sem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.h,v 1.3 1998/05/11 06:20:35 deraadt Exp $ */ +/* $OpenBSD: sem.h,v 1.4 1998/06/10 08:46:18 deraadt Exp $ */ /* $NetBSD: sem.h,v 1.8 1996/02/09 18:25:29 christos Exp $ */ /* @@ -167,7 +167,7 @@ int *semu; /* undo structure pool */ #include <sys/cdefs.h> __BEGIN_DECLS -int semctl __P((int, int, int, union semun)); +int semctl __P((int, int, int, ...)); int __semctl __P((int, int, int, union semun *)); int semget __P((key_t, int, int)); int semop __P((int, struct sembuf *, u_int)); |