1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_LINUX_SEM_H
3 #define _UAPI_LINUX_SEM_H
8 #define SEM_UNDO 0x1000 /* undo the operation on exit */
10 /* semctl Command Definitions. */
11 #define GETPID 11 /* get sempid */
12 #define GETVAL 12 /* get semval */
13 #define GETALL 13 /* get all semval's */
14 #define GETNCNT 14 /* get semncnt */
15 #define GETZCNT 15 /* get semzcnt */
16 #define SETVAL 16 /* set semval */
17 #define SETALL 17 /* set all semval's */
22 #define SEM_STAT_ANY 20
24 /* Obsolete, used only for backwards compatibility and libc5 compiles */
26 struct ipc_perm sem_perm; /* permissions .. see ipc.h */
27 __kernel_old_time_t sem_otime; /* last semop time */
28 __kernel_old_time_t sem_ctime; /* create/last semctl() time */
29 struct sem *sem_base; /* ptr to first semaphore in array */
30 struct sem_queue *sem_pending; /* pending operations to be processed */
31 struct sem_queue **sem_pending_last; /* last pending operation */
32 struct sem_undo *undo; /* undo requests on this array */
33 unsigned short sem_nsems; /* no. of semaphores in array */
36 /* Include the definition of semid64_ds */
37 #include <asm/sembuf.h>
39 /* semop system calls takes an array of these. */
41 unsigned short sem_num; /* semaphore index in array */
42 short sem_op; /* semaphore operation */
43 short sem_flg; /* operation flags */
46 /* arg for semctl system calls. */
48 int val; /* value for SETVAL */
49 struct semid_ds __user *buf; /* buffer for IPC_STAT & IPC_SET */
50 unsigned short __user *array; /* array for GETALL & SETALL */
51 struct seminfo __user *__buf; /* buffer for IPC_INFO */
69 * SEMMNI, SEMMSL and SEMMNS are default values which can be
71 * The values has been chosen to be larger than necessary for any
72 * known configuration.
74 * SEMOPM should not be increased beyond 1000, otherwise there is the
75 * risk that semop()/semtimedop() fails due to kernel memory fragmentation when
76 * allocating the sop array.
80 #define SEMMNI 32000 /* <= IPCMNI max # of semaphore identifiers */
81 #define SEMMSL 32000 /* <= INT_MAX max num of semaphores per id */
82 #define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
83 #define SEMOPM 500 /* <= 1 000 max num of ops per semop call */
84 #define SEMVMX 32767 /* <= 32767 semaphore maximum value */
85 #define SEMAEM SEMVMX /* adjust on exit max value */
88 #define SEMUME SEMOPM /* max num of undo entries per process */
89 #define SEMMNU SEMMNS /* num of undo structures system wide */
90 #define SEMMAP SEMMNS /* # of entries in semaphore map */
91 #define SEMUSZ 20 /* sizeof struct sem_undo */
94 #endif /* _UAPI_LINUX_SEM_H */