Implement C23 memalignment

Paul Eggert eggert@cs.ucla.edu
Wed Oct 1 21:18:21 GMT 2025


On 2025-10-01 13:27, Joseph Myers wrote:
> +
> +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.

I suggest adding the following paragraph, somewhat derived from Gnulib's 
documentation for memalignment:

Although this function is needed for some theoretical platforms,
it is unnecessary on all known practical platforms.
To check whether a pointer @var{P} has alignment @var{A},
testing @code{(uintptr_t) @var{P} % @var{A}}
suffices, and is typically more efficient than
comparing @code{memalignment (@var{P})} to @var{A}.


>  * The ISO C23 memset_explicit function has been added.
>  
> +* The ISO C23 memalignment function has been added.

Perhaps sort these alphabetically?


More information about the Libc-alpha mailing list