1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _UAPI_LINUX_SHM_H_ 2 #ifndef _UAPI_LINUX_SHM_H_ 3 #define _UAPI_LINUX_SHM_H_ 3 #define _UAPI_LINUX_SHM_H_ 4 4 5 #include <linux/ipc.h> 5 #include <linux/ipc.h> 6 #include <linux/errno.h> 6 #include <linux/errno.h> 7 #include <asm-generic/hugetlb_encode.h> 7 #include <asm-generic/hugetlb_encode.h> 8 #ifndef __KERNEL__ 8 #ifndef __KERNEL__ 9 #include <unistd.h> 9 #include <unistd.h> 10 #endif 10 #endif 11 11 12 /* 12 /* 13 * SHMMNI, SHMMAX and SHMALL are default upper 13 * SHMMNI, SHMMAX and SHMALL are default upper limits which can be 14 * modified by sysctl. The SHMMAX and SHMALL v 14 * modified by sysctl. The SHMMAX and SHMALL values have been chosen to 15 * be as large possible without facilitating s 15 * be as large possible without facilitating scenarios where userspace 16 * causes overflows when adjusting the limits 16 * causes overflows when adjusting the limits via operations of the form 17 * "retrieve current limit; add X; update limi 17 * "retrieve current limit; add X; update limit". It is therefore not 18 * advised to make SHMMAX and SHMALL any large 18 * advised to make SHMMAX and SHMALL any larger. These limits are 19 * suitable for both 32 and 64-bit systems. 19 * suitable for both 32 and 64-bit systems. 20 */ 20 */ 21 #define SHMMIN 1 /* mi 21 #define SHMMIN 1 /* min shared seg size (bytes) */ 22 #define SHMMNI 4096 /* ma 22 #define SHMMNI 4096 /* max num of segs system wide */ 23 #define SHMMAX (ULONG_MAX - (1UL << 24)) /* ma 23 #define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */ 24 #define SHMALL (ULONG_MAX - (1UL << 24)) /* ma 24 #define SHMALL (ULONG_MAX - (1UL << 24)) /* max shm system wide (pages) */ 25 #define SHMSEG SHMMNI /* ma 25 #define SHMSEG SHMMNI /* max shared segs per process */ 26 26 27 /* Obsolete, used only for backwards compatibi 27 /* Obsolete, used only for backwards compatibility and libc5 compiles */ 28 struct shmid_ds { 28 struct shmid_ds { 29 struct ipc_perm shm_perm; 29 struct ipc_perm shm_perm; /* operation perms */ 30 int shm_segsz; 30 int shm_segsz; /* size of segment (bytes) */ 31 __kernel_old_time_t shm_atime; !! 31 __kernel_time_t shm_atime; /* last attach time */ 32 __kernel_old_time_t shm_dtime; !! 32 __kernel_time_t shm_dtime; /* last detach time */ 33 __kernel_old_time_t shm_ctime; !! 33 __kernel_time_t shm_ctime; /* last change time */ 34 __kernel_ipc_pid_t shm_cpid; 34 __kernel_ipc_pid_t shm_cpid; /* pid of creator */ 35 __kernel_ipc_pid_t shm_lpid; 35 __kernel_ipc_pid_t shm_lpid; /* pid of last operator */ 36 unsigned short shm_nattch; 36 unsigned short shm_nattch; /* no. of current attaches */ 37 unsigned short shm_unused; 37 unsigned short shm_unused; /* compatibility */ 38 void *shm_unused2; 38 void *shm_unused2; /* ditto - used by DIPC */ 39 void *shm_unused3; 39 void *shm_unused3; /* unused */ 40 }; 40 }; 41 41 42 /* Include the definition of shmid64_ds and sh 42 /* Include the definition of shmid64_ds and shminfo64 */ 43 #include <asm/shmbuf.h> 43 #include <asm/shmbuf.h> 44 44 45 /* 45 /* 46 * shmget() shmflg values. 46 * shmget() shmflg values. 47 */ 47 */ 48 /* The bottom nine bits are the same as open(2 48 /* The bottom nine bits are the same as open(2) mode flags */ 49 #define SHM_R 0400 /* or S_IRUGO 49 #define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */ 50 #define SHM_W 0200 /* or S_IWUGO 50 #define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */ 51 /* Bits 9 & 10 are IPC_CREAT and IPC_EXCL */ 51 /* Bits 9 & 10 are IPC_CREAT and IPC_EXCL */ 52 #define SHM_HUGETLB 04000 /* segment wil 52 #define SHM_HUGETLB 04000 /* segment will use huge TLB pages */ 53 #define SHM_NORESERVE 010000 /* don't check 53 #define SHM_NORESERVE 010000 /* don't check for reservations */ 54 54 55 /* 55 /* 56 * Huge page size encoding when SHM_HUGETLB is 56 * Huge page size encoding when SHM_HUGETLB is specified, and a huge page 57 * size other than the default is desired. Se 57 * size other than the default is desired. See hugetlb_encode.h 58 */ 58 */ 59 #define SHM_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SH 59 #define SHM_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT 60 #define SHM_HUGE_MASK HUGETLB_FLAG_ENCODE_MA 60 #define SHM_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK 61 61 62 #define SHM_HUGE_64KB HUGETLB_FLAG_ENCODE_64 62 #define SHM_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB 63 #define SHM_HUGE_512KB HUGETLB_FLAG_ENCODE_51 63 #define SHM_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB 64 #define SHM_HUGE_1MB HUGETLB_FLAG_ENCODE_1M 64 #define SHM_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB 65 #define SHM_HUGE_2MB HUGETLB_FLAG_ENCODE_2M 65 #define SHM_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB 66 #define SHM_HUGE_8MB HUGETLB_FLAG_ENCODE_8M 66 #define SHM_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB 67 #define SHM_HUGE_16MB HUGETLB_FLAG_ENCODE_16 67 #define SHM_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB 68 #define SHM_HUGE_32MB HUGETLB_FLAG_ENCODE_32 68 #define SHM_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB 69 #define SHM_HUGE_256MB HUGETLB_FLAG_ENCODE_25 69 #define SHM_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB 70 #define SHM_HUGE_512MB HUGETLB_FLAG_ENCODE_51 70 #define SHM_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB 71 #define SHM_HUGE_1GB HUGETLB_FLAG_ENCODE_1G 71 #define SHM_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB 72 #define SHM_HUGE_2GB HUGETLB_FLAG_ENCODE_2G 72 #define SHM_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB 73 #define SHM_HUGE_16GB HUGETLB_FLAG_ENCODE_16 73 #define SHM_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB 74 74 75 /* 75 /* 76 * shmat() shmflg values 76 * shmat() shmflg values 77 */ 77 */ 78 #define SHM_RDONLY 010000 /* read-only a 78 #define SHM_RDONLY 010000 /* read-only access */ 79 #define SHM_RND 020000 /* round attac 79 #define SHM_RND 020000 /* round attach address to SHMLBA boundary */ 80 #define SHM_REMAP 040000 /* take-over r 80 #define SHM_REMAP 040000 /* take-over region on attach */ 81 #define SHM_EXEC 0100000 /* execution a 81 #define SHM_EXEC 0100000 /* execution access */ 82 82 83 /* super user shmctl commands */ 83 /* super user shmctl commands */ 84 #define SHM_LOCK 11 84 #define SHM_LOCK 11 85 #define SHM_UNLOCK 12 85 #define SHM_UNLOCK 12 86 86 87 /* ipcs ctl commands */ 87 /* ipcs ctl commands */ 88 #define SHM_STAT 13 88 #define SHM_STAT 13 89 #define SHM_INFO 14 89 #define SHM_INFO 14 90 #define SHM_STAT_ANY 15 90 #define SHM_STAT_ANY 15 91 91 92 /* Obsolete, used only for backwards compatibi 92 /* Obsolete, used only for backwards compatibility */ 93 struct shminfo { 93 struct shminfo { 94 int shmmax; 94 int shmmax; 95 int shmmin; 95 int shmmin; 96 int shmmni; 96 int shmmni; 97 int shmseg; 97 int shmseg; 98 int shmall; 98 int shmall; 99 }; 99 }; 100 100 101 struct shm_info { 101 struct shm_info { 102 int used_ids; 102 int used_ids; 103 __kernel_ulong_t shm_tot; /* tot 103 __kernel_ulong_t shm_tot; /* total allocated shm */ 104 __kernel_ulong_t shm_rss; /* tot 104 __kernel_ulong_t shm_rss; /* total resident shm */ 105 __kernel_ulong_t shm_swp; /* tot 105 __kernel_ulong_t shm_swp; /* total swapped shm */ 106 __kernel_ulong_t swap_attempts; 106 __kernel_ulong_t swap_attempts; 107 __kernel_ulong_t swap_successes; 107 __kernel_ulong_t swap_successes; 108 }; 108 }; 109 109 110 110 111 #endif /* _UAPI_LINUX_SHM_H_ */ 111 #endif /* _UAPI_LINUX_SHM_H_ */ 112 112
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.