OSDN Git Service

(split) LDP: Update POT and ja.po to LDP v3.54
[linuxjm/LDP_man-pages.git] / po4a / memory / po / memory.pot
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2013-09-28 04:06+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: build/C/man2/alloc_hugepages.2:25
21 #, no-wrap
22 msgid "ALLOC_HUGEPAGES"
23 msgstr ""
24
25 #. type: TH
26 #: build/C/man2/alloc_hugepages.2:25
27 #, no-wrap
28 msgid "2007-05-31"
29 msgstr ""
30
31 #. type: TH
32 #: build/C/man2/alloc_hugepages.2:25 build/C/man2/cacheflush.2:25 build/C/man2/fallocate.2:11 build/C/man2/madvise.2:35 build/C/man3/mallinfo.3:26 build/C/man3/malloc_stats.3:26 build/C/man3/malloc_trim.3:26 build/C/man3/mallopt.3:26 build/C/man2/mlock.2:26 build/C/man2/mmap.2:40 build/C/man2/mmap2.2:29 build/C/man2/mprotect.2:38 build/C/man2/mremap.2:30 build/C/man2/msync.2:25 build/C/man2/posix_fadvise.2:28 build/C/man2/readahead.2:28 build/C/man2/remap_file_pages.2:28 build/C/man3/shm_open.3:26 build/C/man7/shm_overview.7:27 build/C/man2/shmctl.2:45 build/C/man2/shmget.2:38 build/C/man2/shmop.2:41 build/C/man2/subpage_prot.2:30 build/C/man2/sync_file_range.2:30
33 #, no-wrap
34 msgid "Linux"
35 msgstr ""
36
37 #. type: TH
38 #: build/C/man2/alloc_hugepages.2:25 build/C/man3/alloca.3:43 build/C/man2/cacheflush.2:25 build/C/man2/fallocate.2:11 build/C/man2/madvise.2:35 build/C/man3/mallinfo.3:26 build/C/man3/malloc_get_state.3:25 build/C/man3/malloc_hook.3:10 build/C/man3/malloc_info.3:25 build/C/man3/malloc_stats.3:26 build/C/man3/malloc_trim.3:26 build/C/man3/malloc_usable_size.3:25 build/C/man3/mallopt.3:26 build/C/man3/mcheck.3:25 build/C/man2/mlock.2:26 build/C/man2/mmap.2:40 build/C/man2/mmap2.2:29 build/C/man2/mprotect.2:38 build/C/man2/mremap.2:30 build/C/man2/msync.2:25 build/C/man3/mtrace.3:25 build/C/man2/posix_fadvise.2:28 build/C/man3/posix_fallocate.3:25 build/C/man3/posix_memalign.3:29 build/C/man2/readahead.2:28 build/C/man2/remap_file_pages.2:28 build/C/man3/shm_open.3:26 build/C/man7/shm_overview.7:27 build/C/man2/shmctl.2:45 build/C/man2/shmget.2:38 build/C/man2/shmop.2:41 build/C/man2/subpage_prot.2:30 build/C/man2/sync_file_range.2:30
39 #, no-wrap
40 msgid "Linux Programmer's Manual"
41 msgstr ""
42
43 #. type: SH
44 #: build/C/man2/alloc_hugepages.2:26 build/C/man3/alloca.3:44 build/C/man2/cacheflush.2:26 build/C/man2/fallocate.2:12 build/C/man2/madvise.2:36 build/C/man3/mallinfo.3:27 build/C/man3/malloc_get_state.3:26 build/C/man3/malloc_hook.3:11 build/C/man3/malloc_info.3:26 build/C/man3/malloc_stats.3:27 build/C/man3/malloc_trim.3:27 build/C/man3/malloc_usable_size.3:26 build/C/man3/mallopt.3:27 build/C/man3/mcheck.3:26 build/C/man2/mlock.2:27 build/C/man2/mmap.2:41 build/C/man2/mmap2.2:30 build/C/man2/mprotect.2:39 build/C/man2/mremap.2:31 build/C/man2/msync.2:26 build/C/man3/mtrace.3:26 build/C/man2/posix_fadvise.2:29 build/C/man3/posix_fallocate.3:26 build/C/man3/posix_memalign.3:30 build/C/man2/readahead.2:29 build/C/man2/remap_file_pages.2:29 build/C/man3/shm_open.3:27 build/C/man7/shm_overview.7:28 build/C/man2/shmctl.2:46 build/C/man2/shmget.2:39 build/C/man2/shmop.2:42 build/C/man2/subpage_prot.2:31 build/C/man2/sync_file_range.2:31
45 #, no-wrap
46 msgid "NAME"
47 msgstr ""
48
49 #. type: Plain text
50 #: build/C/man2/alloc_hugepages.2:28
51 msgid "alloc_hugepages, free_hugepages - allocate or free huge pages"
52 msgstr ""
53
54 #. type: SH
55 #: build/C/man2/alloc_hugepages.2:28 build/C/man3/alloca.3:46 build/C/man2/cacheflush.2:28 build/C/man2/fallocate.2:14 build/C/man2/madvise.2:38 build/C/man3/mallinfo.3:29 build/C/man3/malloc_get_state.3:28 build/C/man3/malloc_hook.3:15 build/C/man3/malloc_info.3:28 build/C/man3/malloc_stats.3:29 build/C/man3/malloc_trim.3:29 build/C/man3/malloc_usable_size.3:28 build/C/man3/mallopt.3:29 build/C/man3/mcheck.3:28 build/C/man2/mlock.2:29 build/C/man2/mmap.2:43 build/C/man2/mmap2.2:32 build/C/man2/mprotect.2:41 build/C/man2/mremap.2:33 build/C/man2/msync.2:28 build/C/man3/mtrace.3:28 build/C/man2/posix_fadvise.2:31 build/C/man3/posix_fallocate.3:28 build/C/man3/posix_memalign.3:32 build/C/man2/readahead.2:31 build/C/man2/remap_file_pages.2:31 build/C/man3/shm_open.3:29 build/C/man2/shmctl.2:48 build/C/man2/shmget.2:41 build/C/man2/shmop.2:44 build/C/man2/subpage_prot.2:33 build/C/man2/sync_file_range.2:33
56 #, no-wrap
57 msgid "SYNOPSIS"
58 msgstr ""
59
60 #.  asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr,
61 #.  unsigned long len, int prot, int flag);
62 #. type: Plain text
63 #: build/C/man2/alloc_hugepages.2:34
64 #, no-wrap
65 msgid ""
66 "B<void *alloc_hugepages(int >I<key>B<, void *>I<addr>B<, size_t "
67 ">I<len>B<,>\n"
68 "B<                      int >I<prot>B<, int >I<flag>B<);>\n"
69 msgstr ""
70
71 #.  asmlinkage int sys_free_hugepages(unsigned long addr);
72 #. type: Plain text
73 #: build/C/man2/alloc_hugepages.2:37
74 #, no-wrap
75 msgid "B<int free_hugepages(void *>I<addr>B<);>\n"
76 msgstr ""
77
78 #. type: SH
79 #: build/C/man2/alloc_hugepages.2:38 build/C/man3/alloca.3:50 build/C/man2/cacheflush.2:34 build/C/man2/fallocate.2:22 build/C/man2/madvise.2:50 build/C/man3/mallinfo.3:33 build/C/man3/malloc_get_state.3:36 build/C/man3/malloc_hook.3:33 build/C/man3/malloc_info.3:34 build/C/man3/malloc_stats.3:33 build/C/man3/malloc_trim.3:33 build/C/man3/malloc_usable_size.3:32 build/C/man3/mallopt.3:33 build/C/man3/mcheck.3:40 build/C/man2/mlock.2:39 build/C/man2/mmap.2:54 build/C/man2/mmap2.2:39 build/C/man2/mprotect.2:47 build/C/man2/mremap.2:42 build/C/man2/msync.2:32 build/C/man3/mtrace.3:34 build/C/man2/posix_fadvise.2:50 build/C/man3/posix_fallocate.3:46 build/C/man3/posix_memalign.3:84 build/C/man2/readahead.2:38 build/C/man2/remap_file_pages.2:39 build/C/man3/shm_open.3:41 build/C/man7/shm_overview.7:30 build/C/man2/shmctl.2:56 build/C/man2/shmget.2:49 build/C/man2/shmop.2:53 build/C/man2/subpage_prot.2:41 build/C/man2/sync_file_range.2:41
80 #, no-wrap
81 msgid "DESCRIPTION"
82 msgstr ""
83
84 #. type: Plain text
85 #: build/C/man2/alloc_hugepages.2:49
86 msgid ""
87 "The system calls B<alloc_hugepages>()  and B<free_hugepages>()  were "
88 "introduced in Linux 2.5.36 and removed again in 2.5.54.  They existed only "
89 "on i386 and ia64 (when built with B<CONFIG_HUGETLB_PAGE>).  In Linux 2.4.20 "
90 "the syscall numbers exist, but the calls fail with the error B<ENOSYS>."
91 msgstr ""
92
93 #. type: Plain text
94 #: build/C/man2/alloc_hugepages.2:57
95 msgid ""
96 "On i386 the memory management hardware knows about ordinary pages (4 KiB)  "
97 "and huge pages (2 or 4 MiB).  Similarly ia64 knows about huge pages of "
98 "several sizes.  These system calls serve to map huge pages into the "
99 "process's memory or to free them again.  Huge pages are locked into memory, "
100 "and are not swapped."
101 msgstr ""
102
103 #. type: Plain text
104 #: build/C/man2/alloc_hugepages.2:66
105 msgid ""
106 "The I<key> argument is an identifier.  When zero the pages are private, and "
107 "not inherited by children.  When positive the pages are shared with other "
108 "applications using the same I<key>, and inherited by child processes."
109 msgstr ""
110
111 #. type: Plain text
112 #: build/C/man2/alloc_hugepages.2:81
113 msgid ""
114 "The I<addr> argument of B<free_hugepages>()  tells which page is being "
115 "freed: it was the return value of a call to B<alloc_hugepages>().  (The "
116 "memory is first actually freed when all users have released it.)  The "
117 "I<addr> argument of B<alloc_hugepages>()  is a hint, that the kernel may or "
118 "may not follow.  Addresses must be properly aligned."
119 msgstr ""
120
121 #. type: Plain text
122 #: build/C/man2/alloc_hugepages.2:86
123 msgid ""
124 "The I<len> argument is the length of the required segment.  It must be a "
125 "multiple of the huge page size."
126 msgstr ""
127
128 #. type: Plain text
129 #: build/C/man2/alloc_hugepages.2:94
130 msgid ""
131 "The I<prot> argument specifies the memory protection of the segment.  It is "
132 "one of B<PROT_READ>, B<PROT_WRITE>, B<PROT_EXEC>."
133 msgstr ""
134
135 #. type: Plain text
136 #: build/C/man2/alloc_hugepages.2:109
137 msgid ""
138 "The I<flag> argument is ignored, unless I<key> is positive.  In that case, "
139 "if I<flag> is B<IPC_CREAT>, then a new huge page segment is created when "
140 "none with the given key existed.  If this flag is not set, then B<ENOENT> is "
141 "returned when no segment with the given key exists."
142 msgstr ""
143
144 #. type: SH
145 #: build/C/man2/alloc_hugepages.2:109 build/C/man3/alloca.3:60 build/C/man2/cacheflush.2:53 build/C/man2/fallocate.2:112 build/C/man2/madvise.2:268 build/C/man3/malloc_get_state.3:61 build/C/man3/malloc_info.3:48 build/C/man3/malloc_trim.3:51 build/C/man3/malloc_usable_size.3:40 build/C/man3/mallopt.3:379 build/C/man3/mcheck.3:129 build/C/man2/mlock.2:116 build/C/man2/mmap.2:375 build/C/man2/mmap2.2:54 build/C/man2/mprotect.2:78 build/C/man2/mremap.2:127 build/C/man2/msync.2:68 build/C/man2/posix_fadvise.2:87 build/C/man3/posix_fallocate.3:66 build/C/man3/posix_memalign.3:142 build/C/man2/readahead.2:65 build/C/man2/remap_file_pages.2:124 build/C/man3/shm_open.3:171 build/C/man2/shmctl.2:279 build/C/man2/shmget.2:180 build/C/man2/shmop.2:171 build/C/man2/subpage_prot.2:66 build/C/man2/sync_file_range.2:141
146 #, no-wrap
147 msgid "RETURN VALUE"
148 msgstr ""
149
150 #. type: Plain text
151 #: build/C/man2/alloc_hugepages.2:118
152 msgid ""
153 "On success, B<alloc_hugepages>()  returns the allocated virtual address, and "
154 "B<free_hugepages>()  returns zero.  On error, -1 is returned, and I<errno> "
155 "is set appropriately."
156 msgstr ""
157
158 #. type: SH
159 #: build/C/man2/alloc_hugepages.2:118 build/C/man2/cacheflush.2:59 build/C/man2/fallocate.2:119 build/C/man2/madvise.2:275 build/C/man3/malloc_info.3:55 build/C/man3/malloc_trim.3:56 build/C/man3/mallopt.3:384 build/C/man2/mlock.2:122 build/C/man2/mmap.2:392 build/C/man2/mmap2.2:61 build/C/man2/mprotect.2:85 build/C/man2/mremap.2:135 build/C/man2/msync.2:73 build/C/man2/posix_fadvise.2:90 build/C/man3/posix_fallocate.3:72 build/C/man3/posix_memalign.3:157 build/C/man2/readahead.2:71 build/C/man2/remap_file_pages.2:131 build/C/man3/shm_open.3:180 build/C/man2/shmctl.2:301 build/C/man2/shmget.2:185 build/C/man2/shmop.2:185 build/C/man2/subpage_prot.2:71 build/C/man2/sync_file_range.2:147
160 #, no-wrap
161 msgid "ERRORS"
162 msgstr ""
163
164 #. type: TP
165 #: build/C/man2/alloc_hugepages.2:119 build/C/man2/fallocate.2:158
166 #, no-wrap
167 msgid "B<ENOSYS>"
168 msgstr ""
169
170 #. type: Plain text
171 #: build/C/man2/alloc_hugepages.2:122
172 msgid "The system call is not supported on this kernel."
173 msgstr ""
174
175 #. type: SH
176 #: build/C/man2/alloc_hugepages.2:122
177 #, no-wrap
178 msgid "FILES"
179 msgstr ""
180
181 #. type: Plain text
182 #: build/C/man2/alloc_hugepages.2:126
183 msgid ""
184 "I</proc/sys/vm/nr_hugepages> Number of configured hugetlb pages.  This can "
185 "be read and written."
186 msgstr ""
187
188 #. type: Plain text
189 #: build/C/man2/alloc_hugepages.2:130
190 msgid ""
191 "I</proc/meminfo> Gives info on the number of configured hugetlb pages and on "
192 "their size in the three variables HugePages_Total, HugePages_Free, "
193 "Hugepagesize."
194 msgstr ""
195
196 #. type: SH
197 #: build/C/man2/alloc_hugepages.2:130 build/C/man3/alloca.3:65 build/C/man2/cacheflush.2:75 build/C/man2/fallocate.2:199 build/C/man2/madvise.2:325 build/C/man3/mallinfo.3:110 build/C/man3/malloc_get_state.3:86 build/C/man3/malloc_hook.3:80 build/C/man3/malloc_info.3:63 build/C/man3/malloc_stats.3:55 build/C/man3/malloc_trim.3:60 build/C/man3/malloc_usable_size.3:48 build/C/man3/mallopt.3:392 build/C/man3/mcheck.3:145 build/C/man2/mlock.2:186 build/C/man2/mmap.2:497 build/C/man2/mmap2.2:77 build/C/man2/mprotect.2:113 build/C/man2/mremap.2:185 build/C/man2/msync.2:96 build/C/man3/mtrace.3:78 build/C/man2/posix_fadvise.2:112 build/C/man3/posix_fallocate.3:103 build/C/man3/posix_memalign.3:182 build/C/man2/readahead.2:87 build/C/man2/remap_file_pages.2:153 build/C/man3/shm_open.3:251 build/C/man7/shm_overview.7:101 build/C/man2/shmctl.2:373 build/C/man2/shmget.2:232 build/C/man2/shmop.2:231 build/C/man2/subpage_prot.2:96 build/C/man2/sync_file_range.2:180
198 #, no-wrap
199 msgid "CONFORMING TO"
200 msgstr ""
201
202 #. type: Plain text
203 #: build/C/man2/alloc_hugepages.2:133
204 msgid ""
205 "These calls are specific to Linux on Intel processors, and should not be "
206 "used in programs intended to be portable."
207 msgstr ""
208
209 #. type: SH
210 #: build/C/man2/alloc_hugepages.2:133 build/C/man3/alloca.3:73 build/C/man2/madvise.2:346 build/C/man3/malloc_get_state.3:88 build/C/man3/malloc_hook.3:82 build/C/man3/malloc_info.3:65 build/C/man3/malloc_stats.3:57 build/C/man3/malloc_trim.3:62 build/C/man3/malloc_usable_size.3:50 build/C/man3/mcheck.3:147 build/C/man2/mlock.2:213 build/C/man2/mmap.2:515 build/C/man2/mmap2.2:79 build/C/man2/mprotect.2:122 build/C/man2/mremap.2:191 build/C/man3/mtrace.3:80 build/C/man2/posix_fadvise.2:121 build/C/man3/posix_memalign.3:221 build/C/man2/readahead.2:92 build/C/man3/shm_open.3:257 build/C/man7/shm_overview.7:103 build/C/man2/shmctl.2:378 build/C/man2/shmget.2:238 build/C/man2/shmop.2:250 build/C/man2/subpage_prot.2:98 build/C/man2/sync_file_range.2:183
211 #, no-wrap
212 msgid "NOTES"
213 msgstr ""
214
215 #. type: Plain text
216 #: build/C/man2/alloc_hugepages.2:141
217 msgid ""
218 "These system calls are gone; they existed only in Linux 2.5.36 through to "
219 "2.5.54.  Now the hugetlbfs filesystem can be used instead.  Memory backed by "
220 "huge pages (if the CPU supports them) is obtained by using B<mmap>(2)  to "
221 "map files in this virtual filesystem."
222 msgstr ""
223
224 #. type: Plain text
225 #: build/C/man2/alloc_hugepages.2:145
226 msgid ""
227 "The maximal number of huge pages can be specified using the B<hugepages=> "
228 "boot parameter."
229 msgstr ""
230
231 #. type: SH
232 #: build/C/man2/alloc_hugepages.2:150 build/C/man3/alloca.3:157 build/C/man2/cacheflush.2:89 build/C/man2/fallocate.2:207 build/C/man2/madvise.2:379 build/C/man3/mallinfo.3:279 build/C/man3/malloc_get_state.3:114 build/C/man3/malloc_hook.3:142 build/C/man3/malloc_info.3:262 build/C/man3/malloc_stats.3:67 build/C/man3/malloc_trim.3:82 build/C/man3/malloc_usable_size.3:64 build/C/man3/mallopt.3:580 build/C/man3/mcheck.3:208 build/C/man2/mlock.2:336 build/C/man2/mmap.2:737 build/C/man2/mmap2.2:98 build/C/man2/mprotect.2:229 build/C/man2/mremap.2:214 build/C/man2/msync.2:124 build/C/man3/mtrace.3:172 build/C/man2/posix_fadvise.2:197 build/C/man3/posix_fallocate.3:133 build/C/man3/posix_memalign.3:277 build/C/man2/readahead.2:103 build/C/man2/remap_file_pages.2:164 build/C/man3/shm_open.3:282 build/C/man7/shm_overview.7:127 build/C/man2/shmctl.2:431 build/C/man2/shmget.2:314 build/C/man2/shmop.2:295 build/C/man2/subpage_prot.2:134 build/C/man2/sync_file_range.2:226
233 #, no-wrap
234 msgid "COLOPHON"
235 msgstr ""
236
237 #. type: Plain text
238 #: build/C/man2/alloc_hugepages.2:157 build/C/man3/alloca.3:164 build/C/man2/cacheflush.2:96 build/C/man2/fallocate.2:214 build/C/man2/madvise.2:386 build/C/man3/mallinfo.3:286 build/C/man3/malloc_get_state.3:121 build/C/man3/malloc_hook.3:149 build/C/man3/malloc_info.3:269 build/C/man3/malloc_stats.3:74 build/C/man3/malloc_trim.3:89 build/C/man3/malloc_usable_size.3:71 build/C/man3/mallopt.3:587 build/C/man3/mcheck.3:215 build/C/man2/mlock.2:343 build/C/man2/mmap.2:744 build/C/man2/mmap2.2:105 build/C/man2/mprotect.2:236 build/C/man2/mremap.2:221 build/C/man2/msync.2:131 build/C/man3/mtrace.3:179 build/C/man2/posix_fadvise.2:204 build/C/man3/posix_fallocate.3:140 build/C/man3/posix_memalign.3:284 build/C/man2/readahead.2:110 build/C/man2/remap_file_pages.2:171 build/C/man3/shm_open.3:289 build/C/man7/shm_overview.7:134 build/C/man2/shmctl.2:438 build/C/man2/shmget.2:321 build/C/man2/shmop.2:302 build/C/man2/subpage_prot.2:141 build/C/man2/sync_file_range.2:233
239 msgid ""
240 "This page is part of release 3.54 of the Linux I<man-pages> project.  A "
241 "description of the project, and information about reporting bugs, can be "
242 "found at \\%http://www.kernel.org/doc/man-pages/."
243 msgstr ""
244
245 #. type: TH
246 #: build/C/man3/alloca.3:43
247 #, no-wrap
248 msgid "ALLOCA"
249 msgstr ""
250
251 #. type: TH
252 #: build/C/man3/alloca.3:43
253 #, no-wrap
254 msgid "2013-05-12"
255 msgstr ""
256
257 #. type: TH
258 #: build/C/man3/alloca.3:43 build/C/man3/malloc_get_state.3:25 build/C/man3/malloc_hook.3:10 build/C/man3/malloc_info.3:25 build/C/man3/malloc_usable_size.3:25 build/C/man3/mcheck.3:25 build/C/man3/mtrace.3:25 build/C/man3/posix_fallocate.3:25 build/C/man3/posix_memalign.3:29
259 #, no-wrap
260 msgid "GNU"
261 msgstr ""
262
263 #. type: Plain text
264 #: build/C/man3/alloca.3:46
265 msgid "alloca - allocate memory that is automatically freed"
266 msgstr ""
267
268 #. type: Plain text
269 #: build/C/man3/alloca.3:48
270 msgid "B<#include E<lt>alloca.hE<gt>>"
271 msgstr ""
272
273 #. type: Plain text
274 #: build/C/man3/alloca.3:50
275 msgid "B<void *alloca(size_t >I<size>B<);>"
276 msgstr ""
277
278 #. type: Plain text
279 #: build/C/man3/alloca.3:60
280 msgid ""
281 "The B<alloca>()  function allocates I<size> bytes of space in the stack "
282 "frame of the caller.  This temporary space is automatically freed when the "
283 "function that called B<alloca>()  returns to its caller."
284 msgstr ""
285
286 #. type: Plain text
287 #: build/C/man3/alloca.3:65
288 msgid ""
289 "The B<alloca>()  function returns a pointer to the beginning of the "
290 "allocated space.  If the allocation causes stack overflow, program behavior "
291 "is undefined."
292 msgstr ""
293
294 #. type: Plain text
295 #: build/C/man3/alloca.3:67
296 msgid "This function is not in POSIX.1-2001."
297 msgstr ""
298
299 #. type: Plain text
300 #: build/C/man3/alloca.3:73
301 msgid ""
302 "There is evidence that the B<alloca>()  function appeared in 32V, PWB, "
303 "PWB.2, 3BSD, and 4BSD.  There is a man page for it in 4.3BSD.  Linux uses "
304 "the GNU version."
305 msgstr ""
306
307 #. type: Plain text
308 #: build/C/man3/alloca.3:88
309 msgid ""
310 "The B<alloca>()  function is machine- and compiler-dependent.  For certain "
311 "applications, its use can improve efficiency compared to the use of "
312 "B<malloc>(3)  plus B<free>(3).  In certain cases, it can also simplify "
313 "memory deallocation in applications that use B<longjmp>(3)  or "
314 "B<siglongjmp>(3).  Otherwise, its use is discouraged."
315 msgstr ""
316
317 #. type: Plain text
318 #: build/C/man3/alloca.3:97
319 msgid ""
320 "Because the space allocated by B<alloca>()  is allocated within the stack "
321 "frame, that space is automatically freed if the function return is jumped "
322 "over by a call to B<longjmp>(3)  or B<siglongjmp>(3)."
323 msgstr ""
324
325 #. type: Plain text
326 #: build/C/man3/alloca.3:102
327 msgid "Do not attempt to B<free>(3)  space allocated by B<alloca>()!"
328 msgstr ""
329
330 #. type: SS
331 #: build/C/man3/alloca.3:102
332 #, no-wrap
333 msgid "Notes on the GNU version"
334 msgstr ""
335
336 #. type: Plain text
337 #: build/C/man3/alloca.3:124
338 msgid ""
339 "Normally, B<gcc>(1)  translates calls to B<alloca>()  with inlined code.  "
340 "This is not done when either the I<-ansi>, I<-std=c89>, I<-std=c99>, or the "
341 "I<-std=c11> option is given B<and> the header I<E<lt>alloca.hE<gt>> is not "
342 "included.  Otherwise (without an -ansi or -std=c* option) the glibc version "
343 "of I<E<lt>stdlib.hE<gt>> includes I<E<lt>alloca.hE<gt>> and that contains "
344 "the lines:"
345 msgstr ""
346
347 #. type: Plain text
348 #: build/C/man3/alloca.3:129
349 #, no-wrap
350 msgid ""
351 "    #ifdef  __GNUC__\n"
352 "    #define alloca(size)   __builtin_alloca (size)\n"
353 "    #endif\n"
354 msgstr ""
355
356 #. type: Plain text
357 #: build/C/man3/alloca.3:132
358 msgid "with messy consequences if one has a private version of this function."
359 msgstr ""
360
361 #. type: Plain text
362 #: build/C/man3/alloca.3:136
363 msgid ""
364 "The fact that the code is inlined means that it is impossible to take the "
365 "address of this function, or to change its behavior by linking with a "
366 "different library."
367 msgstr ""
368
369 #. type: Plain text
370 #: build/C/man3/alloca.3:140
371 msgid ""
372 "The inlined code often consists of a single instruction adjusting the stack "
373 "pointer, and does not check for stack overflow.  Thus, there is no NULL "
374 "error return."
375 msgstr ""
376
377 #. type: SH
378 #: build/C/man3/alloca.3:140 build/C/man2/cacheflush.2:82 build/C/man3/mallinfo.3:114 build/C/man3/mallopt.3:406 build/C/man2/mlock.2:304 build/C/man2/mmap.2:587 build/C/man3/mtrace.3:102 build/C/man2/posix_fadvise.2:186 build/C/man2/shmget.2:300
379 #, no-wrap
380 msgid "BUGS"
381 msgstr ""
382
383 #. type: Plain text
384 #: build/C/man3/alloca.3:145
385 msgid ""
386 "There is no error indication if the stack frame cannot be extended.  "
387 "(However, after a failed allocation, the program is likely to receive a "
388 "B<SIGSEGV> signal if it attempts to access the unallocated space.)"
389 msgstr ""
390
391 #. type: Plain text
392 #: build/C/man3/alloca.3:153
393 msgid ""
394 "On many systems B<alloca>()  cannot be used inside the list of arguments of "
395 "a function call, because the stack space reserved by B<alloca>()  would "
396 "appear on the stack in the middle of the space for the function arguments."
397 msgstr ""
398
399 #. type: SH
400 #: build/C/man3/alloca.3:153 build/C/man2/fallocate.2:202 build/C/man2/madvise.2:371 build/C/man3/mallinfo.3:270 build/C/man3/malloc_get_state.3:111 build/C/man3/malloc_hook.3:137 build/C/man3/malloc_info.3:256 build/C/man3/malloc_stats.3:61 build/C/man3/malloc_trim.3:78 build/C/man3/malloc_usable_size.3:62 build/C/man3/mallopt.3:566 build/C/man3/mcheck.3:204 build/C/man2/mlock.2:329 build/C/man2/mmap.2:712 build/C/man2/mmap2.2:92 build/C/man2/mprotect.2:226 build/C/man2/mremap.2:199 build/C/man2/msync.2:120 build/C/man3/mtrace.3:167 build/C/man2/posix_fadvise.2:191 build/C/man3/posix_fallocate.3:128 build/C/man3/posix_memalign.3:272 build/C/man2/readahead.2:97 build/C/man2/remap_file_pages.2:157 build/C/man3/shm_open.3:271 build/C/man7/shm_overview.7:114 build/C/man2/shmctl.2:424 build/C/man2/shmget.2:306 build/C/man2/shmop.2:287 build/C/man2/subpage_prot.2:128 build/C/man2/sync_file_range.2:221
401 #, no-wrap
402 msgid "SEE ALSO"
403 msgstr ""
404
405 #. type: Plain text
406 #: build/C/man3/alloca.3:157
407 msgid "B<brk>(2), B<longjmp>(3), B<malloc>(3)"
408 msgstr ""
409
410 #. type: TH
411 #: build/C/man2/cacheflush.2:25
412 #, no-wrap
413 msgid "CACHEFLUSH"
414 msgstr ""
415
416 #. type: TH
417 #: build/C/man2/cacheflush.2:25
418 #, no-wrap
419 msgid "2007-05-26"
420 msgstr ""
421
422 #. type: Plain text
423 #: build/C/man2/cacheflush.2:28
424 msgid "cacheflush - flush contents of instruction and/or data cache"
425 msgstr ""
426
427 #. type: Plain text
428 #: build/C/man2/cacheflush.2:31
429 #, no-wrap
430 msgid "B<#include E<lt>asm/cachectl.hE<gt>>\n"
431 msgstr ""
432
433 #. type: Plain text
434 #: build/C/man2/cacheflush.2:33
435 #, no-wrap
436 msgid "B<int cacheflush(char *>I<addr>B<, int >I<nbytes>B<, int >I<cache>B<);>\n"
437 msgstr ""
438
439 #. type: Plain text
440 #: build/C/man2/cacheflush.2:43
441 msgid ""
442 "B<cacheflush>()  flushes the contents of the indicated cache(s) for the user "
443 "addresses in the range I<addr> to I<(addr+nbytes-1)>.  I<cache> may be one "
444 "of:"
445 msgstr ""
446
447 #. type: TP
448 #: build/C/man2/cacheflush.2:43
449 #, no-wrap
450 msgid "B<ICACHE>"
451 msgstr ""
452
453 #. type: Plain text
454 #: build/C/man2/cacheflush.2:46
455 msgid "Flush the instruction cache."
456 msgstr ""
457
458 #. type: TP
459 #: build/C/man2/cacheflush.2:46
460 #, no-wrap
461 msgid "B<DCACHE>"
462 msgstr ""
463
464 #. type: Plain text
465 #: build/C/man2/cacheflush.2:49
466 msgid "Write back to memory and invalidate the affected valid cache lines."
467 msgstr ""
468
469 #. type: TP
470 #: build/C/man2/cacheflush.2:49
471 #, no-wrap
472 msgid "B<BCACHE>"
473 msgstr ""
474
475 #. type: Plain text
476 #: build/C/man2/cacheflush.2:53
477 msgid "Same as B<(ICACHE|DCACHE)>."
478 msgstr ""
479
480 #. type: Plain text
481 #: build/C/man2/cacheflush.2:59
482 msgid ""
483 "B<cacheflush>()  returns 0 on success or -1 on error.  If errors are "
484 "detected, I<errno> will indicate the error."
485 msgstr ""
486
487 #. type: TP
488 #: build/C/man2/cacheflush.2:60 build/C/man2/mmap2.2:62 build/C/man2/mremap.2:142 build/C/man2/shmctl.2:310 build/C/man2/subpage_prot.2:72
489 #, no-wrap
490 msgid "B<EFAULT>"
491 msgstr ""
492
493 #. type: Plain text
494 #: build/C/man2/cacheflush.2:67
495 msgid ""
496 "Some or all of the address range I<addr> to I<(addr+nbytes-1)> is not "
497 "accessible."
498 msgstr ""
499
500 #. type: TP
501 #: build/C/man2/cacheflush.2:67 build/C/man2/fallocate.2:131 build/C/man2/madvise.2:282 build/C/man3/malloc_info.3:56 build/C/man2/mlock.2:157 build/C/man2/mlock.2:164 build/C/man2/mlock.2:176 build/C/man2/mmap.2:423 build/C/man2/mmap.2:431 build/C/man2/mmap.2:436 build/C/man2/mmap2.2:65 build/C/man2/mprotect.2:95 build/C/man2/mremap.2:151 build/C/man2/msync.2:80 build/C/man2/posix_fadvise.2:94 build/C/man3/posix_fallocate.3:81 build/C/man3/posix_memalign.3:158 build/C/man2/readahead.2:76 build/C/man2/remap_file_pages.2:132 build/C/man2/remap_file_pages.2:139 build/C/man3/shm_open.3:213 build/C/man2/shmctl.2:324 build/C/man2/shmget.2:199 build/C/man2/shmop.2:200 build/C/man2/shmop.2:223 build/C/man2/subpage_prot.2:77 build/C/man2/sync_file_range.2:152
502 #, no-wrap
503 msgid "B<EINVAL>"
504 msgstr ""
505
506 #. type: Plain text
507 #: build/C/man2/cacheflush.2:75
508 msgid "I<cache> is not one of B<ICACHE>, B<DCACHE>, or B<BCACHE>."
509 msgstr ""
510
511 #.  FIXME This system call was only on MIPS back in 1.2 days, but
512 #.  by now it is on a number of other architectures (but not i386).
513 #.  Investigate the details and update this page.
514 #.  Irix 6.5 appears to have a cacheflush() syscall -- mtk
515 #. type: Plain text
516 #: build/C/man2/cacheflush.2:82
517 msgid ""
518 "This Linux-specific system call is available only on MIPS-based systems.  It "
519 "should not be used in programs intended to be portable."
520 msgstr ""
521
522 #. type: Plain text
523 #: build/C/man2/cacheflush.2:89
524 msgid ""
525 "The current implementation ignores the I<addr> and I<nbytes> arguments.  "
526 "Therefore, the whole cache is always flushed."
527 msgstr ""
528
529 #. type: TH
530 #: build/C/man2/fallocate.2:11
531 #, no-wrap
532 msgid "FALLOCATE"
533 msgstr ""
534
535 #. type: TH
536 #: build/C/man2/fallocate.2:11
537 #, no-wrap
538 msgid "2013-06-10"
539 msgstr ""
540
541 #. type: Plain text
542 #: build/C/man2/fallocate.2:14
543 msgid "fallocate - manipulate file space"
544 msgstr ""
545
546 #. type: Plain text
547 #: build/C/man2/fallocate.2:18 build/C/man2/readahead.2:35
548 #, no-wrap
549 msgid ""
550 "B<#define _GNU_SOURCE>             /* See feature_test_macros(7) */\n"
551 "B<#include E<lt>fcntl.hE<gt>>\n"
552 msgstr ""
553
554 #. type: Plain text
555 #: build/C/man2/fallocate.2:21
556 #, no-wrap
557 msgid ""
558 "B<int fallocate(int >I<fd>B<, int >I<mode>B<, off_t >I<offset>B<, off_t "
559 ">I<len>B<);>\n"
560 msgstr ""
561
562 #. type: Plain text
563 #: build/C/man2/fallocate.2:27
564 msgid ""
565 "This is a nonportable, Linux-specific system call.  For the portable, "
566 "POSIX.1-specified method of ensuring that space is allocated for a file, see "
567 "B<posix_fallocate>(3)."
568 msgstr ""
569
570 #. type: Plain text
571 #: build/C/man2/fallocate.2:37
572 msgid ""
573 "B<fallocate>()  allows the caller to directly manipulate the allocated disk "
574 "space for the file referred to by I<fd> for the byte range starting at "
575 "I<offset> and continuing for I<len> bytes."
576 msgstr ""
577
578 #. type: Plain text
579 #: build/C/man2/fallocate.2:42
580 msgid ""
581 "The I<mode> argument determines the operation to be performed on the given "
582 "range.  Details of the supported operations are given in the subsections "
583 "below."
584 msgstr ""
585
586 #. type: SS
587 #: build/C/man2/fallocate.2:42
588 #, no-wrap
589 msgid "Allocating disk space"
590 msgstr ""
591
592 #. type: Plain text
593 #: build/C/man2/fallocate.2:61
594 msgid ""
595 "The default operation (i.e., I<mode> is zero) of B<fallocate>()  allocates "
596 "and initializes to zero the disk space within the range specified by "
597 "I<offset> and I<len>.  The file size (as reported by B<stat>(2))  will be "
598 "changed if I<offset>+I<len> is greater than the file size.  This default "
599 "behavior closely resembles the behavior of the B<posix_fallocate>(3)  "
600 "library function, and is intended as a method of optimally implementing that "
601 "function."
602 msgstr ""
603
604 #. type: Plain text
605 #: build/C/man2/fallocate.2:67
606 msgid ""
607 "After a successful call, subsequent writes into the range specified by "
608 "I<offset> and I<len> are guaranteed not to fail because of lack of disk "
609 "space."
610 msgstr ""
611
612 #. type: Plain text
613 #: build/C/man2/fallocate.2:78
614 msgid ""
615 "If the B<FALLOC_FL_KEEP_SIZE> flag is specified in I<mode>, the behavior of "
616 "the call is similar, but the file size will not be changed even if "
617 "I<offset>+I<len> is greater than the file size.  Preallocating zeroed blocks "
618 "beyond the end of the file in this manner is useful for optimizing append "
619 "workloads."
620 msgstr ""
621
622 #. type: Plain text
623 #: build/C/man2/fallocate.2:82
624 msgid ""
625 "Because allocation is done in block size chunks, B<fallocate>()  may "
626 "allocate a larger range of disk space than was specified."
627 msgstr ""
628
629 #. type: SS
630 #: build/C/man2/fallocate.2:82
631 #, no-wrap
632 msgid "Deallocating file space"
633 msgstr ""
634
635 #. type: Plain text
636 #: build/C/man2/fallocate.2:97
637 msgid ""
638 "Specifying the B<FALLOC_FL_PUNCH_HOLE> flag (available since Linux 2.6.38) "
639 "in I<mode> deallocates space (i.e., creates a hole)  in the byte range "
640 "starting at I<offset> and continuing for I<len> bytes.  Within the specified "
641 "range, partial filesystem blocks are zeroed, and whole filesystem blocks are "
642 "removed from the file.  After a successful call, subsequent reads from this "
643 "range will return zeroes."
644 msgstr ""
645
646 #. type: Plain text
647 #: build/C/man2/fallocate.2:108
648 msgid ""
649 "The B<FALLOC_FL_PUNCH_HOLE> flag must be ORed with B<FALLOC_FL_KEEP_SIZE> in "
650 "I<mode>; in other words, even when punching off the end of the file, the "
651 "file size (as reported by B<stat>(2))  does not change."
652 msgstr ""
653
654 #. type: Plain text
655 #: build/C/man2/fallocate.2:112
656 msgid ""
657 "Not all filesystems support B<FALLOC_FL_PUNCH_HOLE>; if a filesystem doesn't "
658 "support the operation, an error is returned."
659 msgstr ""
660
661 #. type: Plain text
662 #: build/C/man2/fallocate.2:119
663 msgid ""
664 "On success, B<fallocate>()  returns zero.  On error, -1 is returned and "
665 "I<errno> is set to indicate the error."
666 msgstr ""
667
668 #. type: TP
669 #: build/C/man2/fallocate.2:120 build/C/man2/madvise.2:279 build/C/man2/mmap.2:417 build/C/man2/posix_fadvise.2:91 build/C/man3/posix_fallocate.3:73 build/C/man2/readahead.2:72 build/C/man2/sync_file_range.2:148
670 #, no-wrap
671 msgid "B<EBADF>"
672 msgstr ""
673
674 #. type: Plain text
675 #: build/C/man2/fallocate.2:124 build/C/man3/posix_fallocate.3:77
676 msgid "I<fd> is not a valid file descriptor, or is not opened for writing."
677 msgstr ""
678
679 #. type: TP
680 #: build/C/man2/fallocate.2:124 build/C/man3/posix_fallocate.3:77
681 #, no-wrap
682 msgid "B<EFBIG>"
683 msgstr ""
684
685 #. type: Plain text
686 #: build/C/man2/fallocate.2:128
687 msgid "I<offset>+I<len> exceeds the maximum file size."
688 msgstr ""
689
690 #. type: TP
691 #: build/C/man2/fallocate.2:128
692 #, no-wrap
693 msgid "B<EINTR>"
694 msgstr ""
695
696 #. type: Plain text
697 #: build/C/man2/fallocate.2:131
698 msgid "A signal was caught during execution."
699 msgstr ""
700
701 #. type: Plain text
702 #: build/C/man2/fallocate.2:143 build/C/man3/posix_fallocate.3:87
703 msgid "I<offset> was less than 0, or I<len> was less than or equal to 0."
704 msgstr ""
705
706 #. type: TP
707 #: build/C/man2/fallocate.2:143 build/C/man2/madvise.2:310 build/C/man2/sync_file_range.2:160
708 #, no-wrap
709 msgid "B<EIO>"
710 msgstr ""
711
712 #. type: Plain text
713 #: build/C/man2/fallocate.2:146
714 msgid "An I/O error occurred while reading from or writing to a filesystem."
715 msgstr ""
716
717 #. type: TP
718 #: build/C/man2/fallocate.2:146 build/C/man2/mmap.2:452 build/C/man3/posix_fallocate.3:87
719 #, no-wrap
720 msgid "B<ENODEV>"
721 msgstr ""
722
723 #. type: Plain text
724 #: build/C/man2/fallocate.2:153
725 msgid ""
726 "I<fd> does not refer to a regular file or a directory.  (If I<fd> is a pipe "
727 "or FIFO, a different error results.)"
728 msgstr ""
729
730 #. type: TP
731 #: build/C/man2/fallocate.2:153 build/C/man3/posix_fallocate.3:91 build/C/man2/shmget.2:217 build/C/man2/sync_file_range.2:166
732 #, no-wrap
733 msgid "B<ENOSPC>"
734 msgstr ""
735
736 #. type: Plain text
737 #: build/C/man2/fallocate.2:158 build/C/man3/posix_fallocate.3:96
738 msgid ""
739 "There is not enough space left on the device containing the file referred to "
740 "by I<fd>."
741 msgstr ""
742
743 #. type: Plain text
744 #: build/C/man2/fallocate.2:162
745 msgid "This kernel does not implement B<fallocate>()."
746 msgstr ""
747
748 #. type: TP
749 #: build/C/man2/fallocate.2:162
750 #, no-wrap
751 msgid "B<EOPNOTSUPP>"
752 msgstr ""
753
754 #. type: Plain text
755 #: build/C/man2/fallocate.2:171
756 msgid ""
757 "The filesystem containing the file referred to by I<fd> does not support "
758 "this operation; or the I<mode> is not supported by the filesystem containing "
759 "the file referred to by I<fd>."
760 msgstr ""
761
762 #. type: TP
763 #: build/C/man2/fallocate.2:171 build/C/man2/mlock.2:143 build/C/man2/mlock.2:182 build/C/man2/mmap.2:460 build/C/man2/shmctl.2:349 build/C/man2/shmget.2:225
764 #, no-wrap
765 msgid "B<EPERM>"
766 msgstr ""
767
768 #. type: Plain text
769 #: build/C/man2/fallocate.2:187
770 msgid ""
771 "The file referred to by I<fd> is marked immutable (see B<chattr>(1)).  Or: "
772 "I<mode> specifies B<FALLOC_FL_PUNCH_HOLE> and the file referred to by I<fd> "
773 "is marked append-only (see B<chattr>(1))."
774 msgstr ""
775
776 #. type: TP
777 #: build/C/man2/fallocate.2:187 build/C/man2/posix_fadvise.2:97 build/C/man3/posix_fallocate.3:96 build/C/man2/sync_file_range.2:169
778 #, no-wrap
779 msgid "B<ESPIPE>"
780 msgstr ""
781
782 #. type: Plain text
783 #: build/C/man2/fallocate.2:191
784 msgid "I<fd> refers to a pipe or FIFO."
785 msgstr ""
786
787 #. type: SH
788 #: build/C/man2/fallocate.2:191 build/C/man3/malloc_info.3:60 build/C/man3/mcheck.3:134 build/C/man2/mmap2.2:74 build/C/man2/posix_fadvise.2:104 build/C/man3/posix_fallocate.3:100 build/C/man3/posix_memalign.3:167 build/C/man2/readahead.2:82 build/C/man2/remap_file_pages.2:148 build/C/man3/shm_open.3:249 build/C/man2/subpage_prot.2:90 build/C/man2/sync_file_range.2:177
789 #, no-wrap
790 msgid "VERSIONS"
791 msgstr ""
792
793 #.  See http://sourceware.org/bugzilla/show_bug.cgi?id=14964
794 #. type: Plain text
795 #: build/C/man2/fallocate.2:199
796 msgid ""
797 "B<fallocate>()  is available on Linux since kernel 2.6.23.  Support is "
798 "provided by glibc since version 2.10.  The B<FALLOC_FL_*> flags are defined "
799 "in glibc headers only since version 2.18."
800 msgstr ""
801
802 #. type: Plain text
803 #: build/C/man2/fallocate.2:202
804 msgid "B<fallocate>()  is Linux-specific."
805 msgstr ""
806
807 #. type: Plain text
808 #: build/C/man2/fallocate.2:207
809 msgid "B<fallocate>(1), B<ftruncate>(2), B<posix_fadvise>(3), B<posix_fallocate>(3)"
810 msgstr ""
811
812 #. type: TH
813 #: build/C/man2/madvise.2:35
814 #, no-wrap
815 msgid "MADVISE"
816 msgstr ""
817
818 #. type: TH
819 #: build/C/man2/madvise.2:35
820 #, no-wrap
821 msgid "2012-04-28"
822 msgstr ""
823
824 #. type: Plain text
825 #: build/C/man2/madvise.2:38
826 msgid "madvise - give advice about use of memory"
827 msgstr ""
828
829 #. type: Plain text
830 #: build/C/man2/madvise.2:40 build/C/man2/msync.2:30 build/C/man3/shm_open.3:31
831 msgid "B<#include E<lt>sys/mman.hE<gt>>"
832 msgstr ""
833
834 #. type: Plain text
835 #: build/C/man2/madvise.2:42
836 msgid "B<int madvise(void *>I<addr>B<, size_t >I<length>B<, int >I<advice>B<);>"
837 msgstr ""
838
839 #. type: Plain text
840 #: build/C/man2/madvise.2:46 build/C/man2/posix_fadvise.2:43 build/C/man3/posix_fallocate.3:39 build/C/man3/posix_memalign.3:49
841 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
842 msgstr ""
843
844 #. type: Plain text
845 #: build/C/man2/madvise.2:50
846 msgid "B<madvise>(): _BSD_SOURCE"
847 msgstr ""
848
849 #. type: Plain text
850 #: build/C/man2/madvise.2:68
851 msgid ""
852 "The B<madvise>()  system call advises the kernel about how to handle paging "
853 "input/output in the address range beginning at address I<addr> and with size "
854 "I<length> bytes.  It allows an application to tell the kernel how it expects "
855 "to use some mapped or shared memory areas, so that the kernel can choose "
856 "appropriate read-ahead and caching techniques.  This call does not influence "
857 "the semantics of the application (except in the case of B<MADV_DONTNEED>), "
858 "but may influence its performance.  The kernel is free to ignore the advice."
859 msgstr ""
860
861 #. type: Plain text
862 #: build/C/man2/madvise.2:72
863 msgid "The advice is indicated in the I<advice> argument which can be"
864 msgstr ""
865
866 #. type: TP
867 #: build/C/man2/madvise.2:72
868 #, no-wrap
869 msgid "B<MADV_NORMAL>"
870 msgstr ""
871
872 #. type: Plain text
873 #: build/C/man2/madvise.2:76
874 msgid "No special treatment.  This is the default."
875 msgstr ""
876
877 #. type: TP
878 #: build/C/man2/madvise.2:76
879 #, no-wrap
880 msgid "B<MADV_RANDOM>"
881 msgstr ""
882
883 #. type: Plain text
884 #: build/C/man2/madvise.2:80
885 msgid ""
886 "Expect page references in random order.  (Hence, read ahead may be less "
887 "useful than normally.)"
888 msgstr ""
889
890 #. type: TP
891 #: build/C/man2/madvise.2:80
892 #, no-wrap
893 msgid "B<MADV_SEQUENTIAL>"
894 msgstr ""
895
896 #. type: Plain text
897 #: build/C/man2/madvise.2:85
898 msgid ""
899 "Expect page references in sequential order.  (Hence, pages in the given "
900 "range can be aggressively read ahead, and may be freed soon after they are "
901 "accessed.)"
902 msgstr ""
903
904 #. type: TP
905 #: build/C/man2/madvise.2:85
906 #, no-wrap
907 msgid "B<MADV_WILLNEED>"
908 msgstr ""
909
910 #. type: Plain text
911 #: build/C/man2/madvise.2:89
912 msgid ""
913 "Expect access in the near future.  (Hence, it might be a good idea to read "
914 "some pages ahead.)"
915 msgstr ""
916
917 #. type: TP
918 #: build/C/man2/madvise.2:89
919 #, no-wrap
920 msgid "B<MADV_DONTNEED>"
921 msgstr ""
922
923 #. type: Plain text
924 #: build/C/man2/madvise.2:100
925 msgid ""
926 "Do not expect access in the near future.  (For the time being, the "
927 "application is finished with the given range, so the kernel can free "
928 "resources associated with it.)  Subsequent accesses of pages in this range "
929 "will succeed, but will result either in reloading of the memory contents "
930 "from the underlying mapped file (see B<mmap>(2))  or zero-fill-on-demand "
931 "pages for mappings without an underlying file."
932 msgstr ""
933
934 #. type: TP
935 #: build/C/man2/madvise.2:100
936 #, no-wrap
937 msgid "B<MADV_REMOVE> (Since Linux 2.6.16)"
938 msgstr ""
939
940 #.  2.6.18-rc5
941 #.  Databases want to use this feature to drop a section of their
942 #.  bufferpool (shared memory segments) - without writing back to
943 #.  disk/swap space.  This feature is also useful for supporting
944 #.  hot-plug memory on UML.
945 #. type: Plain text
946 #: build/C/man2/madvise.2:113
947 msgid ""
948 "Free up a given range of pages and its associated backing store.  Currently, "
949 "only shmfs/tmpfs supports this; other filesystems return with the error "
950 "B<ENOSYS>."
951 msgstr ""
952
953 #. type: TP
954 #: build/C/man2/madvise.2:113
955 #, no-wrap
956 msgid "B<MADV_DONTFORK> (Since Linux 2.6.16)"
957 msgstr ""
958
959 #.  See http://lwn.net/Articles/171941/
960 #.  [PATCH] madvise MADV_DONTFORK/MADV_DOFORK
961 #.  Currently, copy-on-write may change the physical address of
962 #.  a page even if the user requested that the page is pinned in
963 #.  memory (either by mlock or by get_user_pages).  This happens
964 #.  if the process forks meanwhile, and the parent writes to that
965 #.  page.  As a result, the page is orphaned: in case of
966 #.  get_user_pages, the application will never see any data hardware
967 #.  DMA's into this page after the COW.  In case of mlock'd memory,
968 #.  the parent is not getting the realtime/security benefits of mlock.
969 #
970 #.  In particular, this affects the Infiniband modules which do DMA from
971 #.  and into user pages all the time.
972 #
973 #.  This patch adds madvise options to control whether memory range is
974 #.  inherited across fork. Useful e.g. for when hardware is doing DMA
975 #.  from/into these pages.  Could also be useful to an application
976 #.  wanting to speed up its forks by cutting large areas out of
977 #.  consideration.
978 #
979 #.  SEE ALSO: http://lwn.net/Articles/171941/
980 #.  "Tweaks to madvise() and posix_fadvise()", 14 Feb 2006
981 #. type: Plain text
982 #: build/C/man2/madvise.2:144
983 msgid ""
984 "Do not make the pages in this range available to the child after a "
985 "B<fork>(2).  This is useful to prevent copy-on-write semantics from changing "
986 "the physical location of a page(s) if the parent writes to it after a "
987 "B<fork>(2).  (Such page relocations cause problems for hardware that DMAs "
988 "into the page(s).)"
989 msgstr ""
990
991 #. type: TP
992 #: build/C/man2/madvise.2:144
993 #, no-wrap
994 msgid "B<MADV_DOFORK> (Since Linux 2.6.16)"
995 msgstr ""
996
997 #. type: Plain text
998 #: build/C/man2/madvise.2:150
999 msgid ""
1000 "Undo the effect of B<MADV_DONTFORK>, restoring the default behavior, whereby "
1001 "a mapping is inherited across B<fork>(2)."
1002 msgstr ""
1003
1004 #. type: TP
1005 #: build/C/man2/madvise.2:150
1006 #, no-wrap
1007 msgid "B<MADV_HWPOISON> (Since Linux 2.6.32)"
1008 msgstr ""
1009
1010 #. type: Plain text
1011 #: build/C/man2/madvise.2:162
1012 msgid ""
1013 "Poison a page and handle it like a hardware memory corruption.  This "
1014 "operation is available only for privileged (B<CAP_SYS_ADMIN>)  processes.  "
1015 "This operation may result in the calling process receiving a B<SIGBUS> and "
1016 "the page being unmapped.  This feature is intended for testing of memory "
1017 "error-handling code; it is available only if the kernel was configured with "
1018 "B<CONFIG_MEMORY_FAILURE>."
1019 msgstr ""
1020
1021 #. type: TP
1022 #: build/C/man2/madvise.2:162
1023 #, no-wrap
1024 msgid "B<MADV_SOFT_OFFLINE> (Since Linux 2.6.33)"
1025 msgstr ""
1026
1027 #. type: Plain text
1028 #: build/C/man2/madvise.2:180
1029 msgid ""
1030 "Soft offline the pages in the range specified by I<addr> and I<length>.  The "
1031 "memory of each page in the specified range is preserved (i.e., when next "
1032 "accessed, the same content will be visible, but in a new physical page "
1033 "frame), and the original page is offlined (i.e., no longer used, and taken "
1034 "out of normal memory management).  The effect of the B<MADV_SOFT_OFFLINE> "
1035 "operation is invisible to (i.e., does not change the semantics of)  the "
1036 "calling process.  This feature is intended for testing of memory "
1037 "error-handling code; it is available only if the kernel was configured with "
1038 "B<CONFIG_MEMORY_FAILURE>."
1039 msgstr ""
1040
1041 #. type: TP
1042 #: build/C/man2/madvise.2:180
1043 #, no-wrap
1044 msgid "B<MADV_MERGEABLE> (since Linux 2.6.32)"
1045 msgstr ""
1046
1047 #. type: Plain text
1048 #: build/C/man2/madvise.2:205
1049 msgid ""
1050 "Enable Kernel Samepage Merging (KSM) for the pages in the range specified by "
1051 "I<addr> and I<length>.  The kernel regularly scans those areas of user "
1052 "memory that have been marked as mergeable, looking for pages with identical "
1053 "content.  These are replaced by a single write-protected page (which is "
1054 "automatically copied if a process later wants to update the content of the "
1055 "page).  KSM merges only private anonymous pages (see B<mmap>(2)).  The KSM "
1056 "feature is intended for applications that generate many instances of the "
1057 "same data (e.g., virtualization systems such as KVM).  It can consume a lot "
1058 "of processing power; use with care.  See the Linux kernel source file "
1059 "I<Documentation/vm/ksm.txt> for more details.  The B<MADV_MERGEABLE> and "
1060 "B<MADV_UNMERGEABLE> operations are available only if the kernel was "
1061 "configured with B<CONFIG_KSM>."
1062 msgstr ""
1063
1064 #. type: TP
1065 #: build/C/man2/madvise.2:205
1066 #, no-wrap
1067 msgid "B<MADV_UNMERGEABLE> (since Linux 2.6.32)"
1068 msgstr ""
1069
1070 #. type: Plain text
1071 #: build/C/man2/madvise.2:214
1072 msgid ""
1073 "Undo the effect of an earlier B<MADV_MERGEABLE> operation on the specified "
1074 "address range; KSM unmerges whatever pages it had merged in the address "
1075 "range specified by I<addr> and I<length>."
1076 msgstr ""
1077
1078 #. type: TP
1079 #: build/C/man2/madvise.2:214
1080 #, no-wrap
1081 msgid "B<MADV_HUGEPAGE> (since Linux 2.6.38)"
1082 msgstr ""
1083
1084 #.  http://lwn.net/Articles/358904/
1085 #.  https://lwn.net/Articles/423584/
1086 #. type: Plain text
1087 #: build/C/man2/madvise.2:243
1088 msgid ""
1089 "Enables Transparent Huge Pages (THP) for pages in the range specified by "
1090 "I<addr> and I<length>.  Currently, Transparent Huge Pages work only with "
1091 "private anonymous pages (see B<mmap>(2)).  The kernel will regularly scan "
1092 "the areas marked as huge page candidates to replace them with huge pages.  "
1093 "The kernel will also allocate huge pages directly when the region is "
1094 "naturally aligned to the huge page size (see B<posix_memalign>(2)).  This "
1095 "feature is primarily aimed at applications that use large mappings of data "
1096 "and access large regions of that memory at a time (e.g., virtualization "
1097 "systems such as QEMU).  It can very easily waste memory (e.g., a 2MB mapping "
1098 "that only ever accesses 1 byte will result in 2MB of wired memory instead of "
1099 "one 4KB page).  See the Linux kernel source file "
1100 "I<Documentation/vm/transhuge.txt> for more details.  The B<MADV_HUGEPAGE> "
1101 "and B<MADV_NOHUGEPAGE> operations are available only if the kernel was "
1102 "configured with B<CONFIG_TRANSPARENT_HUGEPAGE>."
1103 msgstr ""
1104
1105 #. type: TP
1106 #: build/C/man2/madvise.2:243
1107 #, no-wrap
1108 msgid "B<MADV_NOHUGEPAGE> (since Linux 2.6.38)"
1109 msgstr ""
1110
1111 #. type: Plain text
1112 #: build/C/man2/madvise.2:250
1113 msgid ""
1114 "Ensures that memory in the address range specified by I<addr> and I<length> "
1115 "will not be collapsed into huge pages."
1116 msgstr ""
1117
1118 #. type: TP
1119 #: build/C/man2/madvise.2:250
1120 #, no-wrap
1121 msgid "B<MADV_DONTDUMP> (since Linux 3.4)"
1122 msgstr ""
1123
1124 #. type: Plain text
1125 #: build/C/man2/madvise.2:264
1126 msgid ""
1127 "Exclude from a core dump those pages in the range specified by I<addr> and "
1128 "I<length>.  This is useful in applications that have large areas of memory "
1129 "that are known not to be useful in a core dump.  The effect of "
1130 "B<MADV_DONTDUMP> takes precedence over the bit mask that is set via the "
1131 "I</proc/PID/coredump_filter> file (see B<core>(5))."
1132 msgstr ""
1133
1134 #. type: TP
1135 #: build/C/man2/madvise.2:264
1136 #, no-wrap
1137 msgid "B<MADV_DODUMP> (since Linux 3.4)"
1138 msgstr ""
1139
1140 #. type: Plain text
1141 #: build/C/man2/madvise.2:268
1142 msgid "Undo the effect of an earlier B<MADV_DONTDUMP>."
1143 msgstr ""
1144
1145 #. type: Plain text
1146 #: build/C/man2/madvise.2:275
1147 msgid ""
1148 "On success B<madvise>()  returns zero.  On error, it returns -1 and I<errno> "
1149 "is set appropriately."
1150 msgstr ""
1151
1152 #. type: TP
1153 #: build/C/man2/madvise.2:276 build/C/man2/mlock.2:154 build/C/man2/mmap.2:413 build/C/man2/mremap.2:136
1154 #, no-wrap
1155 msgid "B<EAGAIN>"
1156 msgstr ""
1157
1158 #. type: Plain text
1159 #: build/C/man2/madvise.2:279
1160 msgid "A kernel resource was temporarily unavailable."
1161 msgstr ""
1162
1163 #. type: Plain text
1164 #: build/C/man2/madvise.2:282
1165 msgid "The map exists, but the area maps something that isn't a file."
1166 msgstr ""
1167
1168 #. type: Plain text
1169 #: build/C/man2/madvise.2:285
1170 msgid "This error can occur for the following reasons:"
1171 msgstr ""
1172
1173 #. type: IP
1174 #: build/C/man2/madvise.2:286 build/C/man2/madvise.2:292 build/C/man2/madvise.2:295 build/C/man2/madvise.2:298 build/C/man2/madvise.2:301 build/C/man3/mallopt.3:235 build/C/man3/mallopt.3:241
1175 #, no-wrap
1176 msgid "*"
1177 msgstr ""
1178
1179 #.  .I len
1180 #.  is zero,
1181 #. type: Plain text
1182 #: build/C/man2/madvise.2:292
1183 msgid "The value I<len> is negative."
1184 msgstr ""
1185
1186 #. type: Plain text
1187 #: build/C/man2/madvise.2:295
1188 msgid "I<addr> is not page-aligned."
1189 msgstr ""
1190
1191 #. type: Plain text
1192 #: build/C/man2/madvise.2:298
1193 msgid "I<advice> is not a valid value"
1194 msgstr ""
1195
1196 #. type: Plain text
1197 #: build/C/man2/madvise.2:301
1198 msgid ""
1199 "The application is attempting to release locked or shared pages (with "
1200 "B<MADV_DONTNEED>)."
1201 msgstr ""
1202
1203 #. type: Plain text
1204 #: build/C/man2/madvise.2:309
1205 msgid ""
1206 "B<MADV_MERGEABLE> or B<MADV_UNMERGEABLE> was specified in I<advice>, but the "
1207 "kernel was not configured with B<CONFIG_KSM>."
1208 msgstr ""
1209
1210 #. type: Plain text
1211 #: build/C/man2/madvise.2:316
1212 msgid ""
1213 "(for B<MADV_WILLNEED>)  Paging in this area would exceed the process's "
1214 "maximum resident set size."
1215 msgstr ""
1216
1217 #. type: TP
1218 #: build/C/man2/madvise.2:316 build/C/man2/madvise.2:321 build/C/man2/mlock.2:123 build/C/man2/mlock.2:131 build/C/man2/mlock.2:169 build/C/man2/mmap.2:456 build/C/man2/mprotect.2:100 build/C/man2/mprotect.2:103 build/C/man2/mremap.2:179 build/C/man2/msync.2:93 build/C/man3/posix_memalign.3:164 build/C/man2/shmctl.2:333 build/C/man2/shmget.2:214 build/C/man2/shmop.2:214 build/C/man2/subpage_prot.2:87 build/C/man2/sync_file_range.2:163
1219 #, no-wrap
1220 msgid "B<ENOMEM>"
1221 msgstr ""
1222
1223 #. type: Plain text
1224 #: build/C/man2/madvise.2:321
1225 msgid "(for B<MADV_WILLNEED>)  Not enough memory: paging in failed."
1226 msgstr ""
1227
1228 #. type: Plain text
1229 #: build/C/man2/madvise.2:325
1230 msgid ""
1231 "Addresses in the specified range are not currently mapped, or are outside "
1232 "the address space of the process."
1233 msgstr ""
1234
1235 #.  FIXME . Write a posix_madvise(3) page.
1236 #. type: Plain text
1237 #: build/C/man2/madvise.2:337
1238 msgid ""
1239 "POSIX.1b.  POSIX.1-2001 describes B<posix_madvise>(3)  with constants "
1240 "B<POSIX_MADV_NORMAL>, etc., with a behavior close to that described here.  "
1241 "There is a similar B<posix_fadvise>(2)  for file access."
1242 msgstr ""
1243
1244 #. type: Plain text
1245 #: build/C/man2/madvise.2:346
1246 msgid ""
1247 "B<MADV_REMOVE>, B<MADV_DONTFORK>, B<MADV_DOFORK>, B<MADV_HWPOISON>, "
1248 "B<MADV_MERGEABLE>, and B<MADV_UNMERGEABLE> are Linux-specific."
1249 msgstr ""
1250
1251 #. type: SS
1252 #: build/C/man2/madvise.2:347 build/C/man2/mlock.2:267 build/C/man2/shmget.2:294
1253 #, no-wrap
1254 msgid "Linux notes"
1255 msgstr ""
1256
1257 #. type: Plain text
1258 #: build/C/man2/madvise.2:355
1259 msgid ""
1260 "The current Linux implementation (2.4.0) views this system call more as a "
1261 "command than as advice and hence may return an error when it cannot do what "
1262 "it usually would do in response to this advice.  (See the ERRORS description "
1263 "above.)  This is nonstandard behavior."
1264 msgstr ""
1265
1266 #.  .SH HISTORY
1267 #.  The
1268 #.  .BR madvise ()
1269 #.  function first appeared in 4.4BSD.
1270 #. type: Plain text
1271 #: build/C/man2/madvise.2:371
1272 msgid ""
1273 "The Linux implementation requires that the address I<addr> be page-aligned, "
1274 "and allows I<length> to be zero.  If there are some parts of the specified "
1275 "address range that are not mapped, the Linux version of B<madvise>()  "
1276 "ignores them and applies the call to the rest (but returns B<ENOMEM> from "
1277 "the system call, as it should)."
1278 msgstr ""
1279
1280 #. type: Plain text
1281 #: build/C/man2/madvise.2:379
1282 msgid ""
1283 "B<getrlimit>(2), B<mincore>(2), B<mmap>(2), B<mprotect>(2), B<msync>(2), "
1284 "B<munmap>(2), B<core>(5)"
1285 msgstr ""
1286
1287 #. type: TH
1288 #: build/C/man3/mallinfo.3:26
1289 #, no-wrap
1290 msgid "MALLINFO"
1291 msgstr ""
1292
1293 #. type: TH
1294 #: build/C/man3/mallinfo.3:26 build/C/man3/malloc_stats.3:26
1295 #, no-wrap
1296 msgid "2012-05-06"
1297 msgstr ""
1298
1299 #. type: Plain text
1300 #: build/C/man3/mallinfo.3:29
1301 msgid "mallinfo - obtain memory allocation information"
1302 msgstr ""
1303
1304 #. type: Plain text
1305 #: build/C/man3/mallinfo.3:31 build/C/man3/malloc_stats.3:31 build/C/man3/malloc_trim.3:31 build/C/man3/malloc_usable_size.3:30 build/C/man3/mallopt.3:31
1306 msgid "B<#include E<lt>malloc.hE<gt>>"
1307 msgstr ""
1308
1309 #. type: Plain text
1310 #: build/C/man3/mallinfo.3:33
1311 msgid "B<struct mallinfo mallinfo(void);>"
1312 msgstr ""
1313
1314 #. type: Plain text
1315 #: build/C/man3/mallinfo.3:41
1316 msgid ""
1317 "The B<mallinfo>()  function returns a copy of a structure containing "
1318 "information about memory allocations performed by B<malloc>(3)  and related "
1319 "functions.  This structure is defined as follows:"
1320 msgstr ""
1321
1322 #. type: Plain text
1323 #: build/C/man3/mallinfo.3:56
1324 #, no-wrap
1325 msgid ""
1326 "struct mallinfo {\n"
1327 "    int arena;     /* Non-mmapped space allocated (bytes) */\n"
1328 "    int ordblks;   /* Number of free chunks */\n"
1329 "    int smblks;    /* Number of free fastbin blocks */\n"
1330 "    int hblks;     /* Number of mmapped regions */\n"
1331 "    int hblkhd;    /* Space allocated in mmapped regions (bytes) */\n"
1332 "    int usmblks;   /* Maximum total allocated space (bytes) */\n"
1333 "    int fsmblks;   /* Space in freed fastbin blocks (bytes) */\n"
1334 "    int uordblks;  /* Total allocated space (bytes) */\n"
1335 "    int fordblks;  /* Total free space (bytes) */\n"
1336 "    int keepcost;  /* Top-most, releasable space (bytes) */\n"
1337 "};\n"
1338 msgstr ""
1339
1340 #. type: Plain text
1341 #: build/C/man3/mallinfo.3:62
1342 msgid "The fields of the I<mallinfo> structure contain the following information:"
1343 msgstr ""
1344
1345 #. type: TP
1346 #: build/C/man3/mallinfo.3:62
1347 #, no-wrap
1348 msgid "I<arena>"
1349 msgstr ""
1350
1351 #. type: Plain text
1352 #: build/C/man3/mallinfo.3:68
1353 msgid ""
1354 "The total amount of memory allocated by means other than B<mmap>(2)  (i.e., "
1355 "memory allocated on the heap).  This figure includes both in-use blocks and "
1356 "blocks on the free list."
1357 msgstr ""
1358
1359 #. type: TP
1360 #: build/C/man3/mallinfo.3:68
1361 #, no-wrap
1362 msgid "I<ordblks>"
1363 msgstr ""
1364
1365 #. type: Plain text
1366 #: build/C/man3/mallinfo.3:71
1367 msgid "The number of ordinary (i.e., non-fastbin) free blocks."
1368 msgstr ""
1369
1370 #. type: TP
1371 #: build/C/man3/mallinfo.3:71
1372 #, no-wrap
1373 msgid "I<smblks>"
1374 msgstr ""
1375
1376 #. type: Plain text
1377 #: build/C/man3/mallinfo.3:75
1378 msgid "The number of fastbin free blocks (see B<mallopt>(3))."
1379 msgstr ""
1380
1381 #. type: TP
1382 #: build/C/man3/mallinfo.3:75
1383 #, no-wrap
1384 msgid "I<hblks>"
1385 msgstr ""
1386
1387 #. type: Plain text
1388 #: build/C/man3/mallinfo.3:83
1389 msgid ""
1390 "The number of blocks currently allocated using B<mmap>(2).  (See the "
1391 "discussion of B<M_MMAP_THRESHOLD> in B<mallopt>(3).)"
1392 msgstr ""
1393
1394 #. type: TP
1395 #: build/C/man3/mallinfo.3:83
1396 #, no-wrap
1397 msgid "I<hblkhd>"
1398 msgstr ""
1399
1400 #. type: Plain text
1401 #: build/C/man3/mallinfo.3:87
1402 msgid "The number of bytes in blocks currently allocated using B<mmap>(2)."
1403 msgstr ""
1404
1405 #. type: TP
1406 #: build/C/man3/mallinfo.3:87
1407 #, no-wrap
1408 msgid "I<usmblks>"
1409 msgstr ""
1410
1411 #. type: Plain text
1412 #: build/C/man3/mallinfo.3:92
1413 msgid ""
1414 "The \"highwater mark\" for allocated space\\(emthat is, the maximum amount "
1415 "of space that was ever allocated.  This field is maintained only in "
1416 "nonthreading environments."
1417 msgstr ""
1418
1419 #. type: TP
1420 #: build/C/man3/mallinfo.3:92
1421 #, no-wrap
1422 msgid "I<fsmblks>"
1423 msgstr ""
1424
1425 #. type: Plain text
1426 #: build/C/man3/mallinfo.3:95
1427 msgid "The total number of bytes in fastbin free blocks."
1428 msgstr ""
1429
1430 #. type: TP
1431 #: build/C/man3/mallinfo.3:95
1432 #, no-wrap
1433 msgid "I<uordblks>"
1434 msgstr ""
1435
1436 #. type: Plain text
1437 #: build/C/man3/mallinfo.3:98
1438 msgid "The total number of bytes used by in-use allocations."
1439 msgstr ""
1440
1441 #. type: TP
1442 #: build/C/man3/mallinfo.3:98
1443 #, no-wrap
1444 msgid "I<fordblks>"
1445 msgstr ""
1446
1447 #. type: Plain text
1448 #: build/C/man3/mallinfo.3:101
1449 msgid "The total number of bytes in free blocks."
1450 msgstr ""
1451
1452 #. type: TP
1453 #: build/C/man3/mallinfo.3:101
1454 #, no-wrap
1455 msgid "I<keepcost>"
1456 msgstr ""
1457
1458 #.  .SH VERSIONS
1459 #.  Available already in glibc 2.0, possibly earlier
1460 #. type: Plain text
1461 #: build/C/man3/mallinfo.3:110
1462 msgid ""
1463 "The total amount of releasable free space at the top of the heap.  This is "
1464 "the maximum number of bytes that could ideally (i.e., ignoring page "
1465 "alignment restrictions, and so on) be released by B<malloc_trim>(3)."
1466 msgstr ""
1467
1468 #. type: Plain text
1469 #: build/C/man3/mallinfo.3:114
1470 msgid ""
1471 "This function is not specified by POSIX or the C standards.  A similar "
1472 "function exists on many System V derivatives, and was specified in the SVID."
1473 msgstr ""
1474
1475 #.  FIXME http://sourceware.org/bugzilla/show_bug.cgi?id=208
1476 #.  See the 24 Aug 2011 mail by Paul Pluzhnikov:
1477 #.      "[patch] Fix mallinfo() to accumulate results for all arenas"
1478 #.  on libc-alpha@sourceware.org
1479 #. type: Plain text
1480 #: build/C/man3/mallinfo.3:126
1481 msgid ""
1482 "B<Information is returned for only the main memory allocation area.> "
1483 "Allocations in other arenas are excluded.  See B<malloc_stats>(3)  and "
1484 "B<malloc_info>(3)  for alternatives that include information about other "
1485 "arenas."
1486 msgstr ""
1487
1488 #. type: Plain text
1489 #: build/C/man3/mallinfo.3:134
1490 msgid ""
1491 "The fields of the I<mallinfo> structure are typed as I<int>.  However, "
1492 "because some internal bookkeeping values may be of type I<long>, the "
1493 "reported values may wrap around zero and thus be inaccurate."
1494 msgstr ""
1495
1496 #. type: SH
1497 #: build/C/man3/mallinfo.3:134 build/C/man3/malloc_hook.3:89 build/C/man3/malloc_info.3:84 build/C/man3/mallopt.3:466 build/C/man3/mcheck.3:159 build/C/man2/mmap.2:630 build/C/man2/mprotect.2:148 build/C/man3/mtrace.3:108
1498 #, no-wrap
1499 msgid "EXAMPLE"
1500 msgstr ""
1501
1502 #. type: Plain text
1503 #: build/C/man3/mallinfo.3:140
1504 msgid ""
1505 "The program below employs B<mallinfo>()  to retrieve memory allocation "
1506 "statistics before and after allocating and freeing some blocks of memory.  "
1507 "The statistics are displayed on standard output."
1508 msgstr ""
1509
1510 #. type: Plain text
1511 #: build/C/man3/mallinfo.3:144
1512 msgid ""
1513 "The first two command-line arguments specify the number and size of blocks "
1514 "to be allocated with B<malloc>(3)."
1515 msgstr ""
1516
1517 #. type: Plain text
1518 #: build/C/man3/mallinfo.3:158
1519 msgid ""
1520 "The remaining three arguments specify which of the allocated blocks should "
1521 "be freed with B<free>(3).  These three arguments are optional, and specify "
1522 "(in order): the step size to be used in the loop that frees blocks (the "
1523 "default is 1, meaning free all blocks in the range); the ordinal position of "
1524 "the first block to be freed (default 0, meaning the first allocated block); "
1525 "and a number one greater than the ordinal position of the last block to be "
1526 "freed (default is one greater than the maximum block number).  If these "
1527 "three arguments are omitted, then the defaults cause all allocated blocks to "
1528 "be freed."
1529 msgstr ""
1530
1531 #. type: Plain text
1532 #: build/C/man3/mallinfo.3:162
1533 msgid ""
1534 "In the following example run of the program, 1000 allocations of 100 bytes "
1535 "are performed, and then every second allocated block is freed:"
1536 msgstr ""
1537
1538 #. type: Plain text
1539 #: build/C/man3/mallinfo.3:177
1540 #, no-wrap
1541 msgid ""
1542 "$ B<./a.out 1000 100 2>\n"
1543 "============== Before allocating blocks ==============\n"
1544 "Total non-mmapped bytes (arena):       0\n"
1545 "# of free chunks (ordblks):            1\n"
1546 "# of free fastbin blocks (smblks):     0\n"
1547 "# of mapped regions (hblks):           0\n"
1548 "Bytes in mapped regions (hblkhd):      0\n"
1549 "Max. total allocated space (usmblks):  0\n"
1550 "Free bytes held in fastbins (fsmblks): 0\n"
1551 "Total allocated space (uordblks):      0\n"
1552 "Total free space (fordblks):           0\n"
1553 "Topmost releasable block (keepcost):   0\n"
1554 msgstr ""
1555
1556 #. type: Plain text
1557 #: build/C/man3/mallinfo.3:189
1558 #, no-wrap
1559 msgid ""
1560 "============== After allocating blocks ==============\n"
1561 "Total non-mmapped bytes (arena):       135168\n"
1562 "# of free chunks (ordblks):            1\n"
1563 "# of free fastbin blocks (smblks):     0\n"
1564 "# of mapped regions (hblks):           0\n"
1565 "Bytes in mapped regions (hblkhd):      0\n"
1566 "Max. total allocated space (usmblks):  0\n"
1567 "Free bytes held in fastbins (fsmblks): 0\n"
1568 "Total allocated space (uordblks):      104000\n"
1569 "Total free space (fordblks):           31168\n"
1570 "Topmost releasable block (keepcost):   31168\n"
1571 msgstr ""
1572
1573 #. type: Plain text
1574 #: build/C/man3/mallinfo.3:201
1575 #, no-wrap
1576 msgid ""
1577 "============== After freeing blocks ==============\n"
1578 "Total non-mmapped bytes (arena):       135168\n"
1579 "# of free chunks (ordblks):            501\n"
1580 "# of free fastbin blocks (smblks):     0\n"
1581 "# of mapped regions (hblks):           0\n"
1582 "Bytes in mapped regions (hblkhd):      0\n"
1583 "Max. total allocated space (usmblks):  0\n"
1584 "Free bytes held in fastbins (fsmblks): 0\n"
1585 "Total allocated space (uordblks):      52000\n"
1586 "Total free space (fordblks):           83168\n"
1587 "Topmost releasable block (keepcost):   31168\n"
1588 msgstr ""
1589
1590 #. type: SS
1591 #: build/C/man3/mallinfo.3:203 build/C/man3/malloc_info.3:167 build/C/man3/mallopt.3:532 build/C/man3/mcheck.3:176 build/C/man2/mprotect.2:165
1592 #, no-wrap
1593 msgid "Program source"
1594 msgstr ""
1595
1596 #. type: Plain text
1597 #: build/C/man3/mallinfo.3:208
1598 #, no-wrap
1599 msgid ""
1600 "#include E<lt>malloc.hE<gt>\n"
1601 "#include \"tlpi_hdr.h\"\n"
1602 msgstr ""
1603
1604 #. type: Plain text
1605 #: build/C/man3/mallinfo.3:213
1606 #, no-wrap
1607 msgid ""
1608 "static void\n"
1609 "display_mallinfo(void)\n"
1610 "{\n"
1611 "    struct mallinfo mi;\n"
1612 msgstr ""
1613
1614 #. type: Plain text
1615 #: build/C/man3/mallinfo.3:215
1616 #, no-wrap
1617 msgid "    mi = mallinfo();\n"
1618 msgstr ""
1619
1620 #. type: Plain text
1621 #: build/C/man3/mallinfo.3:227
1622 #, no-wrap
1623 msgid ""
1624 "    printf(\"Total non-mmapped bytes (arena):       %d\\en\", mi.arena);\n"
1625 "    printf(\"# of free chunks (ordblks):            %d\\en\", mi.ordblks);\n"
1626 "    printf(\"# of free fastbin blocks (smblks):     %d\\en\", mi.smblks);\n"
1627 "    printf(\"# of mapped regions (hblks):           %d\\en\", mi.hblks);\n"
1628 "    printf(\"Bytes in mapped regions (hblkhd):      %d\\en\", mi.hblkhd);\n"
1629 "    printf(\"Max. total allocated space (usmblks):  %d\\en\", mi.usmblks);\n"
1630 "    printf(\"Free bytes held in fastbins (fsmblks): %d\\en\", mi.fsmblks);\n"
1631 "    printf(\"Total allocated space (uordblks):      %d\\en\", "
1632 "mi.uordblks);\n"
1633 "    printf(\"Total free space (fordblks):           %d\\en\", "
1634 "mi.fordblks);\n"
1635 "    printf(\"Topmost releasable block (keepcost):   %d\\en\", "
1636 "mi.keepcost);\n"
1637 "}\n"
1638 msgstr ""
1639
1640 #. type: Plain text
1641 #: build/C/man3/mallinfo.3:235
1642 #, no-wrap
1643 msgid ""
1644 "int\n"
1645 "main(int argc, char *argv[])\n"
1646 "{\n"
1647 "#define MAX_ALLOCS 2000000\n"
1648 "    char *alloc[MAX_ALLOCS];\n"
1649 "    int numBlocks, j, freeBegin, freeEnd, freeStep;\n"
1650 "    size_t blockSize;\n"
1651 msgstr ""
1652
1653 #. type: Plain text
1654 #: build/C/man3/mallinfo.3:239
1655 #, no-wrap
1656 msgid ""
1657 "    if (argc E<lt> 3 || strcmp(argv[1], \"--help\") == 0)\n"
1658 "        usageErr(\"%s num-blocks block-size [free-step [start-free \"\n"
1659 "                \"[end-free]]]\\en\", argv[0]);\n"
1660 msgstr ""
1661
1662 #. type: Plain text
1663 #: build/C/man3/mallinfo.3:245
1664 #, no-wrap
1665 msgid ""
1666 "    numBlocks = atoi(argv[1]);\n"
1667 "    blockSize = atoi(argv[2]);\n"
1668 "    freeStep = (argc E<gt> 3) ? atoi(argv[3]) : 1;\n"
1669 "    freeBegin = (argc E<gt> 4) ? atoi(argv[4]) : 0;\n"
1670 "    freeEnd = (argc E<gt> 5) ? atoi(argv[5]) : numBlocks;\n"
1671 msgstr ""
1672
1673 #. type: Plain text
1674 #: build/C/man3/mallinfo.3:248
1675 #, no-wrap
1676 msgid ""
1677 "    printf(\"============== Before allocating blocks "
1678 "==============\\en\");\n"
1679 "    display_mallinfo();\n"
1680 msgstr ""
1681
1682 #. type: Plain text
1683 #: build/C/man3/mallinfo.3:252
1684 #, no-wrap
1685 msgid ""
1686 "    for (j = 0; j E<lt> numBlocks; j++) {\n"
1687 "        if (numBlocks E<gt>= MAX_ALLOCS)\n"
1688 "            fatal(\"Too many allocations\");\n"
1689 msgstr ""
1690
1691 #. type: Plain text
1692 #: build/C/man3/mallinfo.3:257
1693 #, no-wrap
1694 msgid ""
1695 "        alloc[j] = malloc(blockSize);\n"
1696 "        if (alloc[j] == NULL)\n"
1697 "            errExit(\"malloc\");\n"
1698 "    }\n"
1699 msgstr ""
1700
1701 #. type: Plain text
1702 #: build/C/man3/mallinfo.3:260
1703 #, no-wrap
1704 msgid ""
1705 "    printf(\"\\en============== After allocating blocks "
1706 "==============\\en\");\n"
1707 "    display_mallinfo();\n"
1708 msgstr ""
1709
1710 #. type: Plain text
1711 #: build/C/man3/mallinfo.3:263
1712 #, no-wrap
1713 msgid ""
1714 "    for (j = freeBegin; j E<lt> freeEnd; j += freeStep)\n"
1715 "        free(alloc[j]);\n"
1716 msgstr ""
1717
1718 #. type: Plain text
1719 #: build/C/man3/mallinfo.3:266
1720 #, no-wrap
1721 msgid ""
1722 "    printf(\"\\en============== After freeing blocks "
1723 "==============\\en\");\n"
1724 "    display_mallinfo();\n"
1725 msgstr ""
1726
1727 #. type: Plain text
1728 #: build/C/man3/mallinfo.3:269 build/C/man3/malloc_info.3:255 build/C/man3/mallopt.3:565 build/C/man3/mcheck.3:203 build/C/man2/mmap.2:711
1729 #, no-wrap
1730 msgid ""
1731 "    exit(EXIT_SUCCESS);\n"
1732 "}\n"
1733 msgstr ""
1734
1735 #. type: Plain text
1736 #: build/C/man3/mallinfo.3:279
1737 msgid ""
1738 "B<mmap>(2), B<malloc>(3), B<malloc_info>(3), B<malloc_stats>(3), "
1739 "B<malloc_trim>(3), B<mallopt>(3)"
1740 msgstr ""
1741
1742 #. type: TH
1743 #: build/C/man3/malloc_get_state.3:25
1744 #, no-wrap
1745 msgid "MALLOC_GET_STATE"
1746 msgstr ""
1747
1748 #. type: TH
1749 #: build/C/man3/malloc_get_state.3:25
1750 #, no-wrap
1751 msgid "2012-05-04"
1752 msgstr ""
1753
1754 #. type: Plain text
1755 #: build/C/man3/malloc_get_state.3:28
1756 msgid ""
1757 "malloc_get_state, malloc_set_state - record and restore state of malloc "
1758 "implementation"
1759 msgstr ""
1760
1761 #. type: Plain text
1762 #: build/C/man3/malloc_get_state.3:31 build/C/man3/posix_memalign.3:35
1763 #, no-wrap
1764 msgid "B<#include E<lt>stdlib.hE<gt>>\n"
1765 msgstr ""
1766
1767 #. type: Plain text
1768 #: build/C/man3/malloc_get_state.3:33
1769 #, no-wrap
1770 msgid "B<void* malloc_get_state(void);>\n"
1771 msgstr ""
1772
1773 #. type: Plain text
1774 #: build/C/man3/malloc_get_state.3:35
1775 #, no-wrap
1776 msgid "B<int malloc_set_state(void *>I<state>B<);>\n"
1777 msgstr ""
1778
1779 #. type: Plain text
1780 #: build/C/man3/malloc_get_state.3:53
1781 msgid ""
1782 "The B<malloc_get_state>()  function records the current state of all "
1783 "B<malloc>(3)  internal bookkeeping variables (but not the actual contents of "
1784 "the heap or the state of B<malloc_hook>(3)  functions pointers).  The state "
1785 "is recorded in a system-dependent opaque data structure dynamically "
1786 "allocated via B<malloc>(3), and a pointer to that data structure is returned "
1787 "as the function result.  (It is the caller's responsibility to B<free>(3)  "
1788 "this memory.)"
1789 msgstr ""
1790
1791 #. type: Plain text
1792 #: build/C/man3/malloc_get_state.3:61
1793 msgid ""
1794 "The B<malloc_set_state>()  function restores the state of all B<malloc>(3)  "
1795 "internal bookkeeping variables to the values recorded in the opaque data "
1796 "structure pointed to by I<state>."
1797 msgstr ""
1798
1799 #. type: Plain text
1800 #: build/C/man3/malloc_get_state.3:68
1801 msgid ""
1802 "On success, B<malloc_get_state>()  returns a pointer to a newly allocated "
1803 "opaque data structure.  On error (for example, memory could not be allocated "
1804 "for the data structure), B<malloc_get_state>()  returns NULL."
1805 msgstr ""
1806
1807 #.  if(ms->magic != MALLOC_STATE_MAGIC) return -1;
1808 #.  /* Must fail if the major version is too high. */
1809 #.  if((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2;
1810 #. type: Plain text
1811 #: build/C/man3/malloc_get_state.3:86
1812 msgid ""
1813 "On success, B<malloc_set_state>()  returns 0.  If the implementation detects "
1814 "that I<state> does not point to a correctly formed data structure, "
1815 "B<malloc_set_state>()  returns -1.  If the implementation detects that the "
1816 "version of the data structure referred to by I<state> is a more recent "
1817 "version than this implementation knows about, B<malloc_set_state>()  returns "
1818 "-2."
1819 msgstr ""
1820
1821 #. type: Plain text
1822 #: build/C/man3/malloc_get_state.3:88 build/C/man3/malloc_hook.3:82 build/C/man3/mcheck.3:147 build/C/man3/mtrace.3:80
1823 msgid "These functions are GNU extensions."
1824 msgstr ""
1825
1826 #. type: Plain text
1827 #: build/C/man3/malloc_get_state.3:94
1828 msgid ""
1829 "These functions are especially useful when using this B<malloc>(3)  "
1830 "implementation as part of a shared library, and the heap contents are "
1831 "saved/restored via some other method.  This technique is used by the GNU "
1832 "Emacs to implement its \"dumping\" function."
1833 msgstr ""
1834
1835 #.  i.e., calls __malloc_check_init()
1836 #.  i.e., malloc checking is not already in use
1837 #.  and the caller requested malloc checking
1838 #. type: Plain text
1839 #: build/C/man3/malloc_get_state.3:111
1840 msgid ""
1841 "Hook function pointers are never saved or restored by these functions, with "
1842 "two exceptions: if malloc checking (see B<mallopt>(3))  was in use when "
1843 "B<malloc_get_state>()  was called, then B<malloc_set_state>()  resets malloc "
1844 "checking hooks if possible; if malloc checking was not in use in the "
1845 "recorded state, but the caller has requested malloc checking, then the hooks "
1846 "are reset to 0."
1847 msgstr ""
1848
1849 #. type: Plain text
1850 #: build/C/man3/malloc_get_state.3:114
1851 msgid "B<malloc>(3), B<mallopt>(3)"
1852 msgstr ""
1853
1854 #. type: TH
1855 #: build/C/man3/malloc_hook.3:10
1856 #, no-wrap
1857 msgid "MALLOC_HOOK"
1858 msgstr ""
1859
1860 #. type: TH
1861 #: build/C/man3/malloc_hook.3:10
1862 #, no-wrap
1863 msgid "2010-10-13"
1864 msgstr ""
1865
1866 #. type: Plain text
1867 #: build/C/man3/malloc_hook.3:15
1868 msgid ""
1869 "__malloc_hook, __malloc_initialize_hook, __memalign_hook, __free_hook, "
1870 "__realloc_hook, __after_morecore_hook - malloc debugging variables"
1871 msgstr ""
1872
1873 #. type: Plain text
1874 #: build/C/man3/malloc_hook.3:18 build/C/man3/malloc_info.3:31 build/C/man3/posix_memalign.3:41
1875 #, no-wrap
1876 msgid "B<#include E<lt>malloc.hE<gt>>\n"
1877 msgstr ""
1878
1879 #. type: Plain text
1880 #: build/C/man3/malloc_hook.3:20
1881 #, no-wrap
1882 msgid "B<void *(*__malloc_hook)(size_t >I<size>B<, const void *>I<caller>B<);>\n"
1883 msgstr ""
1884
1885 #. type: Plain text
1886 #: build/C/man3/malloc_hook.3:23
1887 #, no-wrap
1888 msgid ""
1889 "B<void *(*__realloc_hook)(void *>I<ptr>B<, size_t >I<size>B<, const void "
1890 "*>I<caller>B<);>\n"
1891 msgstr ""
1892
1893 #. type: Plain text
1894 #: build/C/man3/malloc_hook.3:26
1895 #, no-wrap
1896 msgid ""
1897 "B<void *(*__memalign_hook)(size_t >I<alignment>B<, size_t >I<size>B<,>\n"
1898 "B<                         const void *>I<caller>B<);>\n"
1899 msgstr ""
1900
1901 #. type: Plain text
1902 #: build/C/man3/malloc_hook.3:28
1903 #, no-wrap
1904 msgid "B<void (*__free_hook)(void *>I<ptr>B<, const void *>I<caller>B<);>\n"
1905 msgstr ""
1906
1907 #. type: Plain text
1908 #: build/C/man3/malloc_hook.3:30
1909 #, no-wrap
1910 msgid "B<void (*__malloc_initialize_hook)(void);>\n"
1911 msgstr ""
1912
1913 #. type: Plain text
1914 #: build/C/man3/malloc_hook.3:32
1915 #, no-wrap
1916 msgid "B<void (*__after_morecore_hook)(void);>\n"
1917 msgstr ""
1918
1919 #. type: Plain text
1920 #: build/C/man3/malloc_hook.3:43
1921 msgid ""
1922 "The GNU C library lets you modify the behavior of B<malloc>(3), "
1923 "B<realloc>(3), and B<free>(3)  by specifying appropriate hook functions.  "
1924 "You can use these hooks to help you debug programs that use dynamic memory "
1925 "allocation, for example."
1926 msgstr ""
1927
1928 #. type: Plain text
1929 #: build/C/man3/malloc_hook.3:50
1930 msgid ""
1931 "The variable B<__malloc_initialize_hook> points at a function that is called "
1932 "once when the malloc implementation is initialized.  This is a weak "
1933 "variable, so it can be overridden in the application with a definition like "
1934 "the following:"
1935 msgstr ""
1936
1937 #. type: Plain text
1938 #: build/C/man3/malloc_hook.3:53
1939 #, no-wrap
1940 msgid "    void (*__malloc_initialize_hook)(void) = my_init_hook;\n"
1941 msgstr ""
1942
1943 #. type: Plain text
1944 #: build/C/man3/malloc_hook.3:58
1945 msgid "Now the function I<my_init_hook>()  can do the initialization of all hooks."
1946 msgstr ""
1947
1948 #. type: Plain text
1949 #: build/C/man3/malloc_hook.3:74
1950 msgid ""
1951 "The four functions pointed to by B<__malloc_hook>, B<__realloc_hook>, "
1952 "B<__memalign_hook>, B<__free_hook> have a prototype like the functions "
1953 "B<malloc>(3), B<realloc>(3), B<memalign>(3), B<free>(3), respectively, "
1954 "except that they have a final argument I<caller> that gives the address of "
1955 "the caller of B<malloc>(3), etc."
1956 msgstr ""
1957
1958 #. type: Plain text
1959 #: build/C/man3/malloc_hook.3:80
1960 msgid ""
1961 "The variable B<__after_morecore_hook> points at a function that is called "
1962 "each time after B<sbrk>(2)  was asked for more memory."
1963 msgstr ""
1964
1965 #.  https://bugzilla.redhat.com/show_bug.cgi?id=450187
1966 #.  http://sourceware.org/bugzilla/show_bug.cgi?id=9957
1967 #. type: Plain text
1968 #: build/C/man3/malloc_hook.3:89
1969 msgid ""
1970 "The use of these hook functions is not safe in multithreaded programs, and "
1971 "they are now deprecated.  Programmers should instead preempt calls to the "
1972 "relevant functions by defining and exporting functions such as \"malloc\" "
1973 "and \"free\"."
1974 msgstr ""
1975
1976 #. type: Plain text
1977 #: build/C/man3/malloc_hook.3:91
1978 msgid "Here is a short example of how to use these variables."
1979 msgstr ""
1980
1981 #. type: Plain text
1982 #: build/C/man3/malloc_hook.3:95
1983 #, no-wrap
1984 msgid ""
1985 "#include E<lt>stdio.hE<gt>\n"
1986 "#include E<lt>malloc.hE<gt>\n"
1987 msgstr ""
1988
1989 #. type: Plain text
1990 #: build/C/man3/malloc_hook.3:99
1991 #, no-wrap
1992 msgid ""
1993 "/* Prototypes for our hooks.  */\n"
1994 "static void my_init_hook(void);\n"
1995 "static void *my_malloc_hook(size_t, const void *);\n"
1996 msgstr ""
1997
1998 #. type: Plain text
1999 #: build/C/man3/malloc_hook.3:102
2000 #, no-wrap
2001 msgid ""
2002 "/* Variables to save original hooks. */\n"
2003 "static void *(*old_malloc_hook)(size_t, const void *);\n"
2004 msgstr ""
2005
2006 #. type: Plain text
2007 #: build/C/man3/malloc_hook.3:105
2008 #, no-wrap
2009 msgid ""
2010 "/* Override initializing hook from the C library. */\n"
2011 "void (*__malloc_initialize_hook) (void) = my_init_hook;\n"
2012 msgstr ""
2013
2014 #. type: Plain text
2015 #: build/C/man3/malloc_hook.3:112
2016 #, no-wrap
2017 msgid ""
2018 "static void\n"
2019 "my_init_hook(void)\n"
2020 "{\n"
2021 "    old_malloc_hook = __malloc_hook;\n"
2022 "    __malloc_hook = my_malloc_hook;\n"
2023 "}\n"
2024 msgstr ""
2025
2026 #. type: Plain text
2027 #: build/C/man3/malloc_hook.3:117
2028 #, no-wrap
2029 msgid ""
2030 "static void *\n"
2031 "my_malloc_hook(size_t size, const void *caller)\n"
2032 "{\n"
2033 "    void *result;\n"
2034 msgstr ""
2035
2036 #. type: Plain text
2037 #: build/C/man3/malloc_hook.3:120
2038 #, no-wrap
2039 msgid ""
2040 "    /* Restore all old hooks */\n"
2041 "    __malloc_hook = old_malloc_hook;\n"
2042 msgstr ""
2043
2044 #. type: Plain text
2045 #: build/C/man3/malloc_hook.3:123
2046 #, no-wrap
2047 msgid ""
2048 "    /* Call recursively */\n"
2049 "    result = malloc(size);\n"
2050 msgstr ""
2051
2052 #. type: Plain text
2053 #: build/C/man3/malloc_hook.3:126
2054 #, no-wrap
2055 msgid ""
2056 "    /* Save underlying hooks */\n"
2057 "    old_malloc_hook = __malloc_hook;\n"
2058 msgstr ""
2059
2060 #. type: Plain text
2061 #: build/C/man3/malloc_hook.3:130
2062 #, no-wrap
2063 msgid ""
2064 "    /* printf() might call malloc(), so protect it too. */\n"
2065 "    printf(\"malloc(%u) called from %p returns %p\\en\",\n"
2066 "            (unsigned int) size, caller, result);\n"
2067 msgstr ""
2068
2069 #. type: Plain text
2070 #: build/C/man3/malloc_hook.3:133
2071 #, no-wrap
2072 msgid ""
2073 "    /* Restore our own hooks */\n"
2074 "    __malloc_hook = my_malloc_hook;\n"
2075 msgstr ""
2076
2077 #. type: Plain text
2078 #: build/C/man3/malloc_hook.3:136
2079 #, no-wrap
2080 msgid ""
2081 "    return result;\n"
2082 "}\n"
2083 msgstr ""
2084
2085 #. type: Plain text
2086 #: build/C/man3/malloc_hook.3:142
2087 msgid "B<mallinfo>(3), B<malloc>(3), B<mcheck>(3), B<mtrace>(3)"
2088 msgstr ""
2089
2090 #. type: TH
2091 #: build/C/man3/malloc_info.3:25
2092 #, no-wrap
2093 msgid "MALLOC_INFO"
2094 msgstr ""
2095
2096 #. type: TH
2097 #: build/C/man3/malloc_info.3:25 build/C/man2/shmget.2:38
2098 #, no-wrap
2099 msgid "2013-04-19"
2100 msgstr ""
2101
2102 #. type: Plain text
2103 #: build/C/man3/malloc_info.3:28
2104 msgid "malloc_info - export malloc state to a stream"
2105 msgstr ""
2106
2107 #. type: Plain text
2108 #: build/C/man3/malloc_info.3:33
2109 #, no-wrap
2110 msgid "B<int malloc_info(int >I<options>B<, FILE *>I<fp>B<);>\n"
2111 msgstr ""
2112
2113 #. type: Plain text
2114 #: build/C/man3/malloc_info.3:44
2115 msgid ""
2116 "The B<malloc_info>()  function exports an XML string that describes the "
2117 "current state of the memory-allocation implementation in the caller.  The "
2118 "string is printed on the file stream I<fp>.  The exported string includes "
2119 "information about all arenas (see B<malloc>(3))."
2120 msgstr ""
2121
2122 #. type: Plain text
2123 #: build/C/man3/malloc_info.3:48
2124 msgid "As currently implemented, I<options> must be zero."
2125 msgstr ""
2126
2127 #. type: Plain text
2128 #: build/C/man3/malloc_info.3:55
2129 msgid ""
2130 "On success, B<malloc_info>()  returns 0; on error, it returns -1, with "
2131 "I<errno> set to indicate the cause."
2132 msgstr ""
2133
2134 #. type: Plain text
2135 #: build/C/man3/malloc_info.3:60
2136 msgid "I<options> was nonzero."
2137 msgstr ""
2138
2139 #. type: Plain text
2140 #: build/C/man3/malloc_info.3:63
2141 msgid "B<malloc_info>()  was added to glibc in version 2.10."
2142 msgstr ""
2143
2144 #. type: Plain text
2145 #: build/C/man3/malloc_info.3:65 build/C/man3/malloc_stats.3:57 build/C/man3/malloc_trim.3:62 build/C/man3/malloc_usable_size.3:50
2146 msgid "This function is a GNU extension."
2147 msgstr ""
2148
2149 #. type: Plain text
2150 #: build/C/man3/malloc_info.3:71
2151 msgid ""
2152 "The memory-allocation information is provided as an XML string (rather than "
2153 "a C structure)  because the information may change over time (according to "
2154 "changes in the underlying implementation).  The output XML string includes a "
2155 "version field."
2156 msgstr ""
2157
2158 #. type: Plain text
2159 #: build/C/man3/malloc_info.3:77
2160 msgid ""
2161 "The B<open_memstream>(3)  function can be used to send the output of "
2162 "B<malloc_info>()  directly into a buffer in memory, rather than to a file."
2163 msgstr ""
2164
2165 #. type: Plain text
2166 #: build/C/man3/malloc_info.3:84
2167 msgid ""
2168 "The B<malloc_info>()  function is designed to address deficiencies in "
2169 "B<malloc_stats>(3)  and B<mallinfo>(3)."
2170 msgstr ""
2171
2172 #. type: Plain text
2173 #: build/C/man3/malloc_info.3:95
2174 msgid ""
2175 "The program below takes up to four command-line arguments, of which the "
2176 "first three are mandatory.  The first argument specifies the number of "
2177 "threads that the program should create.  All of the threads, including the "
2178 "main thread, allocate the number of blocks of memory specified by the second "
2179 "argument.  The third argument controls the size of the blocks to be "
2180 "allocated.  The main thread creates blocks of this size, the second thread "
2181 "created by the program allocates blocks of twice this size, the third thread "
2182 "allocates blocks of three times this size, and so on."
2183 msgstr ""
2184
2185 #. type: Plain text
2186 #: build/C/man3/malloc_info.3:102
2187 msgid ""
2188 "The program calls B<malloc_info>()  twice to display the memory-allocation "
2189 "state.  The first call takes place before any threads are created or memory "
2190 "allocated.  The second call is performed after all threads have allocated "
2191 "memory."
2192 msgstr ""
2193
2194 #. type: Plain text
2195 #: build/C/man3/malloc_info.3:110
2196 msgid ""
2197 "In the following example, the command-line arguments specify the creation of "
2198 "one additional thread, and both the main thread and the additional thread "
2199 "allocate 10000 blocks of memory.  After the blocks of memory have been "
2200 "allocated, B<malloc_info>()  shows the state of two allocation arenas."
2201 msgstr ""
2202
2203 #. type: Plain text
2204 #: build/C/man3/malloc_info.3:135
2205 #, no-wrap
2206 msgid ""
2207 "$ B<getconf GNU_LIBC_VERSION>\n"
2208 "glibc 2.13\n"
2209 "$ B<./a.out 1 10000 100>\n"
2210 "============ Before allocating blocks ============\n"
2211 "E<lt>malloc version=\"1\"E<gt>\n"
2212 "E<lt>heap nr=\"0\"E<gt>\n"
2213 "E<lt>sizesE<gt>\n"
2214 "E<lt>/sizesE<gt>\n"
2215 "E<lt>total type=\"fast\" count=\"0\" size=\"0\"/E<gt>\n"
2216 "E<lt>total type=\"rest\" count=\"0\" size=\"0\"/E<gt>\n"
2217 "E<lt>system type=\"current\" size=\"135168\"/E<gt>\n"
2218 "E<lt>system type=\"max\" size=\"135168\"/E<gt>\n"
2219 "E<lt>aspace type=\"total\" size=\"135168\"/E<gt>\n"
2220 "E<lt>aspace type=\"mprotect\" size=\"135168\"/E<gt>\n"
2221 "E<lt>/heapE<gt>\n"
2222 "E<lt>total type=\"fast\" count=\"0\" size=\"0\"/E<gt>\n"
2223 "E<lt>total type=\"rest\" count=\"0\" size=\"0\"/E<gt>\n"
2224 "E<lt>system type=\"current\" size=\"135168\"/E<gt>\n"
2225 "E<lt>system type=\"max\" size=\"135168\"/E<gt>\n"
2226 "E<lt>aspace type=\"total\" size=\"135168\"/E<gt>\n"
2227 "E<lt>aspace type=\"mprotect\" size=\"135168\"/E<gt>\n"
2228 "E<lt>/mallocE<gt>\n"
2229 msgstr ""
2230
2231 #. type: Plain text
2232 #: build/C/man3/malloc_info.3:165
2233 #, no-wrap
2234 msgid ""
2235 "============ After allocating blocks ============\n"
2236 "E<lt>malloc version=\"1\"E<gt>\n"
2237 "E<lt>heap nr=\"0\"E<gt>\n"
2238 "E<lt>sizesE<gt>\n"
2239 "E<lt>/sizesE<gt>\n"
2240 "E<lt>total type=\"fast\" count=\"0\" size=\"0\"/E<gt>\n"
2241 "E<lt>total type=\"rest\" count=\"0\" size=\"0\"/E<gt>\n"
2242 "E<lt>system type=\"current\" size=\"1081344\"/E<gt>\n"
2243 "E<lt>system type=\"max\" size=\"1081344\"/E<gt>\n"
2244 "E<lt>aspace type=\"total\" size=\"1081344\"/E<gt>\n"
2245 "E<lt>aspace type=\"mprotect\" size=\"1081344\"/E<gt>\n"
2246 "E<lt>/heapE<gt>\n"
2247 "E<lt>heap nr=\"1\"E<gt>\n"
2248 "E<lt>sizesE<gt>\n"
2249 "E<lt>/sizesE<gt>\n"
2250 "E<lt>total type=\"fast\" count=\"0\" size=\"0\"/E<gt>\n"
2251 "E<lt>total type=\"rest\" count=\"0\" size=\"0\"/E<gt>\n"
2252 "E<lt>system type=\"current\" size=\"1032192\"/E<gt>\n"
2253 "E<lt>system type=\"max\" size=\"1032192\"/E<gt>\n"
2254 "E<lt>aspace type=\"total\" size=\"1032192\"/E<gt>\n"
2255 "E<lt>aspace type=\"mprotect\" size=\"1032192\"/E<gt>\n"
2256 "E<lt>/heapE<gt>\n"
2257 "E<lt>total type=\"fast\" count=\"0\" size=\"0\"/E<gt>\n"
2258 "E<lt>total type=\"rest\" count=\"0\" size=\"0\"/E<gt>\n"
2259 "E<lt>system type=\"current\" size=\"2113536\"/E<gt>\n"
2260 "E<lt>system type=\"max\" size=\"2113536\"/E<gt>\n"
2261 "E<lt>aspace type=\"total\" size=\"2113536\"/E<gt>\n"
2262 "E<lt>aspace type=\"mprotect\" size=\"2113536\"/E<gt>\n"
2263 "E<lt>/mallocE<gt>\n"
2264 msgstr ""
2265
2266 #. type: Plain text
2267 #: build/C/man3/malloc_info.3:175
2268 #, no-wrap
2269 msgid ""
2270 "#include E<lt>unistd.hE<gt>\n"
2271 "#include E<lt>stdlib.hE<gt>\n"
2272 "#include E<lt>pthread.hE<gt>\n"
2273 "#include E<lt>malloc.hE<gt>\n"
2274 "#include E<lt>errno.hE<gt>\n"
2275 msgstr ""
2276
2277 #. type: Plain text
2278 #: build/C/man3/malloc_info.3:178
2279 #, no-wrap
2280 msgid ""
2281 "static size_t blockSize;\n"
2282 "static int numThreads, numBlocks;\n"
2283 msgstr ""
2284
2285 #. type: Plain text
2286 #: build/C/man3/malloc_info.3:181
2287 #, no-wrap
2288 msgid ""
2289 "#define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \\e\n"
2290 "                        } while (0)\n"
2291 msgstr ""
2292
2293 #. type: Plain text
2294 #: build/C/man3/malloc_info.3:187
2295 #, no-wrap
2296 msgid ""
2297 "static void *\n"
2298 "thread_func(void *arg)\n"
2299 "{\n"
2300 "    int j;\n"
2301 "    int tn = (int) arg;\n"
2302 msgstr ""
2303
2304 #. type: Plain text
2305 #: build/C/man3/malloc_info.3:190
2306 #, no-wrap
2307 msgid ""
2308 "    /* The multiplier \\(aq(2 + tn)\\(aq ensures that each thread "
2309 "(including\n"
2310 "       the main thread) allocates a different amount of memory */\n"
2311 msgstr ""
2312
2313 #. type: Plain text
2314 #: build/C/man3/malloc_info.3:194
2315 #, no-wrap
2316 msgid ""
2317 "    for (j = 0; j E<lt> numBlocks; j++)\n"
2318 "        if (malloc(blockSize * (2 + tn)) == NULL)\n"
2319 "            errExit(\"malloc-thread\");\n"
2320 msgstr ""
2321
2322 #. type: Plain text
2323 #: build/C/man3/malloc_info.3:198
2324 #, no-wrap
2325 msgid ""
2326 "    sleep(100);         /* Sleep until main thread terminates */\n"
2327 "    return NULL;\n"
2328 "}\n"
2329 msgstr ""
2330
2331 #. type: Plain text
2332 #: build/C/man3/malloc_info.3:204
2333 #, no-wrap
2334 msgid ""
2335 "int\n"
2336 "main(int argc, char *argv[])\n"
2337 "{\n"
2338 "    int j, tn, sleepTime;\n"
2339 "    pthread_t *thr;\n"
2340 msgstr ""
2341
2342 #. type: Plain text
2343 #: build/C/man3/malloc_info.3:211
2344 #, no-wrap
2345 msgid ""
2346 "    if (argc E<lt> 4) {\n"
2347 "        fprintf(stderr,\n"
2348 "                \"%s num-threads num-blocks block-size [sleep-time]\\en\",\n"
2349 "                argv[0]);\n"
2350 "        exit(EXIT_FAILURE);\n"
2351 "    }\n"
2352 msgstr ""
2353
2354 #. type: Plain text
2355 #: build/C/man3/malloc_info.3:216
2356 #, no-wrap
2357 msgid ""
2358 "    numThreads = atoi(argv[1]);\n"
2359 "    numBlocks = atoi(argv[2]);\n"
2360 "    blockSize = atoi(argv[3]);\n"
2361 "    sleepTime = (argc E<gt> 4) ? atoi(argv[4]) : 0;\n"
2362 msgstr ""
2363
2364 #. type: Plain text
2365 #: build/C/man3/malloc_info.3:220
2366 #, no-wrap
2367 msgid ""
2368 "    thr = calloc(numThreads, sizeof(pthread_t));\n"
2369 "    if (thr == NULL)\n"
2370 "        errExit(\"calloc\");\n"
2371 msgstr ""
2372
2373 #. type: Plain text
2374 #: build/C/man3/malloc_info.3:223
2375 #, no-wrap
2376 msgid ""
2377 "    printf(\"============ Before allocating blocks ============\\en\");\n"
2378 "    malloc_info(0, stdout);\n"
2379 msgstr ""
2380
2381 #. type: Plain text
2382 #: build/C/man3/malloc_info.3:225
2383 #, no-wrap
2384 msgid "    /* Create threads that allocate different amounts of memory */\n"
2385 msgstr ""
2386
2387 #. type: Plain text
2388 #: build/C/man3/malloc_info.3:231
2389 #, no-wrap
2390 msgid ""
2391 "    for (tn = 0; tn E<lt> numThreads; tn++) {\n"
2392 "        errno = pthread_create(&thr[tn], NULL, thread_func,\n"
2393 "                               (void *) tn);\n"
2394 "        if (errno != 0)\n"
2395 "            errExit(\"pthread_create\");\n"
2396 msgstr ""
2397
2398 #. type: Plain text
2399 #: build/C/man3/malloc_info.3:236
2400 #, no-wrap
2401 msgid ""
2402 "        /* If we add a sleep interval after the start-up of each\n"
2403 "           thread, the threads likely won\\(aqt contend for malloc\n"
2404 "           mutexes, and therefore additional arenas won\\(aqt be\n"
2405 "           allocated (see malloc(3)). */\n"
2406 msgstr ""
2407
2408 #. type: Plain text
2409 #: build/C/man3/malloc_info.3:240
2410 #, no-wrap
2411 msgid ""
2412 "        if (sleepTime E<gt> 0)\n"
2413 "            sleep(sleepTime);\n"
2414 "    }\n"
2415 msgstr ""
2416
2417 #. type: Plain text
2418 #: build/C/man3/malloc_info.3:242
2419 #, no-wrap
2420 msgid "    /* The main thread also allocates some memory */\n"
2421 msgstr ""
2422
2423 #. type: Plain text
2424 #: build/C/man3/malloc_info.3:246
2425 #, no-wrap
2426 msgid ""
2427 "    for (j = 0; j E<lt> numBlocks; j++)\n"
2428 "        if (malloc(blockSize) == NULL)\n"
2429 "            errExit(\"malloc\");\n"
2430 msgstr ""
2431
2432 #. type: Plain text
2433 #: build/C/man3/malloc_info.3:249
2434 #, no-wrap
2435 msgid ""
2436 "    sleep(2);           /* Give all threads a chance to\n"
2437 "                           complete allocations */\n"
2438 msgstr ""
2439
2440 #. type: Plain text
2441 #: build/C/man3/malloc_info.3:252
2442 #, no-wrap
2443 msgid ""
2444 "    printf(\"\\en============ After allocating blocks ============\\en\");\n"
2445 "    malloc_info(0, stdout);\n"
2446 msgstr ""
2447
2448 #. type: Plain text
2449 #: build/C/man3/malloc_info.3:262
2450 msgid ""
2451 "B<mallinfo>(3), B<malloc>(3), B<malloc_stats>(3), B<mallopt>(3), "
2452 "B<open_memstream>(3)"
2453 msgstr ""
2454
2455 #. type: TH
2456 #: build/C/man3/malloc_stats.3:26
2457 #, no-wrap
2458 msgid "MALLOC_STATS"
2459 msgstr ""
2460
2461 #. type: Plain text
2462 #: build/C/man3/malloc_stats.3:29
2463 msgid "malloc_stats - print memory allocation statistics"
2464 msgstr ""
2465
2466 #. type: Plain text
2467 #: build/C/man3/malloc_stats.3:33
2468 msgid "B<void malloc_stats(void);>"
2469 msgstr ""
2470
2471 #.  .SH VERSIONS
2472 #.  Available already in glibc 2.0, possibly earlier
2473 #. type: Plain text
2474 #: build/C/man3/malloc_stats.3:55
2475 msgid ""
2476 "The B<malloc_stats>()  function prints (on standard error) statistics about "
2477 "memory allocated by B<malloc>(3)  and related functions.  For each arena "
2478 "(allocation area), this function prints the total amount of memory allocated "
2479 "and the total number of bytes consumed by in-use allocations.  (These two "
2480 "values correspond to the I<arena> and I<uordblks> fields retrieved by "
2481 "B<mallinfo>(3).)  In addition, the function prints the sum of these two "
2482 "statistics for all arenas, and the maximum number of blocks and bytes that "
2483 "were ever simultaneously allocated using B<mmap>(2)."
2484 msgstr ""
2485
2486 #. type: Plain text
2487 #: build/C/man3/malloc_stats.3:61
2488 msgid ""
2489 "More detailed information about memory allocations in the main arena can be "
2490 "obtained using B<mallinfo>(3)."
2491 msgstr ""
2492
2493 #. type: Plain text
2494 #: build/C/man3/malloc_stats.3:67
2495 msgid "B<mmap>(2), B<mallinfo>(3), B<malloc>(3), B<malloc_info>(3), B<mallopt>(3)"
2496 msgstr ""
2497
2498 #. type: TH
2499 #: build/C/man3/malloc_trim.3:26
2500 #, no-wrap
2501 msgid "MALLOC_TRIM"
2502 msgstr ""
2503
2504 #. type: TH
2505 #: build/C/man3/malloc_trim.3:26 build/C/man3/malloc_usable_size.3:25
2506 #, no-wrap
2507 msgid "2012-03-29"
2508 msgstr ""
2509
2510 #. type: Plain text
2511 #: build/C/man3/malloc_trim.3:29
2512 msgid "malloc_trim - release free memory from the top of the heap"
2513 msgstr ""
2514
2515 #. type: Plain text
2516 #: build/C/man3/malloc_trim.3:33
2517 msgid "B<void malloc_trim(size_t >I<pad>B<);>"
2518 msgstr ""
2519
2520 #. type: Plain text
2521 #: build/C/man3/malloc_trim.3:40
2522 msgid ""
2523 "The B<malloc_trim>()  function attempts to release free memory at the top of "
2524 "the heap (by calling B<sbrk>(2)  with a suitable argument)."
2525 msgstr ""
2526
2527 #. type: Plain text
2528 #: build/C/man3/malloc_trim.3:51
2529 msgid ""
2530 "The I<pad> argument specifies the amount of free space to leave untrimmed at "
2531 "the top of the heap.  If this argument is 0, only the minimum amount of "
2532 "memory is maintained at the top of the heap (i.e., one page or less).  A "
2533 "nonzero argument can be used to maintain some trailing space at the top of "
2534 "the heap in order to allow future allocations to be made without having to "
2535 "extend the heap with B<sbrk>(2)."
2536 msgstr ""
2537
2538 #. type: Plain text
2539 #: build/C/man3/malloc_trim.3:56
2540 msgid ""
2541 "The B<malloc_trim>()  function returns 1 if memory was actually released "
2542 "back to the system, or 0 if it was not possible to release any memory."
2543 msgstr ""
2544
2545 #.  .SH VERSIONS
2546 #.  Available already in glibc 2.0, possibly earlier
2547 #. type: Plain text
2548 #: build/C/man3/malloc_trim.3:60
2549 msgid "No errors are defined."
2550 msgstr ""
2551
2552 #. type: Plain text
2553 #: build/C/man3/malloc_trim.3:71
2554 msgid ""
2555 "This function is automatically called by B<free>(3)  in certain "
2556 "circumstances; see the discussion of B<M_TOP_PAD> and B<M_TRIM_THRESHOLD> in "
2557 "B<mallopt>(3)."
2558 msgstr ""
2559
2560 #. type: Plain text
2561 #: build/C/man3/malloc_trim.3:74
2562 msgid ""
2563 "This function cannot release free memory located at places other than the "
2564 "top of the heap."
2565 msgstr ""
2566
2567 #.  malloc/malloc.c::mTRIm():
2568 #.      return result | (av == &main_arena ? sYSTRIm (pad, av) : 0);
2569 #. type: Plain text
2570 #: build/C/man3/malloc_trim.3:78
2571 msgid "This function releases only memory in the main arena."
2572 msgstr ""
2573
2574 #. type: Plain text
2575 #: build/C/man3/malloc_trim.3:82
2576 msgid "B<sbrk>(2), B<malloc>(3), B<mallopt>(3)"
2577 msgstr ""
2578
2579 #. type: TH
2580 #: build/C/man3/malloc_usable_size.3:25
2581 #, no-wrap
2582 msgid "MALLOC_USABLE_SIZE"
2583 msgstr ""
2584
2585 #. type: Plain text
2586 #: build/C/man3/malloc_usable_size.3:28
2587 msgid "malloc_usable_size - obtain size of block of memory allocated from heap"
2588 msgstr ""
2589
2590 #. type: Plain text
2591 #: build/C/man3/malloc_usable_size.3:32
2592 msgid "B<size_t malloc_usable_size (void *>I<ptr>B<);>"
2593 msgstr ""
2594
2595 #. type: Plain text
2596 #: build/C/man3/malloc_usable_size.3:40
2597 msgid ""
2598 "The B<malloc_usable_size>()  function returns the number of usable bytes in "
2599 "the block pointed to by I<ptr>, a pointer to a block of memory allocated by "
2600 "B<malloc>(3)  or a related function."
2601 msgstr ""
2602
2603 #. type: Plain text
2604 #: build/C/man3/malloc_usable_size.3:48
2605 msgid ""
2606 "B<malloc_usable_size>()  returns the number of usable bytes in the block of "
2607 "allocated memory pointed to by I<ptr>.  If I<ptr> is NULL, 0 is returned."
2608 msgstr ""
2609
2610 #. type: Plain text
2611 #: build/C/man3/malloc_usable_size.3:60
2612 msgid ""
2613 "The value returned by B<malloc_usable_size>()  may be greater than the "
2614 "requested size of the allocation because of alignment and minimum size "
2615 "constraints.  Although the excess bytes can be overwritten by the "
2616 "application without ill effects, this is not good programming practice: the "
2617 "number of excess bytes in an allocation depends on the underlying "
2618 "implementation."
2619 msgstr ""
2620
2621 #. type: Plain text
2622 #: build/C/man3/malloc_usable_size.3:62
2623 msgid "The main use of this function is for debugging and introspection."
2624 msgstr ""
2625
2626 #. type: Plain text
2627 #: build/C/man3/malloc_usable_size.3:64
2628 msgid "B<malloc>(3)"
2629 msgstr ""
2630
2631 #. type: TH
2632 #: build/C/man3/mallopt.3:26
2633 #, no-wrap
2634 msgid "MALLOPT"
2635 msgstr ""
2636
2637 #. type: TH
2638 #: build/C/man3/mallopt.3:26
2639 #, no-wrap
2640 msgid "2012-04-30"
2641 msgstr ""
2642
2643 #. type: Plain text
2644 #: build/C/man3/mallopt.3:29
2645 msgid "mallopt - set memory allocation parameters"
2646 msgstr ""
2647
2648 #. type: Plain text
2649 #: build/C/man3/mallopt.3:33
2650 msgid "B<int mallopt(int >I<param>B<, int >I<value>B<);>"
2651 msgstr ""
2652
2653 #. type: Plain text
2654 #: build/C/man3/mallopt.3:44
2655 msgid ""
2656 "The B<mallopt>()  function adjusts parameters that control the behavior of "
2657 "the memory-allocation functions (see B<malloc>(3)).  The I<param> argument "
2658 "specifies the parameter to be modified, and I<value> specifies the new value "
2659 "for that parameter."
2660 msgstr ""
2661
2662 #. type: Plain text
2663 #: build/C/man3/mallopt.3:47
2664 msgid "The following values can be specified for I<param>:"
2665 msgstr ""
2666
2667 #. type: TP
2668 #: build/C/man3/mallopt.3:47
2669 #, no-wrap
2670 msgid "B<M_CHECK_ACTION>"
2671 msgstr ""
2672
2673 #. type: Plain text
2674 #: build/C/man3/mallopt.3:53
2675 msgid ""
2676 "Setting this parameter controls how glibc responds when various kinds of "
2677 "programming errors are detected (e.g., freeing the same pointer twice).  The "
2678 "3 least significant bits (2, 1, and 0) of the value assigned to this "
2679 "parameter determine the glibc behavior, as follows:"
2680 msgstr ""
2681
2682 #. type: TP
2683 #: build/C/man3/mallopt.3:54
2684 #, no-wrap
2685 msgid "Bit 0"
2686 msgstr ""
2687
2688 #. type: Plain text
2689 #: build/C/man3/mallopt.3:64
2690 msgid ""
2691 "If this bit is set, then print a one-line message on I<stderr> that provides "
2692 "details about the error.  The message starts with the string \"***\\ glibc "
2693 "detected\\ ***\", followed by the program name, the name of the "
2694 "memory-allocation function in which the error was detected, a brief "
2695 "description of the error, and the memory address where the error was "
2696 "detected."
2697 msgstr ""
2698
2699 #. type: TP
2700 #: build/C/man3/mallopt.3:64
2701 #, no-wrap
2702 msgid "Bit 1"
2703 msgstr ""
2704
2705 #. type: Plain text
2706 #: build/C/man3/mallopt.3:79
2707 msgid ""
2708 "If this bit is set, then, after printing any error message specified by bit "
2709 "0, the program is terminated by calling B<abort>(3).  In glibc versions "
2710 "since 2.4, if bit 0 is also set, then, between printing the error message "
2711 "and aborting, the program also prints a stack trace in the manner of "
2712 "B<backtrace>(3), and prints the process's memory mapping in the style of "
2713 "I</proc/[pid]/maps> (see B<proc>(5))."
2714 msgstr ""
2715
2716 #. type: TP
2717 #: build/C/man3/mallopt.3:79
2718 #, no-wrap
2719 msgid "Bit 2 (since glibc 2.4)"
2720 msgstr ""
2721
2722 #. type: Plain text
2723 #: build/C/man3/mallopt.3:86
2724 msgid ""
2725 "This bit has an effect only if bit 0 is also set.  If this bit is set, then "
2726 "the one-line message describing the error is simplified to contain just the "
2727 "name of the function where the error was detected and the brief description "
2728 "of the error."
2729 msgstr ""
2730
2731 #. type: Plain text
2732 #: build/C/man3/mallopt.3:91
2733 msgid "The remaining bits in I<value> are ignored."
2734 msgstr ""
2735
2736 #. type: Plain text
2737 #: build/C/man3/mallopt.3:95
2738 msgid ""
2739 "Combining the above details, the following numeric values are meaningful for "
2740 "B<M_CHECK_ACTION>:"
2741 msgstr ""
2742
2743 #. type: IP
2744 #: build/C/man3/mallopt.3:96
2745 #, no-wrap
2746 msgid "0"
2747 msgstr ""
2748
2749 #. type: Plain text
2750 #: build/C/man3/mallopt.3:98
2751 msgid "Ignore error conditions; continue execution (with undefined results)."
2752 msgstr ""
2753
2754 #. type: IP
2755 #: build/C/man3/mallopt.3:98
2756 #, no-wrap
2757 msgid "1"
2758 msgstr ""
2759
2760 #. type: Plain text
2761 #: build/C/man3/mallopt.3:100
2762 msgid "Print a detailed error message and continue execution."
2763 msgstr ""
2764
2765 #. type: IP
2766 #: build/C/man3/mallopt.3:100
2767 #, no-wrap
2768 msgid "2"
2769 msgstr ""
2770
2771 #. type: Plain text
2772 #: build/C/man3/mallopt.3:102
2773 msgid "Abort the program."
2774 msgstr ""
2775
2776 #. type: IP
2777 #: build/C/man3/mallopt.3:102
2778 #, no-wrap
2779 msgid "3"
2780 msgstr ""
2781
2782 #. type: Plain text
2783 #: build/C/man3/mallopt.3:105
2784 msgid ""
2785 "Print detailed error message, stack trace, and memory mappings, and abort "
2786 "the program."
2787 msgstr ""
2788
2789 #. type: IP
2790 #: build/C/man3/mallopt.3:105
2791 #, no-wrap
2792 msgid "5"
2793 msgstr ""
2794
2795 #. type: Plain text
2796 #: build/C/man3/mallopt.3:107
2797 msgid "Print a simple error message and continue execution."
2798 msgstr ""
2799
2800 #. type: IP
2801 #: build/C/man3/mallopt.3:107
2802 #, no-wrap
2803 msgid "7"
2804 msgstr ""
2805
2806 #. type: Plain text
2807 #: build/C/man3/mallopt.3:110
2808 msgid ""
2809 "Print simple error message, stack trace, and memory mappings, and abort the "
2810 "program."
2811 msgstr ""
2812
2813 #. type: Plain text
2814 #: build/C/man3/mallopt.3:116
2815 msgid ""
2816 "Since glibc 2.3.4, the default value for the B<M_CHECK_ACTION> parameter is "
2817 "3.  In glibc version 2.3.3 and earlier, the default value is 1."
2818 msgstr ""
2819
2820 #. type: Plain text
2821 #: build/C/man3/mallopt.3:121
2822 msgid ""
2823 "Using a nonzero B<M_CHECK_ACTION> value can be useful because otherwise a "
2824 "crash may happen much later, and the true cause of the problem is then very "
2825 "hard to track down."
2826 msgstr ""
2827
2828 #. type: TP
2829 #: build/C/man3/mallopt.3:121
2830 #, no-wrap
2831 msgid "B<M_MMAP_MAX>"
2832 msgstr ""
2833
2834 #.  The following text adapted from comments in the glibc source:
2835 #. type: Plain text
2836 #: build/C/man3/mallopt.3:131
2837 msgid ""
2838 "This parameter specifies the maximum number of allocation requests that may "
2839 "be simultaneously serviced using B<mmap>(2).  This parameter exists because "
2840 "some systems have a limited number of internal tables for use by B<mmap>(2), "
2841 "and using more than a few of them may degrade performance."
2842 msgstr ""
2843
2844 #. type: Plain text
2845 #: build/C/man3/mallopt.3:138
2846 msgid ""
2847 "The default value is 65,536, a value which has no special significance and "
2848 "which servers only as a safeguard.  Setting this parameter to 0 disables the "
2849 "use of B<mmap>(2)  for servicing large allocation requests."
2850 msgstr ""
2851
2852 #. type: TP
2853 #: build/C/man3/mallopt.3:138
2854 #, no-wrap
2855 msgid "B<M_MMAP_THRESHOLD>"
2856 msgstr ""
2857
2858 #. type: Plain text
2859 #: build/C/man3/mallopt.3:147
2860 msgid ""
2861 "For allocations greater than or equal to the limit specified (in bytes) by "
2862 "B<M_MMAP_THRESHOLD> that can't be satisfied from the free list, the "
2863 "memory-allocation functions employ B<mmap>(2)  instead of increasing the "
2864 "program break using B<sbrk>(2)."
2865 msgstr ""
2866
2867 #. type: Plain text
2868 #: build/C/man3/mallopt.3:167
2869 msgid ""
2870 "Allocating memory using B<mmap>(2)  has the significant advantage that the "
2871 "allocated memory blocks can always be independently released back to the "
2872 "system.  (By contrast, the heap can be trimmed only if memory is freed at "
2873 "the top end.)  On the other hand, there are some disadvantages to the use of "
2874 "B<mmap>(2): deallocated space is not placed on the free list for reuse by "
2875 "later allocations; memory may be wasted because B<mmap>(2)  allocations must "
2876 "be page-aligned; and the kernel must perform the expensive task of zeroing "
2877 "out memory allocated via B<mmap>(2).  Balancing these factors leads to a "
2878 "default setting of 128*1024 for the B<M_MMAP_THRESHOLD> parameter."
2879 msgstr ""
2880
2881 #. type: Plain text
2882 #: build/C/man3/mallopt.3:174
2883 msgid ""
2884 "The lower limit for this parameter is 0.  The upper limit is "
2885 "B<DEFAULT_MMAP_THRESHOLD_MAX>: 512*1024 on 32-bit systems or "
2886 "I<4*1024*1024*sizeof(long)> on 64-bit systems."
2887 msgstr ""
2888
2889 #. type: Plain text
2890 #: build/C/man3/mallopt.3:192
2891 msgid ""
2892 "I<Note:> Nowadays, glibc uses a dynamic mmap threshold by default.  The "
2893 "initial value of the threshold is 128*1024, but when blocks larger than the "
2894 "current threshold and less than or equal to B<DEFAULT_MMAP_THRESHOLD_MAX> "
2895 "are freed, the threshold is adjusted upwards to the size of the freed "
2896 "block.  When dynamic mmap thresholding is in effect, the threshold for "
2897 "trimming the heap is also dynamically adjusted to be twice the dynamic mmap "
2898 "threshold.  Dynamic adjustment of the mmap threshold is disabled if any of "
2899 "the B<M_TRIM_THRESHOLD>, B<M_TOP_PAD>, B<M_MMAP_THRESHOLD>, or B<M_MMAP_MAX> "
2900 "parameters is set."
2901 msgstr ""
2902
2903 #. type: TP
2904 #: build/C/man3/mallopt.3:192
2905 #, no-wrap
2906 msgid "B<M_MXFAST> (since glibc 2.3)"
2907 msgstr ""
2908
2909 #.  The following text adapted from comments in the glibc sources:
2910 #. type: Plain text
2911 #: build/C/man3/mallopt.3:212
2912 msgid ""
2913 "Set the upper limit for memory allocation requests that are satisfied using "
2914 "\"fastbins\".  (The measurement unit for this parameter is bytes.)  Fastbins "
2915 "are storage areas that hold deallocated blocks of memory of the same size "
2916 "without merging adjacent free blocks.  Subsequent reallocation of blocks of "
2917 "the same size can be handled very quickly by allocating from the fastbin, "
2918 "although memory fragmentation and the overall memory footprint of the "
2919 "program can increase.  The default value for this parameter is "
2920 "I<64*sizeof(size_t)/4> (i.e., 64 on 32-bit architectures).  The range for "
2921 "this parameter is 0 to I<80*sizeof(size_t)/4>.  Setting B<M_MXFAST> to 0 "
2922 "disables the use of fastbins."
2923 msgstr ""
2924
2925 #. type: TP
2926 #: build/C/man3/mallopt.3:212
2927 #, no-wrap
2928 msgid "B<M_PERTURB> (since glibc 2.4)"
2929 msgstr ""
2930
2931 #. type: Plain text
2932 #: build/C/man3/mallopt.3:227
2933 msgid ""
2934 "If this parameter is set to a nonzero value, then bytes of allocated memory "
2935 "(other than allocations via B<calloc>(3))  are initialized to the complement "
2936 "of the value in the least significant byte of I<value>, and when allocated "
2937 "memory is released using B<free>(3), the freed bytes are set to the least "
2938 "significant byte of I<value>.  This can be useful for detecting errors where "
2939 "programs incorrectly rely on allocated memory being initialized to zero, or "
2940 "reuse values in memory that has already been freed."
2941 msgstr ""
2942
2943 #. type: TP
2944 #: build/C/man3/mallopt.3:227
2945 #, no-wrap
2946 msgid "B<M_TOP_PAD>"
2947 msgstr ""
2948
2949 #. type: Plain text
2950 #: build/C/man3/mallopt.3:234
2951 msgid ""
2952 "This parameter defines the amount of padding to employ when calling "
2953 "B<sbrk>(2)  to modify the program break.  (The measurement unit for this "
2954 "parameter is bytes.)  This parameter has an effect in the following "
2955 "circumstances:"
2956 msgstr ""
2957
2958 #. type: Plain text
2959 #: build/C/man3/mallopt.3:241
2960 msgid ""
2961 "When the program break is increased, then B<M_TOP_PAD> bytes are added to "
2962 "the B<sbrk>(2)  request."
2963 msgstr ""
2964
2965 #. type: Plain text
2966 #: build/C/man3/mallopt.3:247
2967 msgid ""
2968 "When the heap is trimmed as a consequence of calling B<free>(3)  (see the "
2969 "discussion of B<M_TRIM_THRESHOLD>)  this much free space is preserved at the "
2970 "top of the heap."
2971 msgstr ""
2972
2973 #. type: Plain text
2974 #: build/C/man3/mallopt.3:251
2975 msgid ""
2976 "In either case, the amount of padding is always rounded to a system page "
2977 "boundary."
2978 msgstr ""
2979
2980 #. type: Plain text
2981 #: build/C/man3/mallopt.3:258
2982 msgid ""
2983 "Modifying B<M_TOP_PAD> is a trade-off between increasing the number of "
2984 "system calls (when the parameter is set low)  and wasting unused memory at "
2985 "the top of the heap (when the parameter is set high)."
2986 msgstr ""
2987
2988 #.  DEFAULT_TOP_PAD in glibc source
2989 #. type: Plain text
2990 #: build/C/man3/mallopt.3:261
2991 msgid "The default value for this parameter is 128*1024."
2992 msgstr ""
2993
2994 #. type: TP
2995 #: build/C/man3/mallopt.3:261
2996 #, no-wrap
2997 msgid "B<M_TRIM_THRESHOLD>"
2998 msgstr ""
2999
3000 #. type: Plain text
3001 #: build/C/man3/mallopt.3:277
3002 msgid ""
3003 "When the amount of contiguous free memory at the top of the heap grows "
3004 "sufficiently large, B<free>(3)  employs B<sbrk>(2)  to release this memory "
3005 "back to the system.  (This can be useful in programs that continue to "
3006 "execute for a long period after freeing a significant amount of memory.)  "
3007 "The B<M_TRIM_THRESHOLD> parameter specifies the minimum size (in bytes) that "
3008 "this block of memory must reach before B<sbrk>(2)  is used to trim the heap."
3009 msgstr ""
3010
3011 #. type: Plain text
3012 #: build/C/man3/mallopt.3:282
3013 msgid ""
3014 "The default value for this parameter is 128*1024.  Setting "
3015 "B<M_TRIM_THRESHOLD> to -1 disables trimming completely."
3016 msgstr ""
3017
3018 #.  FIXME Do the arena parameters need to be documented?
3019 #.  .TP
3020 #.  .BR M_ARENA_TEST " (since glibc 2.10)"
3021 #.  .TP
3022 #.  .BR M_ARENA_MAX " (since glibc 2.10)"
3023 #
3024 #.  Environment variables
3025 #.      MALLOC_ARENA_MAX_
3026 #.      MALLOC_ARENA_TEST_
3027 #
3028 #.  http://udrepper.livejournal.com/20948.html describes some details
3029 #.      of the MALLOC_ARENA_* environment variables.
3030 #
3031 #.  These macros aren't enabled in production releases until 2.15?
3032 #.  (see glibc malloc/Makefile)
3033 #. type: Plain text
3034 #: build/C/man3/mallopt.3:305
3035 msgid ""
3036 "Modifying B<M_TRIM_THRESHOLD> is a trade-off between increasing the number "
3037 "of system calls (when the parameter is set low)  and wasting unused memory "
3038 "at the top of the heap (when the parameter is set high)."
3039 msgstr ""
3040
3041 #. type: SS
3042 #: build/C/man3/mallopt.3:305
3043 #, no-wrap
3044 msgid "Environment variables"
3045 msgstr ""
3046
3047 #. type: Plain text
3048 #: build/C/man3/mallopt.3:320
3049 msgid ""
3050 "A number of environment variables can be defined to modify some of the same "
3051 "parameters as are controlled by B<mallopt>().  Using these variables has the "
3052 "advantage that the source code of the program need not be changed.  To be "
3053 "effective, these variables must be defined before the first call to a "
3054 "memory-allocation function.  (If the same parameters are adjusted via "
3055 "B<mallopt>()  then the B<mallopt>()  settings take precedence.)  For "
3056 "security reasons, these variables are ignored in set-user-ID and "
3057 "set-group-ID programs."
3058 msgstr ""
3059
3060 #. type: Plain text
3061 #: build/C/man3/mallopt.3:323
3062 msgid ""
3063 "The environment variables are as follows (note the trailing underscore at "
3064 "the end of the name of each variable):"
3065 msgstr ""
3066
3067 #. type: TP
3068 #: build/C/man3/mallopt.3:323
3069 #, no-wrap
3070 msgid "B<MALLOC_CHECK_>"
3071 msgstr ""
3072
3073 #.  On glibc 2.12/x86, a simple malloc()+free() loop is about 70% slower
3074 #.  when MALLOC_CHECK_ was set.
3075 #. type: Plain text
3076 #: build/C/man3/mallopt.3:340
3077 msgid ""
3078 "This environment variable controls the same parameter as B<mallopt>()  "
3079 "B<M_CHECK_ACTION>.  If this variable is set to a nonzero value, then a "
3080 "special implementation of the memory-allocation functions is used.  (This is "
3081 "accomplished using the B<malloc_hook>(3)  feature.)  This implementation "
3082 "performs additional error checking, but is slower than the standard set of "
3083 "memory-allocation functions.  (This implementation does not detect all "
3084 "possible errors; memory leaks can still occur.)"
3085 msgstr ""
3086
3087 #. type: Plain text
3088 #: build/C/man3/mallopt.3:345
3089 msgid ""
3090 "The value assigned to this environment variable should be a single digit, "
3091 "whose meaning is as described for B<M_CHECK_ACTION>.  Any characters beyond "
3092 "the initial digit are ignored."
3093 msgstr ""
3094
3095 #. type: Plain text
3096 #: build/C/man3/mallopt.3:354
3097 msgid ""
3098 "For security reasons, the effect of B<MALLOC_CHECK_> is disabled by default "
3099 "for set-user-ID and set-group-ID programs.  However, if the file "
3100 "I</etc/suid-debug> exists (the content of the file is irrelevant), then "
3101 "B<MALLOC_CHECK_> also has an effect for set-user-ID and set-group-ID "
3102 "programs."
3103 msgstr ""
3104
3105 #. type: TP
3106 #: build/C/man3/mallopt.3:354
3107 #, no-wrap
3108 msgid "B<MALLOC_MMAP_MAX_>"
3109 msgstr ""
3110
3111 #. type: Plain text
3112 #: build/C/man3/mallopt.3:359
3113 msgid "Controls the same parameter as B<mallopt>()  B<M_MMAP_MAX>."
3114 msgstr ""
3115
3116 #. type: TP
3117 #: build/C/man3/mallopt.3:359
3118 #, no-wrap
3119 msgid "B<MALLOC_MMAP_THRESHOLD_>"
3120 msgstr ""
3121
3122 #. type: Plain text
3123 #: build/C/man3/mallopt.3:364
3124 msgid "Controls the same parameter as B<mallopt>()  B<M_MMAP_THRESHOLD>."
3125 msgstr ""
3126
3127 #. type: TP
3128 #: build/C/man3/mallopt.3:364
3129 #, no-wrap
3130 msgid "B<MALLOC_PERTURB_>"
3131 msgstr ""
3132
3133 #. type: Plain text
3134 #: build/C/man3/mallopt.3:369
3135 msgid "Controls the same parameter as B<mallopt>()  B<M_PERTURB>."
3136 msgstr ""
3137
3138 #. type: TP
3139 #: build/C/man3/mallopt.3:369
3140 #, no-wrap
3141 msgid "B<MALLOC_TRIM_THRESHOLD_>"
3142 msgstr ""
3143
3144 #. type: Plain text
3145 #: build/C/man3/mallopt.3:374
3146 msgid "Controls the same parameter as B<mallopt>()  B<M_TRIM_THRESHOLD>."
3147 msgstr ""
3148
3149 #. type: TP
3150 #: build/C/man3/mallopt.3:374
3151 #, no-wrap
3152 msgid "B<MALLOC_TOP_PAD_>"
3153 msgstr ""
3154
3155 #. type: Plain text
3156 #: build/C/man3/mallopt.3:379
3157 msgid "Controls the same parameter as B<mallopt>()  B<M_TOP_PAD>."
3158 msgstr ""
3159
3160 #. type: Plain text
3161 #: build/C/man3/mallopt.3:384
3162 msgid "On success, B<mallopt>()  returns 1.  On error, it returns 0."
3163 msgstr ""
3164
3165 #.  .SH VERSIONS
3166 #.  Available already in glibc 2.0, possibly earlier
3167 #. type: Plain text
3168 #: build/C/man3/mallopt.3:392
3169 msgid "On error, I<errno> is I<not> set."
3170 msgstr ""
3171
3172 #.  .SH NOTES
3173 #. type: Plain text
3174 #: build/C/man3/mallopt.3:406
3175 msgid ""
3176 "This function is not specified by POSIX or the C standards.  A similar "
3177 "function exists on many System V derivatives, but the range of values for "
3178 "I<param> varies across systems.  The SVID defined options B<M_MXFAST>, "
3179 "B<M_NLBLKS>, B<M_GRAIN>, and B<M_KEEP>, but only the first of these is "
3180 "implemented in glibc."
3181 msgstr ""
3182
3183 #. type: Plain text
3184 #: build/C/man3/mallopt.3:410
3185 msgid "Specifying an invalid value for I<param> does not generate an error."
3186 msgstr ""
3187
3188 #.  FIXME This looks buggy:
3189 #.  setting the M_MXFAST limit rounds up:    (s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)
3190 #.  malloc requests are rounded up:
3191 #.     (req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK
3192 #.  http://sources.redhat.com/bugzilla/show_bug.cgi?id=12129
3193 #. type: Plain text
3194 #: build/C/man3/mallopt.3:418
3195 msgid ""
3196 "A calculation error within the glibc implementation means that a call of the "
3197 "form:"
3198 msgstr ""
3199
3200 #. type: Plain text
3201 #: build/C/man3/mallopt.3:421
3202 #, no-wrap
3203 msgid "    mallopt(M_MXFAST, n)\n"
3204 msgstr ""
3205
3206 #.  Bins are multiples of 2 * sizeof(size_t) + sizeof(size_t)
3207 #. type: Plain text
3208 #: build/C/man3/mallopt.3:433
3209 msgid ""
3210 "does not result in fastbins being employed for all allocations of size up to "
3211 "I<n>.  To ensure desired results, I<n> should be rounded up to the next "
3212 "multiple greater than or equal to I<(2k+1)*sizeof(size_t)>, where I<k> is an "
3213 "integer."
3214 msgstr ""
3215
3216 #.  FIXME MALLOC_MMAP_THRESHOLD_ and MALLOC_MMAP_MAX_
3217 #.  do have an effect for set-user-ID programs (but not
3218 #.  set-group-ID programs).
3219 #.  http://sources.redhat.com/bugzilla/show_bug.cgi?id=12155
3220 #. type: Plain text
3221 #: build/C/man3/mallopt.3:445
3222 msgid ""
3223 "The B<MALLOC_MMAP_THRESHOLD_> and B<MALLOC_MMAP_MAX_> variables are I<not> "
3224 "ignored in set-group-ID programs."
3225 msgstr ""
3226
3227 #.  FIXME http://sources.redhat.com/bugzilla/show_bug.cgi?id=12140
3228 #. type: Plain text
3229 #: build/C/man3/mallopt.3:466
3230 msgid ""
3231 "If B<mallopt>()  is used to set B<M_PERTURB>, then, as expected, the bytes "
3232 "of allocated memory are initialized to the complement of the byte in "
3233 "I<value>, and when that memory is freed, the bytes of the region are "
3234 "initialized to the byte specified in I<value>.  However, there is an "
3235 "off-by-I<sizeof(size_t)> error in the implementation: instead of "
3236 "initializing precisely the block of memory being freed by the call "
3237 "I<free(p)>, the block starting at I<p+sizeof(size_t)> is initialized."
3238 msgstr ""
3239
3240 #. type: Plain text
3241 #: build/C/man3/mallopt.3:475
3242 msgid ""
3243 "The program below demonstrates the use of B<M_CHECK_ACTION>.  If the program "
3244 "is supplied with an (integer) command-line argument, then that argument is "
3245 "used to set the B<M_CHECK_ACTION> parameter.  The program then allocates a "
3246 "block of memory, and frees it twice (an error)."
3247 msgstr ""
3248
3249 #. type: Plain text
3250 #: build/C/man3/mallopt.3:479
3251 msgid ""
3252 "The following shell session shows what happens when we run this program "
3253 "under glibc, with the default value for B<M_CHECK_ACTION>:"
3254 msgstr ""
3255
3256 #. type: Plain text
3257 #: build/C/man3/mallopt.3:499
3258 #, no-wrap
3259 msgid ""
3260 "$ B<./a.out>\n"
3261 "main(): returned from first free() call\n"
3262 "*** glibc detected *** ./a.out: double free or corruption (top): 0x09d30008 "
3263 "***\n"
3264 "======= Backtrace: =========\n"
3265 "/lib/libc.so.6(+0x6c501)[0x523501]\n"
3266 "/lib/libc.so.6(+0x6dd70)[0x524d70]\n"
3267 "/lib/libc.so.6(cfree+0x6d)[0x527e5d]\n"
3268 "\\&./a.out[0x80485db]\n"
3269 "/lib/libc.so.6(__libc_start_main+0xe7)[0x4cdce7]\n"
3270 "\\&./a.out[0x8048471]\n"
3271 "======= Memory map: ========\n"
3272 "001e4000-001fe000 r-xp 00000000 08:06 1083555    /lib/libgcc_s.so.1\n"
3273 "001fe000-001ff000 r--p 00019000 08:06 1083555    /lib/libgcc_s.so.1\n"
3274 "[some lines omitted]\n"
3275 "b7814000-b7817000 rw-p 00000000 00:00 0\n"
3276 "bff53000-bff74000 rw-p 00000000 00:00 0          [stack]\n"
3277 "Aborted (core dumped)\n"
3278 msgstr ""
3279
3280 #. type: Plain text
3281 #: build/C/man3/mallopt.3:504
3282 msgid ""
3283 "The following runs show the results when employing other values for "
3284 "B<M_CHECK_ACTION>:"
3285 msgstr ""
3286
3287 #. type: Plain text
3288 #: build/C/man3/mallopt.3:517
3289 #, no-wrap
3290 msgid ""
3291 "$ B<./a.out 1>             # Diagnose error and continue\n"
3292 "main(): returned from first free() call\n"
3293 "*** glibc detected *** ./a.out: double free or corruption (top): 0x09cbe008 "
3294 "***\n"
3295 "main(): returned from second free() call\n"
3296 "$ B<./a.out 2>             # Abort without error message\n"
3297 "main(): returned from first free() call\n"
3298 "Aborted (core dumped)\n"
3299 "$ B<./a.out 0>             # Ignore error and continue\n"
3300 "main(): returned from first free() call\n"
3301 "main(): returned from second free() call\n"
3302 msgstr ""
3303
3304 #. type: Plain text
3305 #: build/C/man3/mallopt.3:523
3306 msgid ""
3307 "The next run shows how to set the same parameter using the B<MALLOC_CHECK_> "
3308 "environment variable:"
3309 msgstr ""
3310
3311 #. type: Plain text
3312 #: build/C/man3/mallopt.3:530
3313 #, no-wrap
3314 msgid ""
3315 "$ B<MALLOC_CHECK_=1 ./a.out>\n"
3316 "main(): returned from first free() call\n"
3317 "*** glibc detected *** ./a.out: free(): invalid pointer: 0x092c2008 ***\n"
3318 "main(): returned from second free() call\n"
3319 msgstr ""
3320
3321 #. type: Plain text
3322 #: build/C/man3/mallopt.3:538
3323 #, no-wrap
3324 msgid ""
3325 "#include E<lt>malloc.hE<gt>\n"
3326 "#include E<lt>stdio.hE<gt>\n"
3327 "#include E<lt>stdlib.hE<gt>\n"
3328 msgstr ""
3329
3330 #. type: Plain text
3331 #: build/C/man3/mallopt.3:543 build/C/man3/mcheck.3:187
3332 #, no-wrap
3333 msgid ""
3334 "int\n"
3335 "main(int argc, char *argv[])\n"
3336 "{\n"
3337 "    char *p;\n"
3338 msgstr ""
3339
3340 #. type: Plain text
3341 #: build/C/man3/mallopt.3:550
3342 #, no-wrap
3343 msgid ""
3344 "    if (argc E<gt> 1) {\n"
3345 "        if (mallopt(M_CHECK_ACTION, atoi(argv[1])) != 1) {\n"
3346 "            fprintf(stderr, \"mallopt() failed\");\n"
3347 "            exit(EXIT_FAILURE);\n"
3348 "        }\n"
3349 "    }\n"
3350 msgstr ""
3351
3352 #. type: Plain text
3353 #: build/C/man3/mallopt.3:556
3354 #, no-wrap
3355 msgid ""
3356 "    p = malloc(1000);\n"
3357 "    if (p == NULL) {\n"
3358 "        fprintf(stderr, \"malloc() failed\");\n"
3359 "        exit(EXIT_FAILURE);\n"
3360 "    }\n"
3361 msgstr ""
3362
3363 #. type: Plain text
3364 #: build/C/man3/mallopt.3:559
3365 #, no-wrap
3366 msgid ""
3367 "    free(p);\n"
3368 "    printf(\"main(): returned from first free() call\\en\");\n"
3369 msgstr ""
3370
3371 #. type: Plain text
3372 #: build/C/man3/mallopt.3:562
3373 #, no-wrap
3374 msgid ""
3375 "    free(p);\n"
3376 "    printf(\"main(): returned from second free() call\\en\");\n"
3377 msgstr ""
3378
3379 #. type: Plain text
3380 #: build/C/man3/mallopt.3:580
3381 msgid ""
3382 "B<mmap>(2), B<sbrk>(2), B<mallinfo>(3), B<malloc>(3), B<malloc_hook>(3), "
3383 "B<malloc_info>(3), B<malloc_stats>(3), B<malloc_trim>(3), B<mcheck>(3), "
3384 "B<mtrace>(3), B<posix_memalign>(3)"
3385 msgstr ""
3386
3387 #. type: TH
3388 #: build/C/man3/mcheck.3:25
3389 #, no-wrap
3390 msgid "MCHECK"
3391 msgstr ""
3392
3393 #. type: TH
3394 #: build/C/man3/mcheck.3:25 build/C/man3/mtrace.3:25
3395 #, no-wrap
3396 msgid "2012-04-18"
3397 msgstr ""
3398
3399 #. type: Plain text
3400 #: build/C/man3/mcheck.3:28
3401 msgid ""
3402 "mcheck, mcheck_check_all, mcheck_pedantic, mprobe - heap consistency "
3403 "checking"
3404 msgstr ""
3405
3406 #. type: Plain text
3407 #: build/C/man3/mcheck.3:31
3408 #, no-wrap
3409 msgid "B<#include E<lt>mcheck.hE<gt>>\n"
3410 msgstr ""
3411
3412 #. type: Plain text
3413 #: build/C/man3/mcheck.3:33
3414 #, no-wrap
3415 msgid "B<int mcheck(void (*>I<abortfunc>B<)(enum mcheck_status >I<mstatus>B<));>\n"
3416 msgstr ""
3417
3418 #. type: Plain text
3419 #: build/C/man3/mcheck.3:35
3420 #, no-wrap
3421 msgid ""
3422 "B<int mcheck_pedantic(void (*>I<abortfunc>B<)(enum mcheck_status "
3423 ">I<mstatus>B<));>\n"
3424 msgstr ""
3425
3426 #. type: Plain text
3427 #: build/C/man3/mcheck.3:37
3428 #, no-wrap
3429 msgid "B<void mcheck_check_all(void);>\n"
3430 msgstr ""
3431
3432 #. type: Plain text
3433 #: build/C/man3/mcheck.3:39
3434 #, no-wrap
3435 msgid "B<enum mcheck_status mprobe(void *>I<ptr>B<);>\n"
3436 msgstr ""
3437
3438 #. type: Plain text
3439 #: build/C/man3/mcheck.3:51
3440 msgid ""
3441 "The B<mcheck>()  function installs a set of debugging hooks for the "
3442 "B<malloc>(3)  family of memory-allocation functions.  These hooks cause "
3443 "certain consistency checks to be performed on the state of the heap.  The "
3444 "checks can detect application errors such as freeing a block of memory more "
3445 "than once or corrupting the bookkeeping data structures that immediately "
3446 "precede a block of allocated memory."
3447 msgstr ""
3448
3449 #. type: Plain text
3450 #: build/C/man3/mcheck.3:63
3451 msgid ""
3452 "To be effective, the B<mcheck>()  function must be called before the first "
3453 "call to B<malloc>(3)  or a related function.  In cases where this is "
3454 "difficult to ensure, linking the program with I<-mcheck> inserts an implicit "
3455 "call to B<mcheck>()  (with a NULL argument)  before the first call to a "
3456 "memory-allocation function."
3457 msgstr ""
3458
3459 #. type: Plain text
3460 #: build/C/man3/mcheck.3:71
3461 msgid ""
3462 "The B<mcheck_pedantic>()  function is similar to B<mcheck>(), but performs "
3463 "checks on all allocated blocks whenever one of the memory-allocation "
3464 "functions is called.  This can be very slow!"
3465 msgstr ""
3466
3467 #. type: Plain text
3468 #: build/C/man3/mcheck.3:78
3469 msgid ""
3470 "The B<mcheck_check_all>()  function causes an immediate check on all "
3471 "allocated blocks.  This call is effective only if B<mcheck>()  is called "
3472 "beforehand."
3473 msgstr ""
3474
3475 #. type: Plain text
3476 #: build/C/man3/mcheck.3:91
3477 msgid ""
3478 "If the system detects an inconsistency in the heap, the caller-supplied "
3479 "function pointed to by I<abortfunc> is invoked with a single argument "
3480 "argument, I<mstatus>, that indicates what type of inconsistency was "
3481 "detected.  If I<abortfunc> is NULL, a default function prints an error "
3482 "message on I<stderr> and calls B<abort>(3)."
3483 msgstr ""
3484
3485 #. type: Plain text
3486 #: build/C/man3/mcheck.3:103
3487 msgid ""
3488 "The B<mprobe>()  function performs a consistency check on the block of "
3489 "allocated memory pointed to by I<ptr>.  The B<mcheck>()  function should be "
3490 "called beforehand (otherwise B<mprobe>()  returns B<MCHECK_DISABLED>)."
3491 msgstr ""
3492
3493 #. type: Plain text
3494 #: build/C/man3/mcheck.3:111
3495 msgid ""
3496 "The following list describes the values returned by B<mprobe>()  or passed "
3497 "as the I<mstatus> argument when I<abortfunc> is invoked:"
3498 msgstr ""
3499
3500 #. type: TP
3501 #: build/C/man3/mcheck.3:111
3502 #, no-wrap
3503 msgid "B<MCHECK_DISABLED> (B<mprobe>() only)"
3504 msgstr ""
3505
3506 #. type: Plain text
3507 #: build/C/man3/mcheck.3:116
3508 msgid ""
3509 "B<mcheck>()  was not called before the first memory allocation function was "
3510 "called.  Consistency checking is not possible."
3511 msgstr ""
3512
3513 #. type: TP
3514 #: build/C/man3/mcheck.3:116
3515 #, no-wrap
3516 msgid "B<MCHECK_OK> (B<mprobe>() only)"
3517 msgstr ""
3518
3519 #. type: Plain text
3520 #: build/C/man3/mcheck.3:119
3521 msgid "No inconsistency detected."
3522 msgstr ""
3523
3524 #. type: TP
3525 #: build/C/man3/mcheck.3:119
3526 #, no-wrap
3527 msgid "B<MCHECK_HEAD>"
3528 msgstr ""
3529
3530 #. type: Plain text
3531 #: build/C/man3/mcheck.3:122
3532 msgid "Memory preceding an allocated block was clobbered."
3533 msgstr ""
3534
3535 #. type: TP
3536 #: build/C/man3/mcheck.3:122
3537 #, no-wrap
3538 msgid "B<MCHECK_TAIL>"
3539 msgstr ""
3540
3541 #. type: Plain text
3542 #: build/C/man3/mcheck.3:125
3543 msgid "Memory following an allocated block was clobbered."
3544 msgstr ""
3545
3546 #. type: TP
3547 #: build/C/man3/mcheck.3:125
3548 #, no-wrap
3549 msgid "B<MCHECK_FREE>"
3550 msgstr ""
3551
3552 #. type: Plain text
3553 #: build/C/man3/mcheck.3:129
3554 msgid "A block of memory was freed twice."
3555 msgstr ""
3556
3557 #. type: Plain text
3558 #: build/C/man3/mcheck.3:134
3559 msgid "B<mcheck>()  and B<mcheck_pedantic>()  return 0 on success, or -1 on error."
3560 msgstr ""
3561
3562 #. type: Plain text
3563 #: build/C/man3/mcheck.3:145
3564 msgid ""
3565 "The B<mcheck_pedantic>()  and B<mcheck_check_all>()  functions are available "
3566 "since glibc 2.2.  The B<mcheck>()  and B<mprobe>()  functions are present "
3567 "since at least glibc 2.0"
3568 msgstr ""
3569
3570 #.  But is MALLOC_CHECK_ slower?
3571 #. type: Plain text
3572 #: build/C/man3/mcheck.3:159
3573 msgid ""
3574 "Linking a program with I<-lmcheck> and using the B<MALLOC_CHECK_> "
3575 "environment variable (described in B<mallopt>(3))  cause the same kinds of "
3576 "errors to be detected.  But, using B<MALLOC_CHECK_> does not require the "
3577 "application to be relinked."
3578 msgstr ""
3579
3580 #. type: Plain text
3581 #: build/C/man3/mcheck.3:165
3582 msgid ""
3583 "The program below calls B<mcheck>()  with a NULL argument and then frees the "
3584 "same block of memory twice.  The following shell session demonstrates what "
3585 "happens when running the program:"
3586 msgstr ""
3587
3588 #. type: Plain text
3589 #: build/C/man3/mcheck.3:170
3590 #, no-wrap
3591 msgid ""
3592 "$B< ./a.out>\n"
3593 "About to free\n"
3594 msgstr ""
3595
3596 #. type: Plain text
3597 #: build/C/man3/mcheck.3:174
3598 #, no-wrap
3599 msgid ""
3600 "About to free a second time\n"
3601 "block freed twice\n"
3602 "Aborted (core dumped)\n"
3603 msgstr ""
3604
3605 #. type: Plain text
3606 #: build/C/man3/mcheck.3:182
3607 #, no-wrap
3608 msgid ""
3609 "#include E<lt>stdlib.hE<gt>\n"
3610 "#include E<lt>stdio.hE<gt>\n"
3611 "#include E<lt>mcheck.hE<gt>\n"
3612 msgstr ""
3613
3614 #. type: Plain text
3615 #: build/C/man3/mcheck.3:190
3616 #, no-wrap
3617 msgid ""
3618 "    if (mcheck(NULL) != 0) {\n"
3619 "        fprintf(stderr, \"mcheck() failed\\en\");\n"
3620 msgstr ""
3621
3622 #. type: Plain text
3623 #: build/C/man3/mcheck.3:193
3624 #, no-wrap
3625 msgid ""
3626 "        exit(EXIT_FAILURE);\n"
3627 "    }\n"
3628 msgstr ""
3629
3630 #. type: Plain text
3631 #: build/C/man3/mcheck.3:195
3632 #, no-wrap
3633 msgid "    p = malloc(1000);\n"
3634 msgstr ""
3635
3636 #. type: Plain text
3637 #: build/C/man3/mcheck.3:200
3638 #, no-wrap
3639 msgid ""
3640 "    fprintf(stderr, \"About to free\\en\");\n"
3641 "    free(p);\n"
3642 "    fprintf(stderr, \"\\enAbout to free a second time\\en\");\n"
3643 "    free(p);\n"
3644 msgstr ""
3645
3646 #. type: Plain text
3647 #: build/C/man3/mcheck.3:208
3648 msgid "B<malloc>(3), B<mallopt>(3), B<mtrace>(3)"
3649 msgstr ""
3650
3651 #. type: TH
3652 #: build/C/man2/mlock.2:26
3653 #, no-wrap
3654 msgid "MLOCK"
3655 msgstr ""
3656
3657 #. type: TH
3658 #: build/C/man2/mlock.2:26
3659 #, no-wrap
3660 msgid "2011-09-14"
3661 msgstr ""
3662
3663 #. type: Plain text
3664 #: build/C/man2/mlock.2:29
3665 msgid "mlock, munlock, mlockall, munlockall - lock and unlock memory"
3666 msgstr ""
3667
3668 #. type: Plain text
3669 #: build/C/man2/mlock.2:32 build/C/man2/mmap.2:46 build/C/man2/mmap2.2:35 build/C/man2/mprotect.2:44 build/C/man2/mremap.2:38
3670 #, no-wrap
3671 msgid "B<#include E<lt>sys/mman.hE<gt>>\n"
3672 msgstr ""
3673
3674 #. type: Plain text
3675 #: build/C/man2/mlock.2:35
3676 #, no-wrap
3677 msgid ""
3678 "B<int mlock(const void *>I<addr>B<, size_t >I<len>B<);>\n"
3679 "B<int munlock(const void *>I<addr>B<, size_t >I<len>B<);>\n"
3680 msgstr ""
3681
3682 #. type: Plain text
3683 #: build/C/man2/mlock.2:38
3684 #, no-wrap
3685 msgid ""
3686 "B<int mlockall(int >I<flags>B<);>\n"
3687 "B<int munlockall(void);>\n"
3688 msgstr ""
3689
3690 #. type: Plain text
3691 #: build/C/man2/mlock.2:54
3692 msgid ""
3693 "B<mlock>()  and B<mlockall>()  respectively lock part or all of the calling "
3694 "process's virtual address space into RAM, preventing that memory from being "
3695 "paged to the swap area.  B<munlock>()  and B<munlockall>()  perform the "
3696 "converse operation, respectively unlocking part or all of the calling "
3697 "process's virtual address space, so that pages in the specified virtual "
3698 "address range may once more to be swapped out if required by the kernel "
3699 "memory manager.  Memory locking and unlocking are performed in units of "
3700 "whole pages."
3701 msgstr ""
3702
3703 #. type: SS
3704 #: build/C/man2/mlock.2:54
3705 #, no-wrap
3706 msgid "mlock() and munlock()"
3707 msgstr ""
3708
3709 #. type: Plain text
3710 #: build/C/man2/mlock.2:64
3711 msgid ""
3712 "B<mlock>()  locks pages in the address range starting at I<addr> and "
3713 "continuing for I<len> bytes.  All pages that contain a part of the specified "
3714 "address range are guaranteed to be resident in RAM when the call returns "
3715 "successfully; the pages are guaranteed to stay in RAM until later unlocked."
3716 msgstr ""
3717
3718 #. type: Plain text
3719 #: build/C/man2/mlock.2:73
3720 msgid ""
3721 "B<munlock>()  unlocks pages in the address range starting at I<addr> and "
3722 "continuing for I<len> bytes.  After this call, all pages that contain a part "
3723 "of the specified memory range can be moved to external swap space again by "
3724 "the kernel."
3725 msgstr ""
3726
3727 #. type: SS
3728 #: build/C/man2/mlock.2:73
3729 #, no-wrap
3730 msgid "mlockall() and munlockall()"
3731 msgstr ""
3732
3733 #. type: Plain text
3734 #: build/C/man2/mlock.2:83
3735 msgid ""
3736 "B<mlockall>()  locks all pages mapped into the address space of the calling "
3737 "process.  This includes the pages of the code, data and stack segment, as "
3738 "well as shared libraries, user space kernel data, shared memory, and "
3739 "memory-mapped files.  All mapped pages are guaranteed to be resident in RAM "
3740 "when the call returns successfully; the pages are guaranteed to stay in RAM "
3741 "until later unlocked."
3742 msgstr ""
3743
3744 #. type: Plain text
3745 #: build/C/man2/mlock.2:88
3746 msgid ""
3747 "The I<flags> argument is constructed as the bitwise OR of one or more of the "
3748 "following constants:"
3749 msgstr ""
3750
3751 #. type: TP
3752 #: build/C/man2/mlock.2:88
3753 #, no-wrap
3754 msgid "B<MCL_CURRENT>"
3755 msgstr ""
3756
3757 #. type: Plain text
3758 #: build/C/man2/mlock.2:92
3759 msgid ""
3760 "Lock all pages which are currently mapped into the address space of the "
3761 "process."
3762 msgstr ""
3763
3764 #. type: TP
3765 #: build/C/man2/mlock.2:92
3766 #, no-wrap
3767 msgid "B<MCL_FUTURE>"
3768 msgstr ""
3769
3770 #. type: Plain text
3771 #: build/C/man2/mlock.2:99
3772 msgid ""
3773 "Lock all pages which will become mapped into the address space of the "
3774 "process in the future.  These could be for instance new pages required by a "
3775 "growing heap and stack as well as new memory mapped files or shared memory "
3776 "regions."
3777 msgstr ""
3778
3779 #. type: Plain text
3780 #: build/C/man2/mlock.2:112
3781 msgid ""
3782 "If B<MCL_FUTURE> has been specified, then a later system call (e.g., "
3783 "B<mmap>(2), B<sbrk>(2), B<malloc>(3)), may fail if it would cause the number "
3784 "of locked bytes to exceed the permitted maximum (see below).  In the same "
3785 "circumstances, stack growth may likewise fail: the kernel will deny stack "
3786 "expansion and deliver a B<SIGSEGV> signal to the process."
3787 msgstr ""
3788
3789 #. type: Plain text
3790 #: build/C/man2/mlock.2:116
3791 msgid ""
3792 "B<munlockall>()  unlocks all pages mapped into the address space of the "
3793 "calling process."
3794 msgstr ""
3795
3796 #. type: Plain text
3797 #: build/C/man2/mlock.2:122
3798 msgid ""
3799 "On success these system calls return 0.  On error, -1 is returned, I<errno> "
3800 "is set appropriately, and no changes are made to any locks in the address "
3801 "space of the process."
3802 msgstr ""
3803
3804 #. type: Plain text
3805 #: build/C/man2/mlock.2:131
3806 msgid ""
3807 "(Linux 2.6.9 and later) the caller had a nonzero B<RLIMIT_MEMLOCK> soft "
3808 "resource limit, but tried to lock more memory than the limit permitted.  "
3809 "This limit is not enforced if the process is privileged (B<CAP_IPC_LOCK>)."
3810 msgstr ""
3811
3812 #.  In the case of mlock(), this check is somewhat buggy: it doesn't
3813 #.  take into account whether the to-be-locked range overlaps with
3814 #.  already locked pages.  Thus, suppose we allocate
3815 #.  (num_physpages / 4 + 1) of memory, and lock those pages once using
3816 #.  mlock(), and then lock the *same* page range a second time.
3817 #.  In the case, the second mlock() call will fail, since the check
3818 #.  calculates that the process is trying to lock (num_physpages / 2 + 2)
3819 #.  pages, which of course is not true.  (MTK, Nov 04, kernel 2.4.28)
3820 #. type: Plain text
3821 #: build/C/man2/mlock.2:143
3822 msgid ""
3823 "(Linux 2.4 and earlier) the calling process tried to lock more than half of "
3824 "RAM."
3825 msgstr ""
3826
3827 #. SVr4 documents an additional EAGAIN error code.
3828 #. type: Plain text
3829 #: build/C/man2/mlock.2:149
3830 msgid ""
3831 "The caller is not privileged, but needs privilege (B<CAP_IPC_LOCK>)  to "
3832 "perform the requested operation."
3833 msgstr ""
3834
3835 #. type: Plain text
3836 #: build/C/man2/mlock.2:154
3837 msgid "For B<mlock>()  and B<munlock>():"
3838 msgstr ""
3839
3840 #. type: Plain text
3841 #: build/C/man2/mlock.2:157
3842 msgid "Some or all of the specified address range could not be locked."
3843 msgstr ""
3844
3845 #. type: Plain text
3846 #: build/C/man2/mlock.2:164
3847 msgid ""
3848 "The result of the addition I<start>+I<len> was less than I<start> (e.g., the "
3849 "addition may have resulted in an overflow)."
3850 msgstr ""
3851
3852 #. type: Plain text
3853 #: build/C/man2/mlock.2:169
3854 msgid "(Not on Linux)  I<addr> was not a multiple of the page size."
3855 msgstr ""
3856
3857 #. type: Plain text
3858 #: build/C/man2/mlock.2:173
3859 msgid ""
3860 "Some of the specified address range does not correspond to mapped pages in "
3861 "the address space of the process."
3862 msgstr ""
3863
3864 #. type: Plain text
3865 #: build/C/man2/mlock.2:176
3866 msgid "For B<mlockall>():"
3867 msgstr ""
3868
3869 #. type: Plain text
3870 #: build/C/man2/mlock.2:179
3871 msgid "Unknown I<flags> were specified."
3872 msgstr ""
3873
3874 #. type: Plain text
3875 #: build/C/man2/mlock.2:182
3876 msgid "For B<munlockall>():"
3877 msgstr ""
3878
3879 #. type: Plain text
3880 #: build/C/man2/mlock.2:186
3881 msgid "(Linux 2.6.8 and earlier) The caller was not privileged (B<CAP_IPC_LOCK>)."
3882 msgstr ""
3883
3884 #. type: Plain text
3885 #: build/C/man2/mlock.2:188
3886 msgid "POSIX.1-2001, SVr4."
3887 msgstr ""
3888
3889 #. type: SH
3890 #: build/C/man2/mlock.2:188 build/C/man2/mmap.2:501 build/C/man2/msync.2:105
3891 #, no-wrap
3892 msgid "AVAILABILITY"
3893 msgstr ""
3894
3895 #. type: Plain text
3896 #: build/C/man2/mlock.2:200
3897 msgid ""
3898 "On POSIX systems on which B<mlock>()  and B<munlock>()  are available, "
3899 "B<_POSIX_MEMLOCK_RANGE> is defined in I<E<lt>unistd.hE<gt>> and the number "
3900 "of bytes in a page can be determined from the constant B<PAGESIZE> (if "
3901 "defined) in I<E<lt>limits.hE<gt>> or by calling I<sysconf(_SC_PAGESIZE)>."
3902 msgstr ""
3903
3904 #.  POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
3905 #.  -1: unavailable, 0: ask using sysconf().
3906 #.  glibc defines it to 1.
3907 #. type: Plain text
3908 #: build/C/man2/mlock.2:213
3909 msgid ""
3910 "On POSIX systems on which B<mlockall>()  and B<munlockall>()  are available, "
3911 "B<_POSIX_MEMLOCK> is defined in I<E<lt>unistd.hE<gt>> to a value greater "
3912 "than 0.  (See also B<sysconf>(3).)"
3913 msgstr ""
3914
3915 #. type: Plain text
3916 #: build/C/man2/mlock.2:231
3917 msgid ""
3918 "Memory locking has two main applications: real-time algorithms and "
3919 "high-security data processing.  Real-time applications require deterministic "
3920 "timing, and, like scheduling, paging is one major cause of unexpected "
3921 "program execution delays.  Real-time applications will usually also switch "
3922 "to a real-time scheduler with B<sched_setscheduler>(2).  Cryptographic "
3923 "security software often handles critical bytes like passwords or secret keys "
3924 "as data structures.  As a result of paging, these secrets could be "
3925 "transferred onto a persistent swap store medium, where they might be "
3926 "accessible to the enemy long after the security software has erased the "
3927 "secrets in RAM and terminated.  (But be aware that the suspend mode on "
3928 "laptops and some desktop computers will save a copy of the system's RAM to "
3929 "disk, regardless of memory locks.)"
3930 msgstr ""
3931
3932 #. type: Plain text
3933 #: build/C/man2/mlock.2:244
3934 msgid ""
3935 "Real-time processes that are using B<mlockall>()  to prevent delays on page "
3936 "faults should reserve enough locked stack pages before entering the "
3937 "time-critical section, so that no page fault can be caused by function "
3938 "calls.  This can be achieved by calling a function that allocates a "
3939 "sufficiently large automatic variable (an array) and writes to the memory "
3940 "occupied by this array in order to touch these stack pages.  This way, "
3941 "enough pages will be mapped for the stack and can be locked into RAM.  The "
3942 "dummy writes ensure that not even copy-on-write page faults can occur in the "
3943 "critical section."
3944 msgstr ""
3945
3946 #. type: Plain text
3947 #: build/C/man2/mlock.2:250
3948 msgid ""
3949 "Memory locks are not inherited by a child created via B<fork>(2)  and are "
3950 "automatically removed (unlocked) during an B<execve>(2)  or when the process "
3951 "terminates."
3952 msgstr ""
3953
3954 #. type: Plain text
3955 #: build/C/man2/mlock.2:254
3956 msgid ""
3957 "The memory lock on an address range is automatically removed if the address "
3958 "range is unmapped via B<munmap>(2)."
3959 msgstr ""
3960
3961 #. type: Plain text
3962 #: build/C/man2/mlock.2:267
3963 msgid ""
3964 "Memory locks do not stack, that is, pages which have been locked several "
3965 "times by calls to B<mlock>()  or B<mlockall>()  will be unlocked by a single "
3966 "call to B<munlock>()  for the corresponding range or by B<munlockall>().  "
3967 "Pages which are mapped to several locations or by several processes stay "
3968 "locked into RAM as long as they are locked at least at one location or by at "
3969 "least one process."
3970 msgstr ""
3971
3972 #. type: Plain text
3973 #: build/C/man2/mlock.2:278
3974 msgid ""
3975 "Under Linux, B<mlock>()  and B<munlock>()  automatically round I<addr> down "
3976 "to the nearest page boundary.  However, POSIX.1-2001 allows an "
3977 "implementation to require that I<addr> is page aligned, so portable "
3978 "applications should ensure this."
3979 msgstr ""
3980
3981 #. type: Plain text
3982 #: build/C/man2/mlock.2:291
3983 msgid ""
3984 "The I<VmLck> field of the Linux-specific I</proc/PID/status> file shows how "
3985 "many kilobytes of memory the process with ID I<PID> has locked using "
3986 "B<mlock>(), B<mlockall>(), and B<mmap>(2)  B<MAP_LOCKED>."
3987 msgstr ""
3988
3989 #. type: SS
3990 #: build/C/man2/mlock.2:291
3991 #, no-wrap
3992 msgid "Limits and permissions"
3993 msgstr ""
3994
3995 #. type: Plain text
3996 #: build/C/man2/mlock.2:298
3997 msgid ""
3998 "In Linux 2.6.8 and earlier, a process must be privileged (B<CAP_IPC_LOCK>)  "
3999 "in order to lock memory and the B<RLIMIT_MEMLOCK> soft resource limit "
4000 "defines a limit on how much memory the process may lock."
4001 msgstr ""
4002
4003 #. type: Plain text
4004 #: build/C/man2/mlock.2:304
4005 msgid ""
4006 "Since Linux 2.6.9, no limits are placed on the amount of memory that a "
4007 "privileged process can lock and the B<RLIMIT_MEMLOCK> soft resource limit "
4008 "instead defines a limit on how much memory an unprivileged process may lock."
4009 msgstr ""
4010
4011 #. type: Plain text
4012 #: build/C/man2/mlock.2:312
4013 msgid ""
4014 "In the 2.4 series Linux kernels up to and including 2.4.17, a bug caused the "
4015 "B<mlockall>()  B<MCL_FUTURE> flag to be inherited across a B<fork>(2).  This "
4016 "was rectified in kernel 2.4.18."
4017 msgstr ""
4018
4019 #.  See the following LKML thread:
4020 #.  http://marc.theaimsgroup.com/?l=linux-kernel&m=113801392825023&w=2
4021 #.  "Rationale for RLIMIT_MEMLOCK"
4022 #.  23 Jan 2006
4023 #. type: Plain text
4024 #: build/C/man2/mlock.2:329
4025 msgid ""
4026 "Since kernel 2.6.9, if a privileged process calls I<mlockall(MCL_FUTURE)> "
4027 "and later drops privileges (loses the B<CAP_IPC_LOCK> capability by, for "
4028 "example, setting its effective UID to a nonzero value), then subsequent "
4029 "memory allocations (e.g., B<mmap>(2), B<brk>(2))  will fail if the "
4030 "B<RLIMIT_MEMLOCK> resource limit is encountered."
4031 msgstr ""
4032
4033 #. type: Plain text
4034 #: build/C/man2/mlock.2:336
4035 msgid ""
4036 "B<mmap>(2), B<setrlimit>(2), B<shmctl>(2), B<sysconf>(3), B<proc>(5), "
4037 "B<capabilities>(7)"
4038 msgstr ""
4039
4040 #. type: TH
4041 #: build/C/man2/mmap.2:40
4042 #, no-wrap
4043 msgid "MMAP"
4044 msgstr ""
4045
4046 #. type: TH
4047 #: build/C/man2/mmap.2:40
4048 #, no-wrap
4049 msgid "2013-04-17"
4050 msgstr ""
4051
4052 #. type: Plain text
4053 #: build/C/man2/mmap.2:43
4054 msgid "mmap, munmap - map or unmap files or devices into memory"
4055 msgstr ""
4056
4057 #. type: Plain text
4058 #: build/C/man2/mmap.2:51
4059 #, no-wrap
4060 msgid ""
4061 "B<void *mmap(void *>I<addr>B<, size_t >I<length>B<, int >I<prot>B<, int "
4062 ">I<flags>B<,>\n"
4063 "B<           int >I<fd>B<, off_t >I<offset>B<);>\n"
4064 "B<int munmap(void *>I<addr>B<, size_t >I<length>B<);>\n"
4065 msgstr ""
4066
4067 #. type: Plain text
4068 #: build/C/man2/mmap.2:54
4069 msgid "See NOTES for information on feature test macro requirements."
4070 msgstr ""
4071
4072 #. type: Plain text
4073 #: build/C/man2/mmap.2:63
4074 msgid ""
4075 "B<mmap>()  creates a new mapping in the virtual address space of the calling "
4076 "process.  The starting address for the new mapping is specified in I<addr>.  "
4077 "The I<length> argument specifies the length of the mapping."
4078 msgstr ""
4079
4080 #.  Before Linux 2.6.24, the address was rounded up to the next page
4081 #.  boundary; since 2.6.24, it is rounded down!
4082 #. type: Plain text
4083 #: build/C/man2/mmap.2:77
4084 msgid ""
4085 "If I<addr> is NULL, then the kernel chooses the address at which to create "
4086 "the mapping; this is the most portable method of creating a new mapping.  If "
4087 "I<addr> is not NULL, then the kernel takes it as a hint about where to place "
4088 "the mapping; on Linux, the mapping will be created at a nearby page "
4089 "boundary.  The address of the new mapping is returned as the result of the "
4090 "call."
4091 msgstr ""
4092
4093 #. type: Plain text
4094 #: build/C/man2/mmap.2:89
4095 msgid ""
4096 "The contents of a file mapping (as opposed to an anonymous mapping; see "
4097 "B<MAP_ANONYMOUS> below), are initialized using I<length> bytes starting at "
4098 "offset I<offset> in the file (or other object) referred to by the file "
4099 "descriptor I<fd>.  I<offset> must be a multiple of the page size as returned "
4100 "by I<sysconf(_SC_PAGE_SIZE)>."
4101 msgstr ""
4102
4103 #. type: Plain text
4104 #: build/C/man2/mmap.2:97
4105 msgid ""
4106 "The I<prot> argument describes the desired memory protection of the mapping "
4107 "(and must not conflict with the open mode of the file).  It is either "
4108 "B<PROT_NONE> or the bitwise OR of one or more of the following flags:"
4109 msgstr ""
4110
4111 #. type: TP
4112 #: build/C/man2/mmap.2:97 build/C/man2/mprotect.2:73
4113 #, no-wrap
4114 msgid "B<PROT_EXEC>"
4115 msgstr ""
4116
4117 #. type: Plain text
4118 #: build/C/man2/mmap.2:100
4119 msgid "Pages may be executed."
4120 msgstr ""
4121
4122 #. type: TP
4123 #: build/C/man2/mmap.2:100 build/C/man2/mprotect.2:67
4124 #, no-wrap
4125 msgid "B<PROT_READ>"
4126 msgstr ""
4127
4128 #. type: Plain text
4129 #: build/C/man2/mmap.2:103
4130 msgid "Pages may be read."
4131 msgstr ""
4132
4133 #. type: TP
4134 #: build/C/man2/mmap.2:103 build/C/man2/mprotect.2:70
4135 #, no-wrap
4136 msgid "B<PROT_WRITE>"
4137 msgstr ""
4138
4139 #. type: Plain text
4140 #: build/C/man2/mmap.2:106
4141 msgid "Pages may be written."
4142 msgstr ""
4143
4144 #. type: TP
4145 #: build/C/man2/mmap.2:106 build/C/man2/mprotect.2:64
4146 #, no-wrap
4147 msgid "B<PROT_NONE>"
4148 msgstr ""
4149
4150 #. type: Plain text
4151 #: build/C/man2/mmap.2:109
4152 msgid "Pages may not be accessed."
4153 msgstr ""
4154
4155 #. type: Plain text
4156 #: build/C/man2/mmap.2:118
4157 msgid ""
4158 "The I<flags> argument determines whether updates to the mapping are visible "
4159 "to other processes mapping the same region, and whether updates are carried "
4160 "through to the underlying file.  This behavior is determined by including "
4161 "exactly one of the following values in I<flags>:"
4162 msgstr ""
4163
4164 #. type: TP
4165 #: build/C/man2/mmap.2:118
4166 #, no-wrap
4167 msgid "B<MAP_SHARED>"
4168 msgstr ""
4169
4170 #. type: Plain text
4171 #: build/C/man2/mmap.2:128
4172 msgid ""
4173 "Share this mapping.  Updates to the mapping are visible to other processes "
4174 "that map this file, and are carried through to the underlying file.  The "
4175 "file may not actually be updated until B<msync>(2)  or B<munmap>()  is "
4176 "called."
4177 msgstr ""
4178
4179 #. type: TP
4180 #: build/C/man2/mmap.2:128
4181 #, no-wrap
4182 msgid "B<MAP_PRIVATE>"
4183 msgstr ""
4184
4185 #. type: Plain text
4186 #: build/C/man2/mmap.2:137
4187 msgid ""
4188 "Create a private copy-on-write mapping.  Updates to the mapping are not "
4189 "visible to other processes mapping the same file, and are not carried "
4190 "through to the underlying file.  It is unspecified whether changes made to "
4191 "the file after the B<mmap>()  call are visible in the mapped region."
4192 msgstr ""
4193
4194 #. type: Plain text
4195 #: build/C/man2/mmap.2:139
4196 msgid "Both of these flags are described in POSIX.1-2001."
4197 msgstr ""
4198
4199 #. type: Plain text
4200 #: build/C/man2/mmap.2:142
4201 msgid "In addition, zero or more of the following values can be ORed in I<flags>:"
4202 msgstr ""
4203
4204 #. type: TP
4205 #: build/C/man2/mmap.2:142
4206 #, no-wrap
4207 msgid "B<MAP_32BIT> (since Linux 2.4.20, 2.6)"
4208 msgstr ""
4209
4210 #.  See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08
4211 #. type: Plain text
4212 #: build/C/man2/mmap.2:158
4213 msgid ""
4214 "Put the mapping into the first 2 Gigabytes of the process address space.  "
4215 "This flag is supported only on x86-64, for 64-bit programs.  It was added to "
4216 "allow thread stacks to be allocated somewhere in the first 2GB of memory, so "
4217 "as to improve context-switch performance on some early 64-bit processors.  "
4218 "Modern x86-64 processors no longer have this performance problem, so use of "
4219 "this flag is not required on those systems.  The B<MAP_32BIT> flag is "
4220 "ignored when B<MAP_FIXED> is set."
4221 msgstr ""
4222
4223 #. type: TP
4224 #: build/C/man2/mmap.2:158
4225 #, no-wrap
4226 msgid "B<MAP_ANON>"
4227 msgstr ""
4228
4229 #. type: Plain text
4230 #: build/C/man2/mmap.2:163
4231 msgid "Synonym for B<MAP_ANONYMOUS>.  Deprecated."
4232 msgstr ""
4233
4234 #. type: TP
4235 #: build/C/man2/mmap.2:163
4236 #, no-wrap
4237 msgid "B<MAP_ANONYMOUS>"
4238 msgstr ""
4239
4240 #. type: Plain text
4241 #: build/C/man2/mmap.2:185
4242 msgid ""
4243 "The mapping is not backed by any file; its contents are initialized to "
4244 "zero.  The I<fd> and I<offset> arguments are ignored; however, some "
4245 "implementations require I<fd> to be -1 if B<MAP_ANONYMOUS> (or B<MAP_ANON>)  "
4246 "is specified, and portable applications should ensure this.  The use of "
4247 "B<MAP_ANONYMOUS> in conjunction with B<MAP_SHARED> is supported on Linux "
4248 "only since kernel 2.4."
4249 msgstr ""
4250
4251 #. type: TP
4252 #: build/C/man2/mmap.2:185
4253 #, no-wrap
4254 msgid "B<MAP_DENYWRITE>"
4255 msgstr ""
4256
4257 #.  Introduced in 1.1.36, removed in 1.3.24.
4258 #. type: Plain text
4259 #: build/C/man2/mmap.2:193
4260 msgid ""
4261 "This flag is ignored.  (Long ago, it signaled that attempts to write to the "
4262 "underlying file should fail with B<ETXTBUSY>.  But this was a source of "
4263 "denial-of-service attacks.)"
4264 msgstr ""
4265
4266 #. type: TP
4267 #: build/C/man2/mmap.2:193
4268 #, no-wrap
4269 msgid "B<MAP_EXECUTABLE>"
4270 msgstr ""
4271
4272 #.  Introduced in 1.1.38, removed in 1.3.24. Flag tested in proc_follow_link.
4273 #.  (Long ago, it signaled that the underlying file is an executable.
4274 #.  However, that information was not really used anywhere.)
4275 #.  Linus talked about DOS related to MAP_EXECUTABLE, but he was thinking of
4276 #.  MAP_DENYWRITE?
4277 #. type: Plain text
4278 #: build/C/man2/mmap.2:201
4279 msgid "This flag is ignored."
4280 msgstr ""
4281
4282 #. type: TP
4283 #: build/C/man2/mmap.2:201
4284 #, no-wrap
4285 msgid "B<MAP_FILE>"
4286 msgstr ""
4287
4288 #.  On some systems, this was required as the opposite of
4289 #.  MAP_ANONYMOUS -- mtk, 1 May 2007
4290 #. type: Plain text
4291 #: build/C/man2/mmap.2:207
4292 msgid "Compatibility flag.  Ignored."
4293 msgstr ""
4294
4295 #. type: TP
4296 #: build/C/man2/mmap.2:207
4297 #, no-wrap
4298 msgid "B<MAP_FIXED>"
4299 msgstr ""
4300
4301 #. type: Plain text
4302 #: build/C/man2/mmap.2:225
4303 msgid ""
4304 "Don't interpret I<addr> as a hint: place the mapping at exactly that "
4305 "address.  I<addr> must be a multiple of the page size.  If the memory region "
4306 "specified by I<addr> and I<len> overlaps pages of any existing mapping(s), "
4307 "then the overlapped part of the existing mapping(s) will be discarded.  If "
4308 "the specified address cannot be used, B<mmap>()  will fail.  Because "
4309 "requiring a fixed address for a mapping is less portable, the use of this "
4310 "option is discouraged."
4311 msgstr ""
4312
4313 #. type: TP
4314 #: build/C/man2/mmap.2:225
4315 #, no-wrap
4316 msgid "B<MAP_GROWSDOWN>"
4317 msgstr ""
4318
4319 #. type: Plain text
4320 #: build/C/man2/mmap.2:230
4321 msgid ""
4322 "Used for stacks.  Indicates to the kernel virtual memory system that the "
4323 "mapping should extend downward in memory."
4324 msgstr ""
4325
4326 #. type: TP
4327 #: build/C/man2/mmap.2:230
4328 #, no-wrap
4329 msgid "B<MAP_HUGETLB> (since Linux 2.6.32)"
4330 msgstr ""
4331
4332 #. type: Plain text
4333 #: build/C/man2/mmap.2:236
4334 msgid ""
4335 "Allocate the mapping using \"huge pages.\" See the Linux kernel source file "
4336 "I<Documentation/vm/hugetlbpage.txt> for further information."
4337 msgstr ""
4338
4339 #. type: TP
4340 #: build/C/man2/mmap.2:236
4341 #, no-wrap
4342 msgid "B<MAP_LOCKED> (since Linux 2.5.37)"
4343 msgstr ""
4344
4345 #.  If set, the mapped pages will not be swapped out.
4346 #. type: Plain text
4347 #: build/C/man2/mmap.2:242
4348 msgid ""
4349 "Lock the pages of the mapped region into memory in the manner of "
4350 "B<mlock>(2).  This flag is ignored in older kernels."
4351 msgstr ""
4352
4353 #. type: TP
4354 #: build/C/man2/mmap.2:242
4355 #, no-wrap
4356 msgid "B<MAP_NONBLOCK> (since Linux 2.5.46)"
4357 msgstr ""
4358
4359 #. type: Plain text
4360 #: build/C/man2/mmap.2:257
4361 msgid ""
4362 "Only meaningful in conjunction with B<MAP_POPULATE>.  Don't perform "
4363 "read-ahead: create page tables entries only for pages that are already "
4364 "present in RAM.  Since Linux 2.6.23, this flag causes B<MAP_POPULATE> to do "
4365 "nothing.  One day the combination of B<MAP_POPULATE> and B<MAP_NONBLOCK> may "
4366 "be reimplemented."
4367 msgstr ""
4368
4369 #. type: TP
4370 #: build/C/man2/mmap.2:257
4371 #, no-wrap
4372 msgid "B<MAP_NORESERVE>"
4373 msgstr ""
4374
4375 #. type: Plain text
4376 #: build/C/man2/mmap.2:272
4377 msgid ""
4378 "Do not reserve swap space for this mapping.  When swap space is reserved, "
4379 "one has the guarantee that it is possible to modify the mapping.  When swap "
4380 "space is not reserved one might get B<SIGSEGV> upon a write if no physical "
4381 "memory is available.  See also the discussion of the file "
4382 "I</proc/sys/vm/overcommit_memory> in B<proc>(5).  In kernels before 2.6, "
4383 "this flag had effect only for private writable mappings."
4384 msgstr ""
4385
4386 #. type: TP
4387 #: build/C/man2/mmap.2:272
4388 #, no-wrap
4389 msgid "B<MAP_POPULATE> (since Linux 2.5.46)"
4390 msgstr ""
4391
4392 #. type: Plain text
4393 #: build/C/man2/mmap.2:279
4394 msgid ""
4395 "Populate (prefault) page tables for a mapping.  For a file mapping, this "
4396 "causes read-ahead on the file.  Later accesses to the mapping will not be "
4397 "blocked by page faults.  B<MAP_POPULATE> is supported for private mappings "
4398 "only since Linux 2.6.23."
4399 msgstr ""
4400
4401 #. type: TP
4402 #: build/C/man2/mmap.2:279
4403 #, no-wrap
4404 msgid "B<MAP_STACK> (since Linux 2.6.27)"
4405 msgstr ""
4406
4407 #.  See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08
4408 #.  commit cd98a04a59e2f94fa64d5bf1e26498d27427d5e7
4409 #.  http://thread.gmane.org/gmane.linux.kernel/720412
4410 #.  "pthread_create() slow for many threads; also time to revisit 64b
4411 #.   context switch optimization?"
4412 #. type: Plain text
4413 #: build/C/man2/mmap.2:292
4414 msgid ""
4415 "Allocate the mapping at an address suitable for a process or thread stack.  "
4416 "This flag is currently a no-op, but is used in the glibc threading "
4417 "implementation so that if some architectures require special treatment for "
4418 "stack allocations, support can later be transparently implemented for glibc."
4419 msgstr ""
4420
4421 #. type: TP
4422 #: build/C/man2/mmap.2:292
4423 #, no-wrap
4424 msgid "B<MAP_UNINITIALIZED> (since Linux 2.6.33)"
4425 msgstr ""
4426
4427 #. type: Plain text
4428 #: build/C/man2/mmap.2:302
4429 msgid ""
4430 "Don't clear anonymous pages.  This flag is intended to improve performance "
4431 "on embedded devices.  This flag is honored only if the kernel was configured "
4432 "with the B<CONFIG_MMAP_ALLOW_UNINITIALIZED> option.  Because of the security "
4433 "implications, that option is normally enabled only on embedded devices "
4434 "(i.e., devices where one has complete control of the contents of user "
4435 "memory)."
4436 msgstr ""
4437
4438 #. type: Plain text
4439 #: build/C/man2/mmap.2:310
4440 msgid ""
4441 "Of the above flags, only B<MAP_FIXED> is specified in POSIX.1-2001.  "
4442 "However, most systems also support B<MAP_ANONYMOUS> (or its synonym "
4443 "B<MAP_ANON>)."
4444 msgstr ""
4445
4446 #. type: Plain text
4447 #: build/C/man2/mmap.2:317
4448 msgid ""
4449 "Some systems document the additional flags B<MAP_AUTOGROW>, "
4450 "B<MAP_AUTORESRV>, B<MAP_COPY>, and B<MAP_LOCAL>."
4451 msgstr ""
4452
4453 #. type: Plain text
4454 #: build/C/man2/mmap.2:323
4455 msgid ""
4456 "Memory mapped by B<mmap>()  is preserved across B<fork>(2), with the same "
4457 "attributes."
4458 msgstr ""
4459
4460 #. type: Plain text
4461 #: build/C/man2/mmap.2:331
4462 msgid ""
4463 "A file is mapped in multiples of the page size.  For a file that is not a "
4464 "multiple of the page size, the remaining memory is zeroed when mapped, and "
4465 "writes to that region are not written out to the file.  The effect of "
4466 "changing the size of the underlying file of a mapping on the pages that "
4467 "correspond to added or removed regions of the file is unspecified."
4468 msgstr ""
4469
4470 #. type: SS
4471 #: build/C/man2/mmap.2:331
4472 #, no-wrap
4473 msgid "munmap()"
4474 msgstr ""
4475
4476 #. type: Plain text
4477 #: build/C/man2/mmap.2:341
4478 msgid ""
4479 "The B<munmap>()  system call deletes the mappings for the specified address "
4480 "range, and causes further references to addresses within the range to "
4481 "generate invalid memory references.  The region is also automatically "
4482 "unmapped when the process is terminated.  On the other hand, closing the "
4483 "file descriptor does not unmap the region."
4484 msgstr ""
4485
4486 #. type: Plain text
4487 #: build/C/man2/mmap.2:351
4488 msgid ""
4489 "The address I<addr> must be a multiple of the page size.  All pages "
4490 "containing a part of the indicated range are unmapped, and subsequent "
4491 "references to these pages will generate B<SIGSEGV>.  It is not an error if "
4492 "the indicated range does not contain any mapped pages."
4493 msgstr ""
4494
4495 #. type: SS
4496 #: build/C/man2/mmap.2:351
4497 #, no-wrap
4498 msgid "Timestamps changes for file-backed mappings"
4499 msgstr ""
4500
4501 #. type: Plain text
4502 #: build/C/man2/mmap.2:358
4503 msgid ""
4504 "For file-backed mappings, the I<st_atime> field for the mapped file may be "
4505 "updated at any time between the B<mmap>()  and the corresponding unmapping; "
4506 "the first reference to a mapped page will update the field if it has not "
4507 "been already."
4508 msgstr ""
4509
4510 #. type: Plain text
4511 #: build/C/man2/mmap.2:375
4512 msgid ""
4513 "The I<st_ctime> and I<st_mtime> field for a file mapped with B<PROT_WRITE> "
4514 "and B<MAP_SHARED> will be updated after a write to the mapped region, and "
4515 "before a subsequent B<msync>(2)  with the B<MS_SYNC> or B<MS_ASYNC> flag, if "
4516 "one occurs."
4517 msgstr ""
4518
4519 #. type: Plain text
4520 #: build/C/man2/mmap.2:392
4521 msgid ""
4522 "On success, B<mmap>()  returns a pointer to the mapped area.  On error, the "
4523 "value B<MAP_FAILED> (that is, I<(void\\ *)\\ -1>)  is returned, and I<errno> "
4524 "is set appropriately.  On success, B<munmap>()  returns 0, on failure -1, "
4525 "and I<errno> is set (probably to B<EINVAL>)."
4526 msgstr ""
4527
4528 #. type: TP
4529 #: build/C/man2/mmap.2:393 build/C/man2/mprotect.2:86 build/C/man3/shm_open.3:187 build/C/man3/shm_open.3:192 build/C/man2/shmctl.2:302 build/C/man2/shmget.2:189 build/C/man2/shmop.2:191
4530 #, no-wrap
4531 msgid "B<EACCES>"
4532 msgstr ""
4533
4534 #. type: Plain text
4535 #: build/C/man2/mmap.2:413
4536 msgid ""
4537 "A file descriptor refers to a non-regular file.  Or B<MAP_PRIVATE> was "
4538 "requested, but I<fd> is not open for reading.  Or B<MAP_SHARED> was "
4539 "requested and B<PROT_WRITE> is set, but I<fd> is not open in read/write "
4540 "(B<O_RDWR>)  mode.  Or B<PROT_WRITE> is set, but the file is append-only."
4541 msgstr ""
4542
4543 #. type: Plain text
4544 #: build/C/man2/mmap.2:417
4545 msgid ""
4546 "The file has been locked, or too much memory has been locked (see "
4547 "B<setrlimit>(2))."
4548 msgstr ""
4549
4550 #. type: Plain text
4551 #: build/C/man2/mmap.2:423
4552 msgid "I<fd> is not a valid file descriptor (and B<MAP_ANONYMOUS> was not set)."
4553 msgstr ""
4554
4555 #. type: Plain text
4556 #: build/C/man2/mmap.2:431
4557 msgid ""
4558 "We don't like I<addr>, I<length>, or I<offset> (e.g., they are too large, or "
4559 "not aligned on a page boundary)."
4560 msgstr ""
4561
4562 #. type: Plain text
4563 #: build/C/man2/mmap.2:436
4564 msgid "(since Linux 2.6.12)  I<length> was 0."
4565 msgstr ""
4566
4567 #. type: Plain text
4568 #: build/C/man2/mmap.2:444
4569 msgid ""
4570 "I<flags> contained neither B<MAP_PRIVATE> or B<MAP_SHARED>, or contained "
4571 "both of these values."
4572 msgstr ""
4573
4574 #. type: TP
4575 #: build/C/man2/mmap.2:444 build/C/man3/shm_open.3:229 build/C/man2/shmget.2:205
4576 #, no-wrap
4577 msgid "B<ENFILE>"
4578 msgstr ""
4579
4580 #.  [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
4581 #. type: Plain text
4582 #: build/C/man2/mmap.2:452 build/C/man2/shmget.2:209
4583 msgid "The system limit on the total number of open files has been reached."
4584 msgstr ""
4585
4586 #. type: Plain text
4587 #: build/C/man2/mmap.2:456
4588 msgid ""
4589 "The underlying filesystem of the specified file does not support memory "
4590 "mapping."
4591 msgstr ""
4592
4593 #. type: Plain text
4594 #: build/C/man2/mmap.2:460
4595 msgid ""
4596 "No memory is available, or the process's maximum number of mappings would "
4597 "have been exceeded."
4598 msgstr ""
4599
4600 #.  (Since 2.4.25 / 2.6.0.)
4601 #. type: Plain text
4602 #: build/C/man2/mmap.2:469
4603 msgid ""
4604 "The I<prot> argument asks for B<PROT_EXEC> but the mapped area belongs to a "
4605 "file on a filesystem that was mounted no-exec."
4606 msgstr ""
4607
4608 #. type: TP
4609 #: build/C/man2/mmap.2:469
4610 #, no-wrap
4611 msgid "B<ETXTBSY>"
4612 msgstr ""
4613
4614 #. type: Plain text
4615 #: build/C/man2/mmap.2:475
4616 msgid ""
4617 "B<MAP_DENYWRITE> was set but the object specified by I<fd> is open for "
4618 "writing."
4619 msgstr ""
4620
4621 #. type: TP
4622 #: build/C/man2/mmap.2:475 build/C/man2/shmctl.2:344
4623 #, no-wrap
4624 msgid "B<EOVERFLOW>"
4625 msgstr ""
4626
4627 #. type: Plain text
4628 #: build/C/man2/mmap.2:487
4629 msgid ""
4630 "On 32-bit architecture together with the large file extension (i.e., using "
4631 "64-bit I<off_t>): the number of pages used for I<length> plus number of "
4632 "pages used for I<offset> would overflow I<unsigned long> (32 bits)."
4633 msgstr ""
4634
4635 #. type: Plain text
4636 #: build/C/man2/mmap.2:489
4637 msgid "Use of a mapped region can result in these signals:"
4638 msgstr ""
4639
4640 #. type: TP
4641 #: build/C/man2/mmap.2:489
4642 #, no-wrap
4643 msgid "B<SIGSEGV>"
4644 msgstr ""
4645
4646 #. type: Plain text
4647 #: build/C/man2/mmap.2:492
4648 msgid "Attempted write into a region mapped as read-only."
4649 msgstr ""
4650
4651 #. type: TP
4652 #: build/C/man2/mmap.2:492
4653 #, no-wrap
4654 msgid "B<SIGBUS>"
4655 msgstr ""
4656
4657 #. type: Plain text
4658 #: build/C/man2/mmap.2:497
4659 msgid ""
4660 "Attempted access to a portion of the buffer that does not correspond to the "
4661 "file (for example, beyond the end of the file, including the case where "
4662 "another process has truncated the file)."
4663 msgstr ""
4664
4665 #.  SVr4 documents additional error codes ENXIO and ENODEV.
4666 #.  SUSv2 documents additional error codes EMFILE and EOVERFLOW.
4667 #. type: Plain text
4668 #: build/C/man2/mmap.2:501
4669 msgid "SVr4, 4.4BSD, POSIX.1-2001."
4670 msgstr ""
4671
4672 #.  POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
4673 #.  -1: unavailable, 0: ask using sysconf().
4674 #.  glibc defines it to 1.
4675 #. type: Plain text
4676 #: build/C/man2/mmap.2:515
4677 msgid ""
4678 "On POSIX systems on which B<mmap>(), B<msync>(2)  and B<munmap>()  are "
4679 "available, B<_POSIX_MAPPED_FILES> is defined in I<E<lt>unistd.hE<gt>> to a "
4680 "value greater than 0.  (See also B<sysconf>(3).)"
4681 msgstr ""
4682
4683 #.  Since around glibc 2.1/2.2, depending on the platform.
4684 #. type: Plain text
4685 #: build/C/man2/mmap.2:530
4686 msgid ""
4687 "This page describes the interface provided by the glibc B<mmap>()  wrapper "
4688 "function.  Originally, this function invoked a system call of the same "
4689 "name.  Since kernel 2.4, that system call has been superseded by "
4690 "B<mmap2>(2), and nowadays the glibc B<mmap>()  wrapper function invokes "
4691 "B<mmap2>(2)  with a suitably adjusted value for I<offset>."
4692 msgstr ""
4693
4694 #. type: Plain text
4695 #: build/C/man2/mmap.2:543
4696 msgid ""
4697 "On some hardware architectures (e.g., i386), B<PROT_WRITE> implies "
4698 "B<PROT_READ>.  It is architecture dependent whether B<PROT_READ> implies "
4699 "B<PROT_EXEC> or not.  Portable programs should always set B<PROT_EXEC> if "
4700 "they intend to execute code in the new mapping."
4701 msgstr ""
4702
4703 #. type: Plain text
4704 #: build/C/man2/mmap.2:558
4705 msgid ""
4706 "The portable way to create a mapping is to specify I<addr> as 0 (NULL), and "
4707 "omit B<MAP_FIXED> from I<flags>.  In this case, the system chooses the "
4708 "address for the mapping; the address is chosen so as not to conflict with "
4709 "any existing mapping, and will not be 0.  If the B<MAP_FIXED> flag is "
4710 "specified, and I<addr> is 0 (NULL), then the mapped address will be 0 "
4711 "(NULL)."
4712 msgstr ""
4713
4714 #. type: Plain text
4715 #: build/C/man2/mmap.2:587
4716 msgid ""
4717 "Certain I<flags> constants are defined only if either B<_BSD_SOURCE> or "
4718 "B<_SVID_SOURCE> is defined.  (Requiring B<_GNU_SOURCE> also suffices, and "
4719 "requiring that macro specifically would have been more logical, since these "
4720 "flags are all Linux specific.)  The relevant flags are: B<MAP_32BIT>, "
4721 "B<MAP_ANONYMOUS> (and the synonym B<MAP_ANON>), B<MAP_DENYWRITE>, "
4722 "B<MAP_EXECUTABLE>, B<MAP_FILE>, B<MAP_GROWSDOWN>, B<MAP_HUGETLB>, "
4723 "B<MAP_LOCKED>, B<MAP_NONBLOCK>, B<MAP_NORESERVE>, B<MAP_POPULATE>, and "
4724 "B<MAP_STACK>."
4725 msgstr ""
4726
4727 #. type: Plain text
4728 #: build/C/man2/mmap.2:592
4729 msgid ""
4730 "On Linux there are no guarantees like those suggested above under "
4731 "B<MAP_NORESERVE>.  By default, any process can be killed at any moment when "
4732 "the system runs out of memory."
4733 msgstr ""
4734
4735 #. type: Plain text
4736 #: build/C/man2/mmap.2:599
4737 msgid ""
4738 "In kernels before 2.6.7, the B<MAP_POPULATE> flag has effect only if I<prot> "
4739 "is specified as B<PROT_NONE>."
4740 msgstr ""
4741
4742 #. type: Plain text
4743 #: build/C/man2/mmap.2:614
4744 msgid ""
4745 "SUSv3 specifies that B<mmap>()  should fail if I<length> is 0.  However, in "
4746 "kernels before 2.6.12, B<mmap>()  succeeded in this case: no mapping was "
4747 "created and the call returned I<addr>.  Since kernel 2.6.12, B<mmap>()  "
4748 "fails with the error B<EINVAL> for this case."
4749 msgstr ""
4750
4751 #. type: Plain text
4752 #: build/C/man2/mmap.2:630
4753 msgid ""
4754 "POSIX specifies that the system shall always zero fill any partial page at "
4755 "the end of the object and that system will never write any modification of "
4756 "the object beyond its end.  On Linux, when you write data to such partial "
4757 "page after the end of the object, the data stays in the page cache even "
4758 "after the file is closed and unmapped and even though the data is never "
4759 "written to the file itself, subsequent mappings may see the modified "
4760 "content.  In some cases, this could be fixed by calling B<msync>(2)  before "
4761 "the unmap takes place; however, this doesn't work on tmpfs (for example, "
4762 "when using POSIX shared memory interface documented in B<shm_overview>(7))."
4763 msgstr ""
4764
4765 #. type: Plain text
4766 #: build/C/man2/mmap.2:642
4767 msgid ""
4768 "The following program prints part of the file specified in its first "
4769 "command-line argument to standard output.  The range of bytes to be printed "
4770 "is specified via offset and length values in the second and third "
4771 "command-line arguments.  The program creates a memory mapping of the "
4772 "required pages of the file and then uses B<write>(2)  to output the desired "
4773 "bytes."
4774 msgstr ""
4775
4776 #. type: Plain text
4777 #: build/C/man2/mmap.2:650
4778 #, no-wrap
4779 msgid ""
4780 "#include E<lt>sys/mman.hE<gt>\n"
4781 "#include E<lt>sys/stat.hE<gt>\n"
4782 "#include E<lt>fcntl.hE<gt>\n"
4783 "#include E<lt>stdio.hE<gt>\n"
4784 "#include E<lt>stdlib.hE<gt>\n"
4785 "#include E<lt>unistd.hE<gt>\n"
4786 msgstr ""
4787
4788 #. type: Plain text
4789 #: build/C/man2/mmap.2:653 build/C/man2/mprotect.2:178
4790 #, no-wrap
4791 msgid ""
4792 "#define handle_error(msg) \\e\n"
4793 "    do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
4794 msgstr ""
4795
4796 #. type: Plain text
4797 #: build/C/man2/mmap.2:663
4798 #, no-wrap
4799 msgid ""
4800 "int\n"
4801 "main(int argc, char *argv[])\n"
4802 "{\n"
4803 "    char *addr;\n"
4804 "    int fd;\n"
4805 "    struct stat sb;\n"
4806 "    off_t offset, pa_offset;\n"
4807 "    size_t length;\n"
4808 "    ssize_t s;\n"
4809 msgstr ""
4810
4811 #. type: Plain text
4812 #: build/C/man2/mmap.2:668
4813 #, no-wrap
4814 msgid ""
4815 "    if (argc E<lt> 3 || argc E<gt> 4) {\n"
4816 "        fprintf(stderr, \"%s file offset [length]\\en\", argv[0]);\n"
4817 "        exit(EXIT_FAILURE);\n"
4818 "    }\n"
4819 msgstr ""
4820
4821 #. type: Plain text
4822 #: build/C/man2/mmap.2:672
4823 #, no-wrap
4824 msgid ""
4825 "    fd = open(argv[1], O_RDONLY);\n"
4826 "    if (fd == -1)\n"
4827 "        handle_error(\"open\");\n"
4828 msgstr ""
4829
4830 #. type: Plain text
4831 #: build/C/man2/mmap.2:675
4832 #, no-wrap
4833 msgid ""
4834 "    if (fstat(fd, &sb) == -1)           /* To obtain file size */\n"
4835 "        handle_error(\"fstat\");\n"
4836 msgstr ""
4837
4838 #. type: Plain text
4839 #: build/C/man2/mmap.2:679
4840 #, no-wrap
4841 msgid ""
4842 "    offset = atoi(argv[2]);\n"
4843 "    pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);\n"
4844 "        /* offset for mmap() must be page aligned */\n"
4845 msgstr ""
4846
4847 #. type: Plain text
4848 #: build/C/man2/mmap.2:684
4849 #, no-wrap
4850 msgid ""
4851 "    if (offset E<gt>= sb.st_size) {\n"
4852 "        fprintf(stderr, \"offset is past end of file\\en\");\n"
4853 "        exit(EXIT_FAILURE);\n"
4854 "    }\n"
4855 msgstr ""
4856
4857 #. type: Plain text
4858 #: build/C/man2/mmap.2:690
4859 #, no-wrap
4860 msgid ""
4861 "    if (argc == 4) {\n"
4862 "        length = atoi(argv[3]);\n"
4863 "        if (offset + length E<gt> sb.st_size)\n"
4864 "            length = sb.st_size - offset;\n"
4865 "                /* Can\\(aqt display bytes past end of file */\n"
4866 msgstr ""
4867
4868 #. type: Plain text
4869 #: build/C/man2/mmap.2:694
4870 #, no-wrap
4871 msgid ""
4872 "    } else {    /* No length arg ==E<gt> display to end of file */\n"
4873 "        length = sb.st_size - offset;\n"
4874 "    }\n"
4875 msgstr ""
4876
4877 #. type: Plain text
4878 #: build/C/man2/mmap.2:699
4879 #, no-wrap
4880 msgid ""
4881 "    addr = mmap(NULL, length + offset - pa_offset, PROT_READ,\n"
4882 "                MAP_PRIVATE, fd, pa_offset);\n"
4883 "    if (addr == MAP_FAILED)\n"
4884 "        handle_error(\"mmap\");\n"
4885 msgstr ""
4886
4887 #. type: Plain text
4888 #: build/C/man2/mmap.2:704
4889 #, no-wrap
4890 msgid ""
4891 "    s = write(STDOUT_FILENO, addr + offset - pa_offset, length);\n"
4892 "    if (s != length) {\n"
4893 "        if (s == -1)\n"
4894 "            handle_error(\"write\");\n"
4895 msgstr ""
4896
4897 #. type: Plain text
4898 #: build/C/man2/mmap.2:708
4899 #, no-wrap
4900 msgid ""
4901 "        fprintf(stderr, \"partial write\");\n"
4902 "        exit(EXIT_FAILURE);\n"
4903 "    }\n"
4904 msgstr ""
4905
4906 #. type: Plain text
4907 #: build/C/man2/mmap.2:725
4908 msgid ""
4909 "B<getpagesize>(2), B<mincore>(2), B<mlock>(2), B<mmap2>(2), B<mprotect>(2), "
4910 "B<mremap>(2), B<msync>(2), B<remap_file_pages>(2), B<setrlimit>(2), "
4911 "B<shmat>(2), B<shm_open>(3), B<shm_overview>(7)"
4912 msgstr ""
4913
4914 #. type: Plain text
4915 #: build/C/man2/mmap.2:732
4916 msgid ""
4917 "The descriptions of the following files in B<proc>(5): I</proc/[pid]/maps>, "
4918 "I</proc/[pid]/map_files>, and I</proc/[pid]/smaps>."
4919 msgstr ""
4920
4921 #. type: Plain text
4922 #: build/C/man2/mmap.2:737 build/C/man2/msync.2:124
4923 msgid "B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391."
4924 msgstr ""
4925
4926 #. type: TH
4927 #: build/C/man2/mmap2.2:29
4928 #, no-wrap
4929 msgid "MMAP2"
4930 msgstr ""
4931
4932 #. type: TH
4933 #: build/C/man2/mmap2.2:29
4934 #, no-wrap
4935 msgid "2012-04-16"
4936 msgstr ""
4937
4938 #. type: Plain text
4939 #: build/C/man2/mmap2.2:32
4940 msgid "mmap2 - map files or devices into memory"
4941 msgstr ""
4942
4943 #. type: Plain text
4944 #: build/C/man2/mmap2.2:38
4945 #, no-wrap
4946 msgid ""
4947 "B<void *mmap2(void *>I<addr>B<, size_t >I<length>B<, int >I<prot>B<,>\n"
4948 "B<             int >I<flags>B<, int >I<fd>B<, off_t >I<pgoffset>B<);>\n"
4949 msgstr ""
4950
4951 #. type: Plain text
4952 #: build/C/man2/mmap2.2:43
4953 msgid ""
4954 "This is probably not the system call that you are interested in; instead, "
4955 "see B<mmap>(2), which describes the glibc wrapper function that invokes this "
4956 "system call."
4957 msgstr ""
4958
4959 #. type: Plain text
4960 #: build/C/man2/mmap2.2:54
4961 msgid ""
4962 "The B<mmap2>()  system call provides the same interface as B<mmap>(2), "
4963 "except that the final argument specifies the offset into the file in "
4964 "4096-byte units (instead of bytes, as is done by B<mmap>(2)).  This enables "
4965 "applications that use a 32-bit I<off_t> to map large files (up to 2^44 "
4966 "bytes)."
4967 msgstr ""
4968
4969 #. type: Plain text
4970 #: build/C/man2/mmap2.2:61
4971 msgid ""
4972 "On success, B<mmap2>()  returns a pointer to the mapped area.  On error -1 "
4973 "is returned and I<errno> is set appropriately."
4974 msgstr ""
4975
4976 #. type: Plain text
4977 #: build/C/man2/mmap2.2:65
4978 msgid "Problem with getting the data from user space."
4979 msgstr ""
4980
4981 #. type: Plain text
4982 #: build/C/man2/mmap2.2:70
4983 msgid ""
4984 "(Various platforms where the page size is not 4096 bytes.)  I<offset\\ *\\ "
4985 "4096> is not a multiple of the system page size."
4986 msgstr ""
4987
4988 #. type: Plain text
4989 #: build/C/man2/mmap2.2:74
4990 msgid "B<mmap2>()  can also return any of the errors described in B<mmap>(2)."
4991 msgstr ""
4992
4993 #. type: Plain text
4994 #: build/C/man2/mmap2.2:77
4995 msgid "B<mmap2>()  is available since Linux 2.3.31."
4996 msgstr ""
4997
4998 #. type: Plain text
4999 #: build/C/man2/mmap2.2:79 build/C/man2/subpage_prot.2:98
5000 msgid "This system call is Linux-specific."
5001 msgstr ""
5002
5003 #. type: Plain text
5004 #: build/C/man2/mmap2.2:85
5005 msgid ""
5006 "Nowadays, the glibc B<mmap>()  wrapper function invokes this system call "
5007 "rather than the B<mmap>(2)  system call."
5008 msgstr ""
5009
5010 #.  ia64 can have page sizes ranging from 4kB to 64kB.
5011 #.  On cris, it looks like the unit might also be the page size,
5012 #.  which is 8192 bytes. -- mtk, June 2007
5013 #. type: Plain text
5014 #: build/C/man2/mmap2.2:92
5015 msgid ""
5016 "On ia64, the unit for I<offset> is actually the system page size, rather "
5017 "than 4096 bytes."
5018 msgstr ""
5019
5020 #. type: Plain text
5021 #: build/C/man2/mmap2.2:98
5022 msgid "B<getpagesize>(2), B<mmap>(2), B<mremap>(2), B<msync>(2), B<shm_open>(3)"
5023 msgstr ""
5024
5025 #. type: TH
5026 #: build/C/man2/mprotect.2:38
5027 #, no-wrap
5028 msgid "MPROTECT"
5029 msgstr ""
5030
5031 #. type: TH
5032 #: build/C/man2/mprotect.2:38
5033 #, no-wrap
5034 msgid "2012-08-14"
5035 msgstr ""
5036
5037 #. type: Plain text
5038 #: build/C/man2/mprotect.2:41
5039 msgid "mprotect - set protection on a region of memory"
5040 msgstr ""
5041
5042 #. type: Plain text
5043 #: build/C/man2/mprotect.2:46
5044 #, no-wrap
5045 msgid "B<int mprotect(void *>I<addr>B<, size_t >I<len>B<, int >I<prot>B<);>\n"
5046 msgstr ""
5047
5048 #. type: Plain text
5049 #: build/C/man2/mprotect.2:54
5050 msgid ""
5051 "B<mprotect>()  changes protection for the calling process's memory page(s)  "
5052 "containing any part of the address range in the interval [I<addr>,\\ "
5053 "I<addr>+I<len>-1].  I<addr> must be aligned to a page boundary."
5054 msgstr ""
5055
5056 #. type: Plain text
5057 #: build/C/man2/mprotect.2:59
5058 msgid ""
5059 "If the calling process tries to access memory in a manner that violates the "
5060 "protection, then the kernel generates a B<SIGSEGV> signal for the process."
5061 msgstr ""
5062
5063 #. type: Plain text
5064 #: build/C/man2/mprotect.2:64
5065 msgid ""
5066 "I<prot> is either B<PROT_NONE> or a bitwise-or of the other values in the "
5067 "following list:"
5068 msgstr ""
5069
5070 #. type: Plain text
5071 #: build/C/man2/mprotect.2:67
5072 msgid "The memory cannot be accessed at all."
5073 msgstr ""
5074
5075 #. type: Plain text
5076 #: build/C/man2/mprotect.2:70
5077 msgid "The memory can be read."
5078 msgstr ""
5079
5080 #. type: Plain text
5081 #: build/C/man2/mprotect.2:73
5082 msgid "The memory can be modified."
5083 msgstr ""
5084
5085 #.  FIXME
5086 #.  Document PROT_GROWSUP and PROT_GROWSDOWN
5087 #. type: Plain text
5088 #: build/C/man2/mprotect.2:78
5089 msgid "The memory can be executed."
5090 msgstr ""
5091
5092 #. type: Plain text
5093 #: build/C/man2/mprotect.2:85
5094 msgid ""
5095 "On success, B<mprotect>()  returns zero.  On error, -1 is returned, and "
5096 "I<errno> is set appropriately."
5097 msgstr ""
5098
5099 #. type: Plain text
5100 #: build/C/man2/mprotect.2:95
5101 msgid ""
5102 "The memory cannot be given the specified access.  This can happen, for "
5103 "example, if you B<mmap>(2)  a file to which you have read-only access, then "
5104 "ask B<mprotect>()  to mark it B<PROT_WRITE>."
5105 msgstr ""
5106
5107 #.  Or: both PROT_GROWSUP and PROT_GROWSDOWN were specified in 'prot'.
5108 #. type: Plain text
5109 #: build/C/man2/mprotect.2:100
5110 msgid "I<addr> is not a valid pointer, or not a multiple of the system page size."
5111 msgstr ""
5112
5113 #. type: Plain text
5114 #: build/C/man2/mprotect.2:103
5115 msgid "Internal kernel structures could not be allocated."
5116 msgstr ""
5117
5118 #. type: Plain text
5119 #: build/C/man2/mprotect.2:113
5120 msgid ""
5121 "Addresses in the range [I<addr>, I<addr>+I<len>-1] are invalid for the "
5122 "address space of the process, or specify one or more pages that are not "
5123 "mapped.  (Before kernel 2.4.19, the error B<EFAULT> was incorrectly produced "
5124 "for these cases.)"
5125 msgstr ""
5126
5127 #.  SVr4 defines an additional error
5128 #.  code EAGAIN. The SVr4 error conditions don't map neatly onto Linux's.
5129 #. type: Plain text
5130 #: build/C/man2/mprotect.2:122
5131 msgid ""
5132 "SVr4, POSIX.1-2001.  POSIX says that the behavior of B<mprotect>()  is "
5133 "unspecified if it is applied to a region of memory that was not obtained via "
5134 "B<mmap>(2)."
5135 msgstr ""
5136
5137 #. type: Plain text
5138 #: build/C/man2/mprotect.2:129
5139 msgid ""
5140 "On Linux it is always permissible to call B<mprotect>()  on any address in a "
5141 "process's address space (except for the kernel vsyscall area).  In "
5142 "particular it can be used to change existing code mappings to be writable."
5143 msgstr ""
5144
5145 #. type: Plain text
5146 #: build/C/man2/mprotect.2:139
5147 msgid ""
5148 "Whether B<PROT_EXEC> has any effect different from B<PROT_READ> is "
5149 "architecture- and kernel version-dependent.  On some hardware architectures "
5150 "(e.g., i386), B<PROT_WRITE> implies B<PROT_READ>."
5151 msgstr ""
5152
5153 #. type: Plain text
5154 #: build/C/man2/mprotect.2:148
5155 msgid ""
5156 "POSIX.1-2001 says that an implementation may permit access other than that "
5157 "specified in I<prot>, but at a minimum can allow write access only if "
5158 "B<PROT_WRITE> has been set, and must not allow any access if B<PROT_NONE> "
5159 "has been set."
5160 msgstr ""
5161
5162 #. type: Plain text
5163 #: build/C/man2/mprotect.2:154
5164 msgid ""
5165 "The program below allocates four pages of memory, makes the third of these "
5166 "pages read-only, and then executes a loop that walks upward through the "
5167 "allocated region modifying bytes."
5168 msgstr ""
5169
5170 #. type: Plain text
5171 #: build/C/man2/mprotect.2:157
5172 msgid "An example of what we might see when running the program is the following:"
5173 msgstr ""
5174
5175 #. type: Plain text
5176 #: build/C/man2/mprotect.2:163
5177 #, no-wrap
5178 msgid ""
5179 "$B< ./a.out>\n"
5180 "Start of region:        0x804c000\n"
5181 "Got SIGSEGV at address: 0x804e000\n"
5182 msgstr ""
5183
5184 #. type: Plain text
5185 #: build/C/man2/mprotect.2:175
5186 #, no-wrap
5187 msgid ""
5188 "#include E<lt>unistd.hE<gt>\n"
5189 "#include E<lt>signal.hE<gt>\n"
5190 "#include E<lt>stdio.hE<gt>\n"
5191 "#include E<lt>malloc.hE<gt>\n"
5192 "#include E<lt>stdlib.hE<gt>\n"
5193 "#include E<lt>errno.hE<gt>\n"
5194 "#include E<lt>sys/mman.hE<gt>\n"
5195 msgstr ""
5196
5197 #. type: Plain text
5198 #: build/C/man2/mprotect.2:180
5199 #, no-wrap
5200 msgid "char *buffer;\n"
5201 msgstr ""
5202
5203 #. type: Plain text
5204 #: build/C/man2/mprotect.2:188
5205 #, no-wrap
5206 msgid ""
5207 "static void\n"
5208 "handler(int sig, siginfo_t *si, void *unused)\n"
5209 "{\n"
5210 "    printf(\"Got SIGSEGV at address: 0x%lx\\en\",\n"
5211 "            (long) si-E<gt>si_addr);\n"
5212 "    exit(EXIT_FAILURE);\n"
5213 "}\n"
5214 msgstr ""
5215
5216 #. type: Plain text
5217 #: build/C/man2/mprotect.2:195
5218 #, no-wrap
5219 msgid ""
5220 "int\n"
5221 "main(int argc, char *argv[])\n"
5222 "{\n"
5223 "    char *p;\n"
5224 "    int pagesize;\n"
5225 "    struct sigaction sa;\n"
5226 msgstr ""
5227
5228 #. type: Plain text
5229 #: build/C/man2/mprotect.2:201
5230 #, no-wrap
5231 msgid ""
5232 "    sa.sa_flags = SA_SIGINFO;\n"
5233 "    sigemptyset(&sa.sa_mask);\n"
5234 "    sa.sa_sigaction = handler;\n"
5235 "    if (sigaction(SIGSEGV, &sa, NULL) == -1)\n"
5236 "        handle_error(\"sigaction\");\n"
5237 msgstr ""
5238
5239 #. type: Plain text
5240 #: build/C/man2/mprotect.2:205
5241 #, no-wrap
5242 msgid ""
5243 "    pagesize = sysconf(_SC_PAGE_SIZE);\n"
5244 "    if (pagesize == -1)\n"
5245 "        handle_error(\"sysconf\");\n"
5246 msgstr ""
5247
5248 #. type: Plain text
5249 #: build/C/man2/mprotect.2:208
5250 #, no-wrap
5251 msgid ""
5252 "    /* Allocate a buffer aligned on a page boundary;\n"
5253 "       initial protection is PROT_READ | PROT_WRITE */\n"
5254 msgstr ""
5255
5256 #. type: Plain text
5257 #: build/C/man2/mprotect.2:212
5258 #, no-wrap
5259 msgid ""
5260 "    buffer = memalign(pagesize, 4 * pagesize);\n"
5261 "    if (buffer == NULL)\n"
5262 "        handle_error(\"memalign\");\n"
5263 msgstr ""
5264
5265 #. type: Plain text
5266 #: build/C/man2/mprotect.2:214
5267 #, no-wrap
5268 msgid "    printf(\"Start of region:        0x%lx\\en\", (long) buffer);\n"
5269 msgstr ""
5270
5271 #. type: Plain text
5272 #: build/C/man2/mprotect.2:218
5273 #, no-wrap
5274 msgid ""
5275 "    if (mprotect(buffer + pagesize * 2, pagesize,\n"
5276 "                PROT_READ) == -1)\n"
5277 "        handle_error(\"mprotect\");\n"
5278 msgstr ""
5279
5280 #. type: Plain text
5281 #: build/C/man2/mprotect.2:221
5282 #, no-wrap
5283 msgid ""
5284 "    for (p = buffer ; ; )\n"
5285 "        *(p++) = \\(aqa\\(aq;\n"
5286 msgstr ""
5287
5288 #. type: Plain text
5289 #: build/C/man2/mprotect.2:225
5290 #, no-wrap
5291 msgid ""
5292 "    printf(\"Loop completed\\en\");     /* Should never happen */\n"
5293 "    exit(EXIT_SUCCESS);\n"
5294 "}\n"
5295 msgstr ""
5296
5297 #. type: Plain text
5298 #: build/C/man2/mprotect.2:229
5299 msgid "B<mmap>(2), B<sysconf>(3)"
5300 msgstr ""
5301
5302 #. type: TH
5303 #: build/C/man2/mremap.2:30
5304 #, no-wrap
5305 msgid "MREMAP"
5306 msgstr ""
5307
5308 #. type: TH
5309 #: build/C/man2/mremap.2:30
5310 #, no-wrap
5311 msgid "2010-06-10"
5312 msgstr ""
5313
5314 #. type: Plain text
5315 #: build/C/man2/mremap.2:33
5316 msgid "mremap - remap a virtual memory address"
5317 msgstr ""
5318
5319 #. type: Plain text
5320 #: build/C/man2/mremap.2:36
5321 #, no-wrap
5322 msgid "B<#define _GNU_SOURCE>         /* See feature_test_macros(7) */\n"
5323 msgstr ""
5324
5325 #. type: Plain text
5326 #: build/C/man2/mremap.2:41
5327 #, no-wrap
5328 msgid ""
5329 "B<void *mremap(void *>I<old_address>B<, size_t >I<old_size>B<,>\n"
5330 "B<             size_t >I<new_size>B<, int >I<flags>B<, ... /* void "
5331 "*>I<new_address>B< */);>\n"
5332 msgstr ""
5333
5334 #. type: Plain text
5335 #: build/C/man2/mremap.2:47
5336 msgid ""
5337 "B<mremap>()  expands (or shrinks) an existing memory mapping, potentially "
5338 "moving it at the same time (controlled by the I<flags> argument and the "
5339 "available virtual address space)."
5340 msgstr ""
5341
5342 #. type: Plain text
5343 #: build/C/man2/mremap.2:61
5344 msgid ""
5345 "I<old_address> is the old address of the virtual memory block that you want "
5346 "to expand (or shrink).  Note that I<old_address> has to be page aligned.  "
5347 "I<old_size> is the old size of the virtual memory block.  I<new_size> is the "
5348 "requested size of the virtual memory block after the resize.  An optional "
5349 "fifth argument, I<new_address>, may be provided; see the description of "
5350 "B<MREMAP_FIXED> below."
5351 msgstr ""
5352
5353 #. type: Plain text
5354 #: build/C/man2/mremap.2:73
5355 msgid ""
5356 "In Linux the memory is divided into pages.  A user process has (one or)  "
5357 "several linear virtual memory segments.  Each virtual memory segment has one "
5358 "or more mappings to real memory pages (in the page table).  Each virtual "
5359 "memory segment has its own protection (access rights), which may cause a "
5360 "segmentation violation if the memory is accessed incorrectly (e.g., writing "
5361 "to a read-only segment).  Accessing virtual memory outside of the segments "
5362 "will also cause a segmentation violation."
5363 msgstr ""
5364
5365 #. type: Plain text
5366 #: build/C/man2/mremap.2:81
5367 msgid ""
5368 "B<mremap>()  uses the Linux page table scheme.  B<mremap>()  changes the "
5369 "mapping between virtual addresses and memory pages.  This can be used to "
5370 "implement a very efficient B<realloc>(3)."
5371 msgstr ""
5372
5373 #. type: Plain text
5374 #: build/C/man2/mremap.2:83
5375 msgid "The I<flags> bit-mask argument may be 0, or include the following flag:"
5376 msgstr ""
5377
5378 #. type: TP
5379 #: build/C/man2/mremap.2:83
5380 #, no-wrap
5381 msgid "B<MREMAP_MAYMOVE>"
5382 msgstr ""
5383
5384 #. type: Plain text
5385 #: build/C/man2/mremap.2:95
5386 msgid ""
5387 "By default, if there is not sufficient space to expand a mapping at its "
5388 "current location, then B<mremap>()  fails.  If this flag is specified, then "
5389 "the kernel is permitted to relocate the mapping to a new virtual address, if "
5390 "necessary.  If the mapping is relocated, then absolute pointers into the old "
5391 "mapping location become invalid (offsets relative to the starting address of "
5392 "the mapping should be employed)."
5393 msgstr ""
5394
5395 #. type: TP
5396 #: build/C/man2/mremap.2:95
5397 #, no-wrap
5398 msgid "B<MREMAP_FIXED> (since Linux 2.3.31)"
5399 msgstr ""
5400
5401 #. type: Plain text
5402 #: build/C/man2/mremap.2:117
5403 msgid ""
5404 "This flag serves a similar purpose to the B<MAP_FIXED> flag of B<mmap>(2).  "
5405 "If this flag is specified, then B<mremap>()  accepts a fifth argument, "
5406 "I<void\\ *new_address>, which specifies a page-aligned address to which the "
5407 "mapping must be moved.  Any previous mapping at the address range specified "
5408 "by I<new_address> and I<new_size> is unmapped.  If B<MREMAP_FIXED> is "
5409 "specified, then B<MREMAP_MAYMOVE> must also be specified."
5410 msgstr ""
5411
5412 #. type: Plain text
5413 #: build/C/man2/mremap.2:127
5414 msgid ""
5415 "If the memory segment specified by I<old_address> and I<old_size> is locked "
5416 "(using B<mlock>(2)  or similar), then this lock is maintained when the "
5417 "segment is resized and/or relocated.  As a consequence, the amount of memory "
5418 "locked by the process may change."
5419 msgstr ""
5420
5421 #. type: Plain text
5422 #: build/C/man2/mremap.2:135
5423 msgid ""
5424 "On success B<mremap>()  returns a pointer to the new virtual memory area.  "
5425 "On error, the value B<MAP_FAILED> (that is, I<(void\\ *)\\ -1>) is returned, "
5426 "and I<errno> is set appropriately."
5427 msgstr ""
5428
5429 #. type: Plain text
5430 #: build/C/man2/mremap.2:142
5431 msgid ""
5432 "The caller tried to expand a memory segment that is locked, but this was not "
5433 "possible without exceeding the B<RLIMIT_MEMLOCK> resource limit."
5434 msgstr ""
5435
5436 #. type: Plain text
5437 #: build/C/man2/mremap.2:151
5438 msgid ""
5439 "\"Segmentation fault.\" Some address in the range I<old_address> to "
5440 "I<old_address>+I<old_size> is an invalid virtual memory address for this "
5441 "process.  You can also get B<EFAULT> even if there exist mappings that cover "
5442 "the whole address space requested, but those mappings are of different "
5443 "types."
5444 msgstr ""
5445
5446 #. type: Plain text
5447 #: build/C/man2/mremap.2:179
5448 msgid ""
5449 "An invalid argument was given.  Possible causes are: I<old_address> was not "
5450 "page aligned; a value other than B<MREMAP_MAYMOVE> or B<MREMAP_FIXED> was "
5451 "specified in I<flags>; I<new_size> was zero; I<new_size> or I<new_address> "
5452 "was invalid; or the new address range specified by I<new_address> and "
5453 "I<new_size> overlapped the old address range specified by I<old_address> and "
5454 "I<old_size>; or B<MREMAP_FIXED> was specified without also specifying "
5455 "B<MREMAP_MAYMOVE>."
5456 msgstr ""
5457
5458 #. type: Plain text
5459 #: build/C/man2/mremap.2:185
5460 msgid ""
5461 "The memory area cannot be expanded at the current virtual address, and the "
5462 "B<MREMAP_MAYMOVE> flag is not set in I<flags>.  Or, there is not enough "
5463 "(virtual) memory available."
5464 msgstr ""
5465
5466 #.  4.2BSD had a (never actually implemented)
5467 #.  .BR mremap (2)
5468 #.  call with completely different semantics.
5469 #. type: Plain text
5470 #: build/C/man2/mremap.2:191
5471 msgid ""
5472 "This call is Linux-specific, and should not be used in programs intended to "
5473 "be portable."
5474 msgstr ""
5475
5476 #. type: Plain text
5477 #: build/C/man2/mremap.2:199
5478 msgid ""
5479 "Prior to version 2.4, glibc did not expose the definition of "
5480 "B<MREMAP_FIXED>, and the prototype for B<mremap>()  did not allow for the "
5481 "I<new_address> argument."
5482 msgstr ""
5483
5484 #. type: Plain text
5485 #: build/C/man2/mremap.2:208
5486 msgid ""
5487 "B<brk>(2), B<getpagesize>(2), B<getrlimit>(2), B<mlock>(2), B<mmap>(2), "
5488 "B<sbrk>(2), B<malloc>(3), B<realloc>(3)"
5489 msgstr ""
5490
5491 #. type: Plain text
5492 #: build/C/man2/mremap.2:214
5493 msgid ""
5494 "Your favorite text book on operating systems for more information on paged "
5495 "memory (e.g., I<Modern Operating Systems> by Andrew S. Tanenbaum, I<Inside "
5496 "Linux> by Randolf Bentson, I<The Design of the UNIX Operating System> by "
5497 "Maurice J. Bach)"
5498 msgstr ""
5499
5500 #. type: TH
5501 #: build/C/man2/msync.2:25
5502 #, no-wrap
5503 msgid "MSYNC"
5504 msgstr ""
5505
5506 #. type: TH
5507 #: build/C/man2/msync.2:25 build/C/man2/remap_file_pages.2:28
5508 #, no-wrap
5509 msgid "2008-04-22"
5510 msgstr ""
5511
5512 #. type: Plain text
5513 #: build/C/man2/msync.2:28
5514 msgid "msync - synchronize a file with a memory map"
5515 msgstr ""
5516
5517 #. type: Plain text
5518 #: build/C/man2/msync.2:32
5519 msgid "B<int msync(void *>I<addr>B<, size_t >I<length>B<, int >I<flags>B<);>"
5520 msgstr ""
5521
5522 #. type: Plain text
5523 #: build/C/man2/msync.2:48
5524 msgid ""
5525 "B<msync>()  flushes changes made to the in-core copy of a file that was "
5526 "mapped into memory using B<mmap>(2)  back to disk.  Without use of this call "
5527 "there is no guarantee that changes are written back before B<munmap>(2)  is "
5528 "called.  To be more precise, the part of the file that corresponds to the "
5529 "memory area starting at I<addr> and having length I<length> is updated."
5530 msgstr ""
5531
5532 #. type: Plain text
5533 #: build/C/man2/msync.2:68
5534 msgid ""
5535 "The I<flags> argument may have the bits B<MS_ASYNC>, B<MS_SYNC>, and "
5536 "B<MS_INVALIDATE> set, but not both B<MS_ASYNC> and B<MS_SYNC>.  B<MS_ASYNC> "
5537 "specifies that an update be scheduled, but the call returns immediately.  "
5538 "B<MS_SYNC> asks for an update and waits for it to complete.  "
5539 "B<MS_INVALIDATE> asks to invalidate other mappings of the same file (so that "
5540 "they can be updated with the fresh values just written)."
5541 msgstr ""
5542
5543 #. type: Plain text
5544 #: build/C/man2/msync.2:73
5545 msgid ""
5546 "On success, zero is returned.  On error, -1 is returned, and I<errno> is set "
5547 "appropriately."
5548 msgstr ""
5549
5550 #. type: TP
5551 #: build/C/man2/msync.2:74
5552 #, no-wrap
5553 msgid "B<EBUSY>"
5554 msgstr ""
5555
5556 #. type: Plain text
5557 #: build/C/man2/msync.2:80
5558 msgid ""
5559 "B<MS_INVALIDATE> was specified in I<flags>, and a memory lock exists for the "
5560 "specified address range."
5561 msgstr ""
5562
5563 #. type: Plain text
5564 #: build/C/man2/msync.2:93
5565 msgid ""
5566 "I<addr> is not a multiple of PAGESIZE; or any bit other than B<MS_ASYNC> | "
5567 "B<MS_INVALIDATE> | B<MS_SYNC> is set in I<flags>; or both B<MS_SYNC> and "
5568 "B<MS_ASYNC> are set in I<flags>."
5569 msgstr ""
5570
5571 #. type: Plain text
5572 #: build/C/man2/msync.2:96
5573 msgid "The indicated memory (or part of it) was not mapped."
5574 msgstr ""
5575
5576 #. type: Plain text
5577 #: build/C/man2/msync.2:98 build/C/man3/posix_fallocate.3:105 build/C/man3/shm_open.3:253 build/C/man7/shm_overview.7:103
5578 msgid "POSIX.1-2001."
5579 msgstr ""
5580
5581 #. type: Plain text
5582 #: build/C/man2/msync.2:105
5583 msgid ""
5584 "This call was introduced in Linux 1.3.21, and then used B<EFAULT> instead of "
5585 "B<ENOMEM>.  In Linux 2.4.19 this was changed to the POSIX value B<ENOMEM>."
5586 msgstr ""
5587
5588 #.  POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
5589 #.  -1: unavailable, 0: ask using sysconf().
5590 #.  glibc defines them to 1.
5591 #. type: Plain text
5592 #: build/C/man2/msync.2:120
5593 msgid ""
5594 "On POSIX systems on which B<msync>()  is available, both "
5595 "B<_POSIX_MAPPED_FILES> and B<_POSIX_SYNCHRONIZED_IO> are defined in "
5596 "I<E<lt>unistd.hE<gt>> to a value greater than 0.  (See also B<sysconf>(3).)"
5597 msgstr ""
5598
5599 #. type: TP
5600 #: build/C/man2/msync.2:122 build/C/man7/shm_overview.7:46
5601 #, no-wrap
5602 msgid "B<mmap>(2)"
5603 msgstr ""
5604
5605 #. type: TH
5606 #: build/C/man3/mtrace.3:25
5607 #, no-wrap
5608 msgid "MTRACE"
5609 msgstr ""
5610
5611 #. type: Plain text
5612 #: build/C/man3/mtrace.3:28
5613 msgid "mtrace, muntrace - malloc tracing"
5614 msgstr ""
5615
5616 #. type: Plain text
5617 #: build/C/man3/mtrace.3:30
5618 msgid "B<#include E<lt>mcheck.hE<gt>>"
5619 msgstr ""
5620
5621 #. type: Plain text
5622 #: build/C/man3/mtrace.3:32
5623 msgid "B<void mtrace(void);>"
5624 msgstr ""
5625
5626 #. type: Plain text
5627 #: build/C/man3/mtrace.3:34
5628 msgid "B<void muntrace(void);>"
5629 msgstr ""
5630
5631 #. type: Plain text
5632 #: build/C/man3/mtrace.3:46
5633 msgid ""
5634 "The B<mtrace>()  function installs hook functions for the memory-allocation "
5635 "functions (B<malloc>(3), B<realloc>(3)  B<memalign>(3), B<free>(3)).  These "
5636 "hook functions record tracing information about memory allocation and "
5637 "deallocation.  The tracing information can be used to discover memory leaks "
5638 "and attempts to free nonallocated memory in a program."
5639 msgstr ""
5640
5641 #. type: Plain text
5642 #: build/C/man3/mtrace.3:57
5643 msgid ""
5644 "The B<muntrace>()  function disables the hook functions installed by "
5645 "B<mtrace>(), so that tracing information is no longer recorded for the "
5646 "memory-allocation functions.  If no hook functions were successfully "
5647 "installed by B<mtrace>(), B<muntrace>()  does nothing."
5648 msgstr ""
5649
5650 #. type: Plain text
5651 #: build/C/man3/mtrace.3:65
5652 msgid ""
5653 "When B<mtrace>()  is called, it checks the value of the environment variable "
5654 "B<MALLOC_TRACE>, which should contain the pathname of a file in which the "
5655 "tracing information is to be recorded.  If the pathname is successfully "
5656 "opened, it is truncated to zero length."
5657 msgstr ""
5658
5659 #. type: Plain text
5660 #: build/C/man3/mtrace.3:78
5661 msgid ""
5662 "If B<MALLOC_TRACE> is not set, or the pathname it specifies is invalid or "
5663 "not writable, then no hook functions are installed, and B<mtrace>()  has no "
5664 "effect.  In set-user-ID and set-group-ID programs, B<MALLOC_TRACE> is "
5665 "ignored, and B<mtrace>()  has no effect."
5666 msgstr ""
5667
5668 #. type: Plain text
5669 #: build/C/man3/mtrace.3:86
5670 msgid ""
5671 "In normal usage, B<mtrace>()  is called once at the start of execution of a "
5672 "program, and B<muntrace>()  is never called."
5673 msgstr ""
5674
5675 #. type: Plain text
5676 #: build/C/man3/mtrace.3:96
5677 msgid ""
5678 "The tracing output produced after a call to B<mtrace>()  is textual, but not "
5679 "designed to be human readable.  The GNU C library provides a Perl script, "
5680 "B<mtrace>(1), that interprets the trace log and produces human-readable "
5681 "output.  For best results, the traced program should be compiled with "
5682 "debugging enabled, so that line-number information is recorded in the "
5683 "executable."
5684 msgstr ""
5685
5686 #. type: Plain text
5687 #: build/C/man3/mtrace.3:102
5688 msgid ""
5689 "The tracing performed by B<mtrace>()  incurs a performance penalty (if "
5690 "B<MALLOC_TRACE> points to a valid, writable pathname)."
5691 msgstr ""
5692
5693 #. type: Plain text
5694 #: build/C/man3/mtrace.3:108
5695 msgid ""
5696 "The line-number information produced by B<mtrace>(1)  is not always precise: "
5697 "the line number references may refer to the previous or following "
5698 "(non-blank)  line of the source code."
5699 msgstr ""
5700
5701 #. type: Plain text
5702 #: build/C/man3/mtrace.3:115
5703 msgid ""
5704 "The shell session below demonstrates the use of the B<mtrace>()  function "
5705 "and the B<mtrace>(1)  command in a program that has memory leaks at two "
5706 "different locations.  The demonstration uses the following program:"
5707 msgstr ""
5708
5709 #. type: Plain text
5710 #: build/C/man3/mtrace.3:122
5711 #, no-wrap
5712 msgid ""
5713 "$ B<cat t_mtrace.c>\n"
5714 "#include E<lt>mcheck.hE<gt>\n"
5715 "#include E<lt>stdlib.hE<gt>\n"
5716 "#include E<lt>stdio.hE<gt>\n"
5717 msgstr ""
5718
5719 #. type: Plain text
5720 #: build/C/man3/mtrace.3:127
5721 #, no-wrap
5722 msgid ""
5723 "int\n"
5724 "main(int argc, char *argv[])\n"
5725 "{\n"
5726 "    int j;\n"
5727 msgstr ""
5728
5729 #. type: Plain text
5730 #: build/C/man3/mtrace.3:129
5731 #, no-wrap
5732 msgid "    mtrace();\n"
5733 msgstr ""
5734
5735 #. type: Plain text
5736 #: build/C/man3/mtrace.3:132
5737 #, no-wrap
5738 msgid ""
5739 "    for (j = 0; j E<lt> 2; j++)\n"
5740 "        malloc(100);            /* Never freed--a memory leak */\n"
5741 msgstr ""
5742
5743 #. type: Plain text
5744 #: build/C/man3/mtrace.3:136
5745 #, no-wrap
5746 msgid ""
5747 "    calloc(16, 16);             /* Never freed--a memory leak */\n"
5748 "    exit(EXIT_SUCCESS);\n"
5749 "}\n"
5750 msgstr ""
5751
5752 #. type: Plain text
5753 #: build/C/man3/mtrace.3:142
5754 msgid ""
5755 "When we run the program as follows, we see that B<mtrace>()  diagnosed "
5756 "memory leaks at two different locations in the program:"
5757 msgstr ""
5758
5759 #. type: Plain text
5760 #: build/C/man3/mtrace.3:155
5761 #, no-wrap
5762 msgid ""
5763 "$ B<cc -g t_mtrace.c -o t_mtrace>\n"
5764 "$ B<export MALLOC_TRACE=/tmp/t>\n"
5765 "$ B<./t_mtrace>\n"
5766 "$ B<mtrace ./t_mtrace $MALLOC_TRACE>\n"
5767 "Memory not freed:\n"
5768 "-----------------\n"
5769 "   Address     Size     Caller\n"
5770 "0x084c9378     0x64  at /home/cecilia/t_mtrace.c:12\n"
5771 "0x084c93e0     0x64  at /home/cecilia/t_mtrace.c:12\n"
5772 "0x084c9448    0x100  at /home/cecilia/t_mtrace.c:16\n"
5773 msgstr ""
5774
5775 #. type: Plain text
5776 #: build/C/man3/mtrace.3:167
5777 msgid ""
5778 "The first two messages about unfreed memory correspond to the two "
5779 "B<malloc>(3)  calls inside the I<for> loop.  The final message corresponds "
5780 "to the call to B<calloc>(3)  (which in turn calls B<malloc>(3))."
5781 msgstr ""
5782
5783 #. type: Plain text
5784 #: build/C/man3/mtrace.3:172
5785 msgid "B<mtrace>(1), B<malloc>(3), B<malloc_hook>(3), B<mcheck>(3)"
5786 msgstr ""
5787
5788 #. type: TH
5789 #: build/C/man2/posix_fadvise.2:28
5790 #, no-wrap
5791 msgid "POSIX_FADVISE"
5792 msgstr ""
5793
5794 #. type: TH
5795 #: build/C/man2/posix_fadvise.2:28 build/C/man2/readahead.2:28 build/C/man2/sync_file_range.2:30
5796 #, no-wrap
5797 msgid "2013-04-01"
5798 msgstr ""
5799
5800 #. type: Plain text
5801 #: build/C/man2/posix_fadvise.2:31
5802 msgid "posix_fadvise - predeclare an access pattern for file data"
5803 msgstr ""
5804
5805 #. type: Plain text
5806 #: build/C/man2/posix_fadvise.2:34 build/C/man3/posix_fallocate.3:31
5807 #, no-wrap
5808 msgid "B<#include E<lt>fcntl.hE<gt>>\n"
5809 msgstr ""
5810
5811 #. type: Plain text
5812 #: build/C/man2/posix_fadvise.2:37
5813 #, no-wrap
5814 msgid ""
5815 "B<int posix_fadvise(int >I<fd>B<, off_t >I<offset>B<, off_t >I<len>B<, int "
5816 ">I<advice>B<);>\n"
5817 msgstr ""
5818
5819 #. type: Plain text
5820 #: build/C/man2/posix_fadvise.2:46
5821 msgid "B<posix_fadvise>():"
5822 msgstr ""
5823
5824 #. type: Plain text
5825 #: build/C/man2/posix_fadvise.2:48 build/C/man3/posix_fallocate.3:44
5826 msgid "_XOPEN_SOURCE\\ E<gt>=\\ 600 || _POSIX_C_SOURCE\\ E<gt>=\\ 200112L"
5827 msgstr ""
5828
5829 #. type: Plain text
5830 #: build/C/man2/posix_fadvise.2:56
5831 msgid ""
5832 "Programs can use B<posix_fadvise>()  to announce an intention to access file "
5833 "data in a specific pattern in the future, thus allowing the kernel to "
5834 "perform appropriate optimizations."
5835 msgstr ""
5836
5837 #. type: Plain text
5838 #: build/C/man2/posix_fadvise.2:63
5839 msgid ""
5840 "The I<advice> applies to a (not necessarily existent) region starting at "
5841 "I<offset> and extending for I<len> bytes (or until the end of the file if "
5842 "I<len> is 0) within the file referred to by I<fd>.  The I<advice> is not "
5843 "binding; it merely constitutes an expectation on behalf of the application."
5844 msgstr ""
5845
5846 #. type: Plain text
5847 #: build/C/man2/posix_fadvise.2:65
5848 msgid "Permissible values for I<advice> include:"
5849 msgstr ""
5850
5851 #. type: TP
5852 #: build/C/man2/posix_fadvise.2:65
5853 #, no-wrap
5854 msgid "B<POSIX_FADV_NORMAL>"
5855 msgstr ""
5856
5857 #. type: Plain text
5858 #: build/C/man2/posix_fadvise.2:71
5859 msgid ""
5860 "Indicates that the application has no advice to give about its access "
5861 "pattern for the specified data.  If no advice is given for an open file, "
5862 "this is the default assumption."
5863 msgstr ""
5864
5865 #. type: TP
5866 #: build/C/man2/posix_fadvise.2:71
5867 #, no-wrap
5868 msgid "B<POSIX_FADV_SEQUENTIAL>"
5869 msgstr ""
5870
5871 #. type: Plain text
5872 #: build/C/man2/posix_fadvise.2:75
5873 msgid ""
5874 "The application expects to access the specified data sequentially (with "
5875 "lower offsets read before higher ones)."
5876 msgstr ""
5877
5878 #. type: TP
5879 #: build/C/man2/posix_fadvise.2:75
5880 #, no-wrap
5881 msgid "B<POSIX_FADV_RANDOM>"
5882 msgstr ""
5883
5884 #. type: Plain text
5885 #: build/C/man2/posix_fadvise.2:78
5886 msgid "The specified data will be accessed in random order."
5887 msgstr ""
5888
5889 #. type: TP
5890 #: build/C/man2/posix_fadvise.2:78
5891 #, no-wrap
5892 msgid "B<POSIX_FADV_NOREUSE>"
5893 msgstr ""
5894
5895 #. type: Plain text
5896 #: build/C/man2/posix_fadvise.2:81
5897 msgid "The specified data will be accessed only once."
5898 msgstr ""
5899
5900 #. type: TP
5901 #: build/C/man2/posix_fadvise.2:81
5902 #, no-wrap
5903 msgid "B<POSIX_FADV_WILLNEED>"
5904 msgstr ""
5905
5906 #. type: Plain text
5907 #: build/C/man2/posix_fadvise.2:84
5908 msgid "The specified data will be accessed in the near future."
5909 msgstr ""
5910
5911 #. type: TP
5912 #: build/C/man2/posix_fadvise.2:84
5913 #, no-wrap
5914 msgid "B<POSIX_FADV_DONTNEED>"
5915 msgstr ""
5916
5917 #. type: Plain text
5918 #: build/C/man2/posix_fadvise.2:87
5919 msgid "The specified data will not be accessed in the near future."
5920 msgstr ""
5921
5922 #. type: Plain text
5923 #: build/C/man2/posix_fadvise.2:90
5924 msgid "On success, zero is returned.  On error, an error number is returned."
5925 msgstr ""
5926
5927 #. type: Plain text
5928 #: build/C/man2/posix_fadvise.2:94
5929 msgid "The I<fd> argument was not a valid file descriptor."
5930 msgstr ""
5931
5932 #. type: Plain text
5933 #: build/C/man2/posix_fadvise.2:97
5934 msgid "An invalid value was specified for I<advice>."
5935 msgstr ""
5936
5937 #. type: Plain text
5938 #: build/C/man2/posix_fadvise.2:104
5939 msgid ""
5940 "The specified file descriptor refers to a pipe or FIFO.  (Linux actually "
5941 "returns B<EINVAL> in this case.)"
5942 msgstr ""
5943
5944 #.  of fadvise64_64()
5945 #. type: Plain text
5946 #: build/C/man2/posix_fadvise.2:112
5947 msgid ""
5948 "Kernel support first appeared in Linux 2.5.60; the underlying system call is "
5949 "called B<fadvise64>().  Library support has been provided since glibc "
5950 "version 2.2, via the wrapper function B<posix_fadvise>()."
5951 msgstr ""
5952
5953 #. type: Plain text
5954 #: build/C/man2/posix_fadvise.2:121
5955 msgid ""
5956 "POSIX.1-2001.  Note that the type of the I<len> argument was changed from "
5957 "I<size_t> to I<off_t> in POSIX.1-2003 TC1."
5958 msgstr ""
5959
5960 #. type: Plain text
5961 #: build/C/man2/posix_fadvise.2:127
5962 msgid ""
5963 "Under Linux, B<POSIX_FADV_NORMAL> sets the readahead window to the default "
5964 "size for the backing device; B<POSIX_FADV_SEQUENTIAL> doubles this size, and "
5965 "B<POSIX_FADV_RANDOM> disables file readahead entirely.  These changes affect "
5966 "the entire file, not just the specified region (but other open file handles "
5967 "to the same file are unaffected)."
5968 msgstr ""
5969
5970 #. type: Plain text
5971 #: build/C/man2/posix_fadvise.2:134
5972 msgid ""
5973 "B<POSIX_FADV_WILLNEED> initiates a nonblocking read of the specified region "
5974 "into the page cache.  The amount of data read may be decreased by the kernel "
5975 "depending on virtual memory load.  (A few megabytes will usually be fully "
5976 "satisfied, and more is rarely useful.)"
5977 msgstr ""
5978
5979 #. type: Plain text
5980 #: build/C/man2/posix_fadvise.2:138
5981 msgid ""
5982 "In kernels before 2.6.18, B<POSIX_FADV_NOREUSE> had the same semantics as "
5983 "B<POSIX_FADV_WILLNEED>.  This was probably a bug; since kernel 2.6.18, this "
5984 "flag is a no-op."
5985 msgstr ""
5986
5987 #. type: Plain text
5988 #: build/C/man2/posix_fadvise.2:146
5989 msgid ""
5990 "B<POSIX_FADV_DONTNEED> attempts to free cached pages associated with the "
5991 "specified region.  This is useful, for example, while streaming large "
5992 "files.  A program may periodically request the kernel to free cached data "
5993 "that has already been used, so that more useful cached pages are not "
5994 "discarded instead."
5995 msgstr ""
5996
5997 #. type: Plain text
5998 #: build/C/man2/posix_fadvise.2:154
5999 msgid ""
6000 "Pages that have not yet been written out will be unaffected, so if the "
6001 "application wishes to guarantee that pages will be released, it should call "
6002 "B<fsync>(2)  or B<fdatasync>(2)  first."
6003 msgstr ""
6004
6005 #. type: SS
6006 #: build/C/man2/posix_fadvise.2:154
6007 #, no-wrap
6008 msgid "Architecture-specific variants"
6009 msgstr ""
6010
6011 #. type: Plain text
6012 #: build/C/man2/posix_fadvise.2:171
6013 msgid ""
6014 "Some architectures require 64-bit arguments to be aligned in a suitable pair "
6015 "of registers (see B<syscall>(2)  for further detail).  On such "
6016 "architectures, the call signature of B<posix_fadvise>()  shown in the "
6017 "SYNOPSIS would force a register to be wasted as padding between the I<fd> "
6018 "and I<len> arguments.  Therefore, these architectures define a version of "
6019 "the system call that orders the arguments suitably, but otherwise is "
6020 "otherwise exactly the same as B<posix_fadvise>()."
6021 msgstr ""
6022
6023 #. type: Plain text
6024 #: build/C/man2/posix_fadvise.2:173
6025 msgid "For example, since Linux 2.6.14, ARM has the following system call:"
6026 msgstr ""
6027
6028 #. type: Plain text
6029 #: build/C/man2/posix_fadvise.2:178
6030 #, no-wrap
6031 msgid ""
6032 "B<long arm_fadvise64_64(int >I<fd>B<, int >I<advice>B<,>\n"
6033 "B<                      loff_t >I<offset>B<, loff_t >I<len>B<);>\n"
6034 msgstr ""
6035
6036 #. type: Plain text
6037 #: build/C/man2/posix_fadvise.2:186
6038 msgid ""
6039 "These architecture-specific details are generally hidden from applications "
6040 "by the glibc B<posix_fadvise>()  wrapper function, which invokes the "
6041 "appropriate architecture-specific system call."
6042 msgstr ""
6043
6044 #. type: Plain text
6045 #: build/C/man2/posix_fadvise.2:191
6046 msgid ""
6047 "In kernels before 2.6.6, if I<len> was specified as 0, then this was "
6048 "interpreted literally as \"zero bytes\", rather than as meaning \"all bytes "
6049 "through to the end of the file\"."
6050 msgstr ""
6051
6052 #.  FIXME . Write a posix_fadvise(3) page.
6053 #. type: Plain text
6054 #: build/C/man2/posix_fadvise.2:197
6055 msgid ""
6056 "B<readahead>(2), B<sync_file_range>(2), B<posix_fallocate>(3), "
6057 "B<posix_madvise>(3)"
6058 msgstr ""
6059
6060 #. type: TH
6061 #: build/C/man3/posix_fallocate.3:25
6062 #, no-wrap
6063 msgid "POSIX_FALLOCATE"
6064 msgstr ""
6065
6066 #. type: TH
6067 #: build/C/man3/posix_fallocate.3:25 build/C/man2/shmop.2:41
6068 #, no-wrap
6069 msgid "2013-02-12"
6070 msgstr ""
6071
6072 #. type: Plain text
6073 #: build/C/man3/posix_fallocate.3:28
6074 msgid "posix_fallocate - allocate file space"
6075 msgstr ""
6076
6077 #. type: Plain text
6078 #: build/C/man3/posix_fallocate.3:33
6079 #, no-wrap
6080 msgid "B<int posix_fallocate(int >I<fd>B<, off_t >I<offset>B<, off_t >I<len>B<);>\n"
6081 msgstr ""
6082
6083 #. type: Plain text
6084 #: build/C/man3/posix_fallocate.3:42
6085 msgid "B<posix_fallocate>():"
6086 msgstr ""
6087
6088 #. type: Plain text
6089 #: build/C/man3/posix_fallocate.3:61
6090 msgid ""
6091 "The function B<posix_fallocate>()  ensures that disk space is allocated for "
6092 "the file referred to by the descriptor I<fd> for the bytes in the range "
6093 "starting at I<offset> and continuing for I<len> bytes.  After a successful "
6094 "call to B<posix_fallocate>(), subsequent writes to bytes in the specified "
6095 "range are guaranteed not to fail because of lack of disk space."
6096 msgstr ""
6097
6098 #. type: Plain text
6099 #: build/C/man3/posix_fallocate.3:66
6100 msgid ""
6101 "If the size of the file is less than I<offset>+I<len>, then the file is "
6102 "increased to this size; otherwise the file size is left unchanged."
6103 msgstr ""
6104
6105 #. type: Plain text
6106 #: build/C/man3/posix_fallocate.3:72
6107 msgid ""
6108 "B<posix_fallocate>()  returns zero on success, or an error number on "
6109 "failure.  Note that I<errno> is not set."
6110 msgstr ""
6111
6112 #. type: Plain text
6113 #: build/C/man3/posix_fallocate.3:81
6114 msgid "I<offset+len> exceeds the maximum file size."
6115 msgstr ""
6116
6117 #. type: Plain text
6118 #: build/C/man3/posix_fallocate.3:91
6119 msgid "I<fd> does not refer to a regular file."
6120 msgstr ""
6121
6122 #. type: Plain text
6123 #: build/C/man3/posix_fallocate.3:100
6124 msgid "I<fd> refers to a pipe."
6125 msgstr ""
6126
6127 #. type: Plain text
6128 #: build/C/man3/posix_fallocate.3:103
6129 msgid "B<posix_fallocate>()  is available since glibc 2.1.94."
6130 msgstr ""
6131
6132 #. type: Plain text
6133 #: build/C/man3/posix_fallocate.3:128
6134 msgid ""
6135 "POSIX.1-2008 says that an implementation I<shall> give the B<EINVAL> error "
6136 "if I<len> was 0, or I<offset> was less than 0.  POSIX.1-2001 says that an "
6137 "implementation I<shall> give the B<EINVAL> error if I<len> is less than 0, "
6138 "or I<offset> was less than 0, and I<may> give the error if I<len> equals "
6139 "zero."
6140 msgstr ""
6141
6142 #. type: Plain text
6143 #: build/C/man3/posix_fallocate.3:133
6144 msgid "B<fallocate>(1), B<fallocate>(2), B<lseek>(2), B<posix_fadvise>(2)"
6145 msgstr ""
6146
6147 #. type: TH
6148 #: build/C/man3/posix_memalign.3:29
6149 #, no-wrap
6150 msgid "POSIX_MEMALIGN"
6151 msgstr ""
6152
6153 #. type: TH
6154 #: build/C/man3/posix_memalign.3:29
6155 #, no-wrap
6156 msgid "2013-09-02"
6157 msgstr ""
6158
6159 #. type: Plain text
6160 #: build/C/man3/posix_memalign.3:32
6161 msgid ""
6162 "posix_memalign, aligned_alloc, memalign, valloc, pvalloc - allocate aligned "
6163 "memory"
6164 msgstr ""
6165
6166 #. type: Plain text
6167 #: build/C/man3/posix_memalign.3:39
6168 #, no-wrap
6169 msgid ""
6170 "B<int posix_memalign(void **>I<memptr>B<, size_t >I<alignment>B<, size_t "
6171 ">I<size>B<);>\n"
6172 "B<void *aligned_alloc(size_t >I<alignment>B<, size_t >I<size>B<);>\n"
6173 "B<void *valloc(size_t >I<size>B<);>\n"
6174 msgstr ""
6175
6176 #. type: Plain text
6177 #: build/C/man3/posix_memalign.3:44
6178 #, no-wrap
6179 msgid ""
6180 "B<void *memalign(size_t >I<alignment>B<, size_t >I<size>B<);>\n"
6181 "B<void *pvalloc(size_t >I<size>B<);>\n"
6182 msgstr ""
6183
6184 #. type: Plain text
6185 #: build/C/man3/posix_memalign.3:54
6186 msgid ""
6187 "B<posix_memalign>(): _POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ "
6188 "E<gt>=\\ 600"
6189 msgstr ""
6190
6191 #. type: Plain text
6192 #: build/C/man3/posix_memalign.3:57
6193 msgid "B<aligned_alloc>(): _ISOC11_SOURCE"
6194 msgstr ""
6195
6196 #. type: Plain text
6197 #: build/C/man3/posix_memalign.3:59
6198 msgid "B<valloc>():"
6199 msgstr ""
6200
6201 #. type: TP
6202 #: build/C/man3/posix_memalign.3:62
6203 #, no-wrap
6204 msgid "Since glibc 2.12:"
6205 msgstr ""
6206
6207 #. type: Plain text
6208 #: build/C/man3/posix_memalign.3:69
6209 #, no-wrap
6210 msgid ""
6211 "_BSD_SOURCE ||\n"
6212 "    (_XOPEN_SOURCE\\ E<gt>=\\ 500 ||\n"
6213 "        _XOPEN_SOURCE\\ &&\\ _XOPEN_SOURCE_EXTENDED) &&\n"
6214 "    !(_POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ 600)\n"
6215 msgstr ""
6216
6217 #. type: TP
6218 #: build/C/man3/posix_memalign.3:71
6219 #, no-wrap
6220 msgid "Before glibc 2.12:"
6221 msgstr ""
6222
6223 #. type: Plain text
6224 #: build/C/man3/posix_memalign.3:75
6225 msgid ""
6226 "_BSD_SOURCE || _XOPEN_SOURCE\\ E<gt>=\\ 500 || _XOPEN_SOURCE\\ &&\\ "
6227 "_XOPEN_SOURCE_EXTENDED"
6228 msgstr ""
6229
6230 #. type: Plain text
6231 #: build/C/man3/posix_memalign.3:82
6232 msgid ""
6233 "(The (nonstandard) header file I<E<lt>malloc.hE<gt>> also exposes the "
6234 "declaration of B<valloc>(); no feature test macros are required.)"
6235 msgstr ""
6236
6237 #.  glibc does this:
6238 #. type: Plain text
6239 #: build/C/man3/posix_memalign.3:104
6240 msgid ""
6241 "The function B<posix_memalign>()  allocates I<size> bytes and places the "
6242 "address of the allocated memory in I<*memptr>.  The address of the allocated "
6243 "memory will be a multiple of I<alignment>, which must be a power of two and "
6244 "a multiple of I<sizeof(void\\ *)>.  If I<size> is 0, then the value placed "
6245 "in I<*memptr> is either NULL, or a unique pointer value that can later be "
6246 "successfully passed to B<free>(3)."
6247 msgstr ""
6248
6249 #.  The behavior of memalign() for size==0 is as for posix_memalign()
6250 #.  but no standards govern this.
6251 #. type: Plain text
6252 #: build/C/man3/posix_memalign.3:115
6253 msgid ""
6254 "The obsolete function B<memalign>()  allocates I<size> bytes and returns a "
6255 "pointer to the allocated memory.  The memory address will be a multiple of "
6256 "I<alignment>, which must be a power of two."
6257 msgstr ""
6258
6259 #. type: Plain text
6260 #: build/C/man3/posix_memalign.3:124
6261 msgid ""
6262 "The function B<aligned_alloc>()  is the same as B<memalign>(), except for "
6263 "the added restriction that I<size> should be a multiple of I<alignment>."
6264 msgstr ""
6265
6266 #. type: Plain text
6267 #: build/C/man3/posix_memalign.3:133
6268 msgid ""
6269 "The obsolete function B<valloc>()  allocates I<size> bytes and returns a "
6270 "pointer to the allocated memory.  The memory address will be a multiple of "
6271 "the page size.  It is equivalent to I<memalign(sysconf(_SC_PAGESIZE),size)>."
6272 msgstr ""
6273
6274 #. type: Plain text
6275 #: build/C/man3/posix_memalign.3:140
6276 msgid ""
6277 "The obsolete function B<pvalloc>()  is similar to B<valloc>(), but rounds "
6278 "the size of the allocation up to the next multiple of the system page size."
6279 msgstr ""
6280
6281 #. type: Plain text
6282 #: build/C/man3/posix_memalign.3:142
6283 msgid "For all of these functions, the memory is not zeroed."
6284 msgstr ""
6285
6286 #. type: Plain text
6287 #: build/C/man3/posix_memalign.3:149
6288 msgid ""
6289 "B<aligned_alloc>(), B<memalign>(), B<valloc>(), and B<pvalloc>()  return a "
6290 "pointer to the allocated memory, or NULL if the request fails."
6291 msgstr ""
6292
6293 #. type: Plain text
6294 #: build/C/man3/posix_memalign.3:157
6295 msgid ""
6296 "B<posix_memalign>()  returns zero on success, or one of the error values "
6297 "listed in the next section on failure.  The value of I<errno> is "
6298 "indeterminate after a call to B<posix_memalign>()."
6299 msgstr ""
6300
6301 #. type: Plain text
6302 #: build/C/man3/posix_memalign.3:164
6303 msgid ""
6304 "The I<alignment> argument was not a power of two, or was not a multiple of "
6305 "I<sizeof(void\\ *)>."
6306 msgstr ""
6307
6308 #. type: Plain text
6309 #: build/C/man3/posix_memalign.3:167
6310 msgid "There was insufficient memory to fulfill the allocation request."
6311 msgstr ""
6312
6313 #. type: Plain text
6314 #: build/C/man3/posix_memalign.3:174
6315 msgid ""
6316 "The functions B<memalign>(), B<valloc>(), and B<pvalloc>()  have been "
6317 "available in all Linux libc libraries."
6318 msgstr ""
6319
6320 #. type: Plain text
6321 #: build/C/man3/posix_memalign.3:178
6322 msgid "The function B<aligned_alloc>()  was added to glibc in version 2.16."
6323 msgstr ""
6324
6325 #. type: Plain text
6326 #: build/C/man3/posix_memalign.3:182
6327 msgid "The function B<posix_memalign>()  is available since glibc 2.1.91."
6328 msgstr ""
6329
6330 #. type: Plain text
6331 #: build/C/man3/posix_memalign.3:189
6332 msgid ""
6333 "The function B<valloc>()  appeared in 3.0BSD.  It is documented as being "
6334 "obsolete in 4.3BSD, and as legacy in SUSv2.  It does not appear in "
6335 "POSIX.1-2001."
6336 msgstr ""
6337
6338 #. type: Plain text
6339 #: build/C/man3/posix_memalign.3:193
6340 msgid "The function B<pvalloc>()  is a GNU extension."
6341 msgstr ""
6342
6343 #. type: Plain text
6344 #: build/C/man3/posix_memalign.3:197
6345 msgid "The function B<memalign>()  appears in SunOS 4.1.3 but not in 4.4BSD."
6346 msgstr ""
6347
6348 #. type: Plain text
6349 #: build/C/man3/posix_memalign.3:201
6350 msgid "The function B<posix_memalign>()  comes from POSIX.1d."
6351 msgstr ""
6352
6353 #. type: Plain text
6354 #: build/C/man3/posix_memalign.3:206
6355 msgid "The function B<aligned_alloc>()  is specified in the C11 standard."
6356 msgstr ""
6357
6358 #. type: SS
6359 #: build/C/man3/posix_memalign.3:206
6360 #, no-wrap
6361 msgid "Headers"
6362 msgstr ""
6363
6364 #. type: Plain text
6365 #: build/C/man3/posix_memalign.3:210
6366 msgid ""
6367 "Everybody agrees that B<posix_memalign>()  is declared in "
6368 "I<E<lt>stdlib.hE<gt>>."
6369 msgstr ""
6370
6371 #. type: Plain text
6372 #: build/C/man3/posix_memalign.3:214
6373 msgid ""
6374 "On some systems B<memalign>()  is declared in I<E<lt>stdlib.hE<gt>> instead "
6375 "of I<E<lt>malloc.hE<gt>>."
6376 msgstr ""
6377
6378 #. type: Plain text
6379 #: build/C/man3/posix_memalign.3:221
6380 msgid ""
6381 "According to SUSv2, B<valloc>()  is declared in I<E<lt>stdlib.hE<gt>>.  "
6382 "Libc4,5 and glibc declare it in I<E<lt>malloc.hE<gt>>, and also in "
6383 "I<E<lt>stdlib.hE<gt>> if suitable feature test macros are defined (see "
6384 "above)."
6385 msgstr ""
6386
6387 #. type: Plain text
6388 #: build/C/man3/posix_memalign.3:230
6389 msgid ""
6390 "On many systems there are alignment restrictions, for example, on buffers "
6391 "used for direct block device I/O.  POSIX specifies the "
6392 "I<pathconf(path,_PC_REC_XFER_ALIGN)> call that tells what alignment is "
6393 "needed.  Now one can use B<posix_memalign>()  to satisfy this requirement."
6394 msgstr ""
6395
6396 #. type: Plain text
6397 #: build/C/man3/posix_memalign.3:239
6398 msgid ""
6399 "B<posix_memalign>()  verifies that I<alignment> matches the requirements "
6400 "detailed above.  B<memalign>()  may not check that the I<alignment> argument "
6401 "is correct."
6402 msgstr ""
6403
6404 #.  Other systems allow passing the result of
6405 #.  .IR valloc ()
6406 #.  to
6407 #.  .IR free (3),
6408 #.  but not to
6409 #.  .IR realloc (3).
6410 #. type: Plain text
6411 #: build/C/man3/posix_memalign.3:267
6412 msgid ""
6413 "POSIX requires that memory obtained from B<posix_memalign>()  can be freed "
6414 "using B<free>(3).  Some systems provide no way to reclaim memory allocated "
6415 "with B<memalign>()  or B<valloc>()  (because one can pass to B<free>(3)  "
6416 "only a pointer obtained from B<malloc>(3), while, for example, B<memalign>()  "
6417 "would call B<malloc>(3)  and then align the obtained value).  The glibc "
6418 "implementation allows memory obtained from any of these functions to be "
6419 "reclaimed with B<free>(3)."
6420 msgstr ""
6421
6422 #. type: Plain text
6423 #: build/C/man3/posix_memalign.3:272
6424 msgid ""
6425 "The glibc B<malloc>(3)  always returns 8-byte aligned memory addresses, so "
6426 "these functions are needed only if you require larger alignment values."
6427 msgstr ""
6428
6429 #. type: Plain text
6430 #: build/C/man3/posix_memalign.3:277
6431 msgid "B<brk>(2), B<getpagesize>(2), B<free>(3), B<malloc>(3)"
6432 msgstr ""
6433
6434 #. type: TH
6435 #: build/C/man2/readahead.2:28
6436 #, no-wrap
6437 msgid "READAHEAD"
6438 msgstr ""
6439
6440 #. type: Plain text
6441 #: build/C/man2/readahead.2:31
6442 msgid "readahead - perform file readahead into page cache"
6443 msgstr ""
6444
6445 #. type: Plain text
6446 #: build/C/man2/readahead.2:37
6447 #, no-wrap
6448 msgid ""
6449 "B<ssize_t readahead(int >I<fd>B<, off64_t >I<offset>B<, size_t "
6450 ">I<count>B<);>\n"
6451 msgstr ""
6452
6453 #. type: Plain text
6454 #: build/C/man2/readahead.2:65
6455 msgid ""
6456 "B<readahead>()  populates the page cache with data from a file so that "
6457 "subsequent reads from that file will not block on disk I/O.  The I<fd> "
6458 "argument is a file descriptor identifying the file which is to be read.  The "
6459 "I<offset> argument specifies the starting point from which data is to be "
6460 "read and I<count> specifies the number of bytes to be read.  I/O is "
6461 "performed in whole pages, so that I<offset> is effectively rounded down to a "
6462 "page boundary and bytes are read up to the next page boundary greater than "
6463 "or equal to I<(offset+count)>.  B<readahead>()  does not read beyond the end "
6464 "of the file.  B<readahead>()  blocks until the specified data has been "
6465 "read.  The current file offset of the open file referred to by I<fd> is left "
6466 "unchanged."
6467 msgstr ""
6468
6469 #. type: Plain text
6470 #: build/C/man2/readahead.2:71
6471 msgid ""
6472 "On success, B<readahead>()  returns 0; on failure, -1 is returned, with "
6473 "I<errno> set to indicate the cause of the error."
6474 msgstr ""
6475
6476 #. type: Plain text
6477 #: build/C/man2/readahead.2:76
6478 msgid "I<fd> is not a valid file descriptor or is not open for reading."
6479 msgstr ""
6480
6481 #. type: Plain text
6482 #: build/C/man2/readahead.2:82
6483 msgid "I<fd> does not refer to a file type to which B<readahead>()  can be applied."
6484 msgstr ""
6485
6486 #. type: Plain text
6487 #: build/C/man2/readahead.2:87
6488 msgid ""
6489 "The B<readahead>()  system call appeared in Linux 2.4.13; glibc support has "
6490 "been provided since version 2.3."
6491 msgstr ""
6492
6493 #. type: Plain text
6494 #: build/C/man2/readahead.2:92
6495 msgid ""
6496 "The B<readahead>()  system call is Linux-specific, and its use should be "
6497 "avoided in portable applications."
6498 msgstr ""
6499
6500 #. type: Plain text
6501 #: build/C/man2/readahead.2:97
6502 msgid ""
6503 "On some 32-bit architectures, the calling signature for this system call "
6504 "differs, for the reasons described in B<syscall>(2)."
6505 msgstr ""
6506
6507 #. type: Plain text
6508 #: build/C/man2/readahead.2:103
6509 msgid "B<lseek>(2), B<madvise>(2), B<mmap>(2), B<posix_fadvise>(2), B<read>(2)"
6510 msgstr ""
6511
6512 #. type: TH
6513 #: build/C/man2/remap_file_pages.2:28
6514 #, no-wrap
6515 msgid "REMAP_FILE_PAGES"
6516 msgstr ""
6517
6518 #. type: Plain text
6519 #: build/C/man2/remap_file_pages.2:31
6520 msgid "remap_file_pages - create a nonlinear file mapping"
6521 msgstr ""
6522
6523 #. type: Plain text
6524 #: build/C/man2/remap_file_pages.2:35
6525 #, no-wrap
6526 msgid ""
6527 "B<#define _GNU_SOURCE>         /* See feature_test_macros(7) */\n"
6528 "B<#include E<lt>sys/mman.hE<gt>>\n"
6529 msgstr ""
6530
6531 #. type: Plain text
6532 #: build/C/man2/remap_file_pages.2:38
6533 #, no-wrap
6534 msgid ""
6535 "B<int remap_file_pages(void *>I<addr>B<, size_t >I<size>B<, int "
6536 ">I<prot>B<,>\n"
6537 "B<                     ssize_t >I<pgoff>B<, int >I<flags>B<);>\n"
6538 msgstr ""
6539
6540 #. type: Plain text
6541 #: build/C/man2/remap_file_pages.2:51
6542 msgid ""
6543 "The B<remap_file_pages>()  system call is used to create a nonlinear "
6544 "mapping, that is, a mapping in which the pages of the file are mapped into a "
6545 "nonsequential order in memory.  The advantage of using B<remap_file_pages>()  "
6546 "over using repeated calls to B<mmap>(2)  is that the former approach does "
6547 "not require the kernel to create additional VMA (Virtual Memory Area) data "
6548 "structures."
6549 msgstr ""
6550
6551 #. type: Plain text
6552 #: build/C/man2/remap_file_pages.2:53
6553 msgid "To create a nonlinear mapping we perform the following steps:"
6554 msgstr ""
6555
6556 #. type: TP
6557 #: build/C/man2/remap_file_pages.2:53
6558 #, no-wrap
6559 msgid "1."
6560 msgstr ""
6561
6562 #. type: Plain text
6563 #: build/C/man2/remap_file_pages.2:61
6564 msgid ""
6565 "Use B<mmap>(2)  to create a mapping (which is initially linear).  This "
6566 "mapping must be created with the B<MAP_SHARED> flag."
6567 msgstr ""
6568
6569 #. type: TP
6570 #: build/C/man2/remap_file_pages.2:61
6571 #, no-wrap
6572 msgid "2."
6573 msgstr ""
6574
6575 #. type: Plain text
6576 #: build/C/man2/remap_file_pages.2:69
6577 msgid ""
6578 "Use one or more calls to B<remap_file_pages>()  to rearrange the "
6579 "correspondence between the pages of the mapping and the pages of the file.  "
6580 "It is possible to map the same page of a file into multiple locations within "
6581 "the mapped region."
6582 msgstr ""
6583
6584 #. type: Plain text
6585 #: build/C/man2/remap_file_pages.2:80
6586 msgid ""
6587 "The I<pgoff> and I<size> arguments specify the region of the file that is to "
6588 "be relocated within the mapping: I<pgoff> is a file offset in units of the "
6589 "system page size; I<size> is the length of the region in bytes."
6590 msgstr ""
6591
6592 #. type: Plain text
6593 #: build/C/man2/remap_file_pages.2:98
6594 msgid ""
6595 "The I<addr> argument serves two purposes.  First, it identifies the mapping "
6596 "whose pages we want to rearrange.  Thus, I<addr> must be an address that "
6597 "falls within a region previously mapped by a call to B<mmap>(2).  Second, "
6598 "I<addr> specifies the address at which the file pages identified by I<pgoff> "
6599 "and I<size> will be placed."
6600 msgstr ""
6601
6602 #.  This rounding is weird, and not consistent with the treatment of
6603 #.  the analogous arguments for munmap()/mprotect() and for mlock().
6604 #.  MTK, 14 Sep 2005
6605 #. type: Plain text
6606 #: build/C/man2/remap_file_pages.2:112
6607 msgid ""
6608 "The values specified in I<addr> and I<size> should be multiples of the "
6609 "system page size.  If they are not, then the kernel rounds I<both> values "
6610 "I<down> to the nearest multiple of the page size."
6611 msgstr ""
6612
6613 #. type: Plain text
6614 #: build/C/man2/remap_file_pages.2:116
6615 msgid "The I<prot> argument must be specified as 0."
6616 msgstr ""
6617
6618 #. type: Plain text
6619 #: build/C/man2/remap_file_pages.2:124
6620 msgid ""
6621 "The I<flags> argument has the same meaning as for B<mmap>(2), but all flags "
6622 "other than B<MAP_NONBLOCK> are ignored."
6623 msgstr ""
6624
6625 #. type: Plain text
6626 #: build/C/man2/remap_file_pages.2:131
6627 msgid ""
6628 "On success, B<remap_file_pages>()  returns 0.  On error, -1 is returned, and "
6629 "I<errno> is set appropriately."
6630 msgstr ""
6631
6632 #. type: Plain text
6633 #: build/C/man2/remap_file_pages.2:139
6634 msgid ""
6635 "I<addr> does not refer to a valid mapping created with the B<MAP_SHARED> "
6636 "flag."
6637 msgstr ""
6638
6639 #.  And possibly others from vma->vm_ops->populate()
6640 #. type: Plain text
6641 #: build/C/man2/remap_file_pages.2:148
6642 msgid "I<addr>, I<size>, I<prot>, or I<pgoff> is invalid."
6643 msgstr ""
6644
6645 #. type: Plain text
6646 #: build/C/man2/remap_file_pages.2:153
6647 msgid ""
6648 "The B<remap_file_pages>()  system call appeared in Linux 2.5.46; glibc "
6649 "support was added in version 2.3.3."
6650 msgstr ""
6651
6652 #. type: Plain text
6653 #: build/C/man2/remap_file_pages.2:157
6654 msgid "The B<remap_file_pages>()  system call is Linux-specific."
6655 msgstr ""
6656
6657 #. type: Plain text
6658 #: build/C/man2/remap_file_pages.2:164
6659 msgid ""
6660 "B<getpagesize>(2), B<mmap>(2), B<mmap2>(2), B<mprotect>(2), B<mremap>(2), "
6661 "B<msync>(2)"
6662 msgstr ""
6663
6664 #. type: TH
6665 #: build/C/man3/shm_open.3:26
6666 #, no-wrap
6667 msgid "SHM_OPEN"
6668 msgstr ""
6669
6670 #. type: TH
6671 #: build/C/man3/shm_open.3:26
6672 #, no-wrap
6673 msgid "2009-02-25"
6674 msgstr ""
6675
6676 #. type: Plain text
6677 #: build/C/man3/shm_open.3:29
6678 msgid "shm_open, shm_unlink - create/open or unlink POSIX shared memory objects"
6679 msgstr ""
6680
6681 #. type: Plain text
6682 #: build/C/man3/shm_open.3:33
6683 msgid "B<#include E<lt>sys/stat.hE<gt>> /* For mode constants */"
6684 msgstr ""
6685
6686 #. type: Plain text
6687 #: build/C/man3/shm_open.3:35
6688 msgid "B<#include E<lt>fcntl.hE<gt>> /* For O_* constants */"
6689 msgstr ""
6690
6691 #. type: Plain text
6692 #: build/C/man3/shm_open.3:37
6693 msgid "B<int shm_open(const char *>I<name>B<, int >I<oflag>B<, mode_t >I<mode>B<);>"
6694 msgstr ""
6695
6696 #. type: Plain text
6697 #: build/C/man3/shm_open.3:39
6698 msgid "B<int shm_unlink(const char *>I<name>B<);>"
6699 msgstr ""
6700
6701 #. type: Plain text
6702 #: build/C/man3/shm_open.3:41
6703 msgid "Link with I<-lrt>."
6704 msgstr ""
6705
6706 #. type: Plain text
6707 #: build/C/man3/shm_open.3:53
6708 msgid ""
6709 "B<shm_open>()  creates and opens a new, or opens an existing, POSIX shared "
6710 "memory object.  A POSIX shared memory object is in effect a handle which can "
6711 "be used by unrelated processes to B<mmap>(2)  the same region of shared "
6712 "memory.  The B<shm_unlink>()  function performs the converse operation, "
6713 "removing an object previously created by B<shm_open>()."
6714 msgstr ""
6715
6716 #.  glibc allows the initial slash to be omitted, and makes
6717 #.  multiple initial slashes equivalent to a single slash.
6718 #.  This differs from the implementation of POSIX message queues.
6719 #.  glibc allows subdirectory components in the name, in which
6720 #.  case the subdirectory must exist under /dev/shm, and allow the
6721 #.  required permissions if a user wants to create a shared memory
6722 #.  object in that subdirectory.
6723 #. type: Plain text
6724 #: build/C/man3/shm_open.3:74
6725 msgid ""
6726 "The operation of B<shm_open>()  is analogous to that of B<open>(2).  I<name> "
6727 "specifies the shared memory object to be created or opened.  For portable "
6728 "use, a shared memory object should be identified by a name of the form "
6729 "I</somename>; that is, a null-terminated string of up to B<NAME_MAX> (i.e., "
6730 "255) characters consisting of an initial slash, followed by one or more "
6731 "characters, none of which are slashes."
6732 msgstr ""
6733
6734 #. type: Plain text
6735 #: build/C/man3/shm_open.3:81
6736 msgid ""
6737 "I<oflag> is a bit mask created by ORing together exactly one of B<O_RDONLY> "
6738 "or B<O_RDWR> and any of the other flags listed here:"
6739 msgstr ""
6740
6741 #. type: TP
6742 #: build/C/man3/shm_open.3:81
6743 #, no-wrap
6744 msgid "B<O_RDONLY>"
6745 msgstr ""
6746
6747 #. type: Plain text
6748 #: build/C/man3/shm_open.3:89
6749 msgid ""
6750 "Open the object for read access.  A shared memory object opened in this way "
6751 "can be B<mmap>(2)ed only for read (B<PROT_READ>)  access."
6752 msgstr ""
6753
6754 #. type: TP
6755 #: build/C/man3/shm_open.3:89
6756 #, no-wrap
6757 msgid "B<O_RDWR>"
6758 msgstr ""
6759
6760 #. type: Plain text
6761 #: build/C/man3/shm_open.3:92
6762 msgid "Open the object for read-write access."
6763 msgstr ""
6764
6765 #. type: TP
6766 #: build/C/man3/shm_open.3:92
6767 #, no-wrap
6768 msgid "B<O_CREAT>"
6769 msgstr ""
6770
6771 #.  In truth it is actually the filesystem IDs on Linux, but these
6772 #.  are nearly always the same as the effective IDs.  (MTK, Jul 05)
6773 #. type: Plain text
6774 #: build/C/man3/shm_open.3:112
6775 msgid ""
6776 "Create the shared memory object if it does not exist.  The user and group "
6777 "ownership of the object are taken from the corresponding effective IDs of "
6778 "the calling process, and the object's permission bits are set according to "
6779 "the low-order 9 bits of I<mode>, except that those bits set in the process "
6780 "file mode creation mask (see B<umask>(2))  are cleared for the new object.  "
6781 "A set of macro constants which can be used to define I<mode> is listed in "
6782 "B<open>(2).  (Symbolic definitions of these constants can be obtained by "
6783 "including I<E<lt>sys/stat.hE<gt>>.)"
6784 msgstr ""
6785
6786 #. type: Plain text
6787 #: build/C/man3/shm_open.3:118
6788 msgid ""
6789 "A new shared memory object initially has zero length\\(emthe size of the "
6790 "object can be set using B<ftruncate>(2).  The newly allocated bytes of a "
6791 "shared memory object are automatically initialized to 0."
6792 msgstr ""
6793
6794 #. type: TP
6795 #: build/C/man3/shm_open.3:118
6796 #, no-wrap
6797 msgid "B<O_EXCL>"
6798 msgstr ""
6799
6800 #. type: Plain text
6801 #: build/C/man3/shm_open.3:127
6802 msgid ""
6803 "If B<O_CREAT> was also specified, and a shared memory object with the given "
6804 "I<name> already exists, return an error.  The check for the existence of the "
6805 "object, and its creation if it does not exist, are performed atomically."
6806 msgstr ""
6807
6808 #. type: TP
6809 #: build/C/man3/shm_open.3:127
6810 #, no-wrap
6811 msgid "B<O_TRUNC>"
6812 msgstr ""
6813
6814 #. type: Plain text
6815 #: build/C/man3/shm_open.3:130
6816 msgid "If the shared memory object already exists, truncate it to zero bytes."
6817 msgstr ""
6818
6819 #. type: Plain text
6820 #: build/C/man3/shm_open.3:133
6821 msgid ""
6822 "Definitions of these flag values can be obtained by including "
6823 "I<E<lt>fcntl.hE<gt>>."
6824 msgstr ""
6825
6826 #. type: Plain text
6827 #: build/C/man3/shm_open.3:144
6828 msgid ""
6829 "On successful completion B<shm_open>()  returns a new file descriptor "
6830 "referring to the shared memory object.  This file descriptor is guaranteed "
6831 "to be the lowest-numbered file descriptor not previously opened within the "
6832 "process.  The B<FD_CLOEXEC> flag (see B<fcntl>(2))  is set for the file "
6833 "descriptor."
6834 msgstr ""
6835
6836 #. type: Plain text
6837 #: build/C/man3/shm_open.3:153
6838 msgid ""
6839 "The file descriptor is normally used in subsequent calls to B<ftruncate>(2)  "
6840 "(for a newly created object) and B<mmap>(2).  After a call to B<mmap>(2)  "
6841 "the file descriptor may be closed without affecting the memory mapping."
6842 msgstr ""
6843
6844 #. type: Plain text
6845 #: build/C/man3/shm_open.3:171
6846 msgid ""
6847 "The operation of B<shm_unlink>()  is analogous to B<unlink>(2): it removes a "
6848 "shared memory object name, and, once all processes have unmapped the object, "
6849 "de-allocates and destroys the contents of the associated memory region.  "
6850 "After a successful B<shm_unlink>(), attempts to B<shm_open>()  an object "
6851 "with the same I<name> will fail (unless B<O_CREAT> was specified, in which "
6852 "case a new, distinct object is created)."
6853 msgstr ""
6854
6855 #. type: Plain text
6856 #: build/C/man3/shm_open.3:180
6857 msgid ""
6858 "On success, B<shm_open>()  returns a nonnegative file descriptor.  On "
6859 "failure, B<shm_open>()  returns -1.  B<shm_unlink>()  returns 0 on success, "
6860 "or -1 on error."
6861 msgstr ""
6862
6863 #. type: Plain text
6864 #: build/C/man3/shm_open.3:187
6865 msgid ""
6866 "On failure, I<errno> is set to indicate the cause of the error.  Values "
6867 "which may appear in I<errno> include the following:"
6868 msgstr ""
6869
6870 #. type: Plain text
6871 #: build/C/man3/shm_open.3:192
6872 msgid "Permission to B<shm_unlink>()  the shared memory object was denied."
6873 msgstr ""
6874
6875 #. type: Plain text
6876 #: build/C/man3/shm_open.3:202
6877 msgid ""
6878 "Permission was denied to B<shm_open>()  I<name> in the specified I<mode>, or "
6879 "B<O_TRUNC> was specified and the caller does not have write permission on "
6880 "the object."
6881 msgstr ""
6882
6883 #. type: TP
6884 #: build/C/man3/shm_open.3:202 build/C/man2/shmget.2:195
6885 #, no-wrap
6886 msgid "B<EEXIST>"
6887 msgstr ""
6888
6889 #. type: Plain text
6890 #: build/C/man3/shm_open.3:213
6891 msgid ""
6892 "Both B<O_CREAT> and B<O_EXCL> were specified to B<shm_open>()  and the "
6893 "shared memory object specified by I<name> already exists."
6894 msgstr ""
6895
6896 #. type: Plain text
6897 #: build/C/man3/shm_open.3:220
6898 msgid "The I<name> argument to B<shm_open>()  was invalid."
6899 msgstr ""
6900
6901 #. type: TP
6902 #: build/C/man3/shm_open.3:220
6903 #, no-wrap
6904 msgid "B<EMFILE>"
6905 msgstr ""
6906
6907 #. type: Plain text
6908 #: build/C/man3/shm_open.3:223
6909 msgid "The process already has the maximum number of files open."
6910 msgstr ""
6911
6912 #. type: TP
6913 #: build/C/man3/shm_open.3:223
6914 #, no-wrap
6915 msgid "B<ENAMETOOLONG>"
6916 msgstr ""
6917
6918 #. type: Plain text
6919 #: build/C/man3/shm_open.3:229
6920 msgid "The length of I<name> exceeds B<PATH_MAX>."
6921 msgstr ""
6922
6923 #. type: Plain text
6924 #: build/C/man3/shm_open.3:233
6925 msgid "The limit on the total number of files open on the system has been reached."
6926 msgstr ""
6927
6928 #. type: TP
6929 #: build/C/man3/shm_open.3:233 build/C/man3/shm_open.3:242 build/C/man2/shmget.2:209
6930 #, no-wrap
6931 msgid "B<ENOENT>"
6932 msgstr ""
6933
6934 #. type: Plain text
6935 #: build/C/man3/shm_open.3:242
6936 msgid ""
6937 "An attempt was made to B<shm_open>()  a I<name> that did not exist, and "
6938 "B<O_CREAT> was not specified."
6939 msgstr ""
6940
6941 #. type: Plain text
6942 #: build/C/man3/shm_open.3:249
6943 msgid "An attempt was to made to B<shm_unlink>()  a I<name> that does not exist."
6944 msgstr ""
6945
6946 #. type: Plain text
6947 #: build/C/man3/shm_open.3:251
6948 msgid "These functions are provided in glibc 2.2 and later."
6949 msgstr ""
6950
6951 #. type: Plain text
6952 #: build/C/man3/shm_open.3:257
6953 msgid ""
6954 "POSIX.1-2001 says that the group ownership of a newly created shared memory "
6955 "object is set to either the calling process's effective group ID or \"a "
6956 "system default group ID\"."
6957 msgstr ""
6958
6959 #. type: Plain text
6960 #: build/C/man3/shm_open.3:266
6961 msgid ""
6962 "POSIX leaves the behavior of the combination of B<O_RDONLY> and B<O_TRUNC> "
6963 "unspecified.  On Linux, this will successfully truncate an existing shared "
6964 "memory object\\(emthis may not be so on other UNIX systems."
6965 msgstr ""
6966
6967 #. type: Plain text
6968 #: build/C/man3/shm_open.3:271
6969 msgid ""
6970 "The POSIX shared memory object implementation on Linux 2.4 makes use of a "
6971 "dedicated filesystem, which is normally mounted under I</dev/shm>."
6972 msgstr ""
6973
6974 #. type: Plain text
6975 #: build/C/man3/shm_open.3:282
6976 msgid ""
6977 "B<close>(2), B<fchmod>(2), B<fchown>(2), B<fcntl>(2), B<fstat>(2), "
6978 "B<ftruncate>(2), B<mmap>(2), B<open>(2), B<umask>(2), B<shm_overview>(7)"
6979 msgstr ""
6980
6981 #. type: TH
6982 #: build/C/man7/shm_overview.7:27
6983 #, no-wrap
6984 msgid "SHM_OVERVIEW"
6985 msgstr ""
6986
6987 #. type: TH
6988 #: build/C/man7/shm_overview.7:27
6989 #, no-wrap
6990 msgid "2010-09-10"
6991 msgstr ""
6992
6993 #. type: Plain text
6994 #: build/C/man7/shm_overview.7:30
6995 msgid "shm_overview - overview of POSIX shared memory"
6996 msgstr ""
6997
6998 #. type: Plain text
6999 #: build/C/man7/shm_overview.7:33
7000 msgid ""
7001 "The POSIX shared memory API allows processes to communicate information by "
7002 "sharing a region of memory."
7003 msgstr ""
7004
7005 #. type: Plain text
7006 #: build/C/man7/shm_overview.7:35
7007 msgid "The interfaces employed in the API are:"
7008 msgstr ""
7009
7010 #. type: TP
7011 #: build/C/man7/shm_overview.7:35
7012 #, no-wrap
7013 msgid "B<shm_open>(3)"
7014 msgstr ""
7015
7016 #. type: Plain text
7017 #: build/C/man7/shm_overview.7:42
7018 msgid ""
7019 "Create and open a new object, or open an existing object.  This is analogous "
7020 "to B<open>(2).  The call returns a file descriptor for use by the other "
7021 "interfaces listed below."
7022 msgstr ""
7023
7024 #. type: TP
7025 #: build/C/man7/shm_overview.7:42
7026 #, no-wrap
7027 msgid "B<ftruncate>(2)"
7028 msgstr ""
7029
7030 #. type: Plain text
7031 #: build/C/man7/shm_overview.7:46
7032 msgid ""
7033 "Set the size of the shared memory object.  (A newly created shared memory "
7034 "object has a length of zero.)"
7035 msgstr ""
7036
7037 #. type: Plain text
7038 #: build/C/man7/shm_overview.7:50
7039 msgid ""
7040 "Map the shared memory object into the virtual address space of the calling "
7041 "process."
7042 msgstr ""
7043
7044 #. type: TP
7045 #: build/C/man7/shm_overview.7:50
7046 #, no-wrap
7047 msgid "B<munmap>(2)"
7048 msgstr ""
7049
7050 #. type: Plain text
7051 #: build/C/man7/shm_overview.7:54
7052 msgid ""
7053 "Unmap the shared memory object from the virtual address space of the calling "
7054 "process."
7055 msgstr ""
7056
7057 #. type: TP
7058 #: build/C/man7/shm_overview.7:54
7059 #, no-wrap
7060 msgid "B<shm_unlink>(3)"
7061 msgstr ""
7062
7063 #. type: Plain text
7064 #: build/C/man7/shm_overview.7:57
7065 msgid "Remove a shared memory object name."
7066 msgstr ""
7067
7068 #. type: TP
7069 #: build/C/man7/shm_overview.7:57
7070 #, no-wrap
7071 msgid "B<close>(2)"
7072 msgstr ""
7073
7074 #. type: Plain text
7075 #: build/C/man7/shm_overview.7:62
7076 msgid ""
7077 "Close the file descriptor allocated by B<shm_open>(3)  when it is no longer "
7078 "needed."
7079 msgstr ""
7080
7081 #. type: TP
7082 #: build/C/man7/shm_overview.7:62
7083 #, no-wrap
7084 msgid "B<fstat>(2)"
7085 msgstr ""
7086
7087 #. type: Plain text
7088 #: build/C/man7/shm_overview.7:76
7089 msgid ""
7090 "Obtain a I<stat> structure that describes the shared memory object.  Among "
7091 "the information returned by this call are the object's size (I<st_size>), "
7092 "permissions (I<st_mode>), owner (I<st_uid>), and group (I<st_gid>)."
7093 msgstr ""
7094
7095 #. type: TP
7096 #: build/C/man7/shm_overview.7:76
7097 #, no-wrap
7098 msgid "B<fchown>(2)"
7099 msgstr ""
7100
7101 #. type: Plain text
7102 #: build/C/man7/shm_overview.7:79
7103 msgid "To change the ownership of a shared memory object."
7104 msgstr ""
7105
7106 #. type: TP
7107 #: build/C/man7/shm_overview.7:79
7108 #, no-wrap
7109 msgid "B<fchmod>(2)"
7110 msgstr ""
7111
7112 #. type: Plain text
7113 #: build/C/man7/shm_overview.7:82
7114 msgid "To change the permissions of a shared memory object."
7115 msgstr ""
7116
7117 #. type: SS
7118 #: build/C/man7/shm_overview.7:82
7119 #, no-wrap
7120 msgid "Versions"
7121 msgstr ""
7122
7123 #. type: Plain text
7124 #: build/C/man7/shm_overview.7:84
7125 msgid "POSIX shared memory is supported since Linux 2.4 and glibc 2.2."
7126 msgstr ""
7127
7128 #. type: SS
7129 #: build/C/man7/shm_overview.7:84
7130 #, no-wrap
7131 msgid "Persistence"
7132 msgstr ""
7133
7134 #. type: Plain text
7135 #: build/C/man7/shm_overview.7:89
7136 msgid ""
7137 "POSIX shared memory objects have kernel persistence: a shared memory object "
7138 "will exist until the system is shut down, or until all processes have "
7139 "unmapped the object and it has been deleted with B<shm_unlink>(3)"
7140 msgstr ""
7141
7142 #. type: SS
7143 #: build/C/man7/shm_overview.7:89
7144 #, no-wrap
7145 msgid "Linking"
7146 msgstr ""
7147
7148 #. type: Plain text
7149 #: build/C/man7/shm_overview.7:94
7150 msgid ""
7151 "Programs using the POSIX shared memory API must be compiled with I<cc -lrt> "
7152 "to link against the real-time library, I<librt>."
7153 msgstr ""
7154
7155 #. type: SS
7156 #: build/C/man7/shm_overview.7:94
7157 #, no-wrap
7158 msgid "Accessing shared memory objects via the filesystem"
7159 msgstr ""
7160
7161 #. type: Plain text
7162 #: build/C/man7/shm_overview.7:101
7163 msgid ""
7164 "On Linux, shared memory objects are created in a (I<tmpfs>)  virtual "
7165 "filesystem, normally mounted under I</dev/shm>.  Since kernel 2.6.19, Linux "
7166 "supports the use of access control lists (ACLs)  to control the permissions "
7167 "of objects in the virtual filesystem."
7168 msgstr ""
7169
7170 #. type: Plain text
7171 #: build/C/man7/shm_overview.7:106
7172 msgid ""
7173 "Typically, processes must synchronize their access to a shared memory "
7174 "object, using, for example, POSIX semaphores."
7175 msgstr ""
7176
7177 #. type: Plain text
7178 #: build/C/man7/shm_overview.7:114
7179 msgid ""
7180 "System V shared memory (B<shmget>(2), B<shmop>(2), etc.) is an older shared "
7181 "memory API.  POSIX shared memory provides a simpler, and better designed "
7182 "interface; on the other hand POSIX shared memory is somewhat less widely "
7183 "available (especially on older systems) than System V shared memory."
7184 msgstr ""
7185
7186 #. type: Plain text
7187 #: build/C/man7/shm_overview.7:127
7188 msgid ""
7189 "B<fchmod>(2), B<fchown>(2), B<fstat>(2), B<ftruncate>(2), B<mmap>(2), "
7190 "B<mprotect>(2), B<munmap>(2), B<shmget>(2), B<shmop>(2), B<shm_open>(3), "
7191 "B<shm_unlink>(3), B<sem_overview>(7)"
7192 msgstr ""
7193
7194 #. type: TH
7195 #: build/C/man2/shmctl.2:45
7196 #, no-wrap
7197 msgid "SHMCTL"
7198 msgstr ""
7199
7200 #. type: TH
7201 #: build/C/man2/shmctl.2:45
7202 #, no-wrap
7203 msgid "2013-03-18"
7204 msgstr ""
7205
7206 #. type: Plain text
7207 #: build/C/man2/shmctl.2:48
7208 msgid "shmctl - System V shared memory control"
7209 msgstr ""
7210
7211 #. type: Plain text
7212 #: build/C/man2/shmctl.2:51 build/C/man2/shmget.2:44
7213 msgid "B<#include E<lt>sys/ipc.hE<gt>>"
7214 msgstr ""
7215
7216 #. type: Plain text
7217 #: build/C/man2/shmctl.2:53 build/C/man2/shmget.2:46
7218 msgid "B<#include E<lt>sys/shm.hE<gt>>"
7219 msgstr ""
7220
7221 #. type: Plain text
7222 #: build/C/man2/shmctl.2:55
7223 msgid "B<int shmctl(int >I<shmid>B<, int >I<cmd>B<, struct shmid_ds *>I<buf>B<);>"
7224 msgstr ""
7225
7226 #. type: Plain text
7227 #: build/C/man2/shmctl.2:62
7228 msgid ""
7229 "B<shmctl>()  performs the control operation specified by I<cmd> on the "
7230 "System V shared memory segment whose identifier is given in I<shmid>."
7231 msgstr ""
7232
7233 #. type: Plain text
7234 #: build/C/man2/shmctl.2:67
7235 msgid ""
7236 "The I<buf> argument is a pointer to a I<shmid_ds> structure, defined in "
7237 "I<E<lt>sys/shm.hE<gt>> as follows:"
7238 msgstr ""
7239
7240 #. type: Plain text
7241 #: build/C/man2/shmctl.2:81
7242 #, no-wrap
7243 msgid ""
7244 "struct shmid_ds {\n"
7245 "    struct ipc_perm shm_perm;    /* Ownership and permissions */\n"
7246 "    size_t          shm_segsz;   /* Size of segment (bytes) */\n"
7247 "    time_t          shm_atime;   /* Last attach time */\n"
7248 "    time_t          shm_dtime;   /* Last detach time */\n"
7249 "    time_t          shm_ctime;   /* Last change time */\n"
7250 "    pid_t           shm_cpid;    /* PID of creator */\n"
7251 "    pid_t           shm_lpid;    /* PID of last shmat(2)/shmdt(2) */\n"
7252 "    shmatt_t        shm_nattch;  /* No. of current attaches */\n"
7253 "    ...\n"
7254 "};\n"
7255 msgstr ""
7256
7257 #. type: Plain text
7258 #: build/C/man2/shmctl.2:89
7259 msgid ""
7260 "The I<ipc_perm> structure is defined as follows (the highlighted fields are "
7261 "settable using B<IPC_SET>):"
7262 msgstr ""
7263
7264 #. type: Plain text
7265 #: build/C/man2/shmctl.2:102
7266 #, no-wrap
7267 msgid ""
7268 "struct ipc_perm {\n"
7269 "    key_t          __key;    /* Key supplied to shmget(2) */\n"
7270 "    uid_t          B<uid>;      /* Effective UID of owner */\n"
7271 "    gid_t          B<gid>;      /* Effective GID of owner */\n"
7272 "    uid_t          cuid;     /* Effective UID of creator */\n"
7273 "    gid_t          cgid;     /* Effective GID of creator */\n"
7274 "    unsigned short B<mode>;     /* B<Permissions> + SHM_DEST and\n"
7275 "                                SHM_LOCKED flags */\n"
7276 "    unsigned short __seq;    /* Sequence number */\n"
7277 "};\n"
7278 msgstr ""
7279
7280 #. type: Plain text
7281 #: build/C/man2/shmctl.2:108
7282 msgid "Valid values for I<cmd> are:"
7283 msgstr ""
7284
7285 #. type: TP
7286 #: build/C/man2/shmctl.2:109
7287 #, no-wrap
7288 msgid "B<IPC_STAT>"
7289 msgstr ""
7290
7291 #. type: Plain text
7292 #: build/C/man2/shmctl.2:118
7293 msgid ""
7294 "Copy information from the kernel data structure associated with I<shmid> "
7295 "into the I<shmid_ds> structure pointed to by I<buf>.  The caller must have "
7296 "read permission on the shared memory segment."
7297 msgstr ""
7298
7299 #. type: TP
7300 #: build/C/man2/shmctl.2:118
7301 #, no-wrap
7302 msgid "B<IPC_SET>"
7303 msgstr ""
7304
7305 #. type: Plain text
7306 #: build/C/man2/shmctl.2:136
7307 msgid ""
7308 "Write the values of some members of the I<shmid_ds> structure pointed to by "
7309 "I<buf> to the kernel data structure associated with this shared memory "
7310 "segment, updating also its I<shm_ctime> member.  The following fields can be "
7311 "changed: I<shm_perm.uid>, I<shm_perm.gid>, and (the least significant 9 bits "
7312 "of) I<shm_perm.mode>.  The effective UID of the calling process must match "
7313 "the owner (I<shm_perm.uid>)  or creator (I<shm_perm.cuid>)  of the shared "
7314 "memory segment, or the caller must be privileged."
7315 msgstr ""
7316
7317 #. type: TP
7318 #: build/C/man2/shmctl.2:136
7319 #, no-wrap
7320 msgid "B<IPC_RMID>"
7321 msgstr ""
7322
7323 #. type: Plain text
7324 #: build/C/man2/shmctl.2:153
7325 msgid ""
7326 "Mark the segment to be destroyed.  The segment will only actually be "
7327 "destroyed after the last process detaches it (i.e., when the I<shm_nattch> "
7328 "member of the associated structure I<shmid_ds> is zero).  The caller must be "
7329 "the owner or creator, or be privileged.  If a segment has been marked for "
7330 "destruction, then the (nonstandard)  B<SHM_DEST> flag of the "
7331 "I<shm_perm.mode> field in the associated data structure retrieved by "
7332 "B<IPC_STAT> will be set."
7333 msgstr ""
7334
7335 #. type: Plain text
7336 #: build/C/man2/shmctl.2:156
7337 msgid ""
7338 "The caller I<must> ensure that a segment is eventually destroyed; otherwise "
7339 "its pages that were faulted in will remain in memory or swap."
7340 msgstr ""
7341
7342 #. type: Plain text
7343 #: build/C/man2/shmctl.2:161
7344 msgid ""
7345 "See also the description of I</proc/sys/kernel/shm_rmid_forced> in "
7346 "B<proc>(5)."
7347 msgstr ""
7348
7349 #. type: TP
7350 #: build/C/man2/shmctl.2:161
7351 #, no-wrap
7352 msgid "B<IPC_INFO> (Linux-specific)"
7353 msgstr ""
7354
7355 #. type: Plain text
7356 #: build/C/man2/shmctl.2:174
7357 msgid ""
7358 "Returns information about system-wide shared memory limits and parameters in "
7359 "the structure pointed to by I<buf>.  This structure is of type I<shminfo> "
7360 "(thus, a cast is required), defined in I<E<lt>sys/shm.hE<gt>> if the "
7361 "B<_GNU_SOURCE> feature test macro is defined:"
7362 msgstr ""
7363
7364 #. type: Plain text
7365 #: build/C/man2/shmctl.2:188
7366 #, no-wrap
7367 msgid ""
7368 "struct  shminfo {\n"
7369 "    unsigned long shmmax; /* Maximum segment size */\n"
7370 "    unsigned long shmmin; /* Minimum segment size;\n"
7371 "                             always 1 */\n"
7372 "    unsigned long shmmni; /* Maximum number of segments */\n"
7373 "    unsigned long shmseg; /* Maximum number of segments\n"
7374 "                             that a process can attach;\n"
7375 "                             unused within kernel */\n"
7376 "    unsigned long shmall; /* Maximum number of pages of\n"
7377 "                             shared memory, system-wide */\n"
7378 "};\n"
7379 msgstr ""
7380
7381 #. type: Plain text
7382 #: build/C/man2/shmctl.2:201
7383 msgid ""
7384 "The I<shmmni>, I<shmmax>, and I<shmall> settings can be changed via I</proc> "
7385 "files of the same name; see B<proc>(5)  for details."
7386 msgstr ""
7387
7388 #. type: TP
7389 #: build/C/man2/shmctl.2:201
7390 #, no-wrap
7391 msgid "B<SHM_INFO> (Linux-specific)"
7392 msgstr ""
7393
7394 #. type: Plain text
7395 #: build/C/man2/shmctl.2:212
7396 msgid ""
7397 "Returns a I<shm_info> structure whose fields contain information about "
7398 "system resources consumed by shared memory.  This structure is defined in "
7399 "I<E<lt>sys/shm.hE<gt>> if the B<_GNU_SOURCE> feature test macro is defined:"
7400 msgstr ""
7401
7402 #. type: Plain text
7403 #: build/C/man2/shmctl.2:229
7404 #, no-wrap
7405 msgid ""
7406 "struct shm_info {\n"
7407 "    int           used_ids; /* # of currently existing\n"
7408 "                               segments */\n"
7409 "    unsigned long shm_tot;  /* Total number of shared\n"
7410 "                               memory pages */\n"
7411 "    unsigned long shm_rss;  /* # of resident shared\n"
7412 "                               memory pages */\n"
7413 "    unsigned long shm_swp;  /* # of swapped shared\n"
7414 "                               memory pages */\n"
7415 "    unsigned long swap_attempts;\n"
7416 "                            /* Unused since Linux 2.4 */\n"
7417 "    unsigned long swap_successes;\n"
7418 "                            /* Unused since Linux 2.4 */\n"
7419 "};\n"
7420 msgstr ""
7421
7422 #. type: TP
7423 #: build/C/man2/shmctl.2:231
7424 #, no-wrap
7425 msgid "B<SHM_STAT> (Linux-specific)"
7426 msgstr ""
7427
7428 #. type: Plain text
7429 #: build/C/man2/shmctl.2:242
7430 msgid ""
7431 "Returns a I<shmid_ds> structure as for B<IPC_STAT>.  However, the I<shmid> "
7432 "argument is not a segment identifier, but instead an index into the kernel's "
7433 "internal array that maintains information about all shared memory segments "
7434 "on the system."
7435 msgstr ""
7436
7437 #. type: Plain text
7438 #: build/C/man2/shmctl.2:245
7439 msgid ""
7440 "The caller can prevent or allow swapping of a shared memory segment with the "
7441 "following I<cmd> values:"
7442 msgstr ""
7443
7444 #. type: TP
7445 #: build/C/man2/shmctl.2:246
7446 #, no-wrap
7447 msgid "B<SHM_LOCK> (Linux-specific)"
7448 msgstr ""
7449
7450 #. type: Plain text
7451 #: build/C/man2/shmctl.2:258
7452 msgid ""
7453 "Prevent swapping of the shared memory segment.  The caller must fault in any "
7454 "pages that are required to be present after locking is enabled.  If a "
7455 "segment has been locked, then the (nonstandard)  B<SHM_LOCKED> flag of the "
7456 "I<shm_perm.mode> field in the associated data structure retrieved by "
7457 "B<IPC_STAT> will be set."
7458 msgstr ""
7459
7460 #. type: TP
7461 #: build/C/man2/shmctl.2:258
7462 #, no-wrap
7463 msgid "B<SHM_UNLOCK> (Linux-specific)"
7464 msgstr ""
7465
7466 #. type: Plain text
7467 #: build/C/man2/shmctl.2:261
7468 msgid "Unlock the segment, allowing it to be swapped out."
7469 msgstr ""
7470
7471 #.  There was some weirdness in 2.6.9: SHM_LOCK and SHM_UNLOCK could
7472 #.  be applied to a segment, regardless of ownership of the segment.
7473 #.  This was a botch-up in the move to RLIMIT_MEMLOCK, and was fixed
7474 #.  in 2.6.10.  MTK, May 2005
7475 #. type: Plain text
7476 #: build/C/man2/shmctl.2:279
7477 msgid ""
7478 "In kernels before 2.6.10, only a privileged process could employ B<SHM_LOCK> "
7479 "and B<SHM_UNLOCK>.  Since kernel 2.6.10, an unprivileged process can employ "
7480 "these operations if its effective UID matches the owner or creator UID of "
7481 "the segment, and (for B<SHM_LOCK>)  the amount of memory to be locked falls "
7482 "within the B<RLIMIT_MEMLOCK> resource limit (see B<setrlimit>(2))."
7483 msgstr ""
7484
7485 #. type: Plain text
7486 #: build/C/man2/shmctl.2:297
7487 msgid ""
7488 "A successful B<IPC_INFO> or B<SHM_INFO> operation returns the index of the "
7489 "highest used entry in the kernel's internal array recording information "
7490 "about all shared memory segments.  (This information can be used with "
7491 "repeated B<SHM_STAT> operations to obtain information about all shared "
7492 "memory segments on the system.)  A successful B<SHM_STAT> operation returns "
7493 "the identifier of the shared memory segment whose index was given in "
7494 "I<shmid>.  Other operations return 0 on success."
7495 msgstr ""
7496
7497 #. type: Plain text
7498 #: build/C/man2/shmctl.2:301
7499 msgid "On error, -1 is returned, and I<errno> is set appropriately."
7500 msgstr ""
7501
7502 #. type: Plain text
7503 #: build/C/man2/shmctl.2:310
7504 msgid ""
7505 "B<IPC_STAT> or B<SHM_STAT> is requested and I<shm_perm.mode> does not allow "
7506 "read access for I<shmid>, and the calling process does not have the "
7507 "B<CAP_IPC_OWNER> capability."
7508 msgstr ""
7509
7510 #. type: Plain text
7511 #: build/C/man2/shmctl.2:321
7512 msgid ""
7513 "The argument I<cmd> has value B<IPC_SET> or B<IPC_STAT> but the address "
7514 "pointed to by I<buf> isn't accessible."
7515 msgstr ""
7516
7517 #. type: TP
7518 #: build/C/man2/shmctl.2:321 build/C/man2/shmop.2:197
7519 #, no-wrap
7520 msgid "B<EIDRM>"
7521 msgstr ""
7522
7523 #. type: Plain text
7524 #: build/C/man2/shmctl.2:324 build/C/man2/shmop.2:200
7525 msgid "I<shmid> points to a removed identifier."
7526 msgstr ""
7527
7528 #. type: Plain text
7529 #: build/C/man2/shmctl.2:333
7530 msgid ""
7531 "I<shmid> is not a valid identifier, or I<cmd> is not a valid command.  Or: "
7532 "for a B<SHM_STAT> operation, the index value specified in I<shmid> referred "
7533 "to an array slot that is currently unused."
7534 msgstr ""
7535
7536 #. type: Plain text
7537 #: build/C/man2/shmctl.2:344
7538 msgid ""
7539 "(In kernels since 2.6.9), B<SHM_LOCK> was specified and the size of the "
7540 "to-be-locked segment would mean that the total bytes in locked shared memory "
7541 "segments would exceed the limit for the real user ID of the calling "
7542 "process.  This limit is defined by the B<RLIMIT_MEMLOCK> soft resource limit "
7543 "(see B<setrlimit>(2))."
7544 msgstr ""
7545
7546 #. type: Plain text
7547 #: build/C/man2/shmctl.2:349
7548 msgid ""
7549 "B<IPC_STAT> is attempted, and the GID or UID value is too large to be stored "
7550 "in the structure pointed to by I<buf>."
7551 msgstr ""
7552
7553 #. type: Plain text
7554 #: build/C/man2/shmctl.2:361
7555 msgid ""
7556 "B<IPC_SET> or B<IPC_RMID> is attempted, and the effective user ID of the "
7557 "calling process is not that of the creator (found in I<shm_perm.cuid>), or "
7558 "the owner (found in I<shm_perm.uid>), and the process was not privileged "
7559 "(Linux: did not have the B<CAP_SYS_ADMIN> capability)."
7560 msgstr ""
7561
7562 #. type: Plain text
7563 #: build/C/man2/shmctl.2:373
7564 msgid ""
7565 "Or (in kernels before 2.6.9), B<SHM_LOCK> or B<SHM_UNLOCK> was specified, "
7566 "but the process was not privileged (Linux: did not have the B<CAP_IPC_LOCK> "
7567 "capability).  (Since Linux 2.6.9, this error can also occur if the "
7568 "B<RLIMIT_MEMLOCK> is 0 and the caller is not privileged.)"
7569 msgstr ""
7570
7571 #.  SVr4 documents an additional error condition EMFILE.
7572 #. type: Plain text
7573 #: build/C/man2/shmctl.2:378 build/C/man2/shmget.2:235 build/C/man2/shmop.2:234
7574 msgid "SVr4, POSIX.1-2001."
7575 msgstr ""
7576
7577 #.  Like Linux, the FreeBSD man pages still document
7578 #.  the inclusion of these header files.
7579 #. type: Plain text
7580 #: build/C/man2/shmctl.2:391 build/C/man2/shmget.2:251
7581 msgid ""
7582 "The inclusion of I<E<lt>sys/types.hE<gt>> and I<E<lt>sys/ipc.hE<gt>> isn't "
7583 "required on Linux or by any version of POSIX.  However, some old "
7584 "implementations required the inclusion of these header files, and the SVID "
7585 "also documented their inclusion.  Applications intended to be portable to "
7586 "such old systems may need to include these header files."
7587 msgstr ""
7588
7589 #. type: Plain text
7590 #: build/C/man2/shmctl.2:403
7591 msgid ""
7592 "The B<IPC_INFO>, B<SHM_STAT> and B<SHM_INFO> operations are used by the "
7593 "B<ipcs>(1)  program to provide information on allocated resources.  In the "
7594 "future these may modified or moved to a I</proc> filesystem interface."
7595 msgstr ""
7596
7597 #. type: Plain text
7598 #: build/C/man2/shmctl.2:411
7599 msgid ""
7600 "Linux permits a process to attach (B<shmat>(2))  a shared memory segment "
7601 "that has already been marked for deletion using I<shmctl(IPC_RMID)>.  This "
7602 "feature is not available on other UNIX implementations; portable "
7603 "applications should avoid relying on it."
7604 msgstr ""
7605
7606 #. type: Plain text
7607 #: build/C/man2/shmctl.2:424
7608 msgid ""
7609 "Various fields in a I<struct shmid_ds> were typed as I<short> under Linux "
7610 "2.2 and have become I<long> under Linux 2.4.  To take advantage of this, a "
7611 "recompilation under glibc-2.1.91 or later should suffice.  (The kernel "
7612 "distinguishes old and new calls by an B<IPC_64> flag in I<cmd>.)"
7613 msgstr ""
7614
7615 #. type: Plain text
7616 #: build/C/man2/shmctl.2:431
7617 msgid ""
7618 "B<mlock>(2), B<setrlimit>(2), B<shmget>(2), B<shmop>(2), B<capabilities>(7), "
7619 "B<svipc>(7)"
7620 msgstr ""
7621
7622 #. type: TH
7623 #: build/C/man2/shmget.2:38
7624 #, no-wrap
7625 msgid "SHMGET"
7626 msgstr ""
7627
7628 #. type: Plain text
7629 #: build/C/man2/shmget.2:41
7630 msgid "shmget - allocates a System V shared memory segment"
7631 msgstr ""
7632
7633 #. type: Plain text
7634 #: build/C/man2/shmget.2:48
7635 msgid "B<int shmget(key_t >I<key>B<, size_t >I<size>B<, int >I<shmflg>B<);>"
7636 msgstr ""
7637
7638 #. type: Plain text
7639 #: build/C/man2/shmget.2:72
7640 msgid ""
7641 "B<shmget>()  returns the identifier of the System V shared memory segment "
7642 "associated with the value of the argument I<key>.  A new shared memory "
7643 "segment, with size equal to the value of I<size> rounded up to a multiple of "
7644 "B<PAGE_SIZE>, is created if I<key> has the value B<IPC_PRIVATE> or I<key> "
7645 "isn't B<IPC_PRIVATE>, no shared memory segment corresponding to I<key> "
7646 "exists, and B<IPC_CREAT> is specified in I<shmflg>."
7647 msgstr ""
7648
7649 #. type: Plain text
7650 #: build/C/man2/shmget.2:91
7651 msgid ""
7652 "If I<shmflg> specifies both B<IPC_CREAT> and B<IPC_EXCL> and a shared memory "
7653 "segment already exists for I<key>, then B<shmget>()  fails with I<errno> set "
7654 "to B<EEXIST>.  (This is analogous to the effect of the combination B<O_CREAT "
7655 "| O_EXCL> for B<open>(2).)"
7656 msgstr ""
7657
7658 #. type: Plain text
7659 #: build/C/man2/shmget.2:95
7660 msgid "The value I<shmflg> is composed of:"
7661 msgstr ""
7662
7663 #. type: TP
7664 #: build/C/man2/shmget.2:95
7665 #, no-wrap
7666 msgid "B<IPC_CREAT>"
7667 msgstr ""
7668
7669 #. type: Plain text
7670 #: build/C/man2/shmget.2:102
7671 msgid ""
7672 "to create a new segment.  If this flag is not used, then B<shmget>()  will "
7673 "find the segment associated with I<key> and check to see if the user has "
7674 "permission to access the segment."
7675 msgstr ""
7676
7677 #. type: TP
7678 #: build/C/man2/shmget.2:102
7679 #, no-wrap
7680 msgid "B<IPC_EXCL>"
7681 msgstr ""
7682
7683 #. type: Plain text
7684 #: build/C/man2/shmget.2:105
7685 msgid "used with B<IPC_CREAT> to ensure failure if the segment already exists."
7686 msgstr ""
7687
7688 #. type: TP
7689 #: build/C/man2/shmget.2:105
7690 #, no-wrap
7691 msgid "I<mode_flags>"
7692 msgstr ""
7693
7694 #. type: Plain text
7695 #: build/C/man2/shmget.2:115
7696 msgid ""
7697 "(least significant 9 bits)  specifying the permissions granted to the owner, "
7698 "group, and world.  These bits have the same format, and the same meaning, as "
7699 "the I<mode> argument of B<open>(2).  Presently, the execute permissions are "
7700 "not used by the system."
7701 msgstr ""
7702
7703 #. type: TP
7704 #: build/C/man2/shmget.2:115
7705 #, no-wrap
7706 msgid "B<SHM_HUGETLB> (since Linux 2.6)"
7707 msgstr ""
7708
7709 #. type: Plain text
7710 #: build/C/man2/shmget.2:121
7711 msgid ""
7712 "Allocate the segment using \"huge pages.\" See the Linux kernel source file "
7713 "I<Documentation/vm/hugetlbpage.txt> for further information."
7714 msgstr ""
7715
7716 #. type: TP
7717 #: build/C/man2/shmget.2:121
7718 #, no-wrap
7719 msgid "B<SHM_NORESERVE> (since Linux 2.6.15)"
7720 msgstr ""
7721
7722 #.  As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
7723 #.  specified.
7724 #. type: Plain text
7725 #: build/C/man2/shmget.2:140
7726 msgid ""
7727 "This flag serves the same purpose as the B<mmap>(2)  B<MAP_NORESERVE> flag.  "
7728 "Do not reserve swap space for this segment.  When swap space is reserved, "
7729 "one has the guarantee that it is possible to modify the segment.  When swap "
7730 "space is not reserved one might get B<SIGSEGV> upon a write if no physical "
7731 "memory is available.  See also the discussion of the file "
7732 "I</proc/sys/vm/overcommit_memory> in B<proc>(5)."
7733 msgstr ""
7734
7735 #. type: Plain text
7736 #: build/C/man2/shmget.2:148
7737 msgid ""
7738 "When a new shared memory segment is created, its contents are initialized to "
7739 "zero values, and its associated data structure, I<shmid_ds> (see "
7740 "B<shmctl>(2)), is initialized as follows:"
7741 msgstr ""
7742
7743 #. type: Plain text
7744 #: build/C/man2/shmget.2:153
7745 msgid ""
7746 "I<shm_perm.cuid> and I<shm_perm.uid> are set to the effective user ID of the "
7747 "calling process."
7748 msgstr ""
7749
7750 #. type: Plain text
7751 #: build/C/man2/shmget.2:158
7752 msgid ""
7753 "I<shm_perm.cgid> and I<shm_perm.gid> are set to the effective group ID of "
7754 "the calling process."
7755 msgstr ""
7756
7757 #. type: Plain text
7758 #: build/C/man2/shmget.2:163
7759 msgid ""
7760 "The least significant 9 bits of I<shm_perm.mode> are set to the least "
7761 "significant 9 bit of I<shmflg>."
7762 msgstr ""
7763
7764 #. type: Plain text
7765 #: build/C/man2/shmget.2:167
7766 msgid "I<shm_segsz> is set to the value of I<size>."
7767 msgstr ""
7768
7769 #. type: Plain text
7770 #: build/C/man2/shmget.2:174
7771 msgid "I<shm_lpid>, I<shm_nattch>, I<shm_atime> and I<shm_dtime> are set to 0."
7772 msgstr ""
7773
7774 #. type: Plain text
7775 #: build/C/man2/shmget.2:177
7776 msgid "I<shm_ctime> is set to the current time."
7777 msgstr ""
7778
7779 #. type: Plain text
7780 #: build/C/man2/shmget.2:180
7781 msgid ""
7782 "If the shared memory segment already exists, the permissions are verified, "
7783 "and a check is made to see if it is marked for destruction."
7784 msgstr ""
7785
7786 #. type: Plain text
7787 #: build/C/man2/shmget.2:185
7788 msgid ""
7789 "On success, a valid shared memory identifier is returned.  On errir, -1 is "
7790 "returned, and I<errno> is set to indicate the error."
7791 msgstr ""
7792
7793 #. type: Plain text
7794 #: build/C/man2/shmget.2:189
7795 msgid "On failure, I<errno> is set to one of the following:"
7796 msgstr ""
7797
7798 #. type: Plain text
7799 #: build/C/man2/shmget.2:195
7800 msgid ""
7801 "The user does not have permission to access the shared memory segment, and "
7802 "does not have the B<CAP_IPC_OWNER> capability."
7803 msgstr ""
7804
7805 #. type: Plain text
7806 #: build/C/man2/shmget.2:199
7807 msgid "B<IPC_CREAT | IPC_EXCL> was specified and the segment exists."
7808 msgstr ""
7809
7810 #. type: Plain text
7811 #: build/C/man2/shmget.2:205
7812 msgid ""
7813 "A new segment was to be created and I<size> E<lt> B<SHMMIN> or I<size> E<gt> "
7814 "B<SHMMAX>, or no new segment was to be created, a segment with given key "
7815 "existed, but I<size> is greater than the size of that segment."
7816 msgstr ""
7817
7818 #. type: Plain text
7819 #: build/C/man2/shmget.2:214
7820 msgid "No segment exists for the given I<key>, and B<IPC_CREAT> was not specified."
7821 msgstr ""
7822
7823 #. type: Plain text
7824 #: build/C/man2/shmget.2:217
7825 msgid "No memory could be allocated for segment overhead."
7826 msgstr ""
7827
7828 #. type: Plain text
7829 #: build/C/man2/shmget.2:225
7830 msgid ""
7831 "All possible shared memory IDs have been taken (B<SHMMNI>), or allocating a "
7832 "segment of the requested I<size> would cause the system to exceed the "
7833 "system-wide limit on shared memory (B<SHMALL>)."
7834 msgstr ""
7835
7836 #. type: Plain text
7837 #: build/C/man2/shmget.2:232
7838 msgid ""
7839 "The B<SHM_HUGETLB> flag was specified, but the caller was not privileged "
7840 "(did not have the B<CAP_IPC_LOCK> capability)."
7841 msgstr ""
7842
7843 #. type: Plain text
7844 #: build/C/man2/shmget.2:238
7845 msgid "B<SHM_HUGETLB> is a nonportable Linux extension."
7846 msgstr ""
7847
7848 #. type: Plain text
7849 #: build/C/man2/shmget.2:261
7850 msgid ""
7851 "B<IPC_PRIVATE> isn't a flag field but a I<key_t> type.  If this special "
7852 "value is used for I<key>, the system call ignores everything but the least "
7853 "significant 9 bits of I<shmflg> and creates a new shared memory segment (on "
7854 "success)."
7855 msgstr ""
7856
7857 #. type: Plain text
7858 #: build/C/man2/shmget.2:265
7859 msgid ""
7860 "The following limits on shared memory segment resources affect the "
7861 "B<shmget>()  call:"
7862 msgstr ""
7863
7864 #. type: TP
7865 #: build/C/man2/shmget.2:265
7866 #, no-wrap
7867 msgid "B<SHMALL>"
7868 msgstr ""
7869
7870 #. type: Plain text
7871 #: build/C/man2/shmget.2:270
7872 msgid ""
7873 "System wide maximum of shared memory pages (on Linux, this limit can be read "
7874 "and modified via I</proc/sys/kernel/shmall>)."
7875 msgstr ""
7876
7877 #. type: TP
7878 #: build/C/man2/shmget.2:270
7879 #, no-wrap
7880 msgid "B<SHMMAX>"
7881 msgstr ""
7882
7883 #. type: Plain text
7884 #: build/C/man2/shmget.2:275
7885 msgid ""
7886 "Maximum size in bytes for a shared memory segment: policy dependent (on "
7887 "Linux, this limit can be read and modified via I</proc/sys/kernel/shmmax>)."
7888 msgstr ""
7889
7890 #. type: TP
7891 #: build/C/man2/shmget.2:275
7892 #, no-wrap
7893 msgid "B<SHMMIN>"
7894 msgstr ""
7895
7896 #. type: Plain text
7897 #: build/C/man2/shmget.2:281
7898 msgid ""
7899 "Minimum size in bytes for a shared memory segment: implementation dependent "
7900 "(currently 1 byte, though B<PAGE_SIZE> is the effective minimum size)."
7901 msgstr ""
7902
7903 #. type: TP
7904 #: build/C/man2/shmget.2:281
7905 #, no-wrap
7906 msgid "B<SHMMNI>"
7907 msgstr ""
7908
7909 #.  Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
7910 #.  that we could create one more segment than SHMMNI -- MTK
7911 #.  This /proc file is not available in Linux 2.2 and earlier -- MTK
7912 #. type: Plain text
7913 #: build/C/man2/shmget.2:290
7914 msgid ""
7915 "System wide maximum number of shared memory segments: implementation "
7916 "dependent (currently 4096, was 128 before Linux 2.3.99; on Linux, this limit "
7917 "can be read and modified via I</proc/sys/kernel/shmmni>)."
7918 msgstr ""
7919
7920 #. type: Plain text
7921 #: build/C/man2/shmget.2:294
7922 msgid ""
7923 "The implementation has no specific limits for the per-process maximum number "
7924 "of shared memory segments (B<SHMSEG>)."
7925 msgstr ""
7926
7927 #. type: Plain text
7928 #: build/C/man2/shmget.2:300
7929 msgid ""
7930 "Until version 2.3.30 Linux would return B<EIDRM> for a B<shmget>()  on a "
7931 "shared memory segment scheduled for deletion."
7932 msgstr ""
7933
7934 #. type: Plain text
7935 #: build/C/man2/shmget.2:306
7936 msgid ""
7937 "The name choice B<IPC_PRIVATE> was perhaps unfortunate, B<IPC_NEW> would "
7938 "more clearly show its function."
7939 msgstr ""
7940
7941 #. type: Plain text
7942 #: build/C/man2/shmget.2:314
7943 msgid ""
7944 "B<shmat>(2), B<shmctl>(2), B<shmdt>(2), B<ftok>(3), B<capabilities>(7), "
7945 "B<shm_overview>(7), B<svipc>(7)"
7946 msgstr ""
7947
7948 #. type: TH
7949 #: build/C/man2/shmop.2:41
7950 #, no-wrap
7951 msgid "SHMOP"
7952 msgstr ""
7953
7954 #. type: Plain text
7955 #: build/C/man2/shmop.2:44
7956 msgid "shmat, shmdt - System V shared memory operations"
7957 msgstr ""
7958
7959 #. type: Plain text
7960 #: build/C/man2/shmop.2:48
7961 #, no-wrap
7962 msgid ""
7963 "B<#include E<lt>sys/types.hE<gt>>\n"
7964 "B<#include E<lt>sys/shm.hE<gt>>\n"
7965 msgstr ""
7966
7967 #. type: Plain text
7968 #: build/C/man2/shmop.2:50
7969 #, no-wrap
7970 msgid ""
7971 "B<void *shmat(int >I<shmid>B<, const void *>I<shmaddr>B<, int "
7972 ">I<shmflg>B<);>\n"
7973 msgstr ""
7974
7975 #. type: Plain text
7976 #: build/C/man2/shmop.2:52
7977 #, no-wrap
7978 msgid "B<int shmdt(const void *>I<shmaddr>B<);>\n"
7979 msgstr ""
7980
7981 #. type: Plain text
7982 #: build/C/man2/shmop.2:61
7983 msgid ""
7984 "B<shmat>()  attaches the System V shared memory segment identified by "
7985 "I<shmid> to the address space of the calling process.  The attaching address "
7986 "is specified by I<shmaddr> with one of the following criteria:"
7987 msgstr ""
7988
7989 #. type: Plain text
7990 #: build/C/man2/shmop.2:67
7991 msgid ""
7992 "If I<shmaddr> is NULL, the system chooses a suitable (unused) address at "
7993 "which to attach the segment."
7994 msgstr ""
7995
7996 #. type: Plain text
7997 #: build/C/man2/shmop.2:82
7998 msgid ""
7999 "If I<shmaddr> isn't NULL and B<SHM_RND> is specified in I<shmflg>, the "
8000 "attach occurs at the address equal to I<shmaddr> rounded down to the nearest "
8001 "multiple of B<SHMLBA>.  Otherwise I<shmaddr> must be a page-aligned address "
8002 "at which the attach occurs."
8003 msgstr ""
8004
8005 #. type: Plain text
8006 #: build/C/man2/shmop.2:92
8007 msgid ""
8008 "If B<SHM_RDONLY> is specified in I<shmflg>, the segment is attached for "
8009 "reading and the process must have read permission for the segment.  "
8010 "Otherwise the segment is attached for read and write and the process must "
8011 "have read and write permission for the segment.  There is no notion of a "
8012 "write-only shared memory segment."
8013 msgstr ""
8014
8015 #. type: Plain text
8016 #: build/C/man2/shmop.2:107
8017 msgid ""
8018 "The (Linux-specific)  B<SHM_REMAP> flag may be specified in I<shmflg> to "
8019 "indicate that the mapping of the segment should replace any existing mapping "
8020 "in the range starting at I<shmaddr> and continuing for the size of the "
8021 "segment.  (Normally an B<EINVAL> error would result if a mapping already "
8022 "exists in this address range.)  In this case, I<shmaddr> must not be NULL."
8023 msgstr ""
8024
8025 #. type: Plain text
8026 #: build/C/man2/shmop.2:114
8027 msgid ""
8028 "The B<brk>(2)  value of the calling process is not altered by the attach.  "
8029 "The segment will automatically be detached at process exit.  The same "
8030 "segment may be attached as a read and as a read-write one, and more than "
8031 "once, in the process's address space."
8032 msgstr ""
8033
8034 #. type: Plain text
8035 #: build/C/man2/shmop.2:122
8036 msgid ""
8037 "A successful B<shmat>()  call updates the members of the I<shmid_ds> "
8038 "structure (see B<shmctl>(2))  associated with the shared memory segment as "
8039 "follows:"
8040 msgstr ""
8041
8042 #. type: Plain text
8043 #: build/C/man2/shmop.2:125
8044 msgid "I<shm_atime> is set to the current time."
8045 msgstr ""
8046
8047 #. type: Plain text
8048 #: build/C/man2/shmop.2:128 build/C/man2/shmop.2:154
8049 msgid "I<shm_lpid> is set to the process-ID of the calling process."
8050 msgstr ""
8051
8052 #. type: Plain text
8053 #: build/C/man2/shmop.2:131
8054 msgid "I<shm_nattch> is incremented by one."
8055 msgstr ""
8056
8057 #. type: Plain text
8058 #: build/C/man2/shmop.2:142
8059 msgid ""
8060 "B<shmdt>()  detaches the shared memory segment located at the address "
8061 "specified by I<shmaddr> from the address space of the calling process.  The "
8062 "to-be-detached segment must be currently attached with I<shmaddr> equal to "
8063 "the value returned by the attaching B<shmat>()  call."
8064 msgstr ""
8065
8066 #. type: Plain text
8067 #: build/C/man2/shmop.2:148
8068 msgid ""
8069 "On a successful B<shmdt>()  call the system updates the members of the "
8070 "I<shmid_ds> structure associated with the shared memory segment as follows:"
8071 msgstr ""
8072
8073 #. type: Plain text
8074 #: build/C/man2/shmop.2:151
8075 msgid "I<shm_dtime> is set to the current time."
8076 msgstr ""
8077
8078 #. type: Plain text
8079 #: build/C/man2/shmop.2:159
8080 msgid ""
8081 "I<shm_nattch> is decremented by one.  If it becomes 0 and the segment is "
8082 "marked for deletion, the segment is deleted."
8083 msgstr ""
8084
8085 #. type: Plain text
8086 #: build/C/man2/shmop.2:163
8087 msgid "After a B<fork>(2)  the child inherits the attached shared memory segments."
8088 msgstr ""
8089
8090 #. type: Plain text
8091 #: build/C/man2/shmop.2:167
8092 msgid ""
8093 "After an B<execve>(2)  all attached shared memory segments are detached from "
8094 "the process."
8095 msgstr ""
8096
8097 #. type: Plain text
8098 #: build/C/man2/shmop.2:171
8099 msgid ""
8100 "Upon B<_exit>(2)  all attached shared memory segments are detached from the "
8101 "process."
8102 msgstr ""
8103
8104 #. type: Plain text
8105 #: build/C/man2/shmop.2:179
8106 msgid ""
8107 "On success B<shmat>()  returns the address of the attached shared memory "
8108 "segment; on error I<(void\\ *)\\ -1> is returned, and I<errno> is set to "
8109 "indicate the cause of the error."
8110 msgstr ""
8111
8112 #. type: Plain text
8113 #: build/C/man2/shmop.2:185
8114 msgid ""
8115 "On success B<shmdt>()  returns 0; on error -1 is returned, and I<errno> is "
8116 "set to indicate the cause of the error."
8117 msgstr ""
8118
8119 #. type: Plain text
8120 #: build/C/man2/shmop.2:191
8121 msgid "When B<shmat>()  fails, I<errno> is set to one of the following:"
8122 msgstr ""
8123
8124 #. type: Plain text
8125 #: build/C/man2/shmop.2:197
8126 msgid ""
8127 "The calling process does not have the required permissions for the requested "
8128 "attach type, and does not have the B<CAP_IPC_OWNER> capability."
8129 msgstr ""
8130
8131 #. type: Plain text
8132 #: build/C/man2/shmop.2:214
8133 msgid ""
8134 "Invalid I<shmid> value, unaligned (i.e., not page-aligned and B<SHM_RND> was "
8135 "not specified) or invalid I<shmaddr> value, or can't attach segment at "
8136 "I<shmaddr>, or B<SHM_REMAP> was specified and I<shmaddr> was NULL."
8137 msgstr ""
8138
8139 #. type: Plain text
8140 #: build/C/man2/shmop.2:217
8141 msgid "Could not allocate memory for the descriptor or for the page tables."
8142 msgstr ""
8143
8144 #. type: Plain text
8145 #: build/C/man2/shmop.2:223
8146 msgid "When B<shmdt>()  fails, I<errno> is set as follows:"
8147 msgstr ""
8148
8149 #.  The following since 2.6.17-rc1:
8150 #. type: Plain text
8151 #: build/C/man2/shmop.2:231
8152 msgid ""
8153 "There is no shared memory segment attached at I<shmaddr>; or, I<shmaddr> is "
8154 "not aligned on a page boundary."
8155 msgstr ""
8156
8157 #. type: Plain text
8158 #: build/C/man2/shmop.2:250
8159 msgid ""
8160 "In SVID 3 (or perhaps earlier)  the type of the I<shmaddr> argument was "
8161 "changed from I<char\\ *> into I<const void\\ *>, and the returned type of "
8162 "B<shmat>()  from I<char\\ *> into I<void\\ *>.  (Linux libc4 and libc5 have "
8163 "the I<char\\ *> prototypes; glibc2 has I<void\\ *>.)"
8164 msgstr ""
8165
8166 #. type: Plain text
8167 #: build/C/man2/shmop.2:262
8168 msgid ""
8169 "Using B<shmat>()  with I<shmaddr> equal to NULL is the preferred, portable "
8170 "way of attaching a shared memory segment.  Be aware that the shared memory "
8171 "segment attached in this way may be attached at different addresses in "
8172 "different processes.  Therefore, any pointers maintained within the shared "
8173 "memory must be made relative (typically to the starting address of the "
8174 "segment), rather than absolute."
8175 msgstr ""
8176
8177 #. type: Plain text
8178 #: build/C/man2/shmop.2:267
8179 msgid ""
8180 "On Linux, it is possible to attach a shared memory segment even if it is "
8181 "already marked to be deleted.  However, POSIX.1-2001 does not specify this "
8182 "behavior and many other implementations do not support it."
8183 msgstr ""
8184
8185 #. type: Plain text
8186 #: build/C/man2/shmop.2:270
8187 msgid "The following system parameter affects B<shmat>():"
8188 msgstr ""
8189
8190 #.  FIXME A good explanation of the rationale for the existence
8191 #.  of SHMLBA would be useful here
8192 #. type: TP
8193 #: build/C/man2/shmop.2:270
8194 #, no-wrap
8195 msgid "B<SHMLBA>"
8196 msgstr ""
8197
8198 #.  FIXME That last sentence isn't true for all Linux
8199 #.  architectures (i.e., SHMLBA != PAGE_SIZE for some architectures)
8200 #.  -- MTK, Nov 04
8201 #. type: Plain text
8202 #: build/C/man2/shmop.2:283
8203 msgid ""
8204 "Segment low boundary address multiple.  Must be page aligned.  For the "
8205 "current implementation the B<SHMLBA> value is B<PAGE_SIZE>."
8206 msgstr ""
8207
8208 #. type: Plain text
8209 #: build/C/man2/shmop.2:287
8210 msgid ""
8211 "The implementation places no intrinsic limit on the per-process maximum "
8212 "number of shared memory segments (B<SHMSEG>)."
8213 msgstr ""
8214
8215 #. type: Plain text
8216 #: build/C/man2/shmop.2:295
8217 msgid ""
8218 "B<brk>(2), B<mmap>(2), B<shmctl>(2), B<shmget>(2), B<capabilities>(7), "
8219 "B<shm_overview>(7), B<svipc>(7)"
8220 msgstr ""
8221
8222 #. type: TH
8223 #: build/C/man2/subpage_prot.2:30
8224 #, no-wrap
8225 msgid "SUBPAGE_PROT"
8226 msgstr ""
8227
8228 #. type: TH
8229 #: build/C/man2/subpage_prot.2:30
8230 #, no-wrap
8231 msgid "2012-07-13"
8232 msgstr ""
8233
8234 #. type: Plain text
8235 #: build/C/man2/subpage_prot.2:33
8236 msgid "subpage_prot - define a subpage protection for an address range"
8237 msgstr ""
8238
8239 #. type: Plain text
8240 #: build/C/man2/subpage_prot.2:37
8241 #, no-wrap
8242 msgid ""
8243 "B<long subpage_prot(unsigned long >I<addr>B<, unsigned long >I<len>B<,>\n"
8244 "B<                  uint32_t *>I<map>B<);>\n"
8245 msgstr ""
8246
8247 #. type: Plain text
8248 #: build/C/man2/subpage_prot.2:41
8249 msgid "I<Note>: There is no glibc wrapper for this system call; see NOTES."
8250 msgstr ""
8251
8252 #. type: Plain text
8253 #: build/C/man2/subpage_prot.2:47
8254 msgid ""
8255 "The PowerPC-specific B<subpage_prot>()  system call provides the facility to "
8256 "control the access permissions on individual 4kB subpages on systems "
8257 "configured with a page size of 64kB."
8258 msgstr ""
8259
8260 #. type: Plain text
8261 #: build/C/man2/subpage_prot.2:54
8262 msgid ""
8263 "The protection map is applied to the memory pages in the region starting at "
8264 "I<addr> and continuing for I<len> bytes.  Both of these arguments must be "
8265 "aligned to a 64-kB boundary."
8266 msgstr ""
8267
8268 #. type: Plain text
8269 #: build/C/man2/subpage_prot.2:66
8270 msgid ""
8271 "The protection map is specified in the buffer pointed to by I<map>.  The map "
8272 "has 2 bits per 4kB subpage; thus each 32-bit word specifies the protections "
8273 "of 16 4kB subpages inside a 64kB page (so, the number of 32-bit words "
8274 "pointed to by I<map> should equate to the number of 64-kB pages specified by "
8275 "I<len>).  Each 2-bit field in the protection map is either 0 to allow any "
8276 "access, 1 to prevent writes, or 2 or 3 to prevent all accesses."
8277 msgstr ""
8278
8279 #. type: Plain text
8280 #: build/C/man2/subpage_prot.2:71
8281 msgid ""
8282 "On success, B<subpage_prot>()  returns 0.  Otherwise, one of the error codes "
8283 "specified below is returned."
8284 msgstr ""
8285
8286 #. type: Plain text
8287 #: build/C/man2/subpage_prot.2:77
8288 msgid "The buffer referred to by I<map> is not accessible."
8289 msgstr ""
8290
8291 #. type: Plain text
8292 #: build/C/man2/subpage_prot.2:87
8293 msgid ""
8294 "The I<addr> or I<len> arguments are incorrect.  Both of these arguments must "
8295 "be aligned to a multiple of the system page size, and they must not refer to "
8296 "a region outside of the address space of the process or to a region that "
8297 "consists of huge pages."
8298 msgstr ""
8299
8300 #. type: Plain text
8301 #: build/C/man2/subpage_prot.2:90 build/C/man2/sync_file_range.2:166
8302 msgid "Out of memory."
8303 msgstr ""
8304
8305 #. type: Plain text
8306 #: build/C/man2/subpage_prot.2:96
8307 msgid ""
8308 "This system call is provided on the PowerPC architecture since Linux "
8309 "2.6.25.  The system call is provided only if the kernel is configured with "
8310 "B<CONFIG_PPC_64K_PAGES>.  No library support is provided."
8311 msgstr ""
8312
8313 #. type: Plain text
8314 #: build/C/man2/subpage_prot.2:101
8315 msgid ""
8316 "Glibc does not provide a wrapper for this system call; call it using "
8317 "B<syscall>(2)."
8318 msgstr ""
8319
8320 #. type: Plain text
8321 #: build/C/man2/subpage_prot.2:106
8322 msgid ""
8323 "Normal page protections (at the 64-kB page level) also apply; the subpage "
8324 "protection mechanism is an additional constraint, so putting 0 in a 2-bit "
8325 "field won't allow writes to a page that is otherwise write-protected."
8326 msgstr ""
8327
8328 #. type: SS
8329 #: build/C/man2/subpage_prot.2:106
8330 #, no-wrap
8331 msgid "Rationale"
8332 msgstr ""
8333
8334 #.  In the initial implementation, it was the case that:
8335 #.      In fact the whole process is switched to use 4k hardware pages when the
8336 #.      subpage_prot system call is used, but this could be improved in future
8337 #.      to switch only the affected segments.
8338 #.  But Paul Mackerass says (Oct 2010): I'm pretty sure we now only switch
8339 #.  the affected segment, not the whole process.
8340 #. type: Plain text
8341 #: build/C/man2/subpage_prot.2:128
8342 msgid ""
8343 "This system call is provided to assist writing emulators that operate using "
8344 "64-kB pages on PowerPC systems.  When emulating systems such as x86, which "
8345 "uses a smaller page size, the emulator can no longer use the "
8346 "memory-management unit (MMU)  and normal system calls for controlling page "
8347 "protections.  (The emulator could emulate the MMU by checking and possibly "
8348 "remapping the address for each memory access in software, but that is slow.)  "
8349 "The idea is that the emulator supplies an array of protection masks to apply "
8350 "to a specified range of virtual addresses.  These masks are applied at the "
8351 "level where hardware page-table entries (PTEs)  are inserted into the "
8352 "hardware page table based on the Linux PTEs, so the Linux PTEs are not "
8353 "affected.  Implicit in this is that the regions of the address space that "
8354 "are protected are switched to use 4-kB hardware pages rather than 64-kB "
8355 "hardware pages (on machines with hardware 64-kB page support)."
8356 msgstr ""
8357
8358 #. type: Plain text
8359 #: build/C/man2/subpage_prot.2:131
8360 msgid "B<mprotect>(2), B<syscall>(2)"
8361 msgstr ""
8362
8363 #. type: Plain text
8364 #: build/C/man2/subpage_prot.2:134
8365 msgid "I<Documentation/vm/hugetlbpage.txt> in the Linux kernel source tree"
8366 msgstr ""
8367
8368 #. type: TH
8369 #: build/C/man2/sync_file_range.2:30
8370 #, no-wrap
8371 msgid "SYNC_FILE_RANGE"
8372 msgstr ""
8373
8374 #. type: Plain text
8375 #: build/C/man2/sync_file_range.2:33
8376 msgid "sync_file_range - sync a file segment with disk"
8377 msgstr ""
8378
8379 #. type: Plain text
8380 #: build/C/man2/sync_file_range.2:37
8381 #, no-wrap
8382 msgid ""
8383 "B<#define _GNU_SOURCE>         /* See feature_test_macros(7) */\n"
8384 "B<#include E<lt>fcntl.hE<gt>>\n"
8385 msgstr ""
8386
8387 #. type: Plain text
8388 #: build/C/man2/sync_file_range.2:40
8389 #, no-wrap
8390 msgid ""
8391 "B<int sync_file_range(int >I<fd>B<, off64_t >I<offset>B<, off64_t "
8392 ">I<nbytes>B<,>\n"
8393 "B<                    unsigned int >I<flags>B<);>\n"
8394 msgstr ""
8395
8396 #. type: Plain text
8397 #: build/C/man2/sync_file_range.2:47
8398 msgid ""
8399 "B<sync_file_range>()  permits fine control when synchronizing the open file "
8400 "referred to by the file descriptor I<fd> with disk."
8401 msgstr ""
8402
8403 #. type: Plain text
8404 #: build/C/man2/sync_file_range.2:61
8405 msgid ""
8406 "I<offset> is the starting byte of the file range to be synchronized.  "
8407 "I<nbytes> specifies the length of the range to be synchronized, in bytes; if "
8408 "I<nbytes> is zero, then all bytes from I<offset> through to the end of file "
8409 "are synchronized.  Synchronization is in units of the system page size: "
8410 "I<offset> is rounded down to a page boundary; I<(offset+nbytes-1)> is "
8411 "rounded up to a page boundary."
8412 msgstr ""
8413
8414 #. type: Plain text
8415 #: build/C/man2/sync_file_range.2:65
8416 msgid "The I<flags> bit-mask argument can include any of the following values:"
8417 msgstr ""
8418
8419 #. type: TP
8420 #: build/C/man2/sync_file_range.2:65
8421 #, no-wrap
8422 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE>"
8423 msgstr ""
8424
8425 #. type: Plain text
8426 #: build/C/man2/sync_file_range.2:70
8427 msgid ""
8428 "Wait upon write-out of all pages in the specified range that have already "
8429 "been submitted to the device driver for write-out before performing any "
8430 "write."
8431 msgstr ""
8432
8433 #. type: TP
8434 #: build/C/man2/sync_file_range.2:70 build/C/man2/sync_file_range.2:120
8435 #, no-wrap
8436 msgid "B<SYNC_FILE_RANGE_WRITE>"
8437 msgstr ""
8438
8439 #. type: Plain text
8440 #: build/C/man2/sync_file_range.2:76
8441 msgid ""
8442 "Initiate write-out of all dirty pages in the specified range which are not "
8443 "presently submitted write-out.  Note that even this may block if you attempt "
8444 "to write more than request queue size."
8445 msgstr ""
8446
8447 #. type: TP
8448 #: build/C/man2/sync_file_range.2:76
8449 #, no-wrap
8450 msgid "B<SYNC_FILE_RANGE_WAIT_AFTER>"
8451 msgstr ""
8452
8453 #. type: Plain text
8454 #: build/C/man2/sync_file_range.2:80
8455 msgid "Wait upon write-out of all pages in the range after performing any write."
8456 msgstr ""
8457
8458 #. type: Plain text
8459 #: build/C/man2/sync_file_range.2:84
8460 msgid "Specifying I<flags> as 0 is permitted, as a no-op."
8461 msgstr ""
8462
8463 #. type: SS
8464 #: build/C/man2/sync_file_range.2:84
8465 #, no-wrap
8466 msgid "Warning"
8467 msgstr ""
8468
8469 #. type: Plain text
8470 #: build/C/man2/sync_file_range.2:100
8471 msgid ""
8472 "This system call is extremely dangerous and should not be used in portable "
8473 "programs.  None of these operations writes out the file's metadata.  "
8474 "Therefore, unless the application is strictly performing overwrites of "
8475 "already-instantiated disk blocks, there are no guarantees that the data will "
8476 "be available after a crash.  There is no user interface to know if a write "
8477 "is purely an overwrite.  On filesystems using copy-on-write semantics (e.g., "
8478 "I<btrfs>)  an overwrite of existing allocated blocks is impossible.  When "
8479 "writing into preallocated space, many filesystems also require calls into "
8480 "the block allocator, which this system call does not sync out to disk.  This "
8481 "system call does not flush disk write caches and thus does not provide any "
8482 "data integrity on systems with volatile disk write caches."
8483 msgstr ""
8484
8485 #. type: SS
8486 #: build/C/man2/sync_file_range.2:100
8487 #, no-wrap
8488 msgid "Some details"
8489 msgstr ""
8490
8491 #. type: Plain text
8492 #: build/C/man2/sync_file_range.2:108
8493 msgid ""
8494 "B<SYNC_FILE_RANGE_WAIT_BEFORE> and B<SYNC_FILE_RANGE_WAIT_AFTER> will detect "
8495 "any I/O errors or B<ENOSPC> conditions and will return these to the caller."
8496 msgstr ""
8497
8498 #. type: Plain text
8499 #: build/C/man2/sync_file_range.2:112
8500 msgid "Useful combinations of the I<flags> bits are:"
8501 msgstr ""
8502
8503 #. type: TP
8504 #: build/C/man2/sync_file_range.2:112
8505 #, no-wrap
8506 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE>"
8507 msgstr ""
8508
8509 #. type: Plain text
8510 #: build/C/man2/sync_file_range.2:120
8511 msgid ""
8512 "Ensures that all pages in the specified range which were dirty when "
8513 "B<sync_file_range>()  was called are placed under write-out.  This is a "
8514 "start-write-for-data-integrity operation."
8515 msgstr ""
8516
8517 #. type: Plain text
8518 #: build/C/man2/sync_file_range.2:127
8519 msgid ""
8520 "Start write-out of all dirty pages in the specified range which are not "
8521 "presently under write-out.  This is an asynchronous flush-to-disk "
8522 "operation.  This is not suitable for data integrity operations."
8523 msgstr ""
8524
8525 #. type: TP
8526 #: build/C/man2/sync_file_range.2:127
8527 #, no-wrap
8528 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE> (or B<SYNC_FILE_RANGE_WAIT_AFTER>)"
8529 msgstr ""
8530
8531 #. type: Plain text
8532 #: build/C/man2/sync_file_range.2:134
8533 msgid ""
8534 "Wait for completion of write-out of all pages in the specified range.  This "
8535 "can be used after an earlier B<SYNC_FILE_RANGE_WAIT_BEFORE | "
8536 "SYNC_FILE_RANGE_WRITE> operation to wait for completion of that operation, "
8537 "and obtain its result."
8538 msgstr ""
8539
8540 #. type: TP
8541 #: build/C/man2/sync_file_range.2:134
8542 #, no-wrap
8543 msgid ""
8544 "B<SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE | "
8545 "SYNC_FILE_RANGE_WAIT_AFTER>"
8546 msgstr ""
8547
8548 #. type: Plain text
8549 #: build/C/man2/sync_file_range.2:141
8550 msgid ""
8551 "This is a write-for-data-integrity operation that will ensure that all pages "
8552 "in the specified range which were dirty when B<sync_file_range>()  was "
8553 "called are committed to disk."
8554 msgstr ""
8555
8556 #. type: Plain text
8557 #: build/C/man2/sync_file_range.2:147
8558 msgid ""
8559 "On success, B<sync_file_range>()  returns 0; on failure -1 is returned and "
8560 "I<errno> is set to indicate the error."
8561 msgstr ""
8562
8563 #. type: Plain text
8564 #: build/C/man2/sync_file_range.2:152
8565 msgid "I<fd> is not a valid file descriptor."
8566 msgstr ""
8567
8568 #. type: Plain text
8569 #: build/C/man2/sync_file_range.2:160
8570 msgid "I<flags> specifies an invalid bit; or I<offset> or I<nbytes> is invalid."
8571 msgstr ""
8572
8573 #. type: Plain text
8574 #: build/C/man2/sync_file_range.2:163
8575 msgid "I/O error."
8576 msgstr ""
8577
8578 #. type: Plain text
8579 #: build/C/man2/sync_file_range.2:169
8580 msgid "Out of disk space."
8581 msgstr ""
8582
8583 #.  FIXME . (bug?) Actually, how can 'fd' refer to a symbolic link (S_ISLNK)?
8584 #.  (In user space at least) it isn't possible to obtain a file descriptor
8585 #.  for a symbolic link.
8586 #. type: Plain text
8587 #: build/C/man2/sync_file_range.2:177
8588 msgid ""
8589 "I<fd> refers to something other than a regular file, a block device, a "
8590 "directory, or a symbolic link."
8591 msgstr ""
8592
8593 #. type: Plain text
8594 #: build/C/man2/sync_file_range.2:180
8595 msgid "B<sync_file_range>()  appeared on Linux in kernel 2.6.17."
8596 msgstr ""
8597
8598 #. type: Plain text
8599 #: build/C/man2/sync_file_range.2:183
8600 msgid ""
8601 "This system call is Linux-specific, and should be avoided in portable "
8602 "programs."
8603 msgstr ""
8604
8605 #.  See kernel commit edd5cd4a9424f22b0fa08bef5e299d41befd5622
8606 #. type: Plain text
8607 #: build/C/man2/sync_file_range.2:200
8608 msgid ""
8609 "Some architectures (e.g., PowerPC, ARM)  need 64-bit arguments to be aligned "
8610 "in a suitable pair of registers.  On such architectures, the call signature "
8611 "of B<sync_file_range>()  shown in the SYNOPSIS would force a register to be "
8612 "wasted as padding between the I<fd> and I<offset> arguments.  (See "
8613 "B<syscall>(2)  for details.)  Therefore, these architectures define a "
8614 "different system call that orders the arguments suitably:"
8615 msgstr ""
8616
8617 #. type: Plain text
8618 #: build/C/man2/sync_file_range.2:205
8619 #, no-wrap
8620 msgid ""
8621 "B<int sync_file_range2(int >I<fd>B<, unsigned int >I<flags>B<,>\n"
8622 "B<                     off64_t >I<offset>B<, off64_t >I<nbytes>B<);>\n"
8623 msgstr ""
8624
8625 #. type: Plain text
8626 #: build/C/man2/sync_file_range.2:210
8627 msgid ""
8628 "The behavior of this system call is otherwise exactly the same as "
8629 "B<sync_file_range>()."
8630 msgstr ""
8631
8632 #. type: Plain text
8633 #: build/C/man2/sync_file_range.2:221
8634 msgid ""
8635 "A system call with this signature first appeared on the ARM architecture in "
8636 "Linux 2.6.20, with the name B<arm_sync_file_range>().  It was renamed in "
8637 "Linux 2.6.22, when the analogous system call was added for PowerPC.  On "
8638 "architectures where glibc support is provided, glibc transparently wraps "
8639 "B<sync_file_range2>()  under the name B<sync_file_range>()."
8640 msgstr ""
8641
8642 #. type: Plain text
8643 #: build/C/man2/sync_file_range.2:226
8644 msgid "B<fdatasync>(2), B<fsync>(2), B<msync>(2), B<sync>(2)"
8645 msgstr ""