sem.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _UAPI_LINUX_SEM_H
  2. #define _UAPI_LINUX_SEM_H
  3. #include <linux/ipc.h>
  4. /* semop flags */
  5. #define SEM_UNDO 0x1000 /* undo the operation on exit */
  6. /* semctl Command Definitions. */
  7. #define GETPID 11 /* get sempid */
  8. #define GETVAL 12 /* get semval */
  9. #define GETALL 13 /* get all semval's */
  10. #define GETNCNT 14 /* get semncnt */
  11. #define GETZCNT 15 /* get semzcnt */
  12. #define SETVAL 16 /* set semval */
  13. #define SETALL 17 /* set all semval's */
  14. /* ipcs ctl cmds */
  15. #define SEM_STAT 18
  16. #define SEM_INFO 19
  17. /* Obsolete, used only for backwards compatibility and libc5 compiles */
  18. struct semid_ds {
  19. struct ipc_perm sem_perm; /* permissions .. see ipc.h */
  20. __kernel_time_t sem_otime; /* last semop time */
  21. __kernel_time_t sem_ctime; /* last change time */
  22. struct sem *sem_base; /* ptr to first semaphore in array */
  23. struct sem_queue *sem_pending; /* pending operations to be processed */
  24. struct sem_queue **sem_pending_last; /* last pending operation */
  25. struct sem_undo *undo; /* undo requests on this array */
  26. unsigned short sem_nsems; /* no. of semaphores in array */
  27. };
  28. /* Include the definition of semid64_ds */
  29. #include <asm/sembuf.h>
  30. /* semop system calls takes an array of these. */
  31. struct sembuf {
  32. unsigned short sem_num; /* semaphore index in array */
  33. short sem_op; /* semaphore operation */
  34. short sem_flg; /* operation flags */
  35. };
  36. /* arg for semctl system calls. */
  37. union semun {
  38. int val; /* value for SETVAL */
  39. struct semid_ds __user *buf; /* buffer for IPC_STAT & IPC_SET */
  40. unsigned short __user *array; /* array for GETALL & SETALL */
  41. struct seminfo __user *__buf; /* buffer for IPC_INFO */
  42. void __user *__pad;
  43. };
  44. struct seminfo {
  45. int semmap;
  46. int semmni;
  47. int semmns;
  48. int semmnu;
  49. int semmsl;
  50. int semopm;
  51. int semume;
  52. int semusz;
  53. int semvmx;
  54. int semaem;
  55. };
  56. /*
  57. * SEMMNI, SEMMSL and SEMMNS are default values which can be
  58. * modified by sysctl.
  59. * The values has been chosen to be larger than necessary for any
  60. * known configuration.
  61. *
  62. * SEMOPM should not be increased beyond 1000, otherwise there is the
  63. * risk that semop()/semtimedop() fails due to kernel memory fragmentation when
  64. * allocating the sop array.
  65. */
  66. #define SEMMNI 32000 /* <= IPCMNI max # of semaphore identifiers */
  67. #define SEMMSL 32000 /* <= INT_MAX max num of semaphores per id */
  68. #define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
  69. #define SEMOPM 500 /* <= 1 000 max num of ops per semop call */
  70. #define SEMVMX 32767 /* <= 32767 semaphore maximum value */
  71. #define SEMAEM SEMVMX /* adjust on exit max value */
  72. /* unused */
  73. #define SEMUME SEMOPM /* max num of undo entries per process */
  74. #define SEMMNU SEMMNS /* num of undo structures system wide */
  75. #define SEMMAP SEMMNS /* # of entries in semaphore map */
  76. #define SEMUSZ 20 /* sizeof struct sem_undo */
  77. #endif /* _UAPI_LINUX_SEM_H */