The following commit has been merged in the next branch: commit 9c7df129e4e85c3a8aa3e249725fc1587e74ab8c Author: Antonio Quartulli ordex@autistici.org Date: Wed Nov 23 11:35:44 2011 +0100
batman-adv: add biggest_unsigned_int(x) macro
in case of dynamic type variable, it could be needed to compute at compile time its maximal value. This macro helps in doing that for unsigned integer types
Signed-off-by: Antonio Quartulli ordex@autistici.org
diff --git a/main.h b/main.h index 2ba8724..e669eea 100644 --- a/main.h +++ b/main.h @@ -231,6 +231,9 @@ static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) /* Returns the smallest signed integer in two's complement with the sizeof x */ #define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
+/* Returns the biggest unsigned integer with the sizeof x */ +#define biggest_unsigned_int(x) (~(x)0) + /* Checks if a sequence number x is a predecessor/successor of y. * they handle overflows/underflows and can correctly check for a * predecessor/successor unless the variable sequence number has grown by