1/* 2 * Copyright 2008, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Salvatore Benedetto <salvatore.benedetto@gmail.com> 7 */ 8 9#include <sys/sem.h> 10 11#include <errno.h> 12#include <fcntl.h> 13#include <stdarg.h> 14#include <stdlib.h> 15 16#include <OS.h> 17 18#include <errno_private.h> 19#include <posix/xsi_semaphore_defs.h> 20#include <syscall_utils.h> 21#include <syscalls.h> 22 23 24int 25semget(key_t key, int numSems, int semFlags) 26{ 27 RETURN_AND_SET_ERRNO(_kern_xsi_semget(key, numSems, semFlags)); 28} 29 30 31int 32semctl(int semID, int semNum, int command, ...) 33{ 34 union semun arg; 35 va_list args; 36 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)); 44 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)); 55 56 default: 57 return EINVAL; 58 } 59} 60 61 62int 63semop(int semID, struct sembuf *semOps, size_t numSemOps) 64{ 65 RETURN_AND_SET_ERRNO(_kern_xsi_semop(semID, semOps, numSemOps)); 66} 67