refactor: use bitsizeof() instead of 8 * sizeof()

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Pierre Habouzit
2009-07-22 23:34:34 +02:00
committed by Junio C Hamano
parent 67da52bedc
commit f630cfda88
3 changed files with 4 additions and 3 deletions

View File

@ -26,6 +26,7 @@
#endif
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#ifdef __GNUC__
#define TYPEOF(x) (__typeof__(x))
@ -33,7 +34,7 @@
#define TYPEOF(x)
#endif
#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))
#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (bitsizeof(x) - (bits))))
#define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */
/* Approximation of the length of the decimal representation of this type. */