Skip to content

Commit 9ebc6f5

Browse files
authored
[libc++] Include headers in <thread> conditionally (#116539)
1 parent 8f53a67 commit 9ebc6f5

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

libcxx/include/thread

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,17 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
9090

9191
#if _LIBCPP_HAS_THREADS
9292

93-
# include <__thread/formatter.h>
94-
# include <__thread/jthread.h>
95-
# include <__thread/support.h>
9693
# include <__thread/this_thread.h>
9794
# include <__thread/thread.h>
95+
96+
# if _LIBCPP_STD_VER >= 20
97+
# include <__thread/jthread.h>
98+
# endif
99+
100+
# if _LIBCPP_STD_VER >= 23
101+
# include <__thread/formatter.h>
102+
# endif
103+
98104
# include <version>
99105

100106
// standard-mandated includes
@@ -108,13 +114,6 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
108114

109115
#endif // _LIBCPP_HAS_THREADS
110116

111-
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
112-
# include <cstddef>
113-
# include <ctime>
114-
# include <iosfwd>
115-
# include <ratio>
116-
#endif
117-
118117
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
119118
# include <chrono>
120119
#endif

libcxx/test/benchmarks/atomic_wait.bench.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// UNSUPPORTED: c++03, c++11, c++14, c++17
1010

1111
#include <atomic>
12+
#include <cstdint>
1213
#include <numeric>
1314
#include <stop_token>
1415
#include <thread>

libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// UNSUPPORTED: c++03, c++11, c++14, c++17
1010

1111
#include <atomic>
12+
#include <cstdint>
1213
#include <mutex>
13-
#include <numeric>
1414
#include <stop_token>
1515
#include <thread>
1616

libcxx/test/benchmarks/stop_token.bench.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17
1010

11-
#include <numeric>
11+
#include <cstdint>
1212
#include <optional>
1313
#include <stop_token>
1414
#include <thread>

libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <atomic>
1616
#include <cassert>
1717
#include <chrono>
18+
#include <cstdint>
1819
#include <thread>
1920

2021
#include "make_test_thread.h"

libcxx/test/std/thread/thread.semaphore/max.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
// <semaphore>
1313

14+
#include <cstddef>
1415
#include <semaphore>
15-
#include <thread>
16-
17-
#include "test_macros.h"
1816

1917
int main(int, char**)
2018
{

0 commit comments

Comments
 (0)