From: Todd Nowacki Date: Tue, 4 Jun 2013 21:43:22 +0000 (-0700) Subject: Folly Changes for Clang, revision 1 X-Git-Tag: v0.22.0~950 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=16d227a14ccecc4fe2655750368e4e482d80485e;p=folly.git Folly Changes for Clang, revision 1 Summary: Depends on D829162 and D830052 A few changes are needed to get folly compiling with clang. There are likely more changes to compile all of folly ---folly/Bits.cpp +++folly/folly-config.h Moved ifunc check, and added an additional check for clang, instead of hard coding it to be 1 ~~~folly/Range.cpp Moved the declaration of a function to get rid of clang's unused function warning. Test Plan: This bit of code was a dependency in another project. That code compiled as it needed to See other diff for more test details Reviewed By: oyamauchi@fb.com FB internal diff: D830075 --- diff --git a/folly/Bits.cpp b/folly/Bits.cpp index 62b759f0..15842b45 100644 --- a/folly/Bits.cpp +++ b/folly/Bits.cpp @@ -22,16 +22,6 @@ // popcnt #ifndef __POPCNT__ -// Clang doesn't support ifuncs. This also allows ifunc support to be explicitly -// passed in as a compile flag. -#ifndef FOLLY_HAVE_IFUNC -# ifdef __clang__ -# define FOLLY_HAVE_IFUNC 0 -# else -# define FOLLY_HAVE_IFUNC 1 -# endif -#endif - namespace { int popcount_builtin(unsigned int x) { @@ -102,4 +92,3 @@ int popcountll(unsigned long long x) } // namespace folly #endif /* !__POPCNT__ */ - diff --git a/folly/Range.cpp b/folly/Range.cpp index b4359bb1..377e293c 100644 --- a/folly/Range.cpp +++ b/folly/Range.cpp @@ -65,14 +65,15 @@ static_assert(kMinPageSize >= 16, #define PAGE_FOR(addr) \ (reinterpret_cast(addr) / kMinPageSize) + +#if FOLLY_HAVE_EMMINTRIN_H inline size_t nextAlignedIndex(const char* arr) { - auto firstPossible = reinterpret_cast(arr) + 1; - return 1 + // add 1 because the index starts at 'arr' - ((firstPossible + 15) & ~0xF) // round up to next multiple of 16 - - firstPossible; + auto firstPossible = reinterpret_cast(arr) + 1; + return 1 + // add 1 because the index starts at 'arr' + ((firstPossible + 15) & ~0xF) // round up to next multiple of 16 + - firstPossible; } -#if FOLLY_HAVE_EMMINTRIN_H // build sse4.2-optimized version even if -msse4.2 is not passed to GCC size_t qfind_first_byte_of_needles16(const StringPiece& haystack, const StringPiece& needles)