[PATCH] memalign: move alignment adjustment to __libc_memalign
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Jan 15 15:40:03 GMT 2026
On 15/01/26 12:37, Florian Weimer wrote:
> * Siddhesh Poyarekar:
>
>> On 2026-01-15 08:50, Adhemerval Zanella Netto wrote:
>>>> alignment > 2 is redundant. If you want to use __glibc_unlikely, this is the place
>>>> to use it since one uses memalign typically only with powers of 2.
>>>>
>>>> + {
>>>> + alignment = (size_t) 2 << (__builtin_clzl (1)
>>>> + - __builtin_clzl (alignment - 1));
>>> As a side note, I think it would be better to use stdbit.h
>>> definitions here.
>>>
>>
>> You mean stdc_count_zeros_ul? I considered it, but decided against it
>> because AFAICT it's not used anywhere within glibc at the moment.
>> Maybe we leave this as is for now and do a mass refactoring later?
>
> We can't use it for the backports because <stdbit.h> is quite new.
> So your proposed approach sounds fine to me.
Right, we can replace it later with stdbit then.
More information about the Libc-alpha
mailing list