diff --git a/include/unifex/config.hpp b/include/unifex/config.hpp index 47deb37b..69a977ab 100644 --- a/include/unifex/config.hpp +++ b/include/unifex/config.hpp @@ -293,7 +293,21 @@ #endif #if defined(__has_builtin) -#define UNIFEX_HAS_BUILTIN(...) __has_builtin(__VA_ARGS__) +# define UNIFEX_HAS_BUILTIN(...) __has_builtin(__VA_ARGS__) #else -#define UNIFEX_HAS_BUILTIN(...) 0 +# define UNIFEX_HAS_BUILTIN(...) 0 #endif + +#if !defined(UNIFEX_NO_ASYNC_STACKS) +// default: +// - release builds do not have async stacks +// - Windows builds do not have async stacks +// +// adding async stacks adds non-trivial binary size at the moment, and I can't +// figure out how to make all the relevant Windows builds succeed +# if defined(NDEBUG) || defined(_MSC_VER) +# define UNIFEX_NO_ASYNC_STACKS 1 +# else +# define UNIFEX_NO_ASYNC_STACKS 0 +# endif +#endif // !defined(UNIFEX_NO_ASYNC_STACKS) diff --git a/include/unifex/sender_concepts.hpp b/include/unifex/sender_concepts.hpp index dc375859..d08e1662 100644 --- a/include/unifex/sender_concepts.hpp +++ b/include/unifex/sender_concepts.hpp @@ -272,12 +272,23 @@ struct _fn { } }; +#if UNIFEX_NO_ASYNC_STACKS +public: + template(typename S, typename R) // + (requires sender AND receiver) // + auto + operator()(S&& s, R&& r) const + noexcept(noexcept(_impl{}(std::forward(s), std::forward(r)))) + -> decltype(_impl{}(std::forward(s), std::forward(r))) { + return _impl{}(std::forward(s), std::forward(r)); + } +#else template using op_t = _inject::op_wrapper>, R>; public: template(typename S, typename R) // - (requires sender AND receiver) + (requires sender AND receiver) // auto operator()(S&& s, R&& r) const noexcept(noexcept(_inject::make_op_wrapper(std::forward(s), std::forward(r), _impl{}))) @@ -287,6 +298,7 @@ struct _fn { std::forward(r), _impl{}); } +#endif }; } // namespace _cpo diff --git a/include/unifex/tracing/inject_async_stack.hpp b/include/unifex/tracing/inject_async_stack.hpp index 63a7daf3..bf785a7d 100644 --- a/include/unifex/tracing/inject_async_stack.hpp +++ b/include/unifex/tracing/inject_async_stack.hpp @@ -16,6 +16,9 @@ #pragma once #include + +#if !UNIFEX_NO_ASYNC_STACKS + #include #include #include @@ -235,3 +238,5 @@ auto make_op_wrapper(S&& s, R&& r, Fn&& fn) noexcept( } // namespace unifex #include + +#endif // !UNIFEX_NO_ASYNC_STACKS