Skip to content

Commit 288e4ac

Browse files
committed
simplify the compiler detection config macros
1 parent 3eb5736 commit 288e4ac

15 files changed

Lines changed: 57 additions & 61 deletions

include/exec/__detail/__atomic_ref.hpp

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

1919
#include <atomic>
2020

21-
#if __cpp_lib_atomic_ref >= 201806L
21+
#if __cpp_lib_atomic_ref >= 2018'06L
2222
template <class T>
2323
using __atomic_ref = std::atomic_ref<T>;
2424
#else

include/exec/__detail/__bit_cast.hpp

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

2121
#if __has_include(<bit>)
2222
# include <bit>
23-
# if __cpp_lib_bit_cast >= 201806L
23+
# if __cpp_lib_bit_cast >= 2018'06L
2424
# define STDEXEC_HAS_BIT_CAST
2525
# endif
2626
#endif

include/exec/__detail/__system_context_replaceability_api.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace exec::system_context_replaceability {
5858
template <>
5959
struct __runtime_property_helper<stdexec::inplace_stop_token> {
6060
static constexpr bool __is_property = true;
61-
static constexpr __uuid __property_identifier{0x8779c09d8aa249df, 0x867db0e653202604};
61+
static constexpr __uuid __property_identifier{0x8779c09d8aa249df, 0x867db0e6532026'04L};
6262
};
6363

6464
/// Concept for a runtime property.
@@ -119,7 +119,7 @@ namespace exec::system_context_replaceability {
119119

120120
/// Interface for the parallel scheduler backend.
121121
struct parallel_scheduler_backend {
122-
static constexpr __uuid __interface_identifier{0x5ee9202498c4bd4f, 0xa1df2508ffcd9d7e};
122+
static constexpr __uuid __interface_identifier{0x5ee92024'98Lc4bd4f, 0xa1df2508ffcd9d7e};
123123

124124
virtual ~parallel_scheduler_backend() = default;
125125

include/exec/__detail/intrusive_heap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ STDEXEC_PRAGMA_PUSH()
2626
STDEXEC_PRAGMA_IGNORE_EDG(not_used_in_partial_spec_arg_list)
2727

2828
namespace exec {
29-
#if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L
29+
#if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 2020'02L
3030
namespace detail {
3131
using std::bit_ceil;
3232
} // namespace detail

include/exec/repeat_effect_until.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace exec {
9797
std::atomic_thread_fence(std::memory_order_release);
9898
// TSan does not support std::atomic_thread_fence, so we
9999
// need to use the TSan-specific __tsan_release instead:
100-
STDEXEC_TSAN(__tsan_release(&__started_));
100+
STDEXEC_WHEN(STDEXEC_TSAN(), __tsan_release(&__started_));
101101
__child_op_.__destroy();
102102
}
103103
}

include/exec/repeat_n.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace exec {
123123
std::atomic_thread_fence(std::memory_order_release);
124124
// TSan does not support std::atomic_thread_fence, so we
125125
// need to use the TSan-specific __tsan_release instead:
126-
STDEXEC_TSAN(__tsan_release(&__started_));
126+
STDEXEC_WHEN(STDEXEC_TSAN(), __tsan_release(&__started_));
127127
__child_op_.__destroy();
128128
}
129129
}

include/stdexec/__detail/__concepts.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#pragma once
1717

18-
#if __cpp_concepts < 201907L
18+
#if __cpp_concepts < 2019'07L
1919
# error This library requires support for C++20 concepts
2020
#endif
2121

@@ -25,7 +25,7 @@
2525
#include <version>
2626

2727
// Perhaps the stdlib lacks support for concepts though:
28-
#if __has_include(<concepts>) && __cpp_lib_concepts >= 202002
28+
#if __has_include(<concepts>) && __cpp_lib_concepts >= 2020'02L
2929
# define STDEXEC_HAS_STD_CONCEPTS_HEADER() 1
3030
#else
3131
# define STDEXEC_HAS_STD_CONCEPTS_HEADER() 0

include/stdexec/__detail/__config.hpp

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// IWYU pragma: always_keep
1919

20-
#if __cplusplus < 202002L
20+
#if __cplusplus < 2020'02L
2121
# if defined(_MSC_VER) && !defined(__clang__)
2222
# error This library requires the use of C++20. Use /Zc:__cplusplus to enable __cplusplus conformance.
2323
# else
@@ -47,76 +47,76 @@
4747
// they expand to the arguments if if the current compiler corresponds to the
4848
// macro name; nothing, otherwise.
4949
#if defined(__NVCC__)
50-
# define STDEXEC_NVCC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
50+
# define STDEXEC_NVCC() 1
5151
# define STDEXEC_NVCC_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__)
5252
#elif defined(__EDG__)
53-
# define STDEXEC_EDG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
53+
# define STDEXEC_EDG() 1
5454
# define STDEXEC_EDG_VERSION __EDG_VERSION__
5555
# if defined(__NVCOMPILER)
56-
# define STDEXEC_NVHPC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
56+
# define STDEXEC_NVHPC() 1
5757
# define STDEXEC_NVHPC_VERSION (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__)
5858
# endif
5959
# if defined(__INTELLISENSE__)
60-
# define STDEXEC_INTELLISENSE(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
61-
# define STDEXEC_MSVC_HEADERS(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
60+
# define STDEXEC_INTELLISENSE() 1
61+
# define STDEXEC_MSVC_HEADERS() 1
6262
# endif
6363
#elif defined(__clang__)
64-
# define STDEXEC_CLANG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
64+
# define STDEXEC_CLANG() 1
6565
# define STDEXEC_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
6666
# if defined(_MSC_VER)
67-
# define STDEXEC_CLANG_CL(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
67+
# define STDEXEC_CLANG_CL() 1
6868
# endif
6969
# if defined(__apple_build_version__)
70-
# define STDEXEC_APPLE_CLANG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
70+
# define STDEXEC_APPLE_CLANG() 1
7171
// Apple clang version is encoded as major * 1000000 + minor * 1000 + patch. We ignore the patch
7272
// version here, as it is not relevant for the purposes of this library.
7373
# define STDEXEC_APPLE_CLANG_VERSION (__apple_build_version__ / 1000)
7474
# endif
7575
#elif defined(__GNUC__)
76-
# define STDEXEC_GCC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
76+
# define STDEXEC_GCC() 1
7777
# define STDEXEC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
7878
#elif defined(_MSC_VER)
79-
# define STDEXEC_MSVC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
80-
# define STDEXEC_MSVC_HEADERS(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
81-
# define STDEXEC_MSVC_VERSION _MSC_VER
79+
# define STDEXEC_MSVC() 1
80+
# define STDEXEC_MSVC_HEADERS() 1
81+
# define STDEXEC_MSVC_VERSION _MSC_VER
8282
#endif
8383

8484
#ifndef STDEXEC_NVCC
85-
# define STDEXEC_NVCC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
85+
# define STDEXEC_NVCC() 0
8686
#endif
8787
#ifndef STDEXEC_NVHPC
88-
# define STDEXEC_NVHPC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
88+
# define STDEXEC_NVHPC() 0
8989
#endif
9090
#ifndef STDEXEC_EDG
91-
# define STDEXEC_EDG(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
91+
# define STDEXEC_EDG() 0
9292
#endif
9393
#ifndef STDEXEC_CLANG
94-
# define STDEXEC_CLANG(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
94+
# define STDEXEC_CLANG() 0
9595
#endif
9696
#ifndef STDEXEC_CLANG_CL
97-
# define STDEXEC_CLANG_CL(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
97+
# define STDEXEC_CLANG_CL() 0
9898
#endif
9999
#ifndef STDEXEC_APPLE_CLANG
100-
# define STDEXEC_APPLE_CLANG(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
100+
# define STDEXEC_APPLE_CLANG() 0
101101
#endif
102102
#ifndef STDEXEC_GCC
103-
# define STDEXEC_GCC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
103+
# define STDEXEC_GCC() 0
104104
#endif
105105
#ifndef STDEXEC_MSVC
106-
# define STDEXEC_MSVC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
106+
# define STDEXEC_MSVC() 0
107107
#endif
108108
#ifndef STDEXEC_MSVC_HEADERS
109-
# define STDEXEC_MSVC_HEADERS(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
109+
# define STDEXEC_MSVC_HEADERS() 0
110110
#endif
111111
#ifndef STDEXEC_INTELLISENSE
112-
# define STDEXEC_INTELLISENSE(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
112+
# define STDEXEC_INTELLISENSE() 0
113113
#endif
114114

115115
////////////////////////////////////////////////////////////////////////////////////////////////////
116116
#if defined(__CUDACC__) || STDEXEC_NVHPC()
117-
# define STDEXEC_CUDA_COMPILATION(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
117+
# define STDEXEC_CUDA_COMPILATION() 1
118118
#else
119-
# define STDEXEC_CUDA_COMPILATION(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
119+
# define STDEXEC_CUDA_COMPILATION() 0
120120
#endif
121121

122122
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -134,7 +134,7 @@
134134
#endif
135135

136136
////////////////////////////////////////////////////////////////////////////////////////////////////
137-
#if __cpp_impl_coroutine >= 201902 && __cpp_lib_coroutine >= 201902
137+
#if __cpp_impl_coroutine >= 2019'02 && __cpp_lib_coroutine >= 2019'02
138138
# include <coroutine> // IWYU pragma: keep
139139
# define STDEXEC_STD_NO_COROUTINES() 0
140140
namespace __coro = std; // NOLINT(misc-unused-alias-decls)
@@ -185,7 +185,8 @@ namespace __coro = std::experimental;
185185
# endif
186186
#elif STDEXEC_CLANG_CL()
187187
// clang-cl does not support [[no_unique_address]]: https://reviews.llvm.org/D110485
188-
# if STDEXEC_CLANG_VERSION < 18'01 // TODO: Find the version that started supporting [[msvc::no_unique_address]]
188+
// TODO: Find the version that started supporting [[msvc::no_unique_address]]
189+
# if STDEXEC_CLANG_VERSION < 18'01
189190
# define STDEXEC_ATTR_WHICH_3(_ATTR) /*nothing*/
190191
# else
191192
# define STDEXEC_ATTR_WHICH_3(_ATTR) [[msvc::no_unique_address]]
@@ -377,7 +378,7 @@ namespace stdexec {
377378
inline constexpr bool __same_as_v<_Ap, _Ap> = true;
378379
} // namespace stdexec
379380

380-
#if defined(__cpp_lib_unreachable) && __cpp_lib_unreachable >= 202202L
381+
#if defined(__cpp_lib_unreachable) && __cpp_lib_unreachable >= 2022'02L
381382
# define STDEXEC_UNREACHABLE() std::unreachable()
382383
#elif STDEXEC_HAS_BUILTIN(__builtin_unreachable)
383384
# define STDEXEC_UNREACHABLE() __builtin_unreachable()
@@ -420,41 +421,42 @@ namespace stdexec {
420421
// Some compilers turn on pack indexing in pre-C++26 code. We want to use it if it is
421422
// available. Pack indexing is disabled for clang < 20 because of:
422423
// https://github.com/llvm/llvm-project/issues/116105
423-
#if defined(__cpp_pack_indexing) && !STDEXEC_NVCC() && !(STDEXEC_CLANG() && STDEXEC_CLANG_VERSION < 20'00)
424-
# define STDEXEC_HAS_PACK_INDEXING() 1
424+
#if defined(__cpp_pack_indexing) && !STDEXEC_NVCC() \
425+
&& !(STDEXEC_CLANG() && STDEXEC_CLANG_VERSION < 20'00)
426+
# define STDEXEC_STD_NO_PACK_INDEXING() 0
425427
#else // ^^^ has pack indexing ^^^ / vvv no pack indexing vvv
426-
# define STDEXEC_HAS_PACK_INDEXING() 0
428+
# define STDEXEC_STD_NO_PACK_INDEXING() 1
427429
#endif // no pack indexing
428430

429431
#if STDEXEC_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)
430-
# define STDEXEC_TSAN(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
432+
# define STDEXEC_TSAN() 1
431433
#else
432-
# define STDEXEC_TSAN(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
434+
# define STDEXEC_TSAN() 0
433435
#endif
434436

435437
// Before clang-16, clang did not like libstdc++'s ranges implementation
436438
#if __has_include(<ranges>) && \
437-
(defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L) && \
439+
(defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 2019'11L) && \
438440
(!STDEXEC_CLANG() || STDEXEC_CLANG_VERSION >= 16'00 || defined(_LIBCPP_VERSION))
439441
# define STDEXEC_HAS_STD_RANGES() 1
440442
#else
441443
# define STDEXEC_HAS_STD_RANGES() 0
442444
#endif
443445

444446
#if __has_include(<memory_resource>) && \
445-
(defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L)
447+
(defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 2016'03L)
446448
# define STDEXEC_HAS_STD_MEMORY_RESOURCE() 1
447449
#else
448450
# define STDEXEC_HAS_STD_MEMORY_RESOURCE() 0
449451
#endif
450452

451-
#if defined(__cpp_lib_execution) && __cpp_lib_execution >= 201603L
453+
#if defined(__cpp_lib_execution) && __cpp_lib_execution >= 2016'03L
452454
# define STDEXEC_HAS_EXECUTION_POLICY() 1
453455
#else
454456
# define STDEXEC_HAS_EXECUTION_POLICY() 0
455457
#endif
456458

457-
#if defined(__cpp_lib_execution) && __cpp_lib_execution >= 201902L
459+
#if defined(__cpp_lib_execution) && __cpp_lib_execution >= 2019'02L
458460
# define STDEXEC_HAS_UNSEQUENCED_EXECUTION_POLICY() 1
459461
#else
460462
# define STDEXEC_HAS_UNSEQUENCED_EXECUTION_POLICY() 0
@@ -486,10 +488,10 @@ namespace stdexec {
486488
# define STDEXEC_FRIENDSHIP_IS_LEXICAL() 0
487489
#endif
488490

489-
#if defined(__cpp_explicit_this_parameter) && (__cpp_explicit_this_parameter >= 202110)
490-
# define STDEXEC_EXPLICIT_THIS(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
491+
#if defined(__cpp_explicit_this_parameter) && (__cpp_explicit_this_parameter >= 2021'10L)
492+
# define STDEXEC_EXPLICIT_THIS() 1
491493
#else
492-
# define STDEXEC_EXPLICIT_THIS(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
494+
# define STDEXEC_EXPLICIT_THIS() 0
493495
#endif
494496

495497
#if STDEXEC_ENABLE_EXTRA_TYPE_CHECKING == 0

include/stdexec/__detail/__meta.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ namespace stdexec {
10251025
using __f = __mor<__minvoke<_Fn, _Args>...>;
10261026
};
10271027

1028-
#if STDEXEC_HAS_PACK_INDEXING()
1028+
#if !STDEXEC_STD_NO_PACK_INDEXING()
10291029
STDEXEC_PRAGMA_PUSH()
10301030
STDEXEC_PRAGMA_IGNORE_GNU("-Wc++26-extensions")
10311031

include/stdexec/__detail/__preprocessor.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@
8888

8989
#define STDEXEC_TAIL(_, ...) __VA_ARGS__
9090

91-
// If tail is non-empty, expand to the tail. Otherwise, expand to the head
92-
#define STDEXEC_HEAD_OR_TAIL(_XP, ...) STDEXEC_EXPAND __VA_OPT__((__VA_ARGS__) STDEXEC_EAT)(_XP)
93-
94-
// If tail is non-empty, expand to nothing. Otherwise, expand to the head
95-
#define STDEXEC_HEAD_OR_NULL(_XP, ...) STDEXEC_EXPAND __VA_OPT__(() STDEXEC_EAT)(_XP)
96-
9791
#define STDEXEC_REPEAT(_N, _MACRO, ...) STDEXEC_REPEAT_(_N, _MACRO, __VA_ARGS__)
9892
#define STDEXEC_REPEAT_(_N, _MACRO, ...) STDEXEC_REPEAT_##_N(_MACRO, __VA_ARGS__)
9993
#define STDEXEC_REPEAT_0(_MACRO, ...)

0 commit comments

Comments
 (0)