Skip to content

Commit

Permalink
Merge pull request #43 from owent/dev
Browse files Browse the repository at this point in the history
Implement unhandled_exception when without exception
  • Loading branch information
owent authored Jan 31, 2023
2 parents 313b8da + bded23d commit ac3a87f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion atframework/cmake-toolset
5 changes: 5 additions & 0 deletions include/libcopp/coroutine/callable_promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// clang-format off
#include <libcopp/utils/config/stl_include_prefix.h> // NOLINT(build/include_order)
// clang-format on
#include <cstdlib>
#include <type_traits>
// clang-format off
#include <libcopp/utils/config/stl_include_suffix.h> // NOLINT(build/include_order)
Expand Down Expand Up @@ -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<promise_type>;
Expand Down
14 changes: 14 additions & 0 deletions include/libcopp/utils/config/libcopp_build_features.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions include/libcotask/task_promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <libcopp/utils/config/stl_include_prefix.h> // NOLINT(build/include_order)
// clang-format on
#include <assert.h>
#include <cstdlib>
#include <functional>
#include <type_traits>

Expand Down Expand Up @@ -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 <class TCONVERT_PRIVATE_DATA>
Expand Down

0 comments on commit ac3a87f

Please sign in to comment.