]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_SHM_H_ |
2 | #define _LINUX_SHM_H_ | |
3 | ||
4 | #include <linux/ipc.h> | |
5 | #include <linux/errno.h> | |
ed7b1889 | 6 | #ifdef __KERNEL__ |
1da177e4 | 7 | #include <asm/page.h> |
ed7b1889 KS |
8 | #else |
9 | #include <unistd.h> | |
10 | #endif | |
1da177e4 LT |
11 | |
12 | /* | |
13 | * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can | |
14 | * be increased by sysctl | |
15 | */ | |
16 | ||
17 | #define SHMMAX 0x2000000 /* max shared seg size (bytes) */ | |
18 | #define SHMMIN 1 /* min shared seg size (bytes) */ | |
19 | #define SHMMNI 4096 /* max num of segs system wide */ | |
ed7b1889 | 20 | #ifdef __KERNEL__ |
1da177e4 | 21 | #define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */ |
ed7b1889 KS |
22 | #else |
23 | #define SHMALL (SHMMAX/getpagesize()*(SHMMNI/16)) | |
24 | #endif | |
1da177e4 LT |
25 | #define SHMSEG SHMMNI /* max shared segs per process */ |
26 | ||
4029a917 | 27 | #ifdef __KERNEL__ |
1da177e4 | 28 | #include <asm/shmparam.h> |
4029a917 | 29 | #endif |
1da177e4 LT |
30 | |
31 | /* Obsolete, used only for backwards compatibility and libc5 compiles */ | |
32 | struct shmid_ds { | |
33 | struct ipc_perm shm_perm; /* operation perms */ | |
34 | int shm_segsz; /* size of segment (bytes) */ | |
35 | __kernel_time_t shm_atime; /* last attach time */ | |
36 | __kernel_time_t shm_dtime; /* last detach time */ | |
37 | __kernel_time_t shm_ctime; /* last change time */ | |
38 | __kernel_ipc_pid_t shm_cpid; /* pid of creator */ | |
39 | __kernel_ipc_pid_t shm_lpid; /* pid of last operator */ | |
40 | unsigned short shm_nattch; /* no. of current attaches */ | |
41 | unsigned short shm_unused; /* compatibility */ | |
42 | void *shm_unused2; /* ditto - used by DIPC */ | |
43 | void *shm_unused3; /* unused */ | |
44 | }; | |
45 | ||
46 | /* Include the definition of shmid64_ds and shminfo64 */ | |
47 | #include <asm/shmbuf.h> | |
48 | ||
49 | /* permission flag for shmget */ | |
50 | #define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */ | |
51 | #define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */ | |
52 | ||
53 | /* mode for attach */ | |
54 | #define SHM_RDONLY 010000 /* read-only access */ | |
55 | #define SHM_RND 020000 /* round attach address to SHMLBA boundary */ | |
56 | #define SHM_REMAP 040000 /* take-over region on attach */ | |
57 | #define SHM_EXEC 0100000 /* execution access */ | |
58 | ||
59 | /* super user shmctl commands */ | |
60 | #define SHM_LOCK 11 | |
61 | #define SHM_UNLOCK 12 | |
62 | ||
63 | /* ipcs ctl commands */ | |
64 | #define SHM_STAT 13 | |
65 | #define SHM_INFO 14 | |
66 | ||
67 | /* Obsolete, used only for backwards compatibility */ | |
68 | struct shminfo { | |
69 | int shmmax; | |
70 | int shmmin; | |
71 | int shmmni; | |
72 | int shmseg; | |
73 | int shmall; | |
74 | }; | |
75 | ||
76 | struct shm_info { | |
77 | int used_ids; | |
78 | unsigned long shm_tot; /* total allocated shm */ | |
79 | unsigned long shm_rss; /* total resident shm */ | |
80 | unsigned long shm_swp; /* total swapped shm */ | |
81 | unsigned long swap_attempts; | |
82 | unsigned long swap_successes; | |
83 | }; | |
84 | ||
85 | #ifdef __KERNEL__ | |
86 | struct shmid_kernel /* private to the kernel */ | |
87 | { | |
88 | struct kern_ipc_perm shm_perm; | |
89 | struct file * shm_file; | |
1da177e4 LT |
90 | unsigned long shm_nattch; |
91 | unsigned long shm_segsz; | |
92 | time_t shm_atim; | |
93 | time_t shm_dtim; | |
94 | time_t shm_ctim; | |
95 | pid_t shm_cprid; | |
96 | pid_t shm_lprid; | |
97 | struct user_struct *mlock_user; | |
5774ed01 VK |
98 | |
99 | /* The task created the shm object. NULL if the task is dead. */ | |
100 | struct task_struct *shm_creator; | |
1da177e4 LT |
101 | }; |
102 | ||
103 | /* shm_mode upper byte flags */ | |
104 | #define SHM_DEST 01000 /* segment will be destroyed on last detach */ | |
105 | #define SHM_LOCKED 02000 /* segment will not be swapped */ | |
106 | #define SHM_HUGETLB 04000 /* segment will use huge TLB pages */ | |
bf8f972d | 107 | #define SHM_NORESERVE 010000 /* don't check for reservations */ |
1da177e4 LT |
108 | |
109 | #ifdef CONFIG_SYSVIPC | |
110 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr); | |
516dffdc | 111 | extern int is_file_shm_hugepages(struct file *file); |
b34a6b1d | 112 | extern void exit_shm(struct task_struct *task); |
1da177e4 LT |
113 | #else |
114 | static inline long do_shmat(int shmid, char __user *shmaddr, | |
115 | int shmflg, unsigned long *addr) | |
116 | { | |
117 | return -ENOSYS; | |
118 | } | |
516dffdc AL |
119 | static inline int is_file_shm_hugepages(struct file *file) |
120 | { | |
121 | return 0; | |
122 | } | |
b34a6b1d VK |
123 | static inline void exit_shm(struct task_struct *task) |
124 | { | |
125 | } | |
1da177e4 LT |
126 | #endif |
127 | ||
128 | #endif /* __KERNEL__ */ | |
129 | ||
130 | #endif /* _LINUX_SHM_H_ */ |