Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_SHM_H_
0003 #define _UAPI_LINUX_SHM_H_
0004 
0005 #include <linux/ipc.h>
0006 #include <linux/errno.h>
0007 #include <asm-generic/hugetlb_encode.h>
0008 #ifndef __KERNEL__
0009 #include <unistd.h>
0010 #endif
0011 
0012 /*
0013  * SHMMNI, SHMMAX and SHMALL are default upper limits which can be
0014  * modified by sysctl. The SHMMAX and SHMALL values have been chosen to
0015  * be as large possible without facilitating scenarios where userspace
0016  * causes overflows when adjusting the limits via operations of the form
0017  * "retrieve current limit; add X; update limit". It is therefore not
0018  * advised to make SHMMAX and SHMALL any larger. These limits are
0019  * suitable for both 32 and 64-bit systems.
0020  */
0021 #define SHMMIN 1             /* min shared seg size (bytes) */
0022 #define SHMMNI 4096          /* max num of segs system wide */
0023 #define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */
0024 #define SHMALL (ULONG_MAX - (1UL << 24)) /* max shm system wide (pages) */
0025 #define SHMSEG SHMMNI            /* max shared segs per process */
0026 
0027 /* Obsolete, used only for backwards compatibility and libc5 compiles */
0028 struct shmid_ds {
0029     struct ipc_perm     shm_perm;   /* operation perms */
0030     int         shm_segsz;  /* size of segment (bytes) */
0031     __kernel_old_time_t shm_atime;  /* last attach time */
0032     __kernel_old_time_t shm_dtime;  /* last detach time */
0033     __kernel_old_time_t shm_ctime;  /* last change time */
0034     __kernel_ipc_pid_t  shm_cpid;   /* pid of creator */
0035     __kernel_ipc_pid_t  shm_lpid;   /* pid of last operator */
0036     unsigned short      shm_nattch; /* no. of current attaches */
0037     unsigned short      shm_unused; /* compatibility */
0038     void            *shm_unused2;   /* ditto - used by DIPC */
0039     void            *shm_unused3;   /* unused */
0040 };
0041 
0042 /* Include the definition of shmid64_ds and shminfo64 */
0043 #include <asm/shmbuf.h>
0044 
0045 /*
0046  * shmget() shmflg values.
0047  */
0048 /* The bottom nine bits are the same as open(2) mode flags */
0049 #define SHM_R       0400    /* or S_IRUGO from <linux/stat.h> */
0050 #define SHM_W       0200    /* or S_IWUGO from <linux/stat.h> */
0051 /* Bits 9 & 10 are IPC_CREAT and IPC_EXCL */
0052 #define SHM_HUGETLB 04000   /* segment will use huge TLB pages */
0053 #define SHM_NORESERVE   010000  /* don't check for reservations */
0054 
0055 /*
0056  * Huge page size encoding when SHM_HUGETLB is specified, and a huge page
0057  * size other than the default is desired.  See hugetlb_encode.h
0058  */
0059 #define SHM_HUGE_SHIFT  HUGETLB_FLAG_ENCODE_SHIFT
0060 #define SHM_HUGE_MASK   HUGETLB_FLAG_ENCODE_MASK
0061 
0062 #define SHM_HUGE_64KB   HUGETLB_FLAG_ENCODE_64KB
0063 #define SHM_HUGE_512KB  HUGETLB_FLAG_ENCODE_512KB
0064 #define SHM_HUGE_1MB    HUGETLB_FLAG_ENCODE_1MB
0065 #define SHM_HUGE_2MB    HUGETLB_FLAG_ENCODE_2MB
0066 #define SHM_HUGE_8MB    HUGETLB_FLAG_ENCODE_8MB
0067 #define SHM_HUGE_16MB   HUGETLB_FLAG_ENCODE_16MB
0068 #define SHM_HUGE_32MB   HUGETLB_FLAG_ENCODE_32MB
0069 #define SHM_HUGE_256MB  HUGETLB_FLAG_ENCODE_256MB
0070 #define SHM_HUGE_512MB  HUGETLB_FLAG_ENCODE_512MB
0071 #define SHM_HUGE_1GB    HUGETLB_FLAG_ENCODE_1GB
0072 #define SHM_HUGE_2GB    HUGETLB_FLAG_ENCODE_2GB
0073 #define SHM_HUGE_16GB   HUGETLB_FLAG_ENCODE_16GB
0074 
0075 /*
0076  * shmat() shmflg values
0077  */
0078 #define SHM_RDONLY  010000  /* read-only access */
0079 #define SHM_RND     020000  /* round attach address to SHMLBA boundary */
0080 #define SHM_REMAP   040000  /* take-over region on attach */
0081 #define SHM_EXEC    0100000 /* execution access */
0082 
0083 /* super user shmctl commands */
0084 #define SHM_LOCK    11
0085 #define SHM_UNLOCK  12
0086 
0087 /* ipcs ctl commands */
0088 #define SHM_STAT    13
0089 #define SHM_INFO    14
0090 #define SHM_STAT_ANY    15
0091 
0092 /* Obsolete, used only for backwards compatibility */
0093 struct  shminfo {
0094     int shmmax;
0095     int shmmin;
0096     int shmmni;
0097     int shmseg;
0098     int shmall;
0099 };
0100 
0101 struct shm_info {
0102     int used_ids;
0103     __kernel_ulong_t shm_tot;   /* total allocated shm */
0104     __kernel_ulong_t shm_rss;   /* total resident shm */
0105     __kernel_ulong_t shm_swp;   /* total swapped shm */
0106     __kernel_ulong_t swap_attempts;
0107     __kernel_ulong_t swap_successes;
0108 };
0109 
0110 
0111 #endif /* _UAPI_LINUX_SHM_H_ */