Commit d2c36642 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

detect choice of stdlib

Summary: The stdlibs export ways to detect which are in use. Cut the unnecessary preprocessor names for detecting/overriding.

Differential Revision: D32515501

fbshipit-source-id: 2bc85cda30ebbdfa0163e3fe287aceb8df923303
parent b6c651ac
...@@ -167,24 +167,6 @@ check_cxx_source_compiles(" ...@@ -167,24 +167,6 @@ check_cxx_source_compiles("
FOLLY_HAVE_EXTRANDOM_SFMT19937 FOLLY_HAVE_EXTRANDOM_SFMT19937
) )
check_cxx_source_compiles("
#include <type_traits>
#if !_LIBCPP_VERSION
#error No libc++
#endif
int main() { return 0; }"
FOLLY_USE_LIBCPP
)
check_cxx_source_compiles("
#include <type_traits>
#if !__GLIBCXX__
#error No libstdc++
#endif
int main() { return 0; }"
FOLLY_USE_LIBSTDCPP
)
check_cxx_source_runs(" check_cxx_source_runs("
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#cmakedefine FOLLY_HAVE_LIBGLOG 1 #cmakedefine FOLLY_HAVE_LIBGLOG 1
#cmakedefine FOLLY_USE_JEMALLOC 1 #cmakedefine FOLLY_USE_JEMALLOC 1
#cmakedefine FOLLY_USE_LIBSTDCPP 1
#if __has_include(<features.h>) #if __has_include(<features.h>)
#include <features.h> #include <features.h>
...@@ -62,7 +61,6 @@ ...@@ -62,7 +61,6 @@
#cmakedefine FOLLY_HAVE_INT128_T 1 #cmakedefine FOLLY_HAVE_INT128_T 1
#cmakedefine FOLLY_HAVE_WCHAR_SUPPORT 1 #cmakedefine FOLLY_HAVE_WCHAR_SUPPORT 1
#cmakedefine FOLLY_HAVE_EXTRANDOM_SFMT19937 1 #cmakedefine FOLLY_HAVE_EXTRANDOM_SFMT19937 1
#cmakedefine FOLLY_USE_LIBCPP 1
#cmakedefine HAVE_VSNPRINTF_ERRORS 1 #cmakedefine HAVE_VSNPRINTF_ERRORS 1
#cmakedefine FOLLY_HAVE_LIBUNWIND 1 #cmakedefine FOLLY_HAVE_LIBUNWIND 1
......
...@@ -220,8 +220,7 @@ constexpr bool kIsSanitize = false; ...@@ -220,8 +220,7 @@ constexpr bool kIsSanitize = false;
// It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement // It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement
// the 'std' namespace; the latter uses inline namespaces. Wrap this decision // the 'std' namespace; the latter uses inline namespaces. Wrap this decision
// up in a macro to make forward-declarations easier. // up in a macro to make forward-declarations easier.
#if FOLLY_USE_LIBCPP #if defined(_LIBCPP_VERSION)
#include <__config> // @manual
#define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD
#define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD
#else #else
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// AtomicSharedPtr-detail.h only works with libstdc++, so skip these tests for // AtomicSharedPtr-detail.h only works with libstdc++, so skip these tests for
// other vendors // other vendors
#if FOLLY_USE_LIBSTDCPP #if defined(__GLIBCXX__)
#include <folly/concurrency/AtomicSharedPtr.h> #include <folly/concurrency/AtomicSharedPtr.h>
...@@ -236,10 +236,10 @@ int main(int, char**) { ...@@ -236,10 +236,10 @@ int main(int, char**) {
return 0; return 0;
} }
#else // #if FOLLY_USE_LIBSTDCPP #else // defined(__GLIBCXX__)
int main(int, char**) { int main(int, char**) {
return 1; return 1;
} }
#endif // #if FOLLY_USE_LIBSTDCPP #endif // defined(__GLIBCXX__)
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// AtomicSharedPtr-detail.h only works with libstdc++, so skip these tests for // AtomicSharedPtr-detail.h only works with libstdc++, so skip these tests for
// other vendors // other vendors
#if FOLLY_USE_LIBSTDCPP #if defined(__GLIBCXX__)
#include <folly/concurrency/test/AtomicSharedPtrCounted.h> #include <folly/concurrency/test/AtomicSharedPtrCounted.h>
...@@ -187,4 +187,4 @@ TEST(AtomicSharedPtr, DeterministicTest) { ...@@ -187,4 +187,4 @@ TEST(AtomicSharedPtr, DeterministicTest) {
DSched::join(t); DSched::join(t);
} }
} }
#endif // #if FOLLY_USE_LIBSTDCPP #endif // defined(__GLIBCXX__)
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// AtomicSharedPtr-detail.h only works with libstdc++, so skip these tests for // AtomicSharedPtr-detail.h only works with libstdc++, so skip these tests for
// other vendors // other vendors
#if FOLLY_USE_LIBSTDCPP #if defined(__GLIBCXX__)
#include <atomic> #include <atomic>
#include <memory> #include <memory>
...@@ -318,7 +318,7 @@ int main(int argc, char** argv) { ...@@ -318,7 +318,7 @@ int main(int argc, char** argv) {
return ret; return ret;
} }
#endif // #if FOLLY_USE_LIBSTDCPP #endif // defined(__GLIBCXX__)
#if 0 #if 0
// On Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz, 2 sockets, 28 cores, 56 threads. // On Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz, 2 sockets, 28 cores, 56 threads.
......
...@@ -205,7 +205,6 @@ std::vector<ExceptionInfo> getCurrentExceptions() { ...@@ -205,7 +205,6 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
return exceptions; return exceptions;
} }
#if FOLLY_USE_LIBSTDCPP
namespace { namespace {
std::terminate_handler origTerminate = abort; std::terminate_handler origTerminate = abort;
...@@ -244,7 +243,6 @@ void installHandlers() { ...@@ -244,7 +243,6 @@ void installHandlers() {
}; };
static Once once; static Once once;
} }
#endif // FOLLY_USE_LIBSTDCPP
} // namespace exception_tracer } // namespace exception_tracer
} // namespace folly } // namespace folly
......
...@@ -183,7 +183,7 @@ void SymbolizePrinter::println( ...@@ -183,7 +183,7 @@ void SymbolizePrinter::println(
namespace { namespace {
int getFD(const std::ios& stream) { int getFD(const std::ios& stream) {
#if FOLLY_USE_LIBSTDCPP && FOLLY_HAS_RTTI #if defined(__GLIBCXX__) && FOLLY_HAS_RTTI
std::streambuf* buf = stream.rdbuf(); std::streambuf* buf = stream.rdbuf();
using namespace __gnu_cxx; using namespace __gnu_cxx;
...@@ -201,7 +201,7 @@ int getFD(const std::ios& stream) { ...@@ -201,7 +201,7 @@ int getFD(const std::ios& stream) {
} }
#else #else
(void)stream; (void)stream;
#endif // __GNUC__ #endif
return -1; return -1;
} }
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
#include <bits/c++config.h> // @manual #include <bits/c++config.h> // @manual
#endif #endif
#if __has_include(<__config>)
#include <__config> // @manual
#endif
#ifdef __ANDROID__ #ifdef __ANDROID__
#include <android/api-level.h> // @manual #include <android/api-level.h> // @manual
#endif #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