Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_SEM_H
0003 #define _UAPI_LINUX_SEM_H
0004 
0005 #include <linux/ipc.h>
0006 
0007 /* semop flags */
0008 #define SEM_UNDO        0x1000  /* undo the operation on exit */
0009 
0010 /* semctl Command Definitions. */
0011 #define GETPID  11       /* get sempid */
0012 #define GETVAL  12       /* get semval */
0013 #define GETALL  13       /* get all semval's */
0014 #define GETNCNT 14       /* get semncnt */
0015 #define GETZCNT 15       /* get semzcnt */
0016 #define SETVAL  16       /* set semval */
0017 #define SETALL  17       /* set all semval's */
0018 
0019 /* ipcs ctl cmds */
0020 #define SEM_STAT 18
0021 #define SEM_INFO 19
0022 #define SEM_STAT_ANY 20
0023 
0024 /* Obsolete, used only for backwards compatibility and libc5 compiles */
0025 struct semid_ds {
0026     struct ipc_perm sem_perm;       /* permissions .. see ipc.h */
0027     __kernel_old_time_t sem_otime;      /* last semop time */
0028     __kernel_old_time_t sem_ctime;      /* create/last semctl() time */
0029     struct sem  *sem_base;      /* ptr to first semaphore in array */
0030     struct sem_queue *sem_pending;      /* pending operations to be processed */
0031     struct sem_queue **sem_pending_last;    /* last pending operation */
0032     struct sem_undo *undo;          /* undo requests on this array */
0033     unsigned short  sem_nsems;      /* no. of semaphores in array */
0034 };
0035 
0036 /* Include the definition of semid64_ds */
0037 #include <asm/sembuf.h>
0038 
0039 /* semop system calls takes an array of these. */
0040 struct sembuf {
0041     unsigned short  sem_num;    /* semaphore index in array */
0042     short       sem_op;     /* semaphore operation */
0043     short       sem_flg;    /* operation flags */
0044 };
0045 
0046 /* arg for semctl system calls. */
0047 union semun {
0048     int val;            /* value for SETVAL */
0049     struct semid_ds __user *buf;    /* buffer for IPC_STAT & IPC_SET */
0050     unsigned short __user *array;   /* array for GETALL & SETALL */
0051     struct seminfo __user *__buf;   /* buffer for IPC_INFO */
0052     void __user *__pad;
0053 };
0054 
0055 struct  seminfo {
0056     int semmap;
0057     int semmni;
0058     int semmns;
0059     int semmnu;
0060     int semmsl;
0061     int semopm;
0062     int semume;
0063     int semusz;
0064     int semvmx;
0065     int semaem;
0066 };
0067 
0068 /*
0069  * SEMMNI, SEMMSL and SEMMNS are default values which can be
0070  * modified by sysctl.
0071  * The values has been chosen to be larger than necessary for any
0072  * known configuration.
0073  *
0074  * SEMOPM should not be increased beyond 1000, otherwise there is the
0075  * risk that semop()/semtimedop() fails due to kernel memory fragmentation when
0076  * allocating the sop array.
0077  */
0078 
0079 
0080 #define SEMMNI  32000           /* <= IPCMNI  max # of semaphore identifiers */
0081 #define SEMMSL  32000           /* <= INT_MAX max num of semaphores per id */
0082 #define SEMMNS  (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
0083 #define SEMOPM  500         /* <= 1 000 max num of ops per semop call */
0084 #define SEMVMX  32767           /* <= 32767 semaphore maximum value */
0085 #define SEMAEM  SEMVMX          /* adjust on exit max value */
0086 
0087 /* unused */
0088 #define SEMUME  SEMOPM          /* max num of undo entries per process */
0089 #define SEMMNU  SEMMNS          /* num of undo structures system wide */
0090 #define SEMMAP  SEMMNS          /* # of entries in semaphore map */
0091 #define SEMUSZ  20      /* sizeof struct sem_undo */
0092 
0093 
0094 #endif /* _UAPI_LINUX_SEM_H */