Skip to content

Commit bbff52b

Browse files
authored
[libc++] Guard PSTL headers with >= C++17 (#108234)
Otherwise we fail to build with modules in C++03 mode once we migrate to a single top-level module, because those headers get pulled in but they don't compile as C++03.
1 parent c3d39cb commit bbff52b

File tree

17 files changed

+88
-20
lines changed

17 files changed

+88
-20
lines changed

libcxx/include/__pstl/backend.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@
1919
_LIBCPP_PUSH_MACROS
2020
#include <__undef_macros>
2121

22-
#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
23-
# include <__pstl/backends/default.h>
24-
# include <__pstl/backends/serial.h>
25-
#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
26-
# include <__pstl/backends/default.h>
27-
# include <__pstl/backends/std_thread.h>
28-
#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
29-
# include <__pstl/backends/default.h>
30-
# include <__pstl/backends/libdispatch.h>
31-
#endif
22+
#if _LIBCPP_STD_VER >= 17
23+
24+
# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
25+
# include <__pstl/backends/default.h>
26+
# include <__pstl/backends/serial.h>
27+
# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
28+
# include <__pstl/backends/default.h>
29+
# include <__pstl/backends/std_thread.h>
30+
# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
31+
# include <__pstl/backends/default.h>
32+
# include <__pstl/backends/libdispatch.h>
33+
# endif
34+
35+
#endif // _LIBCPP_STD_VER >= 17
3236

3337
_LIBCPP_POP_MACROS
3438

libcxx/include/__pstl/backend_fwd.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ _LIBCPP_PUSH_MACROS
3939
// the user.
4040
//
4141

42+
#if _LIBCPP_STD_VER >= 17
43+
4244
_LIBCPP_BEGIN_NAMESPACE_STD
4345
namespace __pstl {
4446

@@ -50,18 +52,18 @@ struct __libdispatch_backend_tag;
5052
struct __serial_backend_tag;
5153
struct __std_thread_backend_tag;
5254

53-
#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
55+
# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
5456
using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>;
55-
#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
57+
# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
5658
using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>;
57-
#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
59+
# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
5860
using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>;
59-
#else
61+
# else
6062

6163
// ...New vendors can add parallel backends here...
6264

63-
# error "Invalid PSTL backend configuration"
64-
#endif
65+
# error "Invalid PSTL backend configuration"
66+
# endif
6567

6668
template <class _Backend, class _ExecutionPolicy>
6769
struct __find_if;
@@ -296,6 +298,8 @@ struct __reduce;
296298
} // namespace __pstl
297299
_LIBCPP_END_NAMESPACE_STD
298300

301+
#endif // _LIBCPP_STD_VER >= 17
302+
299303
_LIBCPP_POP_MACROS
300304

301305
#endif // _LIBCPP___PSTL_BACKEND_FWD_H

libcxx/include/__pstl/backends/default.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
_LIBCPP_PUSH_MACROS
3434
#include <__undef_macros>
3535

36+
#if _LIBCPP_STD_VER >= 17
37+
3638
_LIBCPP_BEGIN_NAMESPACE_STD
3739
namespace __pstl {
3840

@@ -498,6 +500,8 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
498500
} // namespace __pstl
499501
_LIBCPP_END_NAMESPACE_STD
500502

503+
#endif // _LIBCPP_STD_VER >= 17
504+
501505
_LIBCPP_POP_MACROS
502506

503507
#endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H

libcxx/include/__pstl/backends/libdispatch.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
_LIBCPP_PUSH_MACROS
4545
#include <__undef_macros>
4646

47+
#if _LIBCPP_STD_VER >= 17
48+
4749
_LIBCPP_BEGIN_NAMESPACE_STD
4850
namespace __pstl {
4951

@@ -140,15 +142,15 @@ struct __cpu_traits<__libdispatch_backend_tag> {
140142

141143
unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
142144
[&]() -> __merge_range_t* {
143-
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
145+
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
144146
try {
145-
#endif
147+
# endif
146148
return std::allocator<__merge_range_t>().allocate(__n_ranges);
147-
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
149+
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
148150
} catch (const std::bad_alloc&) {
149151
return nullptr;
150152
}
151-
#endif
153+
# endif
152154
}(),
153155
__destroy);
154156

@@ -392,6 +394,8 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>
392394
} // namespace __pstl
393395
_LIBCPP_END_NAMESPACE_STD
394396

397+
#endif // _LIBCPP_STD_VER >= 17
398+
395399
_LIBCPP_POP_MACROS
396400

397401
#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H

libcxx/include/__pstl/backends/serial.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
_LIBCPP_PUSH_MACROS
3131
#include <__undef_macros>
3232

33+
#if _LIBCPP_STD_VER >= 17
34+
3335
_LIBCPP_BEGIN_NAMESPACE_STD
3436
namespace __pstl {
3537

@@ -176,6 +178,8 @@ struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> {
176178
} // namespace __pstl
177179
_LIBCPP_END_NAMESPACE_STD
178180

181+
#endif // _LIBCPP_STD_VER >= 17
182+
179183
_LIBCPP_POP_MACROS
180184

181185
#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H

libcxx/include/__pstl/backends/std_thread.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
_LIBCPP_PUSH_MACROS
3333
#include <__undef_macros>
3434

35+
#if _LIBCPP_STD_VER >= 17
36+
3537
_LIBCPP_BEGIN_NAMESPACE_STD
3638
namespace __pstl {
3739

@@ -131,6 +133,8 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy>
131133
} // namespace __pstl
132134
_LIBCPP_END_NAMESPACE_STD
133135

136+
#endif // _LIBCPP_STD_VER >= 17
137+
134138
_LIBCPP_POP_MACROS
135139

136140
#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H

libcxx/include/__pstl/cpu_algos/any_of.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
_LIBCPP_PUSH_MACROS
2727
#include <__undef_macros>
2828

29+
#if _LIBCPP_STD_VER >= 17
30+
2931
_LIBCPP_BEGIN_NAMESPACE_STD
3032
namespace __pstl {
3133

@@ -94,6 +96,8 @@ struct __cpu_parallel_any_of {
9496
} // namespace __pstl
9597
_LIBCPP_END_NAMESPACE_STD
9698

99+
#endif // _LIBCPP_STD_VER >= 17
100+
97101
_LIBCPP_POP_MACROS
98102

99103
#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H

libcxx/include/__pstl/cpu_algos/cpu_traits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
_LIBCPP_PUSH_MACROS
2020
#include <__undef_macros>
2121

22+
#if _LIBCPP_STD_VER >= 17
23+
2224
_LIBCPP_BEGIN_NAMESPACE_STD
2325
namespace __pstl {
2426

@@ -81,6 +83,8 @@ struct __cpu_traits;
8183
} // namespace __pstl
8284
_LIBCPP_END_NAMESPACE_STD
8385

86+
#endif // _LIBCPP_STD_VER >= 17
87+
8488
_LIBCPP_POP_MACROS
8589

8690
#endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H

libcxx/include/__pstl/cpu_algos/fill.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# pragma GCC system_header
2424
#endif
2525

26+
#if _LIBCPP_STD_VER >= 17
27+
2628
_LIBCPP_BEGIN_NAMESPACE_STD
2729
namespace __pstl {
2830

@@ -63,4 +65,6 @@ struct __cpu_parallel_fill {
6365
} // namespace __pstl
6466
_LIBCPP_END_NAMESPACE_STD
6567

68+
#endif // _LIBCPP_STD_VER >= 17
69+
6670
#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H

libcxx/include/__pstl/cpu_algos/find_if.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
_LIBCPP_PUSH_MACROS
3232
#include <__undef_macros>
3333

34+
#if _LIBCPP_STD_VER >= 17
35+
3436
_LIBCPP_BEGIN_NAMESPACE_STD
3537
namespace __pstl {
3638

@@ -132,6 +134,8 @@ struct __cpu_parallel_find_if {
132134
} // namespace __pstl
133135
_LIBCPP_END_NAMESPACE_STD
134136

137+
#endif // _LIBCPP_STD_VER >= 17
138+
135139
_LIBCPP_POP_MACROS
136140

137141
#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H

libcxx/include/__pstl/cpu_algos/for_each.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# pragma GCC system_header
2424
#endif
2525

26+
#if _LIBCPP_STD_VER >= 17
27+
2628
_LIBCPP_BEGIN_NAMESPACE_STD
2729
namespace __pstl {
2830

@@ -63,4 +65,6 @@ struct __cpu_parallel_for_each {
6365
} // namespace __pstl
6466
_LIBCPP_END_NAMESPACE_STD
6567

68+
#endif // _LIBCPP_STD_VER >= 17
69+
6670
#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H

libcxx/include/__pstl/cpu_algos/merge.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
_LIBCPP_PUSH_MACROS
2727
#include <__undef_macros>
2828

29+
#if _LIBCPP_STD_VER >= 17
30+
2931
_LIBCPP_BEGIN_NAMESPACE_STD
3032
namespace __pstl {
3133

@@ -80,6 +82,8 @@ struct __cpu_parallel_merge {
8082
} // namespace __pstl
8183
_LIBCPP_END_NAMESPACE_STD
8284

85+
#endif // _LIBCPP_STD_VER >= 17
86+
8387
_LIBCPP_POP_MACROS
8488

8589
#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H

libcxx/include/__pstl/cpu_algos/stable_sort.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# pragma GCC system_header
2222
#endif
2323

24+
#if _LIBCPP_STD_VER >= 17
25+
2426
_LIBCPP_BEGIN_NAMESPACE_STD
2527
namespace __pstl {
2628

@@ -44,4 +46,6 @@ struct __cpu_parallel_stable_sort {
4446
} // namespace __pstl
4547
_LIBCPP_END_NAMESPACE_STD
4648

49+
#endif // _LIBCPP_STD_VER >= 17
50+
4751
#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H

libcxx/include/__pstl/cpu_algos/transform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
_LIBCPP_PUSH_MACROS
2828
#include <__undef_macros>
2929

30+
#if _LIBCPP_STD_VER >= 17
31+
3032
_LIBCPP_BEGIN_NAMESPACE_STD
3133
namespace __pstl {
3234

@@ -148,6 +150,8 @@ struct __cpu_parallel_transform_binary {
148150
} // namespace __pstl
149151
_LIBCPP_END_NAMESPACE_STD
150152

153+
#endif // _LIBCPP_STD_VER >= 17
154+
151155
_LIBCPP_POP_MACROS
152156

153157
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H

libcxx/include/__pstl/cpu_algos/transform_reduce.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
_LIBCPP_PUSH_MACROS
3232
#include <__undef_macros>
3333

34+
#if _LIBCPP_STD_VER >= 17
35+
3436
_LIBCPP_BEGIN_NAMESPACE_STD
3537
namespace __pstl {
3638

@@ -211,6 +213,8 @@ struct __cpu_parallel_transform_reduce {
211213
} // namespace __pstl
212214
_LIBCPP_END_NAMESPACE_STD
213215

216+
#endif // _LIBCPP_STD_VER >= 17
217+
214218
_LIBCPP_POP_MACROS
215219

216220
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H

libcxx/include/__pstl/dispatch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
_LIBCPP_PUSH_MACROS
2424
#include <__undef_macros>
2525

26+
#if _LIBCPP_STD_VER >= 17
27+
2628
_LIBCPP_BEGIN_NAMESPACE_STD
2729
namespace __pstl {
2830

@@ -61,6 +63,8 @@ using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfigu
6163
} // namespace __pstl
6264
_LIBCPP_END_NAMESPACE_STD
6365

66+
#endif // _LIBCPP_STD_VER >= 17
67+
6468
_LIBCPP_POP_MACROS
6569

6670
#endif // _LIBCPP___PSTL_DISPATCH_H

libcxx/include/__pstl/handle_exception.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
_LIBCPP_PUSH_MACROS
2323
#include <__undef_macros>
2424

25+
#if _LIBCPP_STD_VER >= 17
26+
2527
_LIBCPP_BEGIN_NAMESPACE_STD
2628
namespace __pstl {
2729

@@ -52,6 +54,8 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) {
5254
} // namespace __pstl
5355
_LIBCPP_END_NAMESPACE_STD
5456

57+
#endif // _LIBCPP_STD_VER >= 17
58+
5559
_LIBCPP_POP_MACROS
5660

5761
#endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H

0 commit comments

Comments
 (0)