1 .\" Copyright (c) 2001 by John Levon <moz@compsoc.man.ac.uk>
2 .\" Based in part on GNU libc documentation.
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" 2001-10-11, 2003-08-22, aeb, added some details
27 .\" Japanese Version Copyright (c) 2001 Akihiro MOTOKI
28 .\" all rights reserved.
29 .\" Translated 2001-11-05, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
30 .\" Updated 2003-09-05, Akihiro MOTOKI, catch up to v1.60
31 .\" Updated 2005-11-19, Akihiro MOTOKI
32 .\" Updated 2010-04-18, Akihiro MOTOKI, LDP v3.24
34 .\"WORD: obsolete 廃止された
35 .\"WORD: a multiple of 〜の倍数
36 .\"WORD: a power of two 2 のべき乗
38 .TH POSIX_MEMALIGN 3 2010-09-20 "GNU" "Linux Programmer's Manual"
41 .\"O posix_memalign, memalign, valloc \- Allocate aligned memory
42 posix_memalign, memalign, valloc \- アラインメントされたメモリの割り当てを行う
46 .B #include <stdlib.h>
48 .BI "int posix_memalign(void **" memptr ", size_t " alignment ", size_t " size );
50 .B #include <malloc.h>
52 .BI "void *valloc(size_t " size );
53 .BI "void *memalign(size_t " boundary ", size_t " size );
57 .\"O Feature Test Macro Requirements for glibc (see
58 .\"O .BR feature_test_macros (7)):
60 .RB ( feature_test_macros (7)
65 .BR posix_memalign ():
67 _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
75 .\"O Since glibc 2.12:
79 (_XOPEN_SOURCE\ >=\ 500 ||
80 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
81 !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
85 .\"O Before glibc 2.12:
87 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
88 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
95 .\"O .BR posix_memalign ()
98 .\"O bytes and places the address of the allocated memory in
100 .\"O The address of the allocated memory will be a multiple of
101 .\"O .IR "alignment" ,
102 .\"O which must be a power of two and a multiple of
103 .\"O .IR "sizeof(void *)".
105 .BR posix_memalign ()
108 バイトのメモリを割り当て、割り当てられたメモリのアドレスを
121 .\"O .BR posix_memalign ()
122 .\"O returns either NULL,
123 .\"O .\" glibc does this:
124 .\"O or a unique pointer value that can later be successfully passed to
128 .BR posix_memalign ()
134 .\"O The obsolete function
138 .\"O bytes and returns a pointer to the allocated memory.
139 .\"O The memory address will be a multiple of
140 .\"O .IR "boundary" ,
141 .\"O which must be a power of two.
146 バイトのメモリを割り当て、割り当てられたメモリへのポインタを返す。
152 .\" The behavior of memalign() for size==0 is as for posix_memalign()
153 .\" but no standards govern this.
155 .\"O The obsolete function
159 .\"O bytes and returns a pointer to the allocated memory.
160 .\"O The memory address will be a multiple of the page size.
161 .\"O It is equivalent to
162 .\"O .IR "memalign(sysconf(_SC_PAGESIZE),size)" .
167 バイトのメモリを割り当て、割り当てられたメモリへのポインタを返す。
168 メモリのアドレスはページサイズの倍数になっているはずである。
170 .I "memalign(sysconf(_SC_PAGESIZE),size)"
173 .\"O For all three routines, the memory is not zeroed.
174 .\" motoki: be not zeroed ってどういう意味?
175 3 つの関数はいずれもメモリのゼロクリアを行わない。
176 .\"O .SH "RETURN VALUE"
181 .\"O return the pointer to the allocated memory, or NULL if the request fails.
185 は割り当てられたメモリへのポインタを返す。
186 割り当てに失敗した場合は NULL を返す。
188 .\"O .BR posix_memalign ()
189 .\"O returns zero on success, or one of the error values listed in the
190 .\"O next section on failure.
194 .BR posix_memalign ()
196 失敗した場合は次のセクションに記載されたエラー値のいずれかを返す。
205 .\"O argument was not a power of two, or was not a multiple of
206 .\"O .IR "sizeof(void *)" .
213 .\"O There was insufficient memory to fulfill the allocation request.
214 割り当て要求を満たすのに十分なメモリがなかった。
221 .\"O have been available in all Linux libc libraries.
225 はすべての Linux libc ライブラリで使用可能である。
227 .\"O .BR posix_memalign ()
228 .\"O is available since glibc 2.1.91.
229 .BR posix_memalign ()
230 は glibc 2.1.91 以降で使用可能である。
231 .\"O .SH "CONFORMING TO"
235 .\"O appeared in 3.0BSD.
236 .\"O It is documented as being obsolete in 4.3BSD,
237 .\"O and as legacy in SUSv2.
238 .\"O It does not appear in POSIX.1-2001.
241 は 3.0BSD で登場した。4.3BSD では廃止されたと記載されており、
242 SUSv2 では過去の名残だと記載されている。
243 POSIX.1-2001 にはもはや存在しない。
246 .\"O appears in SunOS 4.1.3 but not in 4.4BSD.
249 は SunOS 4.1.3 で登場したが、4.4BSD にはない。
251 .\"O .BR posix_memalign ()
252 .\"O comes from POSIX.1d.
254 .BR posix_memalign ()
258 .\"O Everybody agrees that
259 .\"O .BR posix_memalign ()
260 .\"O is declared in \fI<stdlib.h>\fP.
261 .BR posix_memalign ()
262 の宣言を \fI<stdlib.h>\fP で行うことに関しては、
267 .\"O is declared in \fI<stdlib.h>\fP instead of \fI<malloc.h>\fP.
270 は \fI<malloc.h>\fP ではなく \fI<stdlib.h>\fP で宣言されている。
272 .\"O According to SUSv2,
274 .\"O is declared in \fI<stdlib.h>\fP.
275 .\"O Libc4,5 and glibc declare it in \fI<malloc.h>\fP and perhaps also in
276 .\"O \fI<stdlib.h>\fP
283 .\"O .B _XOPEN_SOURCE_EXTENDED
284 .\"O is defined, or, equivalently,
285 .\"O .B _XOPEN_SOURCE
286 .\"O is defined to a value not less than 500).
304 .B _XOPEN_SOURCE_EXTENDED
308 が 500 より小さくない値に定義されている)。
311 .\"O On many systems there are alignment restrictions, for example, on buffers
312 .\"O used for direct block device I/O.
313 .\"O POSIX specifies the
314 .\"O .I "pathconf(path,_PC_REC_XFER_ALIGN)"
315 .\"O call that tells what alignment is needed.
317 .\"O .BR posix_memalign ()
318 .\"O to satisfy this requirement.
319 多くのシステムでは、アラインメントに関して制限がある。例えば、
320 ブロックデバイスに対するダイレクト I/O に使用するバッファには
322 POSIX では、どんなアラインメントが必要かを知るために
323 .I "pathconf(path,_PC_REC_XFER_ALIGN)"
325 .BR posix_memalign ()
326 を使うと、この必要条件を満たすことができる。
328 .\"O .BR posix_memalign ()
331 .\"O matches the requirements detailed above.
332 .BR posix_memalign ()
335 が上で詳細に述べた必要条件を満たすかどうかを確かめる。
337 .\"O may not check that the
339 .\"O argument is correct.
343 引き数が正しいかどうかの確認を行わないかもしれない。
345 .\"O POSIX requires that memory obtained from
346 .\"O .BR posix_memalign ()
347 .\"O can be freed using
350 .BR posix_memalign ()
354 .\"O Some systems provide no way to reclaim memory allocated with
362 で割り当てられたメモリを再利用する手段が提供されていない。
363 .\"O (because one can only pass to
365 .\"O a pointer gotten from
367 .\"O while, for example,
371 .\"O and then align the obtained value).
372 .\" motoki: while の前後のつながりはこれでいい?
382 を呼び出し、得た値をアラインメントしてしまうからである)
383 .\" Other systems allow passing the result of
389 .\"O The glibc implementation
390 .\"O allows memory obtained from any of these three routines to be
394 ここに述べた 3 つの関数のいずれで獲得したメモリも
400 .\"O always returns 8-byte aligned memory addresses, so these routines are only
401 .\"O needed if you require larger alignment values.
404 は常に 8 バイトにアラインメントされたメモリアドレスを返すので、
406 8 バイトよりも大きなアラインメントが必要な場合だけである。