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