1 /* 2 * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SYS_SEM_H 6 #define _SYS_SEM_H 7 8 9 #include <sys/cdefs.h> 10 #include <sys/ipc.h> 11 #include <sys/types.h> 12 13 14 /* Semaphore operation flags */ 15 #define SEM_UNDO 10 16 17 /* Command definition for semctl */ 18 #define GETPID 3 /* Get process ID of last element manipulating */ 19 #define GETVAL 4 /* Get semval */ 20 #define GETALL 5 /* Get all semval */ 21 #define GETNCNT 6 /* Get semncnt */ 22 #define GETZCNT 7 /* Get semzcnt */ 23 #define SETVAL 8 /* Set semval */ 24 #define SETALL 9 /* Set all semval */ 25 26 struct semid_ds { 27 struct ipc_perm sem_perm; /* Operation permission structure */ 28 unsigned short sem_nsems; /* Number of semaphores in set */ 29 time_t sem_otime; /* Last semop */ 30 time_t sem_ctime; /* Last time changed by semctl */ 31 }; 32 33 /* Structure passed as parameter to the semop function */ 34 struct sembuf { 35 unsigned short sem_num; /* Semaphore number */ 36 short sem_op; /* Semaphore operation */ 37 short sem_flg; /* Operation flags */ 38 }; 39 40 /* 41 * Semaphore info structure. Useful for the ipcs 42 * standard utily 43 */ 44 struct seminfo { 45 int semmni; /* Number of semaphore identifies */ 46 int semmns; /* Number of semaphore in system */ 47 int semmnu; /* Number of undo structures in system */ 48 int semmsl; /* Max number of semaphores per id */ 49 int semopm; /* Max number of operations per semop call */ 50 int semume; /* Max number of undo entries per process */ 51 int semusz; /* Size in bytes of undo structure */ 52 int semvmx; /* Semaphore maximum valure */ 53 int semaem; /* adjust on exit max value */ 54 }; 55 56 57 __BEGIN_DECLS 58 59 int semctl(int semID, int semNum, int command, ...); 60 int semget(key_t key, int numSems, int semFlags); 61 int semop(int semID, struct sembuf *semOps, size_t numSemOps); 62 63 __END_DECLS 64 65 #endif /* _SYS_SEM_H */ 66