diff --git a/CMakeLists.txt b/CMakeLists.txt index d16b6e3..95ebe36 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ enable_testing() project( libcopp - VERSION "2.1.1" + VERSION "2.1.2" DESCRIPTION "Cross-platform coroutine library in C++ ." HOMEPAGE_URL "https://libcopp.atframe.work" LANGUAGES C CXX ASM) diff --git a/atframework/cmake-toolset b/atframework/cmake-toolset index 3575c16..4ef61a7 160000 --- a/atframework/cmake-toolset +++ b/atframework/cmake-toolset @@ -1 +1 @@ -Subproject commit 3575c165f676f3ed8343ee481fde09856ec4a0e2 +Subproject commit 4ef61a71c5c299245bb8d609fbc99170ee522d9e diff --git a/include/libcopp/coroutine/callable_promise.h b/include/libcopp/coroutine/callable_promise.h index 19cbf1c..57d362e 100644 --- a/include/libcopp/coroutine/callable_promise.h +++ b/include/libcopp/coroutine/callable_promise.h @@ -7,6 +7,7 @@ // clang-format off #include // NOLINT(build/include_order) // clang-format on +#include #include // clang-format off #include // NOLINT(build/include_order) @@ -295,6 +296,10 @@ class LIBCOPP_COPP_API_HEAD_ONLY callable_future { initial_awaitable initial_suspend() noexcept { return {}; } # if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION void unhandled_exception() { throw; } +# elif defined(LIBCOPP_MACRO_HAS_EXCEPTION) && LIBCOPP_MACRO_HAS_EXCEPTION + void unhandled_exception() { throw; } +# else + void unhandled_exception() { std::abort(); } # endif }; using handle_type = LIBCOPP_MACRO_STD_COROUTINE_NAMESPACE coroutine_handle; diff --git a/include/libcopp/utils/config/libcopp_build_features.h.in b/include/libcopp/utils/config/libcopp_build_features.h.in index cd01075..8ebcf6e 100644 --- a/include/libcopp/utils/config/libcopp_build_features.h.in +++ b/include/libcopp/utils/config/libcopp_build_features.h.in @@ -83,6 +83,20 @@ #cmakedefine THREAD_TLS_USE_PTHREAD @THREAD_TLS_USE_PTHREAD@ #endif +#if defined(__cpp_exceptions) +# define LIBCOPP_MACRO_HAS_EXCEPTION __cpp_exceptions +#elif defined(__EXCEPTIONS) && __EXCEPTIONS +# define LIBCOPP_MACRO_HAS_EXCEPTION 1 +#elif defined(__clang__) +# if __has_feature(cxx_exceptions) +# define LIBCOPP_MACRO_HAS_EXCEPTION 1 +# endif +#elif defined(_MSC_VER) +# if defined(_CPPUNWIND) +# define LIBCOPP_MACRO_HAS_EXCEPTION 1 +# endif +#endif + #cmakedefine01 LIBCOPP_MACRO_ENABLE_STD_COROUTINE #cmakedefine01 LIBCOPP_MACRO_USE_STD_EXPERIMENTAL_COROUTINE #cmakedefine01 LIBCOPP_MACRO_ENABLE_EXCEPTION diff --git a/include/libcotask/task_promise.h b/include/libcotask/task_promise.h index 56827b4..913c0e6 100644 --- a/include/libcotask/task_promise.h +++ b/include/libcotask/task_promise.h @@ -16,6 +16,7 @@ #include // NOLINT(build/include_order) // clang-format on #include +#include #include #include @@ -1231,6 +1232,10 @@ class LIBCOPP_COTASK_API_HEAD_ONLY task_future throw; // get_context()->last_exception_ = std::current_exception(); } +# elif defined(LIBCOPP_MACRO_HAS_EXCEPTION) && LIBCOPP_MACRO_HAS_EXCEPTION + void unhandled_exception() { throw; } +# else + void unhandled_exception() { std::abort(); } # endif template