xref: /titanic_50/usr/src/man/man3c/aligned_alloc.3c (revision dcdfe824b3dff2df12578b936adf1daf000aa129)
1*dcdfe824SRobert Mustacchi.\"
2*dcdfe824SRobert Mustacchi.\" This file and its contents are supplied under the terms of the
3*dcdfe824SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0.
4*dcdfe824SRobert Mustacchi.\" You may only use this file in accordance with the terms of version
5*dcdfe824SRobert Mustacchi.\" 1.0 of the CDDL.
6*dcdfe824SRobert Mustacchi.\"
7*dcdfe824SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this
8*dcdfe824SRobert Mustacchi.\" source.  A copy of the CDDL is also available via the Internet at
9*dcdfe824SRobert Mustacchi.\" http://www.illumos.org/license/CDDL.
10*dcdfe824SRobert Mustacchi.\"
11*dcdfe824SRobert Mustacchi.\"
12*dcdfe824SRobert Mustacchi.\" Copyright 2016 Joyent, Inc.
13*dcdfe824SRobert Mustacchi.\"
14*dcdfe824SRobert Mustacchi.Dd "Mar 26, 2016"
15*dcdfe824SRobert Mustacchi.Dt ALIGNED_ALLOC 3C
16*dcdfe824SRobert Mustacchi.Os
17*dcdfe824SRobert Mustacchi.Sh NAME
18*dcdfe824SRobert Mustacchi.Nm aligned_alloc
19*dcdfe824SRobert Mustacchi.Nd aligned memory allocation
20*dcdfe824SRobert Mustacchi.Sh SYNOPSIS
21*dcdfe824SRobert Mustacchi.In stdlib.h
22*dcdfe824SRobert Mustacchi.Ft "void *"
23*dcdfe824SRobert Mustacchi.Fo aligned_alloc
24*dcdfe824SRobert Mustacchi.Fa "size_t alignment"
25*dcdfe824SRobert Mustacchi.Fa "size_t size"
26*dcdfe824SRobert Mustacchi.Fc
27*dcdfe824SRobert Mustacchi.Sh DESCRIPTION
28*dcdfe824SRobert MustacchiThe
29*dcdfe824SRobert Mustacchi.Fn aligned_alloc
30*dcdfe824SRobert Mustacchifunction allocates
31*dcdfe824SRobert Mustacchi.Fa size
32*dcdfe824SRobert Mustacchibytes aligned on the specified alignment boundary
33*dcdfe824SRobert Mustacchi.Fa alignment .
34*dcdfe824SRobert MustacchiThe value of
35*dcdfe824SRobert Mustacchi.Fa alignment
36*dcdfe824SRobert Mustacchiis constrained, it must be a power of two and it must be greater than or
37*dcdfe824SRobert Mustacchiequal to the size of a word on the platform.
38*dcdfe824SRobert Mustacchi.Sh RETURN VALUES
39*dcdfe824SRobert MustacchiUpon successful completion, the
40*dcdfe824SRobert Mustacchi.Fn aligned_alloc
41*dcdfe824SRobert Mustacchifunction returns a pointer to suitably aligned memory at least
42*dcdfe824SRobert Mustacchi.Fa size
43*dcdfe824SRobert Mustacchibytes large. Otherwise, a
44*dcdfe824SRobert Mustacchi.Sy NULL
45*dcdfe824SRobert Mustacchipointer is returned and
46*dcdfe824SRobert Mustacchi.Sy errno
47*dcdfe824SRobert Mustacchiis set to indicate the error.
48*dcdfe824SRobert Mustacchi.Sh ERRORS
49*dcdfe824SRobert MustacchiThe
50*dcdfe824SRobert Mustacchi.Fn aligned_alloc
51*dcdfe824SRobert Mustacchifunction will fail if:
52*dcdfe824SRobert Mustacchi.Bl -tag -width Er
53*dcdfe824SRobert Mustacchi.It Er ENOMEM
54*dcdfe824SRobert MustacchiThe physical limits of the system are exceeded by
55*dcdfe824SRobert Mustacchi.Fa size
56*dcdfe824SRobert Mustacchibytes of memory which cannot be allocated.
57*dcdfe824SRobert Mustacchi.It Er EAGAIN
58*dcdfe824SRobert MustacchiThere is not enough memory available to allocate
59*dcdfe824SRobert Mustacchi.Fa size
60*dcdfe824SRobert Mustacchibytes of memory; but the application could try again later.
61*dcdfe824SRobert Mustacchi.It Er EINVAL
62*dcdfe824SRobert MustacchiAn invalid value for
63*dcdfe824SRobert Mustacchi.Fa alignment
64*dcdfe824SRobert Mustacchiwas passed in. It is not a power of two multiple of the word size.
65*dcdfe824SRobert Mustacchi.El
66*dcdfe824SRobert Mustacchi.Sh INTERFACE STABILITY
67*dcdfe824SRobert Mustacchi.Sy STANDARD
68*dcdfe824SRobert Mustacchi.Sh MT-LEVEL
69*dcdfe824SRobert Mustacchi.Sy MT-Safe
70*dcdfe824SRobert Mustacchi.Sh SEE ALSO
71*dcdfe824SRobert Mustacchi.Xr malloc 3C ,
72*dcdfe824SRobert Mustacchi.Xr memalgin 3C ,
73*dcdfe824SRobert Mustacchi.Xr posix_memalign 3C ,
74*dcdfe824SRobert Mustacchi.Xr attributes 5
75