xref: /titanic_52/usr/src/man/man3c/aligned_alloc.3c (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
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. Otherwise, a
44.Sy NULL
45pointer is returned and
46.Sy errno
47is set to indicate the error.
48.Sh ERRORS
49The
50.Fn aligned_alloc
51function will fail if:
52.Bl -tag -width Er
53.It Er ENOMEM
54The physical limits of the system are exceeded by
55.Fa size
56bytes of memory which cannot be allocated.
57.It Er EAGAIN
58There is not enough memory available to allocate
59.Fa size
60bytes of memory; but the application could try again later.
61.It Er EINVAL
62An invalid value for
63.Fa alignment
64was passed in. It is not a power of two multiple of the word size.
65.El
66.Sh INTERFACE STABILITY
67.Sy STANDARD
68.Sh MT-LEVEL
69.Sy MT-Safe
70.Sh SEE ALSO
71.Xr malloc 3C ,
72.Xr memalgin 3C ,
73.Xr posix_memalign 3C ,
74.Xr attributes 5
75