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