sem.h 3.0 KB

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