From ae1c8fd0e7284639b16aad0646ed99ecd12a89af Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Wed, 3 Oct 2018 13:19:03 -0700 Subject: [PATCH 01/10] Fix compilation with Dinkumware headers older than version 601 on FreeBSD. --- folly/Conv.h | 1 + folly/ExceptionWrapper.h | 4 ++ folly/FBString.h | 2 +- folly/GLog.h | 17 ++++++ folly/Portability.h | 6 ++- folly/String.cpp | 3 +- folly/String.h | 1 + folly/Traits.h | 2 +- folly/Utility.h | 4 ++ folly/container/SparseByteSet.h | 6 ++- folly/detail/Futex.h | 6 ++- folly/detail/RangeCommon.h | 3 -- folly/detail/RangeSse42.cpp | 4 +- folly/detail/ThreadLocalDetail.h | 2 - folly/dynamic-inl.h | 1 + folly/dynamic.h | 4 ++ folly/folly-config.h | 88 ++++++++++++++++++++++++++++++++ folly/hash/Hash.h | 8 +++ folly/hash/SpookyHashV1.h | 4 ++ folly/hash/SpookyHashV2.h | 4 ++ folly/lang/Bits.h | 8 +++ folly/memory/Malloc.h | 4 +- folly/portability/Malloc.h | 2 +- folly/portability/PThread.h | 4 +- folly/system/ThreadId.h | 4 +- 25 files changed, 172 insertions(+), 20 deletions(-) create mode 100644 folly/folly-config.h diff --git a/folly/Conv.h b/folly/Conv.h index 9fc2fa4992d..253aef3044d 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index f3af915de5d..6bfb4a12cb4 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -20,7 +20,11 @@ #pragma once #include +#if __has_include() #include +#else +#include +#endif #include #include #include diff --git a/folly/FBString.h b/folly/FBString.h index 43739676904..5179c3dde18 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -2789,7 +2789,7 @@ operator<<( os.setstate(_ostream_type::badbit | _ostream_type::failbit); } } -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) || defined(HAS_NO_OSTREAM_INSERT) typedef decltype(os.precision()) streamsize; // MSVC doesn't define __ostream_insert os.write(str.data(), static_cast(str.size())); diff --git a/folly/GLog.h b/folly/GLog.h index 3724aaa59a4..989687d384e 100644 --- a/folly/GLog.h +++ b/folly/GLog.h @@ -16,6 +16,7 @@ #pragma once +#if FOLLY_HAVE_LIBGLOG #include #include @@ -57,3 +58,19 @@ LOG(severity) #endif +#else +#include +#ifndef FB_LOG_EVERY_MS +#define FB_LOG_EVERY_MS(severity, milli_interval) +#endif +#define CHECK(x) std::cerr +#define CHECK_GE(x,y) +#define DCHECK_EQ(x,y) +#define DCHECK_GT(x,y) +#define DCHECK_LT(x,y) +#define DCHECK_LE(x,y) +#define DCHECK(x) +#define WARNING 0 +#define DFATAL 0 +#define LOG(x) std::cerr +#endif diff --git a/folly/Portability.h b/folly/Portability.h index e305a7cddb4..8e046c3db49 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -200,8 +200,10 @@ FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS */ #if defined(_MSC_VER) #define FOLLY_TLS __declspec(thread) -#elif defined(__GNUC__) || defined(__clang__) +#elif (defined(__GNUC__) || defined(__clang__)) && !_LIBCPP_VER #define FOLLY_TLS __thread +#elif (defined(__GNUC__) || defined(__clang__)) && _LIBCPP_VER +#define FOLLY_TLS thread_local #else #error cannot define platform specific thread local storage #endif @@ -214,7 +216,9 @@ FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS // the 'std' namespace; the latter uses inline namespaces. Wrap this decision // up in a macro to make forward-declarations easier. #if FOLLY_USE_LIBCPP +#if __has_include(<__config>) #include <__config> // @manual +#endif #define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD #else diff --git a/folly/String.cpp b/folly/String.cpp index aa838304369..ab8678153a1 100644 --- a/folly/String.cpp +++ b/folly/String.cpp @@ -24,8 +24,7 @@ #include #include -#include - +#include #include #include #include diff --git a/folly/String.h b/folly/String.h index 8cf89a873e2..3b125225075 100644 --- a/folly/String.h +++ b/folly/String.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/folly/Traits.h b/folly/Traits.h index 9fd77a7d1cd..8832f6810ae 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -420,7 +420,7 @@ namespace traits_detail_IsNothrowSwappable { // is enabled. template using IsNothrowSwappable = std::is_nothrow_swappable; -#elif _CPPLIB_VER +#elif _CPPLIB_VER > 601 // MSVC 2015+ defines the base even if C++17 is disabled, and // MSVC 2015 has issues with our fallback implementation due to // over-eager evaluation of noexcept. diff --git a/folly/Utility.h b/folly/Utility.h index 1e3e10a523c..16f962c5a0b 100644 --- a/folly/Utility.h +++ b/folly/Utility.h @@ -16,7 +16,11 @@ #pragma once +#if __has_include() #include +#else +#include +#endif #include #include #include diff --git a/folly/container/SparseByteSet.h b/folly/container/SparseByteSet.h index 717fa2d33bf..b5a1e12c572 100644 --- a/folly/container/SparseByteSet.h +++ b/folly/container/SparseByteSet.h @@ -16,9 +16,13 @@ #pragma once +#if __has_include() #include +#else +#include +#endif -#include +#include namespace folly { diff --git a/folly/detail/Futex.h b/folly/detail/Futex.h index 71fa98024be..760ed62766b 100644 --- a/folly/detail/Futex.h +++ b/folly/detail/Futex.h @@ -19,7 +19,11 @@ #include #include #include +#if __has_include() #include +#else +#include +#endif #include #include @@ -48,7 +52,7 @@ enum class FutexResult { * functions are available as free functions rather than member functions */ template