In the interest of portability, I don't know if this is correct (I
may be wrong, though...). While I've never worked on a system where
the suggested macros wouldn't work, maybe there are machines out
there (1's complement rather than 2's complement, or sign/magnitude)
where these macros will give plain wrong answers. I'm not sure there's
any portable way to write a macro that covers all possible cases.
Maybe that's why they haven't been provided already...
tw
P.S. as an example, if you're rusty on number representations:
bit pattern 2's comp 1's comp sign/mag
=========== ======== ======== ========
10000000 -128 -127 -0
10000001 -127 -126 -1
...
11111110 -2 -1 -126
11111111 -1 -0 -127
On 03/15/2000 18:24 +1100, Rusty Russell wrote:
>> Linus, please apply.
>>
>> Needed for netfilter code, and makes more sense here than in a .c
>> file.
>>
>> --- linux-2.3-official/include/linux/kernel.h Tue Mar 14 23:55:31 2000
>> +++ linux-2.3-nfmerge/include/linux/kernel.h Wed Mar 15 18:23:12 2000
>> @@ -15,8 +15,10 @@
>> #define barrier() __asm__ __volatile__("": : :"memory")
>>
>> #define INT_MAX ((int)(~0U>>1))
>> +#define INT_MIN (-INT_MAX - 1)
>> #define UINT_MAX (~0U)
>> #define LONG_MAX ((long)(~0UL>>1))
>> +#define LONG_MIN (-LONG_MAX - 1)
>> #define ULONG_MAX (~0UL)
>>
>> #define STACK_MAGIC 0xdeadbeef
>>
>> --
>> Hacking time.
>>
>> -
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.rutgers.edu
>> Please read the FAQ at http://www.tux.org/lkml/
End of included message
-- +--------------------------+------------------------------+ | Tim Walberg | tewalberg@mediaone.net | | 828 Marshall Ct. | www.concentric.net/~twalberg | | Palatine, IL 60074 | | +--------------------------+------------------------------+
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:17 EST