xref: /minix3/lib/libc/stdlib/posix_memalign.3 (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras.\"	$NetBSD: posix_memalign.3,v 1.1 2007/11/19 14:48:43 ad Exp $
2*2fe8fb19SBen Gras.\"
3*2fe8fb19SBen Gras.\" Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>.
4*2fe8fb19SBen Gras.\" All rights reserved.
5*2fe8fb19SBen Gras.\"
6*2fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
7*2fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
8*2fe8fb19SBen Gras.\" are met:
9*2fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
10*2fe8fb19SBen Gras.\"    notice(s), this list of conditions and the following disclaimer as
11*2fe8fb19SBen Gras.\"    the first lines of this file unmodified other than the possible
12*2fe8fb19SBen Gras.\"    addition of one or more copyright notices.
13*2fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
14*2fe8fb19SBen Gras.\"    notice(s), this list of conditions and the following disclaimer in
15*2fe8fb19SBen Gras.\"    the documentation and/or other materials provided with the
16*2fe8fb19SBen Gras.\"    distribution.
17*2fe8fb19SBen Gras.\"
18*2fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
19*2fe8fb19SBen Gras.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*2fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21*2fe8fb19SBen Gras.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
22*2fe8fb19SBen Gras.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*2fe8fb19SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*2fe8fb19SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25*2fe8fb19SBen Gras.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26*2fe8fb19SBen Gras.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27*2fe8fb19SBen Gras.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28*2fe8fb19SBen Gras.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*2fe8fb19SBen Gras.\"
30*2fe8fb19SBen Gras.\" FreeBSD: src/lib/libc/stdlib/posix_memalign.3,v 1.3 2007/03/28 04:32:51 jasone Exp
31*2fe8fb19SBen Gras.\"
32*2fe8fb19SBen Gras.Dd November 19, 2007
33*2fe8fb19SBen Gras.Dt POSIX_MEMALIGN 3
34*2fe8fb19SBen Gras.Os
35*2fe8fb19SBen Gras.Sh NAME
36*2fe8fb19SBen Gras.Nm posix_memalign
37*2fe8fb19SBen Gras.Nd aligned memory allocation
38*2fe8fb19SBen Gras.Sh LIBRARY
39*2fe8fb19SBen Gras.Lb libc
40*2fe8fb19SBen Gras.Sh SYNOPSIS
41*2fe8fb19SBen Gras.In stdlib.h
42*2fe8fb19SBen Gras.Ft int
43*2fe8fb19SBen Gras.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size"
44*2fe8fb19SBen Gras.Sh DESCRIPTION
45*2fe8fb19SBen GrasThe
46*2fe8fb19SBen Gras.Fn posix_memalign
47*2fe8fb19SBen Grasfunction allocates
48*2fe8fb19SBen Gras.Fa size
49*2fe8fb19SBen Grasbytes of memory such that the allocation's base address is an even multiple of
50*2fe8fb19SBen Gras.Fa alignment ,
51*2fe8fb19SBen Grasand returns the allocation in the value pointed to by
52*2fe8fb19SBen Gras.Fa ptr .
53*2fe8fb19SBen Gras.Pp
54*2fe8fb19SBen GrasThe requested
55*2fe8fb19SBen Gras.Fa alignment
56*2fe8fb19SBen Grasmust be a power of 2 at least as large as
57*2fe8fb19SBen Gras.Fn sizeof "void *" .
58*2fe8fb19SBen Gras.Pp
59*2fe8fb19SBen GrasMemory that is allocated via
60*2fe8fb19SBen Gras.Fn posix_memalign
61*2fe8fb19SBen Grascan be used as an argument in subsequent calls to
62*2fe8fb19SBen Gras.Xr realloc 3
63*2fe8fb19SBen Grasand
64*2fe8fb19SBen Gras.Xr free 3 .
65*2fe8fb19SBen Gras.Sh RETURN VALUES
66*2fe8fb19SBen GrasThe
67*2fe8fb19SBen Gras.Fn posix_memalign
68*2fe8fb19SBen Grasfunction returns the value 0 if successful; otherwise it returns an error value.
69*2fe8fb19SBen Gras.Sh ERRORS
70*2fe8fb19SBen GrasThe
71*2fe8fb19SBen Gras.Fn posix_memalign
72*2fe8fb19SBen Grasfunction will fail if:
73*2fe8fb19SBen Gras.Bl -tag -width Er
74*2fe8fb19SBen Gras.It Bq Er EINVAL
75*2fe8fb19SBen GrasThe
76*2fe8fb19SBen Gras.Fa alignment
77*2fe8fb19SBen Grasparameter is not a power of 2 at least as large as
78*2fe8fb19SBen Gras.Fn sizeof "void *" .
79*2fe8fb19SBen Gras.It Bq Er ENOMEM
80*2fe8fb19SBen GrasMemory allocation error.
81*2fe8fb19SBen Gras.El
82*2fe8fb19SBen Gras.Sh SEE ALSO
83*2fe8fb19SBen Gras.Xr free 3 ,
84*2fe8fb19SBen Gras.Xr malloc 3 ,
85*2fe8fb19SBen Gras.Xr realloc 3 ,
86*2fe8fb19SBen Gras.Xr valloc 3
87*2fe8fb19SBen Gras.Sh STANDARDS
88*2fe8fb19SBen GrasThe
89*2fe8fb19SBen Gras.Fn posix_memalign
90*2fe8fb19SBen Grasfunction conforms to
91*2fe8fb19SBen Gras.St -p1003.1-2001 .
92