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 22:20:31 +0200
Oleg Nesterov <oleg@redhat.com> wrote:

> > > 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.
>
> May be we can demand to fix them?
>
> I agree with Alexey, it is a bit ugly to have abs() and abs64(), and abs()
> itself doesn't look very nice.
>
> What if we simply add
>
> BUILD_BUG_ON( (typeof(_x)-1) > 0 );
>
> into abs()?
>
> After that it would be trivial to find the offenders and fix them,
>
> - abs(unsigned_int)
> + abs((int) unsigned_int)

Something like that. But it should be done before we change abs(), to
avoid nasty breakage in obscure places.

Or we rework the abs() implementation so that the abs(unsigned)
behavior is unchanged.

There will remain the problem that the abs() return value's signedness
has changed.


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