sem.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /* Flags for `semop'. */
  21. #define SEM_UNDO 0x1000 /* undo the operation on exit */
  22. /* Commands for `semctl'. */
  23. #define GETPID 11 /* get sempid */
  24. #define GETVAL 12 /* get semval */
  25. #define GETALL 13 /* get all semval's */
  26. #define GETNCNT 14 /* get semncnt */
  27. #define GETZCNT 15 /* get semzcnt */
  28. #define SETVAL 16 /* set semval */
  29. #define SETALL 17 /* set all semval's */
  30. /* Data structure describing a set of semaphores. */
  31. struct semid_ds
  32. {
  33. struct ipc_perm sem_perm; /* operation permission struct */
  34. #if __WORDSIZE == 32
  35. unsigned int __unused1;
  36. #endif
  37. __time_t sem_otime; /* last semop() time */
  38. #if __WORDSIZE == 32
  39. unsigned int __unused2;
  40. #endif
  41. __time_t sem_ctime; /* last time changed by semctl() */
  42. unsigned long int sem_nsems; /* number of semaphores in set */
  43. unsigned long __unused3;
  44. unsigned long __unused4;
  45. };
  46. /* The user should define a union like the following to use it for arguments
  47. for `semctl'.
  48. union semun
  49. {
  50. int val; <= value for SETVAL
  51. struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
  52. unsigned short int *array; <= array for GETALL & SETALL
  53. struct seminfo *__buf; <= buffer for IPC_INFO
  54. };
  55. Previous versions of this file used to define this union but this is
  56. incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
  57. one must define the union or not. */
  58. #define _SEM_SEMUN_UNDEFINED 1
  59. #ifdef __USE_MISC
  60. /* ipcs ctl cmds */
  61. # define SEM_STAT 18
  62. # define SEM_INFO 19
  63. struct seminfo
  64. {
  65. int semmap;
  66. int semmni;
  67. int semmns;
  68. int semmnu;
  69. int semmsl;
  70. int semopm;
  71. int semume;
  72. int semusz;
  73. int semvmx;
  74. int semaem;
  75. };
  76. #endif /* __USE_MISC */