Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/mman.h
+++ new/usr/src/uts/common/sys/mman.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */
23 23 /*
24 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 + *
24 26 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 27 * Use is subject to license terms.
26 28 */
27 29
28 30 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
29 31 /* All Rights Reserved */
30 32
31 33 /*
32 34 * University Copyright- Copyright (c) 1982, 1986, 1988
33 35 * The Regents of the University of California
34 36 * All Rights Reserved
35 37 *
36 38 * University Acknowledgment- Portions of this document are derived from
37 39 * software developed by the University of California, Berkeley, and its
38 40 * contributors.
39 41 */
40 42
41 43 #ifndef _SYS_MMAN_H
42 44 #define _SYS_MMAN_H
43 45
44 46 #include <sys/feature_tests.h>
45 47
46 48 #ifdef __cplusplus
47 49 extern "C" {
48 50 #endif
49 51
50 52 #if !defined(_ASM) && !defined(_KERNEL)
51 53 #include <sys/types.h>
52 54 #endif /* !_ASM && !_KERNEL */
53 55
54 56 /*
55 57 * Protections are chosen from these bits, or-ed together.
56 58 * Note - not all implementations literally provide all possible
57 59 * combinations. PROT_WRITE is often implemented as (PROT_READ |
58 60 * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE).
59 61 * However, no implementation will permit a write to succeed
60 62 * where PROT_WRITE has not been set. Also, no implementation will
61 63 * allow any access to succeed where prot is specified as PROT_NONE.
62 64 */
63 65 #define PROT_READ 0x1 /* pages can be read */
64 66 #define PROT_WRITE 0x2 /* pages can be written */
65 67 #define PROT_EXEC 0x4 /* pages can be executed */
66 68
67 69 #ifdef _KERNEL
68 70 #define PROT_USER 0x8 /* pages are user accessable */
69 71 #define PROT_ZFOD (PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
70 72 #define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
71 73 #endif /* _KERNEL */
72 74
73 75 #define PROT_NONE 0x0 /* pages cannot be accessed */
74 76
75 77 /* sharing types: must choose either SHARED or PRIVATE */
76 78 #define MAP_SHARED 1 /* share changes */
77 79 #define MAP_PRIVATE 2 /* changes are private */
78 80 #define MAP_TYPE 0xf /* mask for share type */
79 81
80 82 /* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */
81 83 #define MAP_FIXED 0x10 /* user assigns address */
82 84 #define MAP_NORESERVE 0x40 /* don't reserve needed swap area */
83 85 #define MAP_ANON 0x100 /* map anonymous pages directly */
84 86 #define MAP_ANONYMOUS MAP_ANON /* (source compatibility) */
85 87 #define MAP_ALIGN 0x200 /* addr specifies alignment */
86 88 #define MAP_TEXT 0x400 /* map code segment */
87 89 #define MAP_INITDATA 0x800 /* map data segment */
88 90
89 91 #ifdef _KERNEL
90 92 #define _MAP_TEXTREPL 0x1000
91 93 #endif /* _KERNEL */
92 94
93 95 /* these flags not yet implemented */
94 96 #define MAP_RENAME 0x20 /* rename private pages to file */
95 97
96 98 #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2)
97 99 /* these flags are used by memcntl */
98 100 #define PROC_TEXT (PROT_EXEC | PROT_READ)
99 101 #define PROC_DATA (PROT_READ | PROT_WRITE | PROT_EXEC)
100 102 #define SHARED 0x10
101 103 #define PRIVATE 0x20
102 104 #define VALID_ATTR (PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE)
103 105 #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */
104 106
105 107 #if (_POSIX_C_SOURCE <= 2) || defined(_XPG4_2)
106 108 #ifdef _KERNEL
107 109 #define PROT_EXCL 0x20
108 110 #endif /* _KERNEL */
109 111
110 112 #define _MAP_LOW32 0x80 /* force mapping in lower 4G of address space */
111 113 #define MAP_32BIT _MAP_LOW32
112 114
113 115 /*
114 116 * For the sake of backward object compatibility, we use the _MAP_NEW flag.
115 117 * This flag will be automatically or'ed in by the C library for all
116 118 * new mmap calls. Previous binaries with old mmap calls will continue
117 119 * to get 0 or -1 for return values. New mmap calls will get the mapped
118 120 * address as the return value if successful and -1 on errors. By default,
119 121 * new mmap calls automatically have the kernel assign the map address
120 122 * unless the MAP_FIXED flag is given.
121 123 */
122 124 #define _MAP_NEW 0x80000000 /* users should not need to use this */
123 125 #endif /* (_POSIX_C_SOURCE <= 2) */
124 126
125 127
126 128 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
127 129 /* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */
128 130 #define MMOBJ_PADDING 0x10000
129 131 #define MMOBJ_INTERPRET 0x20000
130 132
131 133 #define MMOBJ_ALL_FLAGS (MMOBJ_PADDING | MMOBJ_INTERPRET)
132 134
133 135 /*
134 136 * Values for mr_flags field of mmapobj_result_t below.
135 137 * The bottom 16 bits are mutually exclusive and thus only one
136 138 * of them can be set at a time. Use MR_GET_TYPE below to check this value.
137 139 * The top 16 bits are used for flags which are not mutually exclusive and
138 140 * thus more than one of these flags can be set for a given mmapobj_result_t.
139 141 *
140 142 * MR_PADDING being set indicates that this memory range represents the user
141 143 * requested padding.
142 144 *
143 145 * MR_HDR_ELF being set indicates that the ELF header of the mapped object
144 146 * is mapped at mr_addr + mr_offset.
145 147 *
146 148 * MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped
147 149 * object is mapped at mr_addr + mr_offset.
148 150 */
149 151
150 152 /*
151 153 * External flags for mr_flags field below.
152 154 */
153 155 #define MR_PADDING 0x1
154 156 #define MR_HDR_ELF 0x2
155 157 #define MR_HDR_AOUT 0x3
156 158
157 159 /*
158 160 * Internal flags for mr_flags field below.
159 161 */
160 162 #ifdef _KERNEL
161 163 #define MR_RESV 0x80000000 /* overmapped /dev/null */
162 164 #endif /* _KERNEL */
163 165
164 166 #define MR_TYPE_MASK 0x0000ffff
165 167 #define MR_GET_TYPE(val) ((val) & MR_TYPE_MASK)
166 168
167 169 #if !defined(_ASM)
168 170 typedef struct mmapobj_result {
169 171 caddr_t mr_addr; /* mapping address */
170 172 size_t mr_msize; /* mapping size */
171 173 size_t mr_fsize; /* file size */
172 174 size_t mr_offset; /* offset into file */
173 175 uint_t mr_prot; /* the protections provided */
174 176 uint_t mr_flags; /* info on the mapping */
175 177 } mmapobj_result_t;
176 178
177 179 #if defined(_KERNEL) || defined(_SYSCALL32)
178 180 typedef struct mmapobj_result32 {
179 181 caddr32_t mr_addr; /* mapping address */
180 182 size32_t mr_msize; /* mapping size */
181 183 size32_t mr_fsize; /* file size */
182 184 size32_t mr_offset; /* offset into file */
183 185 uint_t mr_prot; /* the protections provided */
184 186 uint_t mr_flags; /* info on the mapping */
185 187 } mmapobj_result32_t;
186 188 #endif /* defined(_KERNEL) || defined(_SYSCALL32) */
187 189 #endif /* !defined(_ASM) */
188 190 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
189 191
190 192 #if !defined(_ASM) && !defined(_KERNEL)
191 193 /*
192 194 * large file compilation environment setup
193 195 *
194 196 * In the LP64 compilation environment, map large file interfaces
195 197 * back to native versions where possible.
196 198 */
197 199
198 200 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
199 201 #ifdef __PRAGMA_REDEFINE_EXTNAME
200 202 #pragma redefine_extname mmap mmap64
201 203 #else
202 204 #define mmap mmap64
203 205 #endif
204 206 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
205 207
206 208 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
207 209 #ifdef __PRAGMA_REDEFINE_EXTNAME
208 210 #pragma redefine_extname mmap64 mmap
209 211 #else
210 212 #define mmap64 mmap
211 213 #endif
212 214 #endif /* _LP64 && _LARGEFILE64_SOURCE */
213 215
↓ open down ↓ |
180 lines elided |
↑ open up ↑ |
214 216 #ifdef __PRAGMA_REDEFINE_EXTNAME
215 217 #pragma redefine_extname getpagesizes getpagesizes2
216 218 #else
217 219 #define getpagesizes getpagesizes2
218 220 #endif
219 221
220 222 /*
221 223 * Except for old binaries mmap() will return the resultant
222 224 * address of mapping on success and (caddr_t)-1 on error.
223 225 */
224 -#ifdef __STDC__
225 226 #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
226 227 extern void *mmap(void *, size_t, int, int, int, off_t);
227 228 extern int munmap(void *, size_t);
228 229 extern int mprotect(void *, size_t, int);
229 230 extern int msync(void *, size_t, int);
230 231 #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
231 232 extern int mlock(const void *, size_t);
232 233 extern int munlock(const void *, size_t);
233 234 #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
234 235 /* transitional large file interface version */
235 236 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
236 237 !defined(__PRAGMA_REDEFINE_EXTNAME))
237 238 extern void *mmap64(void *, size_t, int, int, int, off64_t);
238 239 #endif /* _LARGEFILE64_SOURCE... */
239 240 #else /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
240 241 extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t);
241 242 extern int munmap(caddr_t, size_t);
242 243 extern int mprotect(caddr_t, size_t, int);
243 244 extern int msync(caddr_t, size_t, int);
244 245 extern int mlock(caddr_t, size_t);
245 246 extern int munlock(caddr_t, size_t);
246 247 extern int mincore(caddr_t, size_t, char *);
247 248 extern int memcntl(caddr_t, size_t, int, caddr_t, int, int);
248 249 extern int madvise(caddr_t, size_t, int);
249 250 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
250 251 extern int getpagesizes(size_t *, int);
251 252 extern int getpagesizes2(size_t *, int);
252 253 extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *);
253 254 /* guard visibility of uint64_t */
254 255 #if defined(_INT64_TYPE)
255 256 extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *,
256 257 uint_t *);
257 258 #endif /* defined(_INT64_TYPE) */
258 259 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
259 260 /* transitional large file interface version */
260 261 #ifdef _LARGEFILE64_SOURCE
261 262 extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t);
262 263 #endif
263 264 #endif /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
264 265
265 266 #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
266 267 extern int mlockall(int);
267 268 extern int munlockall(void);
268 269 extern int shm_open(const char *, int, mode_t);
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
269 270 extern int shm_unlink(const char *);
270 271 #endif
271 272
272 273 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
273 274 extern int posix_madvise(void *, size_t, int);
274 275 #endif
275 276
276 277 /* mmap failure value */
277 278 #define MAP_FAILED ((void *) -1)
278 279
279 -#else /* __STDC__ */
280 -extern caddr_t mmap();
281 -extern int munmap();
282 -extern int mmapobj();
283 -extern int mprotect();
284 -extern int mincore();
285 -extern int memcntl();
286 -extern int msync();
287 -extern int madvise();
288 -extern int posix_madvise();
289 -extern int getpagesizes();
290 -extern int getpagesizes2();
291 -extern int mlock();
292 -extern int mlockall();
293 -extern int munlock();
294 -extern int munlockall();
295 -extern int meminfo();
296 -extern int shm_open();
297 -extern int shm_unlink();
298 280
299 -/* transitional large file interface version */
300 -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
301 - !defined(__PRAGMA_REDEFINE_EXTNAME))
302 -extern caddr_t mmap64();
303 -#endif /* _LARGEFILE64_SOURCE... */
304 -#endif /* __STDC__ */
305 -
306 -
307 281 #endif /* !_ASM && !_KERNEL */
308 282
309 283 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
310 284 #if !defined(_ASM)
311 285 /*
312 286 * structure for memcntl hat advise operations.
313 287 */
314 288 struct memcntl_mha {
315 289 uint_t mha_cmd; /* command(s) */
316 290 uint_t mha_flags;
317 291 size_t mha_pagesize;
318 292 };
319 293
320 294 #if defined(_SYSCALL32)
321 295 struct memcntl_mha32 {
322 296 uint_t mha_cmd; /* command(s) */
323 297 uint_t mha_flags;
324 298 size32_t mha_pagesize;
325 299 };
326 300 #endif /* _SYSCALL32 */
327 301 #endif /* !defined(_ASM) */
328 302 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
329 303
330 304 #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
331 305 /* advice to madvise */
332 306 #define MADV_NORMAL 0 /* no further special treatment */
333 307 #define MADV_RANDOM 1 /* expect random page references */
334 308 #define MADV_SEQUENTIAL 2 /* expect sequential page references */
335 309 #define MADV_WILLNEED 3 /* will need these pages */
336 310 #define MADV_DONTNEED 4 /* don't need these pages */
337 311 #define MADV_FREE 5 /* contents can be freed */
338 312 #define MADV_ACCESS_DEFAULT 6 /* default access */
339 313 #define MADV_ACCESS_LWP 7 /* next LWP to access heavily */
340 314 #define MADV_ACCESS_MANY 8 /* many processes to access heavily */
341 315 #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
342 316
343 317 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
344 318 /* advice to posix_madvise */
345 319 /* these values must be kept in sync with the MADV_* values, above */
346 320 #define POSIX_MADV_NORMAL 0 /* MADV_NORMAL */
347 321 #define POSIX_MADV_RANDOM 1 /* MADV_RANDOM */
348 322 #define POSIX_MADV_SEQUENTIAL 2 /* MADV_SEQUENTIAL */
349 323 #define POSIX_MADV_WILLNEED 3 /* MADV_WILLNEED */
350 324 #define POSIX_MADV_DONTNEED 4 /* MADV_DONTNEED */
351 325 #endif
352 326
353 327 /* flags to msync */
354 328 #define MS_OLDSYNC 0x0 /* old value of MS_SYNC */
355 329 /* modified for UNIX98 compliance */
356 330 #define MS_SYNC 0x4 /* wait for msync */
357 331 #define MS_ASYNC 0x1 /* return immediately */
358 332 #define MS_INVALIDATE 0x2 /* invalidate caches */
359 333
360 334 #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
361 335 /* functions to mctl */
362 336 #define MC_SYNC 1 /* sync with backing store */
363 337 #define MC_LOCK 2 /* lock pages in memory */
364 338 #define MC_UNLOCK 3 /* unlock pages from memory */
365 339 #define MC_ADVISE 4 /* give advice to management */
366 340 #define MC_LOCKAS 5 /* lock address space in memory */
367 341 #define MC_UNLOCKAS 6 /* unlock address space from memory */
368 342 #define MC_HAT_ADVISE 7 /* advise hat map size */
369 343
370 344 /* sub-commands for MC_HAT_ADVISE */
371 345 #define MHA_MAPSIZE_VA 0x1 /* set preferred page size */
372 346 #define MHA_MAPSIZE_BSSBRK 0x2 /* set preferred page size */
373 347 /* for last bss adjacent to */
374 348 /* brk area and brk area itself */
375 349 #define MHA_MAPSIZE_STACK 0x4 /* set preferred page size */
376 350 /* processes main stack */
377 351
378 352 #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
379 353
380 354 #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
381 355 /* flags to mlockall */
382 356 #define MCL_CURRENT 0x1 /* lock current mappings */
383 357 #define MCL_FUTURE 0x2 /* lock future mappings */
384 358 #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE)) || defined(__EXTENSIONS__) */
385 359
386 360 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
387 361
388 362 /* definitions for meminfosys syscall */
389 363 #define MISYS_MEMINFO 0x0
390 364
391 -#if !defined(_ASM) && defined(__STDC__)
365 +#if !defined(_ASM)
392 366
393 367 #if defined(_INT64_TYPE)
394 368 /* private structure for meminfo */
395 369 typedef struct meminfo {
396 370 const uint64_t *mi_inaddr; /* array of input addresses */
397 371 const uint_t *mi_info_req; /* array of types of info requested */
398 372 uint64_t *mi_outdata; /* array of results are placed */
399 373 uint_t *mi_validity; /* array of bitwise result codes */
400 374 int mi_info_count; /* number of pieces of info requested */
401 375 } meminfo_t;
402 376 #endif /* defined(_INT64_TYPE) */
403 377
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
404 378 #if defined(_SYSCALL32)
405 379 typedef struct meminfo32 {
406 380 caddr32_t mi_inaddr; /* array of input addresses */
407 381 caddr32_t mi_info_req; /* array of types of information requested */
408 382 caddr32_t mi_outdata; /* array of results are placed */
409 383 caddr32_t mi_validity; /* array of bitwise result codes */
410 384 int32_t mi_info_count; /* number of pieces of information requested */
411 385 } meminfo32_t;
412 386 #endif /* defined(_SYSCALL32) */
413 387
414 -#endif /* !defined(_ASM) && defined(__STDC__) */
388 +#endif /* !defined(_ASM) */
415 389
416 390 /*
417 391 * info_req request type definitions for meminfo
418 392 * request types starting with MEMINFO_V are used for Virtual addresses
419 393 * and should not be mixed with MEMINFO_PLGRP which is targeted for Physical
420 394 * addresses
421 395 */
422 396 #define MEMINFO_SHIFT 16
423 397 #define MEMINFO_MASK (0xFF << MEMINFO_SHIFT)
424 398 #define MEMINFO_VPHYSICAL (0x01 << MEMINFO_SHIFT) /* get physical addr */
425 399 #define MEMINFO_VLGRP (0x02 << MEMINFO_SHIFT) /* get lgroup */
426 400 #define MEMINFO_VPAGESIZE (0x03 << MEMINFO_SHIFT) /* size of phys page */
427 401 #define MEMINFO_VREPLCNT (0x04 << MEMINFO_SHIFT) /* no. of replica */
428 402 #define MEMINFO_VREPL (0x05 << MEMINFO_SHIFT) /* physical replica */
429 403 #define MEMINFO_VREPL_LGRP (0x06 << MEMINFO_SHIFT) /* lgrp of replica */
430 404 #define MEMINFO_PLGRP (0x07 << MEMINFO_SHIFT) /* lgroup for paddr */
431 405
432 406 /* maximum number of addresses meminfo() can process at a time */
433 407 #define MAX_MEMINFO_CNT 256
434 408
435 409 /* maximum number of request types */
436 410 #define MAX_MEMINFO_REQ 31
437 411
438 412 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
439 413
440 414 #ifdef __cplusplus
441 415 }
442 416 #endif
443 417
444 418 #endif /* _SYS_MMAN_H */
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX