/* * Copyright 2008, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Salvatore Benedetto */ #include #include #include #include #include #include //#include #include #include // TODO: this should be removed when the above commented header exists #if 1 /* * For the semctl option argument, the user * should declare explicitly the following union */ union semun { int val; struct semid_ds *buf; unsigned short *array; }; #endif int semget(key_t key, int numSems, int semFlags) { RETURN_AND_SET_ERRNO(_kern_xsi_semget(key, numSems, semFlags)); } int semctl(int semID, int semNum, int command, ...) { union semun arg; va_list args; switch (command) { case GETVAL: case GETPID: case GETNCNT: case GETZCNT: case IPC_RMID: RETURN_AND_SET_ERRNO(_kern_xsi_semctl(semID, semNum, command, 0)); case SETVAL: case GETALL: case SETALL: case IPC_STAT: case IPC_SET: va_start(args, command); arg = va_arg(args, union semun); va_end(args); RETURN_AND_SET_ERRNO(_kern_xsi_semctl(semID, semNum, command, &arg)); default: return EINVAL; } } int semop(int semID, struct sembuf *semOps, size_t numSemOps) { RETURN_AND_SET_ERRNO(_kern_xsi_semop(semID, semOps, numSemOps)); }