xref: /freebsd/lib/libc/stdlib/memalignment.3 (revision 6c57e368eb1777f6097158eeca2fcc175d068dba)
1.\"
2.\" Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
3.\"
4.\" SPDX-License-Identifier: BSD-2-Clause
5.\"
6.Dd November 10, 2025
7.Dt MEMALIGNMENT 3
8.Os
9.Sh NAME
10.Nm memalignment
11.Nd find the memory alignment of an object
12.Sh SYNOPSIS
13.Lb libc
14.In stdlib.h
15.Ft size_t
16.Fn memalignment "const void *ptr"
17.Sh DESCRIPTION
18The
19.Fn memalignment
20function determines the alignment of the object pointed to by
21.Fa ptr .
22This alignment is a power of\~2, and may be larger than the range
23supported by the
24.Sy alignof
25operator.
26The value returned can be compared to the result of
27.Sy alignof ,
28and if it is greater or equal, the alignment requirement of the operand
29is satisfied.
30.Sh RETURN VALUES
31Returns the alignment of
32.Fa ptr
33as a power of\~2.
34If
35.Fa ptr
36is a null pointer, an alignment of zero is returned.
37An alignment of zero indicates that the tested pointer cannot be used to
38access an object of any type.
39.Sh SEE ALSO
40.Xr aligned_alloc 3 ,
41.Xr posix_memalign 3
42.Sh STANDARDS
43The
44.Fn memalignment
45function conforms to
46.St -isoC-2023 .
47.Sh HISTORY
48The
49.Fn memalignment
50function was added in
51.Fx 15.1.
52.Sh AUTHOR
53.An Robert Clausecker Aq Mt fuz@FreeBSD.org
54