summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 67da52b)
raw | patch | inline | side by side (parent: 67da52b)
author | Pierre Habouzit <madcoder@debian.org> | |
Wed, 22 Jul 2009 21:34:34 +0000 (23:34 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 23 Jul 2009 04:57:41 +0000 (21:57 -0700) |
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h | patch | blob | history | |
sha1_file.c | patch | blob | history | |
xdiff/xdiffi.c | patch | blob | history |
diff --git a/git-compat-util.h b/git-compat-util.h
index 913f41a42cfb1ef07416069c3c36a734011914e7..6dfc0ddd90ae6abc7863086f520a678c545850a5 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
#endif
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#ifdef __GNUC__
#define TYPEOF(x) (__typeof__(x))
#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. */
diff --git a/sha1_file.c b/sha1_file.c
index 4576ff77f3ceec7231b14261f7386abb2289cd5c..1d996a199036c115d46c1d630d53edf29b3b78e7 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
size = c & 15;
shift = 4;
while (c & 0x80) {
- if (len <= used || sizeof(long) * 8 <= shift) {
+ if (len <= used || bitsizeof(long) <= shift) {
error("bad object header");
return 0;
}
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 1ebab687f77218d1520a4527214170eeab176d31..da67c04357dfe4d3283c589f5d47be9c5f2b7fcf 100644 (file)
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
#define XDL_MAX_COST_MIN 256
#define XDL_HEUR_MIN_COST 256
-#define XDL_LINE_MAX (long)((1UL << (8 * sizeof(long) - 1)) - 1)
+#define XDL_LINE_MAX (long)((1UL << (CHAR_BIT * sizeof(long) - 1)) - 1)
#define XDL_SNAKE_CNT 20
#define XDL_K_HEUR 4