Implement C23 memalignment

Florian Weimer fweimer@redhat.com
Thu Oct 2 09:01:22 GMT 2025


* Joseph Myers:

> diff --git a/manual/memory.texi b/manual/memory.texi
> index 6a70168e61..1e30631125 100644
> --- a/manual/memory.texi
> +++ b/manual/memory.texi
> @@ -1135,6 +1135,17 @@ The @code{valloc} function is obsolete and @code{aligned_alloc} or
>  @code{posix_memalign} should be used instead.
>  @end deftypefun
>  
> +You can determine the alignment of a pointer with the
> +@code{memalignment} function.
> +
> +@deftypefun size_t memalignment (void *@var{p})
> +@standards{C23, stdlib.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +
> +This function, defined in C23, returns the alignment of @var{p}, as a
> +power of two.  If @var{p} is a null pointer, it returns zero.
> +@end deftypefun

Does the pointer have to be a valid object pointer?  I think we should
support arbitrary bit patterns as a GNU extension.

Thanks,
Florian



More information about the Libc-alpha mailing list