Skip to content

[libc++] Guard PSTL headers with >= C++17 #108234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions libcxx/include/__pstl/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
# include <__pstl/backends/default.h>
# include <__pstl/backends/serial.h>
#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
# include <__pstl/backends/default.h>
# include <__pstl/backends/std_thread.h>
#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
# include <__pstl/backends/default.h>
# include <__pstl/backends/libdispatch.h>
#endif
#if _LIBCPP_STD_VER >= 17

# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
# include <__pstl/backends/default.h>
# include <__pstl/backends/serial.h>
# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
# include <__pstl/backends/default.h>
# include <__pstl/backends/std_thread.h>
# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
# include <__pstl/backends/default.h>
# include <__pstl/backends/libdispatch.h>
# endif

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

Expand Down
16 changes: 10 additions & 6 deletions libcxx/include/__pstl/backend_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ _LIBCPP_PUSH_MACROS
// the user.
//

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand All @@ -50,18 +52,18 @@ struct __libdispatch_backend_tag;
struct __serial_backend_tag;
struct __std_thread_backend_tag;

#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>;
#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>;
#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>;
#else
# else

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

# error "Invalid PSTL backend configuration"
#endif
# error "Invalid PSTL backend configuration"
# endif

template <class _Backend, class _ExecutionPolicy>
struct __find_if;
Expand Down Expand Up @@ -296,6 +298,8 @@ struct __reduce;
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_BACKEND_FWD_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/backends/default.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -498,6 +500,8 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H
12 changes: 8 additions & 4 deletions libcxx/include/__pstl/backends/libdispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -140,15 +142,15 @@ struct __cpu_traits<__libdispatch_backend_tag> {

unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
[&]() -> __merge_range_t* {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
#endif
# endif
return std::allocator<__merge_range_t>().allocate(__n_ranges);
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (const std::bad_alloc&) {
return nullptr;
}
#endif
# endif
}(),
__destroy);

Expand Down Expand Up @@ -392,6 +394,8 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/backends/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -176,6 +178,8 @@ struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/backends/std_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -131,6 +133,8 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy>
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/any_of.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -94,6 +96,8 @@ struct __cpu_parallel_any_of {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/cpu_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -81,6 +83,8 @@ struct __cpu_traits;
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/fill.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -63,4 +65,6 @@ struct __cpu_parallel_fill {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/find_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -132,6 +134,8 @@ struct __cpu_parallel_find_if {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/for_each.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -63,4 +65,6 @@ struct __cpu_parallel_for_each {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -80,6 +82,8 @@ struct __cpu_parallel_merge {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/stable_sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand All @@ -44,4 +46,6 @@ struct __cpu_parallel_stable_sort {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -148,6 +150,8 @@ struct __cpu_parallel_transform_binary {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/cpu_algos/transform_reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -211,6 +213,8 @@ struct __cpu_parallel_transform_reduce {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -61,6 +63,8 @@ using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfigu
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_DISPATCH_H
4 changes: 4 additions & 0 deletions libcxx/include/__pstl/handle_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {

Expand Down Expand Up @@ -52,6 +54,8 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 17

_LIBCPP_POP_MACROS

#endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H
Loading