Skip to content

Commit acb896a

Browse files
authored
[libc++] Remove unnecessary #ifdef guards around PSTL implementation details (#95268)
We want the PSTL implementation details to be available regardless of the Standard mode or whether the experimental PSTL is enabled. This patch guards the inclusion of the PSTL to the top-level headers that define the public API in `__numeric` and `__algorithm`.
1 parent 148417b commit acb896a

File tree

14 files changed

+34
-80
lines changed

14 files changed

+34
-80
lines changed

libcxx/include/__algorithm/pstl.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@
1010
#define _LIBCPP___ALGORITHM_PSTL_H
1111

1212
#include <__config>
13-
#include <__functional/operations.h>
14-
#include <__iterator/cpp17_iterator_concepts.h>
15-
#include <__iterator/iterator_traits.h>
16-
#include <__pstl/backend.h>
17-
#include <__pstl/dispatch.h>
18-
#include <__pstl/handle_exception.h>
19-
#include <__type_traits/enable_if.h>
20-
#include <__type_traits/is_execution_policy.h>
21-
#include <__type_traits/remove_cvref.h>
22-
#include <__utility/forward.h>
23-
#include <__utility/move.h>
2413

2514
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2615
# pragma GCC system_header
@@ -31,6 +20,18 @@ _LIBCPP_PUSH_MACROS
3120

3221
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
3322

23+
# include <__functional/operations.h>
24+
# include <__iterator/cpp17_iterator_concepts.h>
25+
# include <__iterator/iterator_traits.h>
26+
# include <__pstl/backend.h>
27+
# include <__pstl/dispatch.h>
28+
# include <__pstl/handle_exception.h>
29+
# include <__type_traits/enable_if.h>
30+
# include <__type_traits/is_execution_policy.h>
31+
# include <__type_traits/remove_cvref.h>
32+
# include <__utility/forward.h>
33+
# include <__utility/move.h>
34+
3435
_LIBCPP_BEGIN_NAMESPACE_STD
3536

3637
template <class _ExecutionPolicy,

libcxx/include/__numeric/pstl.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@
1010
#define _LIBCPP___NUMERIC_PSTL_H
1111

1212
#include <__config>
13-
#include <__functional/identity.h>
14-
#include <__functional/operations.h>
15-
#include <__iterator/cpp17_iterator_concepts.h>
16-
#include <__iterator/iterator_traits.h>
17-
#include <__pstl/backend.h>
18-
#include <__pstl/dispatch.h>
19-
#include <__pstl/handle_exception.h>
20-
#include <__type_traits/enable_if.h>
21-
#include <__type_traits/is_execution_policy.h>
22-
#include <__type_traits/remove_cvref.h>
23-
#include <__utility/forward.h>
24-
#include <__utility/move.h>
2513

2614
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2715
# pragma GCC system_header
@@ -32,6 +20,19 @@ _LIBCPP_PUSH_MACROS
3220

3321
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
3422

23+
# include <__functional/identity.h>
24+
# include <__functional/operations.h>
25+
# include <__iterator/cpp17_iterator_concepts.h>
26+
# include <__iterator/iterator_traits.h>
27+
# include <__pstl/backend.h>
28+
# include <__pstl/dispatch.h>
29+
# include <__pstl/handle_exception.h>
30+
# include <__type_traits/enable_if.h>
31+
# include <__type_traits/is_execution_policy.h>
32+
# include <__type_traits/remove_cvref.h>
33+
# include <__utility/forward.h>
34+
# include <__utility/move.h>
35+
3536
_LIBCPP_BEGIN_NAMESPACE_STD
3637

3738
template <class _ExecutionPolicy,

libcxx/include/__pstl/backends/default.h

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

36-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
37-
3836
_LIBCPP_BEGIN_NAMESPACE_STD
3937
namespace __pstl {
4038

@@ -500,8 +498,6 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
500498
} // namespace __pstl
501499
_LIBCPP_END_NAMESPACE_STD
502500

503-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
504-
505501
_LIBCPP_POP_MACROS
506502

507503
#endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H

libcxx/include/__pstl/backends/libdispatch.h

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

47-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
48-
4947
_LIBCPP_BEGIN_NAMESPACE_STD
5048
namespace __pstl {
5149

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

143141
unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
144142
[&]() -> __merge_range_t* {
145-
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
143+
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
146144
try {
147-
# endif
145+
#endif
148146
return std::allocator<__merge_range_t>().allocate(__n_ranges);
149-
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
147+
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
150148
} catch (const std::bad_alloc&) {
151149
return nullptr;
152150
}
153-
# endif
151+
#endif
154152
}(),
155153
__destroy);
156154

@@ -394,8 +392,6 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>
394392
} // namespace __pstl
395393
_LIBCPP_END_NAMESPACE_STD
396394

397-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
398-
399395
_LIBCPP_POP_MACROS
400396

401397
#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H

