Re: [RFC][PATCH] fix abs() macro to work with types wider than int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 25 Apr 2007, John Anthony Kazos Jr. wrote:

>>>> I think it's like it is just to be consistent with abs() in C,
>>>> which also contains labs() and llabs().
>>>>
>>> We actually had labs() before (few months ago), but since it was not
>>> used, and if it would it seemed better to just fix abs(), it was
>>> removed. So I think this is the appropriate way to go.
>>
>> Sounds like when someone actually needs labs() or llabs()
>> they can submit a patch for however they would like to use it.
>
> However they would like to use *abs()? What different ways are possible to
> take the arithmetic absolute value? I see record of many cases where
> dozens of authors have macros that then get collapsed to include files. So
> why not avoid that annoyance this time and -start- with it in the include
> files?
>
> Can there even be any reason beyond unnecessary pedantics to have
> [l[l]]abs?

Isn't any macro that looks for "< 0" insensitive to the word length? I think 
it's only when people try tricks with "sign-bits," that they get into trouble.
I think this works, regardless of the length of the integers:

#define abs(x) (((x)<0)?-(x):(x))



Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips).
New book: http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux