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