[PATCH] stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabs
Paul Eggert
eggert@cs.ucla.edu
Fri Mar 7 01:38:28 GMT 2025
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