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