2 * D header file for POSIX.
4 * Copyright: Public Domain
5 * License: Public Domain
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9 module stdc.posix.sys.mman;
11 private import stdc.posix.config;
12 public import stdc.stddef; // for size_t
13 public import stdc.posix.sys.types; // for off_t, mode_t
18 // Advisory Information (ADV)
21 int posix_madvise(void*, size_t, int);
25 // Advisory Information and either Memory Mapped Files or Shared Memory Objects (MC1)
37 const POSIX_MADV_NORMAL = 0;
38 const POSIX_MADV_RANDOM = 1;
39 const POSIX_MADV_SEQUENTIAL = 2;
40 const POSIX_MADV_WILLNEED = 3;
41 const POSIX_MADV_DONTNEED = 4;
43 else version( darwin )
45 const POSIX_MADV_NORMAL = 0;
46 const POSIX_MADV_RANDOM = 1;
47 const POSIX_MADV_SEQUENTIAL = 2;
48 const POSIX_MADV_WILLNEED = 3;
49 const POSIX_MADV_DONTNEED = 4;
51 else version( freebsd )
53 const POSIX_MADV_NORMAL = 0;
54 const POSIX_MADV_RANDOM = 1;
55 const POSIX_MADV_SEQUENTIAL = 2;
56 const POSIX_MADV_WILLNEED = 3;
57 const POSIX_MADV_DONTNEED = 4;
61 // Memory Mapped Files, Shared Memory Objects, or Memory Protection (MC2)
72 const PROT_NONE = 0x0;
73 const PROT_READ = 0x1;
74 const PROT_WRITE = 0x2;
75 const PROT_EXEC = 0x4;
77 else version( darwin )
79 const PROT_NONE = 0x00;
80 const PROT_READ = 0x01;
81 const PROT_WRITE = 0x02;
82 const PROT_EXEC = 0x04;
84 else version( freebsd )
86 const PROT_NONE = 0x00;
87 const PROT_READ = 0x01;
88 const PROT_WRITE = 0x02;
89 const PROT_EXEC = 0x04;
93 // Memory Mapped Files, Shared Memory Objects, or Typed Memory Objects (MC3)
96 void* mmap(void*, size_t, int, int, int, off_t);
97 int munmap(void*, size_t);
102 //void* mmap(void*, size_t, int, int, int, off_t);
103 int munmap(void*, size_t);
105 static if( __USE_LARGEFILE64 )
107 void* mmap64(void*, size_t, int, int, int, off_t);
112 void* mmap(void*, size_t, int, int, int, off_t);
115 else version( darwin )
117 void* mmap(void*, size_t, int, int, int, off_t);
118 int munmap(void*, size_t);
120 else version( freebsd )
122 void* mmap(void*, size_t, int, int, int, off_t);
123 int munmap(void*, size_t);
127 // Memory Mapped Files (MF)
137 MS_INVALIDATE (MF|SIO)
139 int msync(void*, size_t, int); (MF|SIO)
144 const MAP_SHARED = 0x01;
145 const MAP_PRIVATE = 0x02;
146 const MAP_FIXED = 0x10;
147 const MAP_ANON = 0x20; // non-standard
149 const MAP_FAILED = cast(void*) -1;
158 int msync(void*, size_t, int);
160 else version( darwin )
162 const MAP_SHARED = 0x0001;
163 const MAP_PRIVATE = 0x0002;
164 const MAP_FIXED = 0x0010;
165 const MAP_ANON = 0x1000; // non-standard
167 const MAP_FAILED = cast(void*)-1;
169 const MS_ASYNC = 0x0001;
170 const MS_INVALIDATE = 0x0002;
171 const MS_SYNC = 0x0010;
173 int msync(void*, size_t, int);
175 else version( darwin )
177 const MAP_SHARED = 0x0001;
178 const MAP_PRIVATE = 0x0002;
179 const MAP_FIXED = 0x0010;
180 const MAP_ANON = 0x1000; // non-standard
182 const MAP_FAILED = cast(void*)-1;
184 const MS_SYNC = 0x0000;
185 const MS_ASYNC = 0x0001;
186 const MS_INVALIDATE = 0x0002;
188 int msync(void*, size_t, int);
192 // Process Memory Locking (ML)
204 const MCL_CURRENT = 1;
205 const MCL_FUTURE = 2;
211 else version( darwin )
213 const MCL_CURRENT = 0x0001;
214 const MCL_FUTURE = 0x0002;
219 else version( freebsd )
221 const MCL_CURRENT = 0x0001;
222 const MCL_FUTURE = 0x0002;
229 // Range Memory Locking (MLR)
232 int mlock(in void*, size_t);
233 int munlock(in void*, size_t);
238 int mlock(in void*, size_t);
239 int munlock(in void*, size_t);
241 else version( darwin )
243 int mlock(in void*, size_t);
244 int munlock(in void*, size_t);
246 else version( freebsd )
248 int mlock(in void*, size_t);
249 int munlock(in void*, size_t);
253 // Memory Protection (MPR)
256 int mprotect(void*, size_t, int);
261 int mprotect(void*, size_t, int);
263 else version( freebsd )
265 int mprotect(void*, size_t, int);
269 // Shared Memory Objects (SHM)
272 int shm_open(in char*, int, mode_t);
273 int shm_unlink(in char*);
278 int shm_open(in char*, int, mode_t);
279 int shm_unlink(in char*);
281 else version( darwin )
283 int shm_open(in char*, int, mode_t);
284 int shm_unlink(in char*);
286 else version( freebsd )
288 int shm_open(in char*, int, mode_t);
289 int shm_unlink(in char*);
293 // Typed Memory Objects (TYM)
296 POSIX_TYPED_MEM_ALLOCATE
297 POSIX_TYPED_MEM_ALLOCATE_CONTIG
298 POSIX_TYPED_MEM_MAP_ALLOCATABLE
300 struct posix_typed_mem_info
302 size_t posix_tmi_length;
305 int posix_mem_offset(in void*, size_t, off_t *, size_t *, int *);
306 int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
307 int posix_typed_mem_open(in char*, int, int);