[libc++][nfc] Add TEST_HAS_NO_THREADS.
authorMark de Wever <koraq@xs4all.nl>
Wed, 2 Feb 2022 18:28:06 +0000 (19:28 +0100)
committerMark de Wever <koraq@xs4all.nl>
Sat, 12 Feb 2022 18:24:06 +0000 (19:24 +0100)
This avoids using an libc++ internal macro in our tests.

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D119563

libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
libcxx/test/std/atomics/types.pass.cpp
libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp
libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp
libcxx/test/support/test_macros.h

index 4b3b8e5..296298c 100644 (file)
 #include <cassert>
 #include <chrono> // for nanoseconds
 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#   include <thread> // for thread_id
+#include "test_macros.h"
+
+#ifndef TEST_HAS_NO_THREADS
+#  include <thread> // for thread_id
 #endif
 
 struct TriviallyCopyable {
@@ -35,7 +37,7 @@ void test(T t) {
 int main(int, char**) {
   test(TriviallyCopyable(42));
   test(std::chrono::nanoseconds(2));
-#ifndef _LIBCPP_HAS_NO_THREADS
+#ifndef TEST_HAS_NO_THREADS
   test(std::this_thread::get_id());
 #endif
 
index 401f932..f95f7a4 100644 (file)
 #include <memory>
 #include <type_traits>
 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#   include <thread>
-#endif
-
 #include "test_macros.h"
 
+#ifndef TEST_HAS_NO_THREADS
+#  include <thread>
+#endif
+
 template <class A, bool Integral>
 struct test_atomic
 {
@@ -167,7 +167,7 @@ int main(int, char**)
     test<LargeTriviallyCopyable>();
 #endif
 
-#ifndef _LIBCPP_HAS_NO_THREADS
+#ifndef TEST_HAS_NO_THREADS
     test<std::thread::id>();
 #endif
     test<std::chrono::nanoseconds>();
index 1f82b8a..df681a7 100644 (file)
 #include <unordered_set>
 #include <vector>
 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#   include <mutex>
+#include "test_macros.h"
+
+#ifndef TEST_HAS_NO_THREADS
+#  include <mutex>
 #endif
 
 #include "compare_types.h"
@@ -1058,7 +1060,7 @@ static_assert(
 static_assert(
     !check_equality_comparable_with<std::list<int>, std::vector<int> >());
 
-#ifndef _LIBCPP_HAS_NO_THREADS
+#ifndef TEST_HAS_NO_THREADS
 static_assert(!check_equality_comparable_with<std::lock_guard<std::mutex>,
                                               std::lock_guard<std::mutex> >());
 static_assert(!check_equality_comparable_with<std::lock_guard<std::mutex>,
index fff78cf..1b7b927 100644 (file)
 #include <unordered_map>
 #include <vector>
 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#   include <mutex>
+#include "test_macros.h"
+
+#ifndef TEST_HAS_NO_THREADS
+#  include <mutex>
 #endif
 
 #include "type_classification/moveconstructible.h"
index fcddf83..4db4f01 100644 (file)
@@ -36,9 +36,6 @@
 #include <set>
 #include <stack>
 #include <span>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#  include <thread>
-#endif
 #include <tuple>
 #include <type_traits>
 #include <unordered_map>
@@ -51,6 +48,9 @@
 #ifndef TEST_HAS_NO_LOCALIZATION
 #  include <regex>
 #endif
+#ifndef TEST_HAS_NO_THREADS
+#  include <thread>
+#endif
 
 // Validate default template argument.
 static_assert(std::same_as<std::formatter<int>, std::formatter<int, char>>);
@@ -217,7 +217,7 @@ void test_P1636() {
 #ifndef TEST_HAS_NO_LOCALIZATION
   assert_formatter_is_disabled<std::sub_match<CharT*>, CharT>();
 #endif
-#ifndef _LIBCPP_HAS_NO_THREADS
+#ifndef TEST_HAS_NO_THREADS
   assert_formatter_is_disabled<std::thread::id, CharT>();
 #endif
   assert_formatter_is_disabled<std::unique_ptr<int>, CharT>();
index 321347f..b5d768b 100644 (file)
@@ -384,6 +384,10 @@ inline void DoNotOptimize(Tp const& value) {
 #  define TEST_HAS_NO_CHAR8_T
 #endif
 
+#if defined(_LIBCPP_HAS_NO_THREADS)
+#  define TEST_HAS_NO_THREADS
+#endif
+
 #if defined(__GNUC__)
 #pragma GCC diagnostic pop
 #endif