libcxx/include/__pstl/backends/serial.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
# pragma GCC system_header
2828
#endif
2929

30-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
31-
3230
_LIBCPP_PUSH_MACROS
33-
# include <__undef_macros>
31+
#include <__undef_macros>
3432

3533
_LIBCPP_BEGIN_NAMESPACE_STD
3634
namespace __pstl {
@@ -180,6 +178,4 @@ _LIBCPP_END_NAMESPACE_STD
180178

181179
_LIBCPP_POP_MACROS
182180

183-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
184-
185181
#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H

libcxx/include/__pstl/backends/std_thread.h

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

35-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
36-
3735
_LIBCPP_BEGIN_NAMESPACE_STD
3836
namespace __pstl {
3937

@@ -133,8 +131,6 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy>
133131
} // namespace __pstl
134132
_LIBCPP_END_NAMESPACE_STD
135133

136-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
137-
138134
_LIBCPP_POP_MACROS
139135

140136
#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H

libcxx/include/__pstl/cpu_algos/any_of.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
#include <cstdint>
2424
#include <optional>
2525

26-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27-
2826
_LIBCPP_PUSH_MACROS
29-
# include <__undef_macros>
27+
#include <__undef_macros>
3028

3129
_LIBCPP_BEGIN_NAMESPACE_STD
3230
namespace __pstl {
@@ -98,6 +96,4 @@ _LIBCPP_END_NAMESPACE_STD
9896

9997
_LIBCPP_POP_MACROS
10098

101-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
102-
10399
#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H

libcxx/include/__pstl/cpu_algos/fill.h

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

26-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27-
2826
_LIBCPP_BEGIN_NAMESPACE_STD
2927
namespace __pstl {
3028

@@ -65,6 +63,4 @@ struct __cpu_parallel_fill {
6563
} // namespace __pstl
6664
_LIBCPP_END_NAMESPACE_STD
6765

68-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
69-
7066
#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H

libcxx/include/__pstl/cpu_algos/find_if.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
# pragma GCC system_header
2929
#endif
3030

31-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
32-
3331
_LIBCPP_PUSH_MACROS
34-
# include <__undef_macros>
32+
#include <__undef_macros>
3533

3634
_LIBCPP_BEGIN_NAMESPACE_STD
3735
namespace __pstl {
@@ -136,6 +134,4 @@ _LIBCPP_END_NAMESPACE_STD
136134

137135
_LIBCPP_POP_MACROS
138136

139-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
140-
141137
#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H

libcxx/include/__pstl/cpu_algos/for_each.h

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

26-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27-
2826
_LIBCPP_BEGIN_NAMESPACE_STD
2927
namespace __pstl {
3028

@@ -65,6 +63,4 @@ struct __cpu_parallel_for_each {
6563
} // namespace __pstl
6664
_LIBCPP_END_NAMESPACE_STD
6765

68-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
69-
7066
#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H

libcxx/include/__pstl/cpu_algos/merge.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
# pragma GCC system_header
2424
#endif
2525

26-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27-
2826
_LIBCPP_PUSH_MACROS
29-
# include <__undef_macros>
27+
#include <__undef_macros>
3028

3129
_LIBCPP_BEGIN_NAMESPACE_STD
3230
namespace __pstl {
@@ -84,6 +82,4 @@ _LIBCPP_END_NAMESPACE_STD
8482

8583
_LIBCPP_POP_MACROS
8684

87-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
88-
8985
#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H

libcxx/include/__pstl/cpu_algos/stable_sort.h

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

24-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
25-
2624
_LIBCPP_BEGIN_NAMESPACE_STD
2725
namespace __pstl {
2826

@@ -46,6 +44,4 @@ struct __cpu_parallel_stable_sort {
4644
} // namespace __pstl
4745
_LIBCPP_END_NAMESPACE_STD
4846

49-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
50-
5147
#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H

libcxx/include/__pstl/cpu_algos/transform.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
# pragma GCC system_header
2525
#endif
2626

27-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
28-
2927
_LIBCPP_PUSH_MACROS
30-
# include <__undef_macros>
28+
#include <__undef_macros>
3129

3230
_LIBCPP_BEGIN_NAMESPACE_STD
3331
namespace __pstl {
@@ -152,6 +150,4 @@ _LIBCPP_END_NAMESPACE_STD
152150

153151
_LIBCPP_POP_MACROS
154152

155-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
156-
157153
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H

libcxx/include/__pstl/cpu_algos/transform_reduce.h

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

34-
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
35-
3634
_LIBCPP_BEGIN_NAMESPACE_STD
3735
namespace __pstl {
3836

@@ -213,8 +211,6 @@ struct __cpu_parallel_transform_reduce {
213211
} // namespace __pstl
214212
_LIBCPP_END_NAMESPACE_STD
215213

216-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
217-
218214
_LIBCPP_POP_MACROS
219215

220216
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H

0 commit comments

Comments
 (0)