[PATCH] stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabs
Lenard
wg14@lenardmollenkopf.de
Fri Mar 7 20:30:48 GMT 2025
Yes, I based this on the N3349. The rationale for using ckd_mul in N3349
was portability. GCC outputs the same instructions on x86_64 and arm. So
I would prefer this version.
On 3/7/25 02:38, Paul Eggert wrote:
> On 3/6/25 14:06, Andrew Pinski wrote:
>> > On Thu, Mar 6, 2025 at 11:27 AM Lenard Mollenkopf ... wrote:
>>> +unsigned int
>>> +uabs (int i)
>>> +{
>>> + if (i < 0){
>>> + unsigned int j;
>>> + __builtin_mul_overflow (i, -1, &j);
>> Why not just do:
>> ```
>> unsigned int j = i;
>> return -j;
>> ```
>> ? Why call __builtin_mul_overflow here?
>
> I expect that's because N3349 did it that way - maybe for portability
> to unusual platforms where INT_MAX != UINT_MAX/2? Not sure whether
> glibc needs to worry about those platforms.
>
> Anyway, regardless of the implementation, the indenting should use
> glibc style.
More information about the Libc-alpha
mailing list