headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / sys / xsi_sem.cpp
blobbddeecb76227663f97e62652bbf76dcb65796aca
1 /*
2 * Copyright 2008, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Salvatore Benedetto <salvatore.benedetto@gmail.com>
7 */
9 #include <sys/sem.h>
11 #include <errno.h>
12 #include <fcntl.h>
13 #include <stdarg.h>
14 #include <stdlib.h>
16 #include <OS.h>
18 #include <errno_private.h>
19 #include <posix/xsi_semaphore_defs.h>
20 #include <syscall_utils.h>
21 #include <syscalls.h>
24 int
25 semget(key_t key, int numSems, int semFlags)
27 RETURN_AND_SET_ERRNO(_kern_xsi_semget(key, numSems, semFlags));
31 int
32 semctl(int semID, int semNum, int command, ...)
34 union semun arg;
35 va_list args;
37 switch (command) {
38 case GETVAL:
39 case GETPID:
40 case GETNCNT:
41 case GETZCNT:
42 case IPC_RMID:
43 RETURN_AND_SET_ERRNO(_kern_xsi_semctl(semID, semNum, command, 0));
45 case SETVAL:
46 case GETALL:
47 case SETALL:
48 case IPC_STAT:
49 case IPC_SET:
50 va_start(args, command);
51 arg = va_arg(args, union semun);
52 va_end(args);
53 RETURN_AND_SET_ERRNO(_kern_xsi_semctl(semID, semNum, command,
54 &arg));
56 default:
57 return EINVAL;
62 int
63 semop(int semID, struct sembuf *semOps, size_t numSemOps)
65 RETURN_AND_SET_ERRNO(_kern_xsi_semop(semID, semOps, numSemOps));