Implement C23 memalignment
Collin Funk
collin.funk1@gmail.com
Thu Oct 2 03:37:45 GMT 2025
Joseph Myers <josmyers@redhat.com> writes:
> +/* Return the alignment of P. */
> +size_t
> +memalignment (const void *p)
> +{
> + size_t i = (size_t) p;
> + return i & -i;
> +}
Doesn't it make more sense to cast the pointer to uintptr_t? In practice
it should be the same as size_t, but theoretically the cast could change
the value and be conformant to ISO C, unlike with uintptr_t.
Patch looks good otherwise, though.
Thanks,
Collin
More information about the Libc-alpha
mailing list