lkml.org 
[lkml]   [2011]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] remove abs64()
On Wed, 13 Apr 2011 16:27:03 +0200
Oleg Nesterov <oleg@redhat.com> wrote:

> On 04/13, Alexey Dobriyan wrote:
> >
> > +#define abs(x) \
> > +({ \
> > + typeof(x) _x = (x); \
> > + \
> > + __builtin_choose_expr( \
> > + __builtin_types_compatible_p(typeof(_x), signed char), \
> > + (unsigned char)({ _x < 0 ? -_x : _x; }), \
> > + __builtin_choose_expr( \
> > + __builtin_types_compatible_p(typeof(_x), short), \
> > + (unsigned short)({ _x < 0 ? -_x : _x; }), \
> > + __builtin_choose_expr( \
> > + __builtin_types_compatible_p(typeof(_x), int), \
> > + (unsigned int)({ _x < 0 ? -_x : _x; }), \
> > + __builtin_choose_expr( \
> > + __builtin_types_compatible_p(typeof(_x), long), \
> > + (unsigned long)({ _x < 0 ? -_x : _x; }), \
> > + __builtin_choose_expr( \
> > + __builtin_types_compatible_p(typeof(_x), long long), \
> > + (unsigned long long)({ _x < 0 ? -_x : _x; }), \
> > + _x))))); \
> > +})
>
> Personally I agree.
>
> But, we have some stupid users which do something like abs(u32_value)
> and expecting that abs() should treat this value as "signed".
>

um, yes, I'd forgotten that one. That's a show-stopper.


\
 
 \ /
  Last update: 2011-04-13 20:51    [W:0.056 / U:3.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site