Commit 37d40eed authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by facebook-github-bot-1

Fix Build: folly/Range.h for build platforms missing SSE42 headers

Summary: [Folly] Fix Build: `folly/Range.h` for build platforms missing SSE42 headers.

We make the assumption that if the compiler defines the appropriate symbols indicating SSE42, that the corresponding intrinsics headers are available.

We also remove `Range.cpp` from `Makefile.am`, which we forgot to do in the blamed diff.

Reviewed By: @nbronson

Differential Revision: D2504934
parent 338a2603
...@@ -309,7 +309,6 @@ libfollybase_la_SOURCES = \ ...@@ -309,7 +309,6 @@ libfollybase_la_SOURCES = \
Format.cpp \ Format.cpp \
FormatTables.cpp \ FormatTables.cpp \
Malloc.cpp \ Malloc.cpp \
Range.cpp \
RangeCommon.cpp \ RangeCommon.cpp \
RangeSse42.cpp \ RangeSse42.cpp \
StringBase.cpp \ StringBase.cpp \
......
...@@ -300,6 +300,9 @@ typedef SSIZE_T ssize_t; ...@@ -300,6 +300,9 @@ typedef SSIZE_T ssize_t;
# endif # endif
#endif #endif
#define FOLLY_SSE_PREREQ(major, minor) \
(FOLLY_SSE > major || FOLLY_SSE == major && FOLLY_SSE_MINOR >= minor)
#if FOLLY_UNUSUAL_GFLAGS_NAMESPACE #if FOLLY_UNUSUAL_GFLAGS_NAMESPACE
namespace FOLLY_GFLAGS_NAMESPACE { } namespace FOLLY_GFLAGS_NAMESPACE { }
namespace gflags { namespace gflags {
......
...@@ -14,16 +14,50 @@ ...@@ -14,16 +14,50 @@
* limitations under the License. * limitations under the License.
*/ */
#include "RangeSse42.h" #include "RangeSse42.h"
#include <glog/logging.h>
#include <folly/Portability.h>
// Essentially, two versions of this file: one with an SSE42 implementation
// and one with a fallback implementation. We determine which version to use by
// testing for the presence of the required headers.
//
// TODO: Maybe this should be done by the build system....
#if !FOLLY_SSE_PREREQ(4, 2)
namespace folly {
namespace detail {
size_t qfind_first_byte_of_sse42(const StringPieceLite haystack,
const StringPieceLite needles) {
CHECK(false) << "Function " << __func__ << " only works with SSE42!";
return qfind_first_byte_of_nosse(haystack, needles);
}
}
}
# else
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
#include <string> #include <string>
#include <emmintrin.h> #include <emmintrin.h>
#include <smmintrin.h> #include <smmintrin.h>
#include <glog/logging.h>
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/Portability.h>
namespace folly { namespace folly {
...@@ -188,3 +222,7 @@ size_t qfind_first_byte_of_sse42(const StringPieceLite haystack, ...@@ -188,3 +222,7 @@ size_t qfind_first_byte_of_sse42(const StringPieceLite haystack,
} }
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment