blob: 1fbf24ea37fdcf63f1da6ccfc5944ac6f21e299f [file] [log] [blame]
David Howells607ca462012-10-13 10:46:48 +01001#ifndef _UAPI_LINUX_SHM_H_
2#define _UAPI_LINUX_SHM_H_
3
4#include <linux/ipc.h>
5#include <linux/errno.h>
6#ifndef __KERNEL__
7#include <unistd.h>
8#endif
9
10/*
Davidlohr Buesof57a19a2014-06-06 14:37:43 -070011 * SHMMNI, SHMMAX and SHMALL are default upper limits which can be
12 * modified by sysctl. The SHMMAX and SHMALL values have been chosen to
13 * be as large possible without facilitating scenarios where userspace
14 * causes overflows when adjusting the limits via operations of the form
15 * "retrieve current limit; add X; update limit". It is therefore not
16 * advised to make SHMMAX and SHMALL any larger. These limits are
17 * suitable for both 32 and 64-bit systems.
David Howells607ca462012-10-13 10:46:48 +010018 */
David Howells607ca462012-10-13 10:46:48 +010019#define SHMMIN 1 /* min shared seg size (bytes) */
20#define SHMMNI 4096 /* max num of segs system wide */
Davidlohr Buesof57a19a2014-06-06 14:37:43 -070021#define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */
22#define SHMALL (ULONG_MAX - (1UL << 24)) /* max shm system wide (pages) */
David Howells607ca462012-10-13 10:46:48 +010023#define SHMSEG SHMMNI /* max shared segs per process */
24
David Howells607ca462012-10-13 10:46:48 +010025/* Obsolete, used only for backwards compatibility and libc5 compiles */
26struct shmid_ds {
27 struct ipc_perm shm_perm; /* operation perms */
28 int shm_segsz; /* size of segment (bytes) */
29 __kernel_time_t shm_atime; /* last attach time */
30 __kernel_time_t shm_dtime; /* last detach time */
31 __kernel_time_t shm_ctime; /* last change time */
32 __kernel_ipc_pid_t shm_cpid; /* pid of creator */
33 __kernel_ipc_pid_t shm_lpid; /* pid of last operator */
34 unsigned short shm_nattch; /* no. of current attaches */
35 unsigned short shm_unused; /* compatibility */
36 void *shm_unused2; /* ditto - used by DIPC */
37 void *shm_unused3; /* unused */
38};
39
40/* Include the definition of shmid64_ds and shminfo64 */
41#include <asm/shmbuf.h>
42
43/* permission flag for shmget */
44#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
45#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
46
47/* mode for attach */
48#define SHM_RDONLY 010000 /* read-only access */
49#define SHM_RND 020000 /* round attach address to SHMLBA boundary */
50#define SHM_REMAP 040000 /* take-over region on attach */
51#define SHM_EXEC 0100000 /* execution access */
52
53/* super user shmctl commands */
54#define SHM_LOCK 11
55#define SHM_UNLOCK 12
56
57/* ipcs ctl commands */
58#define SHM_STAT 13
59#define SHM_INFO 14
60
61/* Obsolete, used only for backwards compatibility */
62struct shminfo {
63 int shmmax;
64 int shmmin;
65 int shmmni;
66 int shmseg;
67 int shmall;
68};
69
70struct shm_info {
71 int used_ids;
H.J. Luf8dcdf02013-12-27 14:14:23 -080072 __kernel_ulong_t shm_tot; /* total allocated shm */
73 __kernel_ulong_t shm_rss; /* total resident shm */
74 __kernel_ulong_t shm_swp; /* total swapped shm */
75 __kernel_ulong_t swap_attempts;
76 __kernel_ulong_t swap_successes;
David Howells607ca462012-10-13 10:46:48 +010077};
78
79
80#endif /* _UAPI_LINUX_SHM_H_ */