{"thread":{"id":"37342","subject":"Undefined reference to __builtin_ctzll","startedAt":"2014-08-13T08:36:57Z","lastAt":"2014-08-13T10:15:44Z","messageCount":2,"participants":["Радослав Йовчев","Erik Faye-Lund"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"247647","messageId":"CAAC8vw4EzaEM13TWzEW9QUuc-qdZFhPfEA9z1=KjCE0Brzotjg@mail.gmail.com","threadId":"37342","inReplyTo":null,"subject":"Undefined reference to __builtin_ctzll","fromName":"Радослав Йовчев","fromEmail":"radoslav.tm@gmail.com","sentAt":"2014-08-13T08:36:57Z","receivedAt":"2014-08-13T08:36:57Z","isPatch":false,"sender":{"key":"radoslav.tm@gmail.com","avatar":null},"body":"Dear GIT community,\n\n\nI found myself in situation where I had to install GIT on Debian 3.1\nsarge.  It comes with GCC 3.3.5. I tried to built from source but the\nlibgcc was not providing the ctzll function, thus I decided to put an\nimplementation.\n\n\nI do not know how to post and do a nice patch (and whether somebody\nwill care), but I guess, for reference I can post my solution. Just\nappended in compat/strlcpy.c the following:\n\n\nint __builtin_ctzll (long long x)\n{\n        int i;\n        for (i = 0; i < 8 * sizeof (long long); ++i)\n                if (x & ((long long) 1  << i))\n                        break;\n        return i;\n}\n\n\nI guess that some ifdef macro can be used to detect compiler version\nor missing __builtin_ctzll.\n\n\nWith best regards and hopes that this can help somebody in similar situation,\nRadoslav.\n"},{"id":"247649","messageId":"CABPQNSZw4vwhF8m+TWrbuOSaV5ycRGm1oeCu42j96_T+f3xtTg@mail.gmail.com","threadId":"37342","inReplyTo":"CAAC8vw4EzaEM13TWzEW9QUuc-qdZFhPfEA9z1=KjCE0Brzotjg@mail.gmail.com","subject":"Re: Undefined reference to __builtin_ctzll","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2014-08-13T10:15:44Z","receivedAt":"2014-08-13T10:15:44Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Wed, Aug 13, 2014 at 10:36 AM, Радослав Йовчев <radoslav.tm@gmail.com> wrote:\n> Dear GIT community,\n>\n>\n> I found myself in situation where I had to install GIT on Debian 3.1\n> sarge.  It comes with GCC 3.3.5. I tried to built from source but the\n> libgcc was not providing the ctzll function, thus I decided to put an\n> implementation.\n>\n>\n> I do not know how to post and do a nice patch (and whether somebody\n> will care), but I guess, for reference I can post my solution. Just\n> appended in compat/strlcpy.c the following:\n>\n>\n> int __builtin_ctzll (long long x)\n> {\n>         int i;\n>         for (i = 0; i < 8 * sizeof (long long); ++i)\n>                 if (x & ((long long) 1  << i))\n>                         break;\n>         return i;\n> }\n>\n>\n> I guess that some ifdef macro can be used to detect compiler version\n> or missing __builtin_ctzll.\n\nIt seems __builtin_ctzll is only available in GCC 3.4.0 and beyond, so\nI think a better fix is something like this:\n\ndiff --git a/ewah/ewok.h b/ewah/ewok.h\nindex 43adeb5..2700fa3 100644\n--- a/ewah/ewok.h\n+++ b/ewah/ewok.h\n@@ -47,7 +47,7 @@ static inline uint32_t ewah_bit_popcount64(uint64_t x)\n  return (x * 0x0101010101010101ULL) >> 56;\n }\n\n-#ifdef __GNUC__\n+#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ > 3\n #define ewah_bit_ctz64(x) __builtin_ctzll(x)\n #else\n static inline int ewah_bit_ctz64(uint64_t x)\n"}]}