sem.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _SYS_SEM_H
  17. # error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
  18. #endif
  19. #include <sys/types.h>
  20. #include <bits/wordsize.h>
  21. /* Flags for `semop'. */
  22. #define SEM_UNDO 0x1000 /* undo the operation on exit */
  23. /* Commands for `semctl'. */
  24. #define GETPID 11 /* get sempid */
  25. #define GETVAL 12 /* get semval */
  26. #define GETALL 13 /* get all semval's */
  27. #define GETNCNT 14 /* get semncnt */
  28. #define GETZCNT 15 /* get semzcnt */
  29. #define SETVAL 16 /* set semval */
  30. #define SETALL 17 /* set all semval's */
  31. /* Data structure describing a set of semaphores. */
  32. struct semid_ds
  33. {
  34. struct ipc_perm sem_perm; /* operation permission struct */
  35. #if __WORDSIZE == 32
  36. unsigned int __unused1;
  37. #endif
  38. __time_t sem_otime; /* last semop() time */
  39. #if __WORDSIZE == 32
  40. unsigned int __unused2;
  41. #endif
  42. __time_t sem_ctime; /* last time changed by semctl() */
  43. unsigned long int sem_nsems; /* number of semaphores in set */
  44. unsigned long __unused3;
  45. unsigned long __unused4;
  46. };
  47. /* The user should define a union like the following to use it for arguments
  48. for `semctl'.
  49. union semun
  50. {
  51. int val; <= value for SETVAL
  52. struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
  53. unsigned short int *array; <= array for GETALL & SETALL
  54. struct seminfo *__buf; <= buffer for IPC_INFO
  55. };
  56. Previous versions of this file used to define this union but this is
  57. incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
  58. one must define the union or not. */
  59. #define _SEM_SEMUN_UNDEFINED 1
  60. #ifdef __USE_MISC
  61. /* ipcs ctl cmds */
  62. # define SEM_STAT 18
  63. # define SEM_INFO 19
  64. struct seminfo
  65. {
  66. int semmap;
  67. int semmni;
  68. int semmns;
  69. int semmnu;
  70. int semmsl;
  71. int semopm;
  72. int semume;
  73. int semusz;
  74. int semvmx;
  75. int semaem;
  76. };
  77. #endif /* __USE_MISC */