initial commit
[glibc.git] / sysdeps / unix / bsd / bsd4.4 / kfreebsd / bits / mman.h
1 /* Definitions for POSIX memory map interface. FreeBSD version.
2 Copyright (C) 1994-1998, 2000-2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #ifndef _SYS_MMAN_H
21 # error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
22 #endif
23
24 #include <features.h>
25 #include <stddef.h>
26
27 /* Protections are chosen from these bits, OR'd together. The
28 implementation does not necessarily support PROT_EXEC or PROT_WRITE
29 without PROT_READ. The only guarantees are that no writing will be
30 allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31
32 #define PROT_NONE 0x00 /* No access. */
33 #define PROT_READ 0x01 /* Pages can be read. */
34 #define PROT_WRITE 0x02 /* Pages can be written. */
35 #define PROT_EXEC 0x04 /* Pages can be executed. */
36
37 /* Flags contain mapping type, sharing type and options. */
38
39 /* Mapping type (must choose one and only one of these). */
40 #ifdef __USE_MISC
41 # define MAP_FILE 0x0000 /* Mapped from a file or device. */
42 # define MAP_ANON 0x1000 /* Allocated from anonymous virtual memory. */
43 # define MAP_TYPE 0x1000 /* Mask for type field. */
44 # ifdef __USE_MISC
45 # define MAP_ANONYMOUS MAP_ANON /* Linux name. */
46 # endif
47 #endif
48
49 /* Sharing types (must choose one and only one of these). */
50 #define MAP_SHARED 0x0001 /* Share changes. */
51 #define MAP_PRIVATE 0x0002 /* Changes private; copy pages on write. */
52 #ifdef __USE_MISC
53 # define MAP_COPY MAP_PRIVATE /* Virtual copy of region at mapping time. */
54 #endif
55
56 /* Other flags. */
57 #define MAP_FIXED 0x0010 /* Map address must be exactly as requested. */
58 #ifdef __USE_MISC
59 #define MAP_RENAME 0x0020 /* Sun: rename private pages to file */
60 #define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */
61 #define MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */
62 #define MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */
63 # define MAP_HASSEMPHORE 0x0200 /* Region may contain semaphores. */
64 # define MAP_STACK 0x0400 /* Region grows down, like a stack. */
65 # define MAP_NOSYNC 0x0800 /* Try to avoid flushing to the disk. */
66 # define MAP_NOCORE 0x20000 /* Don't include these pages in a core dump. */
67 #endif
68
69 /* Advice to `madvise'. */
70 #ifdef __USE_MISC
71 # define MADV_NORMAL 0 /* No further special treatment. */
72 # define MADV_RANDOM 1 /* Expect random page references. */
73 # define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
74 # define MADV_WILLNEED 3 /* Will need these pages. */
75 # define MADV_DONTNEED 4 /* Don't need these pages. */
76 # define MADV_FREE 5 /* Don't need these pages, they contain junk. */
77 # define MADV_NOSYNC 6 /* Try to avoid flushing to the disk. */
78 # define MADV_AUTOSYNC 7 /* Use the default flushing strategy. */
79 # define MADV_NOCORE 8 /* Don't include these pages in a core dump. */
80 # define MADV_CORE 9 /* Include pages in a core dump (default). */
81 # define MADV_PROTECT 10 /* protect process from pageout kill */
82 #endif
83
84 /* The POSIX people had to invent similar names for the same things. */
85 #ifdef __USE_XOPEN2K
86 # define POSIX_MADV_NORMAL 0 /* No further special treatment. */
87 # define POSIX_MADV_RANDOM 1 /* Expect random page references. */
88 # define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
89 # define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
90 # define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
91 #endif
92
93 /* Flags to `msync'. */
94 #define MS_ASYNC 1 /* Sync memory asynchronously. */
95 #define MS_SYNC 0 /* Synchronous memory sync. */
96 #define MS_INVALIDATE 2 /* Invalidate the caches. */
97
98 /* Flags for `mlockall' (can be OR'd together). */
99 #define MCL_CURRENT 1 /* Lock all currently mapped pages. */
100 #define MCL_FUTURE 2 /* Lock all additions to address
101 space. */
102
103 /* Flags for 'minherit'. */
104 #ifdef __USE_MISC
105 # define INHERIT_SHARE 0
106 # define INHERIT_COPY 1
107 # define INHERIT_NONE 2
108 #endif
109
110
111 /*
112 * Return bits from mincore
113 */
114 #ifdef __USE_MISC
115 #define MINCORE_INCORE 0x1 /* Page is incore */
116 #define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */
117 #define MINCORE_MODIFIED 0x4 /* Page has been modified by us */
118 #define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
119 #define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */
120 #endif /* Use MISC */
121
122 #ifdef __USE_MISC
123
124 __BEGIN_DECLS
125
126 extern int minherit (void *__addr, size_t __len, int __inherit);
127
128 __END_DECLS
129
130 #endif /* Use BSD */