Get rid of varargs.h.
[dragonfly.git] / lib / libc / gen / semctl.c
1 /* $DragonFly: src/lib/libc/gen/semctl.c,v 1.2 2004/07/27 07:59:10 asmodai Exp $ */
2
3 #include <sys/types.h>
4 #include <sys/ipc.h>
5 #include <sys/sem.h>
6 #include <stdarg.h>
7 #include <stdlib.h>
8
9 int semctl(int semid, int semnum, int cmd, ...)
10 {
11         va_list ap;
12         union semun semun;
13         union semun *semun_ptr;
14         va_start(ap, cmd);
15         if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL
16             || cmd == SETVAL || cmd == SETALL) {
17                 semun = va_arg(ap, union semun);
18                 semun_ptr = &semun;
19         } else {
20                 semun_ptr = NULL;
21         }
22         va_end(ap);
23
24 #ifdef  __NETBSD_SYSCALLS
25         return (__semctl(semid, semnum, cmd, semun_ptr));
26 #else
27         return (semsys(0, semid, semnum, cmd, semun_ptr));
28 #endif
29 }