Folly Changes for Clang, revision 1
authorTodd Nowacki <tmn@fb.com>
Tue, 4 Jun 2013 21:43:22 +0000 (14:43 -0700)
committerJordan DeLong <jdelong@fb.com>
Wed, 26 Jun 2013 02:45:50 +0000 (19:45 -0700)
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

folly/Bits.cpp
folly/Range.cpp

index 62b759f09182193e78ca79a57babff82dbc4c6d1..15842b4571b6c4b80ffae997d90deec4f76a1064 100644 (file)
 // 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__ */
-
index b4359bb1e56c0d84c04f0bd6f639d857a6c53c0f..377e293c4d92a3577616f3094e4790239d9bc01d 100644 (file)
@@ -65,14 +65,15 @@ static_assert(kMinPageSize >= 16,
 #define PAGE_FOR(addr) \
   (reinterpret_cast<uintptr_t>(addr) / kMinPageSize)
 
+
+#if FOLLY_HAVE_EMMINTRIN_H
 inline size_t nextAlignedIndex(const char* arr) {
-  auto firstPossible = reinterpret_cast<uintptr_t>(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<uintptr_t>(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)