From: Thomas Rast <trast@student.ethz.ch>
To: Brian Gernhardt <brian@gernhardtsoftware.com>
Cc: Git List <git@vger.kernel.org>, Thomas Rast <trast@student.ethz.ch>
Subject: Re: XDL_FAST_HASH breaks git on OS X 10.7.3
Date: Mon, 30 Apr 2012 18:38:37 +0200 [thread overview]
Message-ID: <87mx5tyy2a.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <441BE38F-E081-4ED8-B587-BF72AD6368EE@gernhardtsoftware.com> (Brian Gernhardt's message of "Sun, 29 Apr 2012 16:52:51 -0400")
Hi Brian
I can reproduce this. The problem is that __WORDSIZE is not defined,
either because it's Darwin or because the GCC is too old. It winds up
compiling the 32-bit case, which of course doesn't work for 64-bit
builds.
Perhaps we can rewrite it in terms of sizeof(long) like this?
diff --git i/xdiff/xutils.c w/xdiff/xutils.c
index e05b5c9..1b3b471 100644
--- i/xdiff/xutils.c
+++ w/xdiff/xutils.c
@@ -290,39 +290,33 @@ static inline unsigned long has_zero(unsigned long a)
return ((a - ONEBYTES) & ~a) & HIGHBITS;
}
-#if __WORDSIZE == 64
-
-/*
- * Jan Achrenius on G+: microoptimized version of
- * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
- * that works for the bytemasks without having to
- * mask them first.
- */
static inline long count_masked_bytes(unsigned long mask)
{
- return mask * 0x0001020304050608 >> 56;
-}
-
-#else /* 32-bit case */
-
-/* Modified Carl Chatfield G+ version for 32-bit */
-static inline long count_masked_bytes(long mask)
-{
- /*
- * (a) gives us
- * -1 (0, ff), 0 (ffff) or 1 (ffffff)
- * (b) gives us
- * 0 for 0, 1 for (ff ffff ffffff)
- * (a+b+1) gives us
- * correct 0-3 bytemask count result
- */
- long a = (mask - 256) >> 23;
- long b = mask & 1;
- return a + b + 1;
+ if (sizeof(long) == 8) {
+ /*
+ * Jan Achrenius on G+: microoptimized version of
+ * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
+ * that works for the bytemasks without having to
+ * mask them first.
+ */
+ return mask * 0x0001020304050608 >> 56;
+ } else {
+ /*
+ * Modified Carl Chatfield G+ version for 32-bit *
+ *
+ * (a) gives us
+ * -1 (0, ff), 0 (ffff) or 1 (ffffff)
+ * (b) gives us
+ * 0 for 0, 1 for (ff ffff ffffff)
+ * (a+b+1) gives us
+ * correct 0-3 bytemask count result
+ */
+ long a = (mask - 256) >> 23;
+ long b = mask & 1;
+ return a + b + 1;
+ }
}
-#endif
-
unsigned long xdl_hash_record(char const **data, char const *top, long flags)
{
unsigned long hash = 5381;
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2012-04-30 16:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 20:52 XDL_FAST_HASH breaks git on OS X 10.7.3 Brian Gernhardt
2012-04-30 16:38 ` Thomas Rast [this message]
2012-05-01 2:13 ` Brian Gernhardt
2012-05-01 4:39 ` Junio C Hamano
2012-05-01 4:41 ` Junio C Hamano
2012-05-01 8:36 ` [PATCH] Choose XDL_FAST_HASH code on sizeof(long) instead of __WORDSIZE Thomas Rast
2012-05-01 17:33 ` Junio C Hamano
2012-05-01 5:32 ` XDL_FAST_HASH breaks git on OS X 10.7.3 David Aguilar
2012-05-01 6:17 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mx5tyy2a.fsf@thomas.inf.ethz.ch \
--to=trast@student.ethz.ch \
--cc=brian@gernhardtsoftware.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.