From 31005a98c091b4f28650cad4b7420d54b72381ad Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Tue, 8 Oct 2013 20:57:32 -0700 Subject: [PATCH] Check for std::this_thread::sleep_for. Summary: - Some installations of libstdc++ don't have this defined. This happens if they were built without --enable-libstdcxx-time. Detect this and avoid tests that rely on this behavior. Test Plan: - fbconfig -r folly && fbmake runtests - ./configure && make check on Ubuntu/FC/Mac Reviewed By: meyering@fb.com FB internal diff: D1002963 --- folly/configure.ac | 9 +++++++++ folly/test/ThreadLocalTest.cpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/folly/configure.ac b/folly/configure.ac index 29ae18fd..1b5e7b10 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -78,6 +78,15 @@ AC_COMPILE_IFELSE( AC_DEFINE([OVERRIDE], [], [Define to "override" if the compiler supports C++11 "override"])] ) + +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE[ + #include + #include + void func() { std::this_thread::sleep_for(std::chrono::seconds(1)); }]], + [AC_DEFINE([HAVE_STD__THIS_THREAD__SLEEP_FOR], [1], + [Define to 1 if std::this_thread::sleep_for() is defined.])]) + AC_COMPILE_IFELSE( [AC_LANG_SOURCE[ #include diff --git a/folly/test/ThreadLocalTest.cpp b/folly/test/ThreadLocalTest.cpp index b9f69a0f..d78e07ea 100644 --- a/folly/test/ThreadLocalTest.cpp +++ b/folly/test/ThreadLocalTest.cpp @@ -346,6 +346,7 @@ class FillObject { } // namespace +#if FOLLY_HAVE_STD__THIS_THREAD__SLEEP_FOR TEST(ThreadLocal, Stress) { constexpr size_t numFillObjects = 250; std::array, numFillObjects> objects; @@ -376,6 +377,7 @@ TEST(ThreadLocal, Stress) { EXPECT_EQ(numFillObjects * numThreads * numReps, gDestroyed); } +#endif // Yes, threads and fork don't mix // (http://cppwisdom.quora.com/Why-threads-and-fork-dont-mix) but if you're -- 2.34.1