summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark de Wever <koraq@xs4all.nl>2022-02-02 19:28:06 +0100
committerMark de Wever <koraq@xs4all.nl>2022-02-12 19:24:06 +0100
commit84bb14599f14b590edb2c1e45b5548af3554e551 (patch)
tree89b87af5afbde0ec16eac909fbf8319b2141053e
parent7af3d4ab3d5da07256e1a7a0438e7308e14b9fd5 (diff)
[libc++][nfc] Add TEST_HAS_NO_THREADS.
This avoids using an libc++ internal macro in our tests. Reviewed By: #libc, philnik, ldionne Differential Revision: https://reviews.llvm.org/D119563
-rw-r--r--libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp8
-rw-r--r--libcxx/test/std/atomics/types.pass.cpp10
-rw-r--r--libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp8
-rw-r--r--libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp6
-rw-r--r--libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp8
-rw-r--r--libcxx/test/support/test_macros.h4
6 files changed, 27 insertions, 17 deletions
diff --git a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
index 4b3b8e59cc10..296298cfd31f 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
@@ -18,8 +18,10 @@
#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
diff --git a/libcxx/test/std/atomics/types.pass.cpp b/libcxx/test/std/atomics/types.pass.cpp
index 401f9328b2fa..f95f7a4c1d47 100644
--- a/libcxx/test/std/atomics/types.pass.cpp
+++ b/libcxx/test/std/atomics/types.pass.cpp
@@ -22,12 +22,12 @@
#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>();
diff --git a/libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp b/libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
index 1f82b8a0d6b0..df681a7caa23 100644
--- a/libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
@@ -26,8 +26,10 @@
#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>,
diff --git a/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp
index fff78cfda3f8..1b7b9275ffd9 100644
--- a/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp
@@ -22,8 +22,10 @@
#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"
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp
index fcddf832df2c..4db4f017e5ac 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp
@@ -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>();
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 321347f801c7..b5d768bff484 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -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