1 /* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002 2 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <http://www.gnu.org/licenses/>. */ 18 19 #ifndef _SYS_SEM_H 20 # error "Never include <bits/sem.h> directly; use <sys/sem.h> instead." 21 #endif 22 23 #include <sys/types.h> 24 25 /* Flags for `semop'. */ 26 #define SEM_UNDO 0x1000 /* undo the operation on exit */ 27 28 /* Commands for `semctl'. */ 29 #define GETPID 11 /* get sempid */ 30 #define GETVAL 12 /* get semval */ 31 #define GETALL 13 /* get all semval's */ 32 #define GETNCNT 14 /* get semncnt */ 33 #define GETZCNT 15 /* get semzcnt */ 34 #define SETVAL 16 /* set semval */ 35 #define SETALL 17 /* set all semval's */ 36 37 38 39 /* Data structure describing a set of semaphores. */ 40 struct semid_ds 41 { 42 struct ipc_perm sem_perm; /* operation permission struct */ 43 #if __WORDSIZE == 32 44 unsigned int __uclibc_unused1; 45 #endif 46 #if defined(__UCLIBC_USE_TIME64__) 47 unsigned long int __sem_otime_internal_1; /* last semop() time */ 48 unsigned long int __sem_otime_internal_2; 49 #else 50 __time_t sem_otime; /* last semop() time */ 51 #endif 52 #if __WORDSIZE == 32 53 unsigned int __uclibc_unused2; 54 #endif 55 #if defined(__UCLIBC_USE_TIME64__) 56 unsigned long int __sem_ctime_internal_1; /* last time changed by semctl() */ 57 unsigned long int __sem_ctime_internal_2; 58 #else 59 __time_t sem_ctime; /* last time changed by semctl() */ 60 #endif 61 unsigned long int sem_nsems; /* number of semaphores in set */ 62 #if defined(__UCLIBC_USE_TIME64__) 63 __time_t sem_otime; 64 __time_t sem_ctime; 65 #endif 66 unsigned long __uclibc_unused3; 67 unsigned long __uclibc_unused4; 68 }; 69 70 71 /* The user should define a union like the following to use it for arguments 72 for `semctl'. 73 74 union semun 75 { 76 int val; <= value for SETVAL 77 struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET 78 unsigned short int *array; <= array for GETALL & SETALL 79 struct seminfo *__buf; <= buffer for IPC_INFO 80 }; 81 82 Previous versions of this file used to define this union but this is 83 incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether 84 one must define the union or not. */ 85 #define _SEM_SEMUN_UNDEFINED 1 86 87 #ifdef __USE_MISC 88 89 /* ipcs ctl cmds */ 90 # define SEM_STAT 18 91 # define SEM_INFO 19 92 93 struct seminfo 94 { 95 int semmap; 96 int semmni; 97 int semmns; 98 int semmnu; 99 int semmsl; 100 int semopm; 101 int semume; 102 int semusz; 103 int semvmx; 104 int semaem; 105 }; 106 107 #endif /* __USE_MISC */ 108