From 37d40eed8324114070253f762dc3545bc938cb1e Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Fri, 2 Oct 2015 23:08:39 -0700 Subject: [PATCH] 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 --- folly/Makefile.am | 1 - folly/Portability.h | 3 +++ folly/detail/RangeSse42.cpp | 42 +++++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/folly/Makefile.am b/folly/Makefile.am index 8301005f..5f4eef08 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -309,7 +309,6 @@ libfollybase_la_SOURCES = \ Format.cpp \ FormatTables.cpp \ Malloc.cpp \ - Range.cpp \ RangeCommon.cpp \ RangeSse42.cpp \ StringBase.cpp \ diff --git a/folly/Portability.h b/folly/Portability.h index 7ccedfac..ca8c28a3 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -300,6 +300,9 @@ typedef SSIZE_T ssize_t; # endif #endif +#define FOLLY_SSE_PREREQ(major, minor) \ + (FOLLY_SSE > major || FOLLY_SSE == major && FOLLY_SSE_MINOR >= minor) + #if FOLLY_UNUSUAL_GFLAGS_NAMESPACE namespace FOLLY_GFLAGS_NAMESPACE { } namespace gflags { diff --git a/folly/detail/RangeSse42.cpp b/folly/detail/RangeSse42.cpp index 1d1d32db..c5409887 100644 --- a/folly/detail/RangeSse42.cpp +++ b/folly/detail/RangeSse42.cpp @@ -14,16 +14,50 @@ * limitations under the License. */ + + #include "RangeSse42.h" +#include +#include + + + +// 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 #include #include #include #include -#include #include -#include namespace folly { @@ -188,3 +222,7 @@ size_t qfind_first_byte_of_sse42(const StringPieceLite haystack, } } + + + +#endif -- 2.34.1