git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: XDL_FAST_HASH breaks git on OS X 10.7.3

From
David Aguilar <davvid@gmail.com>
Date
May 1, 2012, 05:32 UTC
Message-ID
<CAJDDKr778t=CufdtitbrhB-vJ3F=xSpSJ_G8e-VK8qCy8Fcfmg@mail.gmail.com>
In-Reply-To
<87mx5tyy2a.fsf@thomas.inf.ethz.ch>
On Mon, Apr 30, 2012 at 9:38 AM, Thomas Rast <trast@student.ethz.ch> wrote:
Show 47 quoted lines
> 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) {
Isn't the whole point of this code to be fast?
This should be a compile-time check... conditionals hurt perf.
-- 
David
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 9 in “XDL_FAST_HASH breaks git on OS X 10.7.3”
  1. Brian GernhardtApr 29, 2012
  2. Thomas RastApr 30, 2012
  3. Brian GernhardtMay 1, 2012
  4. Junio C HamanoMay 1, 2012
  5. Junio C HamanoMay 1, 2012
  6. Choose XDL_FAST_HASH code on sizeof(long) instead of __WORDSIZEThomas Rast, May 1, 2012
  7. Junio C HamanoMay 1, 2012
  8. David AguilarMay 1, 2012
  9. Junio C HamanoMay 1, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.