summaryrefslogtreecommitdiff
path: root/boost/context
diff options
context:
space:
mode:
Diffstat (limited to 'boost/context')
-rw-r--r--boost/context/continuation_ucontext.hpp4
-rw-r--r--boost/context/detail/config.hpp9
-rw-r--r--boost/context/execution_context_v2.hpp4
-rw-r--r--boost/context/execution_context_v2_void.ipp4
-rw-r--r--boost/context/fiber_fcontext.hpp11
-rw-r--r--boost/context/fiber_ucontext.hpp4
-rw-r--r--boost/context/stack_context.hpp4
7 files changed, 32 insertions, 8 deletions
diff --git a/boost/context/continuation_ucontext.hpp b/boost/context/continuation_ucontext.hpp
index a1ad97f440..1390a72887 100644
--- a/boost/context/continuation_ucontext.hpp
+++ b/boost/context/continuation_ucontext.hpp
@@ -299,6 +299,8 @@ static activation_record * create_context1( StackAlloc && salloc, Fn && fn) {
reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sctx.size) );
// create user-context
if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
+ record->~capture_t();
+ salloc.deallocate( sctx);
throw std::system_error(
std::error_code( errno, std::system_category() ),
"getcontext() failed");
@@ -332,6 +334,8 @@ static activation_record * create_context2( preallocated palloc, StackAlloc && s
reinterpret_cast< uintptr_t >( palloc.sctx.sp) - static_cast< uintptr_t >( palloc.sctx.size) );
// create user-context
if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
+ record->~capture_t();
+ salloc.deallocate( palloc.sctx);
throw std::system_error(
std::error_code( errno, std::system_category() ),
"getcontext() failed");
diff --git a/boost/context/detail/config.hpp b/boost/context/detail/config.hpp
index 15d03574b1..b0b03c14ec 100644
--- a/boost/context/detail/config.hpp
+++ b/boost/context/detail/config.hpp
@@ -115,4 +115,13 @@ static constexpr std::size_t cacheline_length{ 64 };
static constexpr std::size_t prefetch_stride{ 4 * cacheline_length };
#endif
+#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
+// GNU libstdc++ 3
+# define BOOST_CONTEXT_HAS_CXXABI_H
+#endif
+
+#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
+# include <cxxabi.h>
+#endif
+
#endif // BOOST_CONTEXT_DETAIL_CONFIG_H
diff --git a/boost/context/execution_context_v2.hpp b/boost/context/execution_context_v2.hpp
index 3f76317eea..8893438df6 100644
--- a/boost/context/execution_context_v2.hpp
+++ b/boost/context/execution_context_v2.hpp
@@ -390,6 +390,10 @@ transfer_t ecv2_context_ontop( transfer_t t) {
#else
std::get< 1 >( std::get< 1 >( * p) ) = helper< sizeof ... (Args) >::convert( std::apply( fn, std::move( args) ) );
#endif
+#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
+ } catch ( abi::__forced_unwind const&) {
+ throw;
+#endif
} catch (...) {
std::get< 0 >( std::get< 1 >( * p) ) = std::current_exception();
}
diff --git a/boost/context/execution_context_v2_void.ipp b/boost/context/execution_context_v2_void.ipp
index eb291d2225..7a1a9e7366 100644
--- a/boost/context/execution_context_v2_void.ipp
+++ b/boost/context/execution_context_v2_void.ipp
@@ -236,6 +236,10 @@ transfer_t ecv2_context_ontop_void( transfer_t t) {
try {
// execute function
fn();
+#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
+ } catch ( abi::__forced_unwind const&) {
+ throw;
+#endif
} catch (...) {
std::get< 1 >( * p) = std::current_exception();
return { t.fctx, & std::get< 1 >( * p ) };
diff --git a/boost/context/fiber_fcontext.hpp b/boost/context/fiber_fcontext.hpp
index 170490ad1d..2503b82b7d 100644
--- a/boost/context/fiber_fcontext.hpp
+++ b/boost/context/fiber_fcontext.hpp
@@ -92,12 +92,11 @@ void fiber_entry( transfer_t t) noexcept {
template< typename Ctx, typename Fn >
transfer_t fiber_ontop( transfer_t t) {
- auto p = static_cast< std::tuple< Fn > * >( t.data);
- BOOST_ASSERT( nullptr != p);
- typename std::decay< Fn >::type fn = std::get< 0 >( * p);
+ BOOST_ASSERT( nullptr != t.data);
+ auto p = *static_cast< Fn * >( t.data);
t.data = nullptr;
// execute function, pass fiber via reference
- Ctx c = fn( Ctx{ t.fctx } );
+ Ctx c = p( Ctx{ t.fctx } );
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
return { exchange( c.fctx_, nullptr), nullptr };
#else
@@ -292,7 +291,7 @@ public:
template< typename Fn >
fiber resume_with( Fn && fn) && {
BOOST_ASSERT( nullptr != fctx_);
- auto p = std::make_tuple( std::forward< Fn >( fn) );
+ auto p = std::forward< Fn >( fn);
return { detail::ontop_fcontext(
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
detail::exchange( fctx_, nullptr),
@@ -300,7 +299,7 @@ public:
std::exchange( fctx_, nullptr),
#endif
& p,
- detail::fiber_ontop< fiber, Fn >).fctx };
+ detail::fiber_ontop< fiber, decltype(p) >).fctx };
}
explicit operator bool() const noexcept {
diff --git a/boost/context/fiber_ucontext.hpp b/boost/context/fiber_ucontext.hpp
index 6484364784..e61b4de4a4 100644
--- a/boost/context/fiber_ucontext.hpp
+++ b/boost/context/fiber_ucontext.hpp
@@ -299,6 +299,8 @@ static fiber_activation_record * create_fiber1( StackAlloc && salloc, Fn && fn)
reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sctx.size) );
// create user-context
if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
+ record->~capture_t();
+ salloc.deallocate( sctx);
throw std::system_error(
std::error_code( errno, std::system_category() ),
"getcontext() failed");
@@ -332,6 +334,8 @@ static fiber_activation_record * create_fiber2( preallocated palloc, StackAlloc
reinterpret_cast< uintptr_t >( palloc.sctx.sp) - static_cast< uintptr_t >( palloc.sctx.size) );
// create user-context
if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
+ record->~capture_t();
+ salloc.deallocate( palloc.sctx);
throw std::system_error(
std::error_code( errno, std::system_category() ),
"getcontext() failed");
diff --git a/boost/context/stack_context.hpp b/boost/context/stack_context.hpp
index 6e516a3adf..740d981dc7 100644
--- a/boost/context/stack_context.hpp
+++ b/boost/context/stack_context.hpp
@@ -21,7 +21,7 @@ namespace boost {
namespace context {
#if ! defined(BOOST_CONTEXT_NO_CXX11)
-struct stack_context {
+struct BOOST_CONTEXT_DECL stack_context {
# if defined(BOOST_USE_SEGMENTED_STACKS)
typedef void * segments_context[BOOST_CONTEXT_SEGMENTS];
# endif
@@ -36,7 +36,7 @@ struct stack_context {
# endif
};
#else
-struct stack_context {
+struct BOOST_CONTEXT_DECL stack_context {
# if defined(BOOST_USE_SEGMENTED_STACKS)
typedef void * segments_context[BOOST_CONTEXT_SEGMENTS];
# endif