1 /** 2 * D header file for POSIX. 3 * 4 * Copyright: Public Domain 5 * License: Public Domain 6 * Authors: Sean Kelly 7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 */ 9 module tango.stdc.posix.sys.shm; 10 11 private import tango.stdc.posix.config; 12 public import tango.stdc.posix.sys.types; // for pid_t, time_t, key_t, size_t 13 public import tango.stdc.posix.sys.ipc; 14 private import tango.core.Octal; 15 extern (C): 16 17 // 18 // XOpen (XSI) 19 // 20 /* 21 SHM_RDONLY 22 SHM_RND 23 24 SHMLBA 25 26 shmatt_t 27 28 struct shmid_ds 29 { 30 ipc_perm shm_perm; 31 size_t shm_segsz; 32 pid_t shm_lpid; 33 pid_t shm_cpid; 34 shmatt_t shm_nattch; 35 time_t shm_atime; 36 time_t shm_dtime; 37 time_t shm_ctime; 38 } 39 40 void* shmat(int, in void*, int); 41 int shmctl(int, int, shmid_ds*); 42 int shmdt(in void*); 43 int shmget(key_t, size_t, int); 44 */ 45 46 version( linux ) 47 { 48 const SHM_RDONLY = octal!10000; 49 const SHM_RND = octal!20000; 50 51 int __getpagesize(); 52 alias __getpagesize SHMLBA; 53 54 alias c_ulong shmatt_t; 55 56 struct shmid_ds 57 { 58 ipc_perm shm_perm; 59 size_t shm_segsz; 60 time_t shm_atime; 61 c_ulong __unused1; 62 time_t shm_dtime; 63 c_ulong __unused2; 64 time_t shm_ctime; 65 c_ulong __unused3; 66 pid_t shm_cpid; 67 pid_t shm_lpid; 68 shmatt_t shm_nattch; 69 c_ulong __unused4; 70 c_ulong __unused5; 71 } 72 73 void* shmat(int, in void*, int); 74 int shmctl(int, int, shmid_ds*); 75 int shmdt(in void*); 76 int shmget(key_t, size_t, int); 77 } 78 else version( FreeBSD ) 79 { 80 const SHM_RDONLY = octal!10000; 81 const SHM_RND = octal!20000; 82 const SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT) 83 84 alias c_ulong shmatt_t; 85 86 struct shmid_ds 87 { 88 ipc_perm shm_perm; 89 size_t shm_segsz; 90 time_t shm_atime; 91 c_ulong __unused1; 92 time_t shm_dtime; 93 c_ulong __unused2; 94 time_t shm_ctime; 95 c_ulong __unused3; 96 pid_t shm_cpid; 97 pid_t shm_lpid; 98 shmatt_t shm_nattch; 99 c_ulong __unused4; 100 c_ulong __unused5; 101 } 102 103 void* shmat(int, in void*, int); 104 int shmctl(int, int, shmid_ds*); 105 int shmdt(in void*); 106 int shmget(key_t, size_t, int); 107 } 108 else version(OSX) 109 { 110 111 } 112 else version( solaris ) 113 { 114 private const _SC_PAGESIZE = 11; // from <sys/unistd.h> 115 private c_long _sysconf(int); 116 117 const SHM_RDONLY = octal!10000; 118 const SHM_RND = octal!20000; 119 const SHM_SHARE_MMU = octal!40000; 120 const SHM_PAGEABLE = octal!100000; /* pageable ISM */ 121 extern(D) c_long SHMLBA(){ return _sysconf(_SC_PAGESIZE); }; 122 123 alias c_ulong shmatt_t; 124 125 struct shmid_ds 126 { 127 ipc_perm shm_perm; /* operation permission struct */ 128 size_t shm_segsz; /* size of segment in bytes */ 129 void* shm_amp; /* segment anon_map pointer */ 130 ushort shm_lkcnt; /* number of times it is being locked */ 131 pid_t shm_lpid; /* pid of last shmop */ 132 pid_t shm_cpid; /* pid of creator */ 133 shmatt_t shm_nattch; /* number of attaches */ 134 ulong shm_cnattch;/* number of ISM attaches */ 135 version(X86_64) { 136 time_t shm_atime; /* last shmat time */ 137 time_t shm_dtime; /* last shmdt time */ 138 time_t shm_ctime; /* last change time */ 139 long[4] shm_pad4; /* reserve area */ 140 } else { 141 time_t shm_atime; /* last shmat time */ 142 int shm_pad1; /* reserved for time_t expansion */ 143 time_t shm_dtime; /* last shmdt time */ 144 int shm_pad2; /* reserved for time_t expansion */ 145 time_t shm_ctime; /* last change time */ 146 int shm_pad3; /* reserved for time_t expansion */ 147 int[4] shm_pad4; /* reserve area */ 148 } 149 } 150 151 void* shmat(int, in void*, int); 152 int shmctl(int, int, shmid_ds*); 153 int shmdt(in void*); 154 int shmget(key_t, size_t, int); 155 }