sem.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_SEM_H
  15. # error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
  16. #endif
  17. #include <sys/types.h>
  18. #include <bits/wordsize.h>
  19. /* Flags for `semop'. */
  20. #define SEM_UNDO 0x1000 /* undo the operation on exit */
  21. /* Commands for `semctl'. */
  22. #define GETPID 11 /* get sempid */
  23. #define GETVAL 12 /* get semval */
  24. #define GETALL 13 /* get all semval's */
  25. #define GETNCNT 14 /* get semncnt */
  26. #define GETZCNT 15 /* get semzcnt */
  27. #define SETVAL 16 /* set semval */
  28. #define SETALL 17 /* set all semval's */
  29. /* Data structure describing a set of semaphores. */
  30. /* parisc places the upper half of each 64-bit time value BEFORE the word that
  31. holds the value itself -- see arch/parisc/include/uapi/asm/{msgbuf,sembuf,
  32. shmbuf}.h. The generic layout in libc/sysdeps/linux/common/bits has it the
  33. other way round, which shifted every time field by one word: msgctl() and
  34. semctl() returned the always-zero upper half, so uClibc reported 1970.
  35. The structure is spelled out once per configuration rather than stitched
  36. together with conditionals inside it. With a 32-bit time_t the field sits
  37. where the kernel's lower word is and the upper one is padding; with a 64-bit
  38. time_t the kernel's two words are kept as the pair it writes, _internal_1
  39. being the lower half, and msgctl()/semctl()/shmctl() compose the value
  40. behind the end of the kernel's structure as
  41. "_internal_1 | _internal_2 << 32". */
  42. #if (__WORDSIZE == 32 && defined(__UCLIBC_USE_TIME64__))
  43. struct semid_ds
  44. {
  45. struct ipc_perm sem_perm; /* operation permission struct */
  46. unsigned long int __sem_otime_internal_2; /* last semop() time */
  47. unsigned long int __sem_otime_internal_1;
  48. unsigned long int __sem_ctime_internal_2; /* last time changed by semctl() */
  49. unsigned long int __sem_ctime_internal_1;
  50. unsigned long int sem_nsems; /* number of semaphores in set */
  51. /* The kernel fills only the pairs above. semctl() composes the __time_t
  52. fields below from them once the call has returned -- and only then,
  53. because the kernel's copy still covers the first of them. */
  54. __time_t sem_otime;
  55. __time_t sem_ctime;
  56. unsigned long int __uclibc_unused1;
  57. unsigned long int __uclibc_unused2;
  58. };
  59. # define __SEMID_DS_TIME64_SPLIT 1
  60. #else
  61. struct semid_ds
  62. {
  63. struct ipc_perm sem_perm; /* operation permission struct */
  64. unsigned int __uclibc_pad1;
  65. __time_t sem_otime; /* last semop() time */
  66. unsigned int __uclibc_pad2;
  67. __time_t sem_ctime; /* last time changed by semctl() */
  68. unsigned long int sem_nsems; /* number of semaphores in set */
  69. unsigned long int __uclibc_unused1;
  70. unsigned long int __uclibc_unused2;
  71. };
  72. #endif
  73. /* The user should define a union like the following to use it for arguments
  74. for `semctl'.
  75. union semun
  76. {
  77. int val; <= value for SETVAL
  78. struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
  79. unsigned short int *array; <= array for GETALL & SETALL
  80. struct seminfo *__buf; <= buffer for IPC_INFO
  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. #ifdef __USE_MISC
  87. /* ipcs ctl cmds */
  88. # define SEM_STAT 18
  89. # define SEM_INFO 19
  90. struct seminfo
  91. {
  92. int semmap;
  93. int semmni;
  94. int semmns;
  95. int semmnu;
  96. int semmsl;
  97. int semopm;
  98. int semume;
  99. int semusz;
  100. int semvmx;
  101. int semaem;
  102. };
  103. #endif /* __USE_MISC */