1 /**
2  * D header file for FreeBSD
3  *
4  * Authors: Martin Nowak
5  */
6 module core.sys.freebsd.sys.mman;
7 
8 version (FreeBSD):
9 extern (C):
10 nothrow:
11 
12 public import core.sys.posix.sys.mman;
13 import core.sys.freebsd.sys.cdefs;
14 import core.sys.posix.sys.types;
15 // https://svnweb.freebsd.org/base/head/sys/sys/mman.h?revision=270825&view=markup
16 
17 static if (__BSD_VISIBLE)
18 {
19     enum INHERIT_SHARE = 0;
20     enum INHERIT_COPY = 1;
21     enum INHERIT_NONE = 2;
22 }
23 
24 // already in core.sys.posix.sys.mman
25 // enum PROT_NONE = 0x00;
26 // enum PROT_READ = 0x01;
27 // enum PROT_WRITE = 0x02;
28 // enum PROT_EXEC = 0x04;
29 // enum MAP_SHARED = 0x0001;
30 // enum MAP_PRIVATE = 0x0002;
31 static if (__BSD_VISIBLE)
32     alias MAP_COPY = MAP_PRIVATE;
33 // enum MAP_FIXED = 0x0010;
34 
35 static if (__BSD_VISIBLE)
36 {
37     enum MAP_RENAME = 0x0020;
38     enum MAP_NORESERVE = 0x0040;
39     enum MAP_RESERVED0080 = 0x0080;
40     enum MAP_RESERVED0100 = 0x0100;
41     enum MAP_HASSEMAPHORE = 0x0200;
42     enum MAP_STACK = 0x0400;
43     enum MAP_NOSYNC = 0x0800;
44 
45     enum MAP_FILE = 0x0000;
46 
47     // already in core.sys.posix.sys.mman
48     // enum MAP_ANON = 0x1000;
49     //#ifndef _KERNEL
50     alias MAP_ANONYMOUS = MAP_ANON;
51     //#endif /* !_KERNEL */
52 
53     enum MAP_EXCL = 0x00004000;
54     enum MAP_NOCORE = 0x00020000;
55     enum MAP_PREFAULT_READ = 0x00040000;
56     version (LP64)
57         enum MAP_32BIT = 0x00080000;
58 
59 
60     extern(D) int MAP_ALIGNED(int n) { return n << MAP_ALIGNMENT_SHIFT; }
61     enum MAP_ALIGNMENT_SHIFT = 24;
62     enum MAP_ALIGNMENT_MASK = MAP_ALIGNED(0xff);
63     enum MAP_ALIGNED_SUPER = MAP_ALIGNED(1);
64 }
65 
66 static if (__POSIX_VISIBLE >= 199309)
67 {
68     // already in core.sys.posix.sys.mman
69     // enum MCL_CURRENT = 0x0001;
70     // enum MCL_FUTURE = 0x0002;
71 }
72 
73 // already in core.sys.posix.sys.mman
74 enum MAP_FAILED = cast(void*)-1;
75 
76 // already in core.sys.posix.sys.mman
77 // enum MS_SYNC = 0x0000;
78 // enum MS_ASYNC = 0x0001;
79 // enum MS_INVALIDATE = 0x0002;
80 
81 enum _MADV_NORMAL = 0;
82 enum _MADV_RANDOM = 1;
83 enum _MADV_SEQUENTIAL = 2;
84 enum _MADV_WILLNEED = 3;
85 enum _MADV_DONTNEED = 4;
86 
87 static if (__BSD_VISIBLE)
88 {
89     alias MADV_NORMAL = _MADV_NORMAL;
90     alias MADV_RANDOM = _MADV_RANDOM;
91     alias MADV_SEQUENTIAL = _MADV_SEQUENTIAL;
92     alias MADV_WILLNEED = _MADV_WILLNEED;
93     alias MADV_DONTNEED = _MADV_DONTNEED;
94     enum MADV_FREE = 5;
95     enum MADV_NOSYNC = 6;
96     enum MADV_AUTOSYNC = 7;
97     enum MADV_NOCORE = 8;
98     enum MADV_CORE = 9;
99     enum MADV_PROTECT = 10;
100 
101     enum MINCORE_INCORE = 0x1;
102     enum MINCORE_REFERENCED = 0x2;
103     enum MINCORE_MODIFIED = 0x4;
104     enum MINCORE_REFERENCED_OTHER = 0x8;
105     enum MINCORE_MODIFIED_OTHER = 0x10;
106     enum MINCORE_SUPER = 0x20;
107 
108     enum SHM_ANON = cast(const(char) *)1;
109 }
110 
111 static if (__POSIX_VISIBLE >= 200112)
112 {
113     // already in core.sys.posix.sys.mman
114     // alias POSIX_MADV_NORMAL = _MADV_NORMAL;
115     // alias POSIX_MADV_RANDOM = _MADV_RANDOM;
116     // alias POSIX_MADV_SEQUENTIAL = _MADV_SEQUENTIAL;
117     // alias POSIX_MADV_WILLNEED = _MADV_WILLNEED;
118     // alias POSIX_MADV_DONTNEED = _MADV_DONTNEED;
119 }
120 
121 static if (__BSD_VISIBLE)
122 {
123     int getpagesizes(size_t *, int);
124     int madvise(void *, size_t, int);
125     int mincore(const(void) *, size_t, char *);
126     int minherit(void *, size_t, int);
127 }
128 // already in core.sys.posix.sys.mman
129 // int mlock(const void *, size_t);
130 // void *  mmap(void *, size_t, int, int, int, off_t);
131 // int mprotect(const void *, size_t, int);
132 // int msync(void *, size_t, int);
133 // int munlock(const void *, size_t);
134 // int munmap(void *, size_t);
135 static if (__POSIX_VISIBLE >= 200112)
136     // int posix_madvise(void *, size_t, int);
137 static if (__POSIX_VISIBLE >= 199309)
138 {
139     // int mlockall(int);
140     // int munlockall();
141     // int shm_open(const(char) *, int, mode_t);
142     // int shm_unlink(const(char) *);
143 }