[libcxx-commits] [libcxx] [libc++] Include headers in <thread> conditionally (PR #116539)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 17 03:21:53 PST 2024
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/116539
>From 65978e3555de13932a7c5af51b28531a763f0c1e Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 17 Nov 2024 11:57:06 +0100
Subject: [PATCH] [libc++] Include headers in <thread> conditionally
---
libcxx/include/thread | 19 +++++++++----------
libcxx/test/benchmarks/atomic_wait.bench.cpp | 1 +
.../atomic_wait_vs_mutex_lock.bench.cpp | 2 +-
libcxx/test/benchmarks/stop_token.bench.cpp | 2 +-
.../atomic_unique_lock.pass.cpp | 1 +
.../std/thread/thread.semaphore/max.pass.cpp | 4 +---
6 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/libcxx/include/thread b/libcxx/include/thread
index bfe7e4a4c51e5c..d7c3f704ad672b 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -90,11 +90,17 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#if _LIBCPP_HAS_THREADS
-# include <__thread/formatter.h>
-# include <__thread/jthread.h>
-# include <__thread/support.h>
# include <__thread/this_thread.h>
# include <__thread/thread.h>
+
+# if _LIBCPP_STD_VER >= 20
+# include <__thread/jthread.h>
+# endif
+
+# if _LIBCPP_STD_VER >= 23
+# include <__thread/formatter.h>
+# endif
+
# include <version>
// standard-mandated includes
@@ -108,13 +114,6 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#endif // _LIBCPP_HAS_THREADS
-#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
-# include <cstddef>
-# include <ctime>
-# include <iosfwd>
-# include <ratio>
-#endif
-
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
# include <chrono>
#endif
diff --git a/libcxx/test/benchmarks/atomic_wait.bench.cpp b/libcxx/test/benchmarks/atomic_wait.bench.cpp
index 49503a318fda16..d19f5fbed8ad60 100644
--- a/libcxx/test/benchmarks/atomic_wait.bench.cpp
+++ b/libcxx/test/benchmarks/atomic_wait.bench.cpp
@@ -9,6 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
#include <atomic>
+#include <cstdint>
#include <numeric>
#include <stop_token>
#include <thread>
diff --git a/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp b/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
index 221fc086d2a626..a554c721df017e 100644
--- a/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
+++ b/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
@@ -9,8 +9,8 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
#include <atomic>
+#include <cstdint>
#include <mutex>
-#include <numeric>
#include <stop_token>
#include <thread>
diff --git a/libcxx/test/benchmarks/stop_token.bench.cpp b/libcxx/test/benchmarks/stop_token.bench.cpp
index 6149f91c6fc384..a627f80697dd5d 100644
--- a/libcxx/test/benchmarks/stop_token.bench.cpp
+++ b/libcxx/test/benchmarks/stop_token.bench.cpp
@@ -8,7 +8,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-#include <numeric>
+#include <cstdint>
#include <optional>
#include <stop_token>
#include <thread>
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
index 44d51921ac74ad..a8093ae22b38dd 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
@@ -15,6 +15,7 @@
#include <atomic>
#include <cassert>
#include <chrono>
+#include <cstdint>
#include <thread>
#include "make_test_thread.h"
diff --git a/libcxx/test/std/thread/thread.semaphore/max.pass.cpp b/libcxx/test/std/thread/thread.semaphore/max.pass.cpp
index bf6b0f05e64f0a..5d540758125606 100644
--- a/libcxx/test/std/thread/thread.semaphore/max.pass.cpp
+++ b/libcxx/test/std/thread/thread.semaphore/max.pass.cpp
@@ -11,10 +11,8 @@
// <semaphore>
+#include <cstddef>
#include <semaphore>
-#include <thread>
-
-#include "test_macros.h"
int main(int, char**)
{
More information about the libcxx-commits
mailing list