From 7381ec6d803a9bf1ffa34204ce0774bd51264d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ke=C3=9Fler?= Date: Tue, 18 Oct 2022 16:28:57 +0200 Subject: [PATCH 1/4] Fixed wrong configuration for ASIO_HAS_CO_AWAIT This adds a more general approach, to check for c++20 coroutines, which takes the feature test macros into account, defined since c++20: Proposal: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0912r5.html cppreference: https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B20 I've kept the old macros, in the case compilers + stl-impl add the support, even, when they did not yet set the feature testing macros. I've also made them more robust: The `#elif` were not mutually exclusive, so I've changed them to `if !defined(ASIO_HAS_CO_AWAIT) && ...` --- asio/include/asio/detail/config.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index b1f24078eb..f55ea3c7a3 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -2069,24 +2069,30 @@ # define ASIO_UNUSED_VARIABLE #endif // !defined(ASIO_UNUSED_VARIABLE) +// Support the co_await keyword on compilers known to allow it. // Support the co_await keyword on compilers known to allow it. #if !defined(ASIO_HAS_CO_AWAIT) # if !defined(ASIO_DISABLE_CO_AWAIT) -# if defined(ASIO_MSVC) -# if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) && !defined(__clang__) +# if has_include() && has_include() && defined(__cpp_coroutines) && (__cpp_coroutines >= 201707L) +# include +# if defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902L) +# define ASIO_HAS_CO_AWAIT 1 +# endif // defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902L) +# if !defined(ASIO_HAS_CO_AWAIT) && defined(ASIO_MSVC) +# if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) # define ASIO_HAS_CO_AWAIT 1 # elif (_MSC_FULL_VER >= 190023506) # if defined(_RESUMABLE_FUNCTIONS_SUPPORTED) # define ASIO_HAS_CO_AWAIT 1 # endif // defined(_RESUMABLE_FUNCTIONS_SUPPORTED) # endif // (_MSC_FULL_VER >= 190023506) -# elif defined(__clang__) +# if !defined(ASIO_HAS_CO_AWAIT) && defined(__clang__) # if (__cplusplus >= 201703) && (__cpp_coroutines >= 201703) # if __has_include() # define ASIO_HAS_CO_AWAIT 1 # endif // __has_include() # endif // (__cplusplus >= 201703) && (__cpp_coroutines >= 201703) -# elif defined(__GNUC__) +# if !defined(ASIO_HAS_CO_AWAIT) && defined(__GNUC__) # if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902) # if __has_include() # define ASIO_HAS_CO_AWAIT 1 From 8a17e7ca017571b5aae79e8129aecb48d55cb014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ke=C3=9Fler?= Date: Tue, 18 Oct 2022 16:37:22 +0200 Subject: [PATCH 2/4] Fixup Todo: squash it (fixup mode) --- asio/include/asio/detail/config.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index f55ea3c7a3..2164d202b8 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -2078,6 +2078,7 @@ # if defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902L) # define ASIO_HAS_CO_AWAIT 1 # endif // defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902L) +# endif //has_include() && has_include() && defined(__cpp_coroutines) && (__cpp_coroutines >= 201707L) # if !defined(ASIO_HAS_CO_AWAIT) && defined(ASIO_MSVC) # if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) # define ASIO_HAS_CO_AWAIT 1 @@ -2086,12 +2087,14 @@ # define ASIO_HAS_CO_AWAIT 1 # endif // defined(_RESUMABLE_FUNCTIONS_SUPPORTED) # endif // (_MSC_FULL_VER >= 190023506) +# endif // !defined(ASIO_HAS_CO_AWAIT) && defined(ASIO_MSVC) # if !defined(ASIO_HAS_CO_AWAIT) && defined(__clang__) # if (__cplusplus >= 201703) && (__cpp_coroutines >= 201703) # if __has_include() # define ASIO_HAS_CO_AWAIT 1 # endif // __has_include() # endif // (__cplusplus >= 201703) && (__cpp_coroutines >= 201703) +# endif // !defined(ASIO_HAS_CO_AWAIT) && defined(__clang__) # if !defined(ASIO_HAS_CO_AWAIT) && defined(__GNUC__) # if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902) # if __has_include() From d51ec05f22bcf07b909bd7d44e7a5c9c0877563a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ke=C3=9Fler?= Date: Tue, 18 Oct 2022 17:02:13 +0200 Subject: [PATCH 3/4] Fixup More general --- asio/include/asio/detail/config.hpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index 2164d202b8..645a763c6a 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -2073,13 +2073,9 @@ // Support the co_await keyword on compilers known to allow it. #if !defined(ASIO_HAS_CO_AWAIT) # if !defined(ASIO_DISABLE_CO_AWAIT) -# if has_include() && has_include() && defined(__cpp_coroutines) && (__cpp_coroutines >= 201707L) -# include -# if defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902L) -# define ASIO_HAS_CO_AWAIT 1 -# endif // defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902L) -# endif //has_include() && has_include() && defined(__cpp_coroutines) && (__cpp_coroutines >= 201707L) -# if !defined(ASIO_HAS_CO_AWAIT) && defined(ASIO_MSVC) +# if ((defined(__cpp_coroutines) && (__cpp_coroutines >= 201707L)) || (defined(__cpp_impl_coroutine) && (__cpp_impl_coroutine >= 201902L))) +# define ASIO_HAS_CO_AWAIT 1 +# elif !defined(ASIO_HAS_CO_AWAIT) && defined(ASIO_MSVC) # if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) # define ASIO_HAS_CO_AWAIT 1 # elif (_MSC_FULL_VER >= 190023506) From b8cfd3d22ea1709ff877f93b53e6993140c015ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ke=C3=9Fler?= Date: Tue, 18 Oct 2022 17:27:47 +0200 Subject: [PATCH 4/4] Fixup: ASIO_HAS_CO_AWAIT should only check for compiler support ASIO_HAS_CO_AWAIT => checks for compiler support ASIO_HAS_STD_COROUTINE => checks for std::coroutine support --- asio/include/asio/detail/config.hpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index 645a763c6a..cbbb2dbdb7 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -2069,7 +2069,6 @@ # define ASIO_UNUSED_VARIABLE #endif // !defined(ASIO_UNUSED_VARIABLE) -// Support the co_await keyword on compilers known to allow it. // Support the co_await keyword on compilers known to allow it. #if !defined(ASIO_HAS_CO_AWAIT) # if !defined(ASIO_DISABLE_CO_AWAIT) @@ -2086,16 +2085,12 @@ # endif // !defined(ASIO_HAS_CO_AWAIT) && defined(ASIO_MSVC) # if !defined(ASIO_HAS_CO_AWAIT) && defined(__clang__) # if (__cplusplus >= 201703) && (__cpp_coroutines >= 201703) -# if __has_include() -# define ASIO_HAS_CO_AWAIT 1 -# endif // __has_include() +# define ASIO_HAS_CO_AWAIT 1 # endif // (__cplusplus >= 201703) && (__cpp_coroutines >= 201703) # endif // !defined(ASIO_HAS_CO_AWAIT) && defined(__clang__) # if !defined(ASIO_HAS_CO_AWAIT) && defined(__GNUC__) # if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902) -# if __has_include() -# define ASIO_HAS_CO_AWAIT 1 -# endif // __has_include() +# define ASIO_HAS_CO_AWAIT 1 # endif // (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902) # endif // defined(__GNUC__) # endif // !defined(ASIO_DISABLE_CO_AWAIT) @@ -2104,12 +2099,20 @@ // Standard library support for coroutines. #if !defined(ASIO_HAS_STD_COROUTINE) # if !defined(ASIO_DISABLE_STD_COROUTINE) -# if defined(ASIO_MSVC) +# if __has_include() +# include +# elif __has_include() +# include +# endif //__has_include() +# if defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902) +# define ASIO_HAS_STD_COROUTINE 1 +# endif // defined(__cpp_lib_coroutine) && (__cpp_lib_coroutine >= 201902) +# if !defined(ASIO_HAS_STD_COROUTINE) && defined(ASIO_MSVC) # if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) # define ASIO_HAS_STD_COROUTINE 1 # endif // (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) # endif // defined(ASIO_MSVC) -# if defined(__GNUC__) +# if !defined(ASIO_HAS_STD_COROUTINE) && defined(__GNUC__) # if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902) # if __has_include() # define ASIO_HAS_STD_COROUTINE 1