]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
9bccf70c | 2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
1c79356b | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
1c79356b A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
24 | /*- | |
25 | * Copyright (c) 1982, 1986, 1993 | |
26 | * The Regents of the University of California. All rights reserved. | |
27 | * | |
28 | * Redistribution and use in source and binary forms, with or without | |
29 | * modification, are permitted provided that the following conditions | |
30 | * are met: | |
31 | * 1. Redistributions of source code must retain the above copyright | |
32 | * notice, this list of conditions and the following disclaimer. | |
33 | * 2. Redistributions in binary form must reproduce the above copyright | |
34 | * notice, this list of conditions and the following disclaimer in the | |
35 | * documentation and/or other materials provided with the distribution. | |
36 | * 3. All advertising materials mentioning features or use of this software | |
37 | * must display the following acknowledgement: | |
38 | * This product includes software developed by the University of | |
39 | * California, Berkeley and its contributors. | |
40 | * 4. Neither the name of the University nor the names of its contributors | |
41 | * may be used to endorse or promote products derived from this software | |
42 | * without specific prior written permission. | |
43 | * | |
44 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
45 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
46 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
47 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
48 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
49 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
50 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
51 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
52 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
53 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
54 | * SUCH DAMAGE. | |
55 | * | |
56 | * @(#)mman.h 8.1 (Berkeley) 6/2/93 | |
57 | */ | |
58 | ||
91447636 A |
59 | /* |
60 | * Currently unsupported: | |
61 | * | |
62 | * [TYM] POSIX_TYPED_MEM_ALLOCATE | |
63 | * [TYM] POSIX_TYPED_MEM_ALLOCATE_CONTIG | |
64 | * [TYM] POSIX_TYPED_MEM_MAP_ALLOCATABLE | |
65 | * [TYM] struct posix_typed_mem_info | |
66 | * [TYM] posix_mem_offset() | |
67 | * [TYM] posix_typed_mem_get_info() | |
68 | * [TYM] posix_typed_mem_open() | |
69 | */ | |
70 | ||
1c79356b A |
71 | #ifndef _SYS_MMAN_H_ |
72 | #define _SYS_MMAN_H_ | |
73 | ||
9bccf70c | 74 | #include <sys/appleapiopts.h> |
91447636 A |
75 | #include <sys/cdefs.h> |
76 | ||
77 | #include <sys/_types.h> | |
78 | ||
79 | /* | |
80 | * [various] The mode_t, off_t, and size_t types shall be defined as | |
81 | * described in <sys/types.h> | |
82 | */ | |
83 | #ifndef _MODE_T | |
84 | typedef __darwin_mode_t mode_t; | |
85 | #define _MODE_T | |
86 | #endif | |
87 | ||
88 | #ifndef _OFF_T | |
89 | typedef __darwin_off_t off_t; | |
90 | #define _OFF_T | |
91 | #endif | |
92 | ||
93 | #ifndef _SIZE_T | |
94 | #define _SIZE_T | |
95 | typedef __darwin_size_t size_t; | |
96 | #endif | |
97 | ||
1c79356b A |
98 | |
99 | /* | |
100 | * Protections are chosen from these bits, or-ed together | |
101 | */ | |
91447636 A |
102 | #define PROT_NONE 0x00 /* [MC2] no permissions */ |
103 | #define PROT_READ 0x01 /* [MC2] pages can be read */ | |
104 | #define PROT_WRITE 0x02 /* [MC2] pages can be written */ | |
105 | #define PROT_EXEC 0x04 /* [MC2] pages can be executed */ | |
1c79356b A |
106 | |
107 | /* | |
108 | * Flags contain sharing type and options. | |
109 | * Sharing types; choose one. | |
110 | */ | |
91447636 A |
111 | #define MAP_SHARED 0x0001 /* [MF|SHM] share changes */ |
112 | #define MAP_PRIVATE 0x0002 /* [MF|SHM] changes are private */ | |
113 | #ifndef _POSIX_C_SOURCE | |
1c79356b | 114 | #define MAP_COPY MAP_PRIVATE /* Obsolete */ |
91447636 | 115 | #endif /* !_POSIX_C_SOURCE */ |
1c79356b A |
116 | |
117 | /* | |
118 | * Other flags | |
119 | */ | |
91447636 A |
120 | #define MAP_FIXED 0x0010 /* [MF|SHM] interpret addr exactly */ |
121 | #ifndef _POSIX_C_SOURCE | |
1c79356b A |
122 | #define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ |
123 | #define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ | |
55e303ae | 124 | #define MAP_RESERVED0080 0x0080 /* previously unimplemented MAP_INHERIT */ |
1c79356b A |
125 | #define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ |
126 | #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ | |
91447636 | 127 | #endif /* !_POSIX_C_SOURCE */ |
1c79356b | 128 | |
1c79356b A |
129 | /* |
130 | * Process memory locking | |
131 | */ | |
91447636 A |
132 | #define MCL_CURRENT 0x0001 /* [ML] Lock only current memory */ |
133 | #define MCL_FUTURE 0x0002 /* [ML] Lock all future memory as well */ | |
1c79356b A |
134 | |
135 | /* | |
136 | * Error return from mmap() | |
137 | */ | |
91447636 | 138 | #define MAP_FAILED ((void *)-1) /* [MF|SHM] mmap failed */ |
1c79356b A |
139 | |
140 | /* | |
141 | * msync() flags | |
142 | */ | |
91447636 A |
143 | #define MS_ASYNC 0x0001 /* [MF|SIO] return immediately */ |
144 | #define MS_INVALIDATE 0x0002 /* [MF|SIO] invalidate all cached data */ | |
145 | #define MS_SYNC 0x0010 /* [MF|SIO] msync synchronously */ | |
1c79356b | 146 | |
91447636 | 147 | #ifndef _POSIX_C_SOURCE |
1c79356b A |
148 | #define MS_KILLPAGES 0x0004 /* invalidate pages, leave mapped */ |
149 | #define MS_DEACTIVATE 0x0008 /* deactivate pages, leave mapped */ | |
1c79356b A |
150 | |
151 | /* | |
152 | * Mapping type | |
153 | */ | |
154 | #define MAP_FILE 0x0000 /* map from file (default) */ | |
155 | #define MAP_ANON 0x1000 /* allocated from memory, swap space */ | |
91447636 A |
156 | #endif /* !_POSIX_C_SOURCE */ |
157 | ||
1c79356b A |
158 | |
159 | /* | |
160 | * Advice to madvise | |
161 | */ | |
91447636 A |
162 | #define POSIX_MADV_NORMAL 0 /* [MC1] no further special treatment */ |
163 | #define POSIX_MADV_RANDOM 1 /* [MC1] expect random page refs */ | |
164 | #define POSIX_MADV_SEQUENTIAL 2 /* [MC1] expect sequential page refs */ | |
165 | #define POSIX_MADV_WILLNEED 3 /* [MC1] will need these pages */ | |
166 | #define POSIX_MADV_DONTNEED 4 /* [MC1] dont need these pages */ | |
167 | ||
168 | #ifndef _POSIX_C_SOURCE | |
169 | #define MADV_NORMAL POSIX_MADV_NORMAL | |
170 | #define MADV_RANDOM POSIX_MADV_RANDOM | |
171 | #define MADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL | |
172 | #define MADV_WILLNEED POSIX_MADV_WILLNEED | |
173 | #define MADV_DONTNEED POSIX_MADV_DONTNEED | |
174 | #define MADV_FREE 5 /* pages unneeded, discard contents */ | |
1c79356b A |
175 | |
176 | /* | |
177 | * Return bits from mincore | |
178 | */ | |
91447636 A |
179 | #define MINCORE_INCORE 0x1 /* Page is incore */ |
180 | #define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */ | |
181 | #define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ | |
182 | #define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ | |
183 | #define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ | |
184 | #endif /* !_POSIX_C_SOURCE */ | |
1c79356b | 185 | |
1c79356b | 186 | |
91447636 | 187 | #ifndef KERNEL |
1c79356b A |
188 | |
189 | __BEGIN_DECLS | |
91447636 A |
190 | /* [ML] */ |
191 | int mlockall(int); | |
192 | int munlockall(void); | |
193 | /* [MR] */ | |
194 | int mlock(const void *, size_t); | |
195 | #ifndef _MMAP | |
196 | #define _MMAP | |
197 | /* [MC3]*/ | |
198 | void * mmap(void *, size_t, int, int, int, off_t) __DARWIN_ALIAS(mmap); | |
1c79356b | 199 | #endif |
91447636 A |
200 | /* [MPR] */ |
201 | int mprotect(void *, size_t, int) __DARWIN_ALIAS(mprotect); | |
202 | /* [MF|SIO] */ | |
203 | int msync(void *, size_t, int) __DARWIN_ALIAS(msync); | |
204 | /* [MR] */ | |
205 | int munlock(const void *, size_t); | |
206 | /* [MC3]*/ | |
207 | int munmap(void *, size_t) __DARWIN_ALIAS(munmap); | |
208 | /* [SHM] */ | |
209 | int shm_open(const char *, int, ...); | |
210 | int shm_unlink(const char *); | |
211 | /* [ADV] */ | |
212 | int posix_madvise(void *, size_t, int); | |
213 | ||
214 | #ifndef _POSIX_C_SOURCE | |
215 | int madvise(void *, size_t, int); | |
216 | int mincore(const void *, size_t, char *); | |
217 | int minherit(void *, size_t, int); | |
1c79356b A |
218 | #endif |
219 | __END_DECLS | |
220 | ||
91447636 A |
221 | #else /* KERNEL */ |
222 | ||
223 | void pshm_cache_init(void); /* for bsd_init() */ | |
224 | ||
225 | /* | |
226 | * XXX routine exported by posix_shm.c, but never used there, only used in | |
227 | * XXX kern_mman.c in the implementation of mmap(). | |
228 | */ | |
229 | struct mmap_args; | |
230 | struct fileproc; | |
231 | int pshm_mmap(struct proc *p, struct mmap_args *uap, user_addr_t *retval, | |
232 | struct fileproc *fp, off_t pageoff); | |
233 | /* Really need to overhaul struct fileops to avoid this... */ | |
234 | struct pshmnode; | |
235 | int pshm_stat(struct pshmnode *pnode, struct stat *sb); | |
236 | struct fileproc; | |
237 | int pshm_truncate(struct proc *p, struct fileproc *fp, int fd, off_t length, register_t *retval); | |
238 | ||
239 | #endif /* KERNEL */ | |
1c79356b | 240 | #endif /* !_SYS_MMAN_H_ */ |