1 /** 2 * D header file for POSIX. 3 * 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 */ 9 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) 14 */ 15 module core.sys.posix.sys.shm; 16 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; 20 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; 29 30 version (Posix): 31 extern (C) nothrow @nogc: 32 33 // 34 // XOpen (XSI) 35 // 36 /* 37 SHM_RDONLY 38 SHM_RND 39 40 shmatt_t 41 42 struct shmid_ds 43 { 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; 52 } 53 */ 54 55 version (linux) 56 { 57 enum SHM_RDONLY = 0x01000; // 010000 58 enum SHM_RND = 0x02000; // 020000 59 enum SHM_REMAP = 0x4000; // 040000 60 61 alias c_ulong shmatt_t; 62 63 /* For any changes, please check /usr/include/bits/shm.h */ 64 struct shmid_ds 65 { 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; 79 } 80 } 81 else version (FreeBSD) 82 { 83 enum SHM_RDONLY = 0x01000; // 010000 84 enum SHM_RND = 0x02000; // 020000 85 86 alias c_ulong shmatt_t; 87 88 struct shmid_ds_old // <= FreeBSD7 89 { 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; 99 } 100 101 struct shmid_ds 102 { 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; 111 } 112 } 113 else version (NetBSD) 114 { 115 enum SHM_RDONLY = 0x01000; // 010000 116 enum SHM_RND = 0x02000; // 020000 117 118 alias c_ulong shmatt_t; 119 120 struct shmid_ds 121 { 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; 131 } 132 } 133 else version (OpenBSD) 134 { 135 enum SHM_RDONLY = 0x01000; // 010000 136 enum SHM_RND = 0x02000; // 020000 137 138 alias short shmatt_t; 139 140 struct shmid_ds 141 { 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; 154 } 155 } 156 else version (DragonFlyBSD) 157 { 158 enum SHM_RDONLY = 0x01000; // 010000 159 enum SHM_RND = 0x02000; // 020000 160 161 alias c_ulong shmatt_t; 162 163 struct shmid_ds 164 { 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; 174 } 175 } 176 else version (Darwin) 177 { 178 179 } 180 else version (Solaris) 181 { 182 183 } 184 else 185 { 186 static assert(false, "Unsupported platform"); 187 } 188 189 /* 190 SHMLBA 191 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); 196 */ 197 198 version (CRuntime_Glibc) 199 { 200 int __getpagesize(); 201 alias __getpagesize SHMLBA; 202 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); 207 } 208 else version (FreeBSD) 209 { 210 enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT) 211 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); 216 } 217 else version (NetBSD) 218 { 219 enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT) 220 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); 225 } 226 else version (OpenBSD) 227 { 228 enum SHMLBA = 1 << _MAX_PAGE_SHIFT; 229 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); 234 } 235 else version (DragonFlyBSD) 236 { 237 enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT) 238 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); 243 } 244 else version (Darwin) 245 { 246 247 } 248 else version (Solaris) 249 { 250 251 } 252 else version (CRuntime_Musl) 253 { 254 enum SHMLBA = 4096; 255 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); 260 } 261 else version (CRuntime_Bionic) 262 { 263 enum SHMLBA = 4096; 264 265 deprecated("Not useful on Android because it's disallowed by SELinux") 266 { 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); 271 } 272 } 273 else version (CRuntime_UClibc) 274 { 275 int __getpagesize(); 276 alias __getpagesize SHMLBA; 277 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); 282 } 283 else 284 { 285 static assert(false, "Unsupported platform"); 286 }