d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / libphobos / libdruntime / core / sys / posix / sys / shm.d
blob6ecdc0defeb891328fae61792c9de5aebcd731c2
1 /**
2 * D header file for POSIX.
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
10 /* Copyright Sean Kelly 2005 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
15 module core.sys.posix.sys.shm;
17 import core.sys.posix.config;
18 public import core.sys.posix.sys.types; // for pid_t, time_t, key_t
19 public import core.sys.posix.sys.ipc;
21 version (OSX)
22 version = Darwin;
23 else version (iOS)
24 version = Darwin;
25 else version (TVOS)
26 version = Darwin;
27 else version (WatchOS)
28 version = Darwin;
30 version (Posix):
31 extern (C) nothrow @nogc:
34 // XOpen (XSI)
37 SHM_RDONLY
38 SHM_RND
40 shmatt_t
42 struct shmid_ds
44 ipc_perm shm_perm;
45 size_t shm_segsz;
46 pid_t shm_lpid;
47 pid_t shm_cpid;
48 shmatt_t shm_nattch;
49 time_t shm_atime;
50 time_t shm_dtime;
51 time_t shm_ctime;
55 version (linux)
57 enum SHM_RDONLY = 0x01000; // 010000
58 enum SHM_RND = 0x02000; // 020000
59 enum SHM_REMAP = 0x4000; // 040000
61 alias c_ulong shmatt_t;
63 /* For any changes, please check /usr/include/bits/shm.h */
64 struct shmid_ds
66 ipc_perm shm_perm;
67 size_t shm_segsz;
68 time_t shm_atime;
69 version (X86_64) {} else c_ulong __unused1;
70 time_t shm_dtime;
71 version (X86_64) {} else c_ulong __unused2;
72 time_t shm_ctime;
73 version (X86_64) {} else c_ulong __unused3;
74 pid_t shm_cpid;
75 pid_t shm_lpid;
76 shmatt_t shm_nattch;
77 c_ulong __unused4;
78 c_ulong __unused5;
81 else version (FreeBSD)
83 enum SHM_RDONLY = 0x01000; // 010000
84 enum SHM_RND = 0x02000; // 020000
86 alias c_ulong shmatt_t;
88 struct shmid_ds_old // <= FreeBSD7
90 ipc_perm_old shm_perm;
91 int shm_segsz;
92 pid_t shm_lpid;
93 pid_t shm_cpid;
94 short shm_nattch;
95 time_t shm_atime;
96 time_t shm_dtime;
97 time_t shm_ctime;
98 void* shm_internal;
101 struct shmid_ds
103 ipc_perm shm_perm;
104 int shm_segsz;
105 pid_t shm_lpid;
106 pid_t shm_cpid;
107 short shm_nattch;
108 time_t shm_atime;
109 time_t shm_dtime;
110 time_t shm_ctime;
113 else version (NetBSD)
115 enum SHM_RDONLY = 0x01000; // 010000
116 enum SHM_RND = 0x02000; // 020000
118 alias c_ulong shmatt_t;
120 struct shmid_ds
122 ipc_perm shm_perm;
123 size_t shm_segsz;
124 pid_t shm_lpid;
125 pid_t shm_cpid;
126 short shm_nattch;
127 time_t shm_atime;
128 time_t shm_dtime;
129 time_t shm_ctime;
130 void* shm_internal;
133 else version (OpenBSD)
135 enum SHM_RDONLY = 0x01000; // 010000
136 enum SHM_RND = 0x02000; // 020000
138 alias short shmatt_t;
140 struct shmid_ds
142 ipc_perm shm_perm;
143 int shm_segsz;
144 pid_t shm_lpid;
145 pid_t shm_cpid;
146 shmatt_t shm_nattch;
147 time_t shm_atime;
148 c_long __shm_atimensec;
149 time_t shm_dtime;
150 c_long __shm_dtimensec;
151 time_t shm_ctime;
152 c_long __shm_ctimensec;
153 void* shm_internal;
156 else version (DragonFlyBSD)
158 enum SHM_RDONLY = 0x01000; // 010000
159 enum SHM_RND = 0x02000; // 020000
161 alias c_ulong shmatt_t;
163 struct shmid_ds
165 ipc_perm shm_perm;
166 int shm_segsz;
167 pid_t shm_lpid;
168 pid_t shm_cpid;
169 short shm_nattch;
170 time_t shm_atime;
171 time_t shm_dtime;
172 time_t shm_ctime;
173 private void* shm_internal;
176 else version (Darwin)
180 else version (Solaris)
184 else
186 static assert(false, "Unsupported platform");
190 SHMLBA
192 void* shmat(int, const scope void*, int);
193 int shmctl(int, int, shmid_ds*);
194 int shmdt(const scope void*);
195 int shmget(key_t, size_t, int);
198 version (CRuntime_Glibc)
200 int __getpagesize();
201 alias __getpagesize SHMLBA;
203 void* shmat(int, const scope void*, int);
204 int shmctl(int, int, shmid_ds*);
205 int shmdt(const scope void*);
206 int shmget(key_t, size_t, int);
208 else version (FreeBSD)
210 enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
212 void* shmat(int, const scope void*, int);
213 int shmctl(int, int, shmid_ds*);
214 int shmdt(const scope void*);
215 int shmget(key_t, size_t, int);
217 else version (NetBSD)
219 enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
221 void* shmat(int, const scope void*, int);
222 int shmctl(int, int, shmid_ds*);
223 int shmdt(const scope void*);
224 int shmget(key_t, size_t, int);
226 else version (OpenBSD)
228 enum SHMLBA = 1 << _MAX_PAGE_SHIFT;
230 void* shmat(int, const scope void*, int);
231 int shmctl(int, int, shmid_ds*);
232 int shmdt(const scope void*);
233 int shmget(key_t, size_t, int);
235 else version (DragonFlyBSD)
237 enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
239 void* shmat(int, const scope void*, int);
240 int shmctl(int, int, shmid_ds*);
241 int shmdt(const scope void*);
242 int shmget(key_t, size_t, int);
244 else version (Darwin)
248 else version (Solaris)
252 else version (CRuntime_Musl)
254 enum SHMLBA = 4096;
256 void* shmat(int, const scope void*, int);
257 int shmctl(int, int, shmid_ds*);
258 int shmdt(const scope void*);
259 int shmget(key_t, size_t, int);
261 else version (CRuntime_Bionic)
263 enum SHMLBA = 4096;
265 deprecated("Not useful on Android because it's disallowed by SELinux")
267 void* shmat(int, const scope void*, int);
268 int shmctl(int, int, shmid_ds*);
269 int shmdt(const scope void*);
270 int shmget(key_t, size_t, int);
273 else version (CRuntime_UClibc)
275 int __getpagesize();
276 alias __getpagesize SHMLBA;
278 void* shmat(int, const scope void*, int);
279 int shmctl(int, int, shmid_ds*);
280 int shmdt(const scope void*);
281 int shmget(key_t, size_t, int);
283 else
285 static assert(false, "Unsupported platform");