Skip to content

Commit de51303

Browse files
committed
the compiler config macros double as inline workaround macros
1 parent d97b5df commit de51303

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

include/stdexec/__detail/__config.hpp

+29-12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#define STDEXEC_EXPAND(...) __VA_ARGS__
3535
#define STDEXEC_EVAL(_MACRO, ...) _MACRO(__VA_ARGS__)
36+
#define STDEXEC_EAT(...)
3637

3738
#define STDEXEC_NOT(_XP) STDEXEC_CAT(STDEXEC_NOT_, _XP)
3839
#define STDEXEC_NOT_0 1
@@ -50,37 +51,53 @@
5051
#define STDEXEC_CHECK_N(_XP, _NP, ...) _NP
5152
#define STDEXEC_PROBE(_XP) _XP, 1,
5253

54+
// If tail is non-empty, expand to the tail. Otherwise, expand to the head
55+
#define STDEXEC_HEAD_OR_TAIL(_XP, ...) STDEXEC_EXPAND __VA_OPT__((__VA_ARGS__)STDEXEC_EAT)(_XP)
56+
57+
// If tail is non-empty, expand to nothing. Otherwise, expand to the head
58+
#define STDEXEC_HEAD_OR_NULL(_XP, ...) STDEXEC_EXPAND __VA_OPT__(()STDEXEC_EAT)(_XP)
59+
60+
// When used with no arguments, these macros expand to 1 if the current
61+
// compiler corresponds to the macro name; 0, otherwise. When used with arguments,
62+
// they expand to the arguments if if the current compiler corresponds to the
63+
// macro name; nothing, otherwise.
5364
#if defined(__NVCC__)
54-
#define STDEXEC_NVCC() 1
65+
#define STDEXEC_NVCC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
5566
#elif defined(__NVCOMPILER)
56-
#define STDEXEC_NVHPC() 1
67+
#define STDEXEC_NVHPC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
5768
#elif defined(__EDG__)
58-
#define LEGATE_EDG() 1
69+
#define STDEXEC_EDG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
5970
#elif defined(__clang__)
60-
#define STDEXEC_CLANG() 1
71+
#define STDEXEC_CLANG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
72+
#if defined(_MSC_VER)
73+
#define STDEXEC_CLANG_CL(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
74+
#endif
6175
#elif defined(__GNUC__)
62-
#define STDEXEC_GCC() 1
76+
#define STDEXEC_GCC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
6377
#elif defined(_MSC_VER)
64-
#define STDEXEC_MSVC() 1
78+
#define STDEXEC_MSVC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
6579
#endif
6680

6781
#ifndef STDEXEC_NVCC
68-
#define STDEXEC_NVCC() 0
82+
#define STDEXEC_NVCC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
6983
#endif
7084
#ifndef STDEXEC_NVHPC
71-
#define STDEXEC_NVHPC() 0
85+
#define STDEXEC_NVHPC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
7286
#endif
7387
#ifndef STDEXEC_EDG
74-
#define STDEXEC_EDG() 0
88+
#define STDEXEC_EDG(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
7589
#endif
7690
#ifndef STDEXEC_CLANG
77-
#define STDEXEC_CLANG() 0
91+
#define STDEXEC_CLANG(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
92+
#endif
93+
#ifndef STDEXEC_CLANG_CL
94+
#define STDEXEC_CLANG_CL(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
7895
#endif
7996
#ifndef STDEXEC_GCC
80-
#define STDEXEC_GCC() 0
97+
#define STDEXEC_GCC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
8198
#endif
8299
#ifndef STDEXEC_MSVC
83-
#define STDEXEC_MSVC() 0
100+
#define STDEXEC_MSVC(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
84101
#endif
85102

86103
#define STDEXEC_STRINGIZE(_ARG) #_ARG

0 commit comments

Comments
 (0)