summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2009-07-22 21:34:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-07-23 04:57:41 (GMT)
commitf630cfda8800aee03c7eb2fcd0f840730fbe43b9 (patch)
treef780eac20525e629c704a31a8d6e629cae6ea011 /git-compat-util.h
parent67da52bedc5750c10a732b9da7d64d5ef73f3b8a (diff)
downloadgit-f630cfda8800aee03c7eb2fcd0f840730fbe43b9.zip
git-f630cfda8800aee03c7eb2fcd0f840730fbe43b9.tar.gz
git-f630cfda8800aee03c7eb2fcd0f840730fbe43b9.tar.bz2
refactor: use bitsizeof() instead of 8 * sizeof()
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 913f41a..6dfc0dd 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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. */