1 #include <sys/cdefs.h> 2 __FBSDID("$FreeBSD$"); 3 4 #include <sys/types.h> 5 #include <sys/ipc.h> 6 #include <sys/sem.h> 7 #include <stdarg.h> 8 #include <stdlib.h> 9 10 int semctl(int semid, int semnum, int cmd, ...) 11 { 12 va_list ap; 13 union semun semun; 14 union semun *semun_ptr; 15 16 va_start(ap, cmd); 17 if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL 18 || cmd == SETVAL || cmd == SETALL) { 19 semun = va_arg(ap, union semun); 20 semun_ptr = &semun; 21 } else { 22 semun_ptr = NULL; 23 } 24 va_end(ap); 25 26 return (__semctl(semid, semnum, cmd, semun_ptr)); 27 } 28