diff options
Diffstat (limited to 'boost/coroutine')
19 files changed, 184 insertions, 274 deletions
diff --git a/boost/coroutine/attributes.hpp b/boost/coroutine/attributes.hpp index 065a4c66e3..ca712ee68d 100644 --- a/boost/coroutine/attributes.hpp +++ b/boost/coroutine/attributes.hpp @@ -25,63 +25,27 @@ struct attributes { std::size_t size; flag_unwind_t do_unwind; - flag_fpu_t preserve_fpu; attributes() BOOST_NOEXCEPT : size( stack_allocator::traits_type::default_size() ), - do_unwind( stack_unwind), - preserve_fpu( fpu_preserved) + do_unwind( stack_unwind) {} explicit attributes( std::size_t size_) BOOST_NOEXCEPT : size( size_), - do_unwind( stack_unwind), - preserve_fpu( fpu_preserved) + do_unwind( stack_unwind) {} explicit attributes( flag_unwind_t do_unwind_) BOOST_NOEXCEPT : size( stack_allocator::traits_type::default_size() ), - do_unwind( do_unwind_), - preserve_fpu( fpu_preserved) - {} - - explicit attributes( flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( stack_allocator::traits_type::default_size() ), - do_unwind( stack_unwind), - preserve_fpu( preserve_fpu_) + do_unwind( do_unwind_) {} explicit attributes( std::size_t size_, flag_unwind_t do_unwind_) BOOST_NOEXCEPT : size( size_), - do_unwind( do_unwind_), - preserve_fpu( fpu_preserved) - {} - - explicit attributes( - std::size_t size_, - flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( size_), - do_unwind( stack_unwind), - preserve_fpu( preserve_fpu_) - {} - - explicit attributes( - flag_unwind_t do_unwind_, - flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( stack_allocator::traits_type::default_size() ), - do_unwind( do_unwind_), - preserve_fpu( preserve_fpu_) - {} - - explicit attributes( - std::size_t size_, - flag_unwind_t do_unwind_, - flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( size_), - do_unwind( do_unwind_), - preserve_fpu( preserve_fpu_) + do_unwind( do_unwind_) {} }; diff --git a/boost/coroutine/detail/config.hpp b/boost/coroutine/detail/config.hpp index 9a3f4bf334..488a401862 100644 --- a/boost/coroutine/detail/config.hpp +++ b/boost/coroutine/detail/config.hpp @@ -35,14 +35,6 @@ # include <boost/config/auto_link.hpp> #endif -#if defined(BOOST_USE_SEGMENTED_STACKS) -# if ! ( (defined(__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 6) || \ - (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3) ) -# error "compiler does not support segmented stacks" -# endif -# define BOOST_COROUTINES_SEGMENTS 10 -#endif - #define BOOST_COROUTINES_UNIDIRECT #define BOOST_COROUTINES_SYMMETRIC diff --git a/boost/coroutine/detail/coroutine_context.hpp b/boost/coroutine/detail/coroutine_context.hpp index 94aa69bd6e..2d2b60ace2 100644 --- a/boost/coroutine/detail/coroutine_context.hpp +++ b/boost/coroutine/detail/coroutine_context.hpp @@ -11,7 +11,7 @@ #include <boost/assert.hpp> #include <boost/config.hpp> -#include <boost/context/fcontext.hpp> +#include <boost/context/detail/fcontext.hpp> #include <boost/coroutine/detail/config.hpp> #include <boost/coroutine/detail/preallocated.hpp> @@ -29,11 +29,22 @@ namespace detail { class BOOST_COROUTINES_DECL coroutine_context { private: + template< typename Coro > + friend void trampoline( context::detail::transfer_t); + template< typename Coro > + friend void trampoline_void( context::detail::transfer_t); + template< typename Coro > + friend void trampoline_pull( context::detail::transfer_t); + template< typename Coro > + friend void trampoline_push( context::detail::transfer_t); + template< typename Coro > + friend void trampoline_push_void( context::detail::transfer_t); + preallocated palloc_; - context::fcontext_t ctx_; + context::detail::fcontext_t ctx_; public: - typedef void( * ctx_fn)( intptr_t); + typedef void( * ctx_fn)( context::detail::transfer_t); // default ctor represents the current execution-context coroutine_context(); @@ -47,7 +58,7 @@ public: coroutine_context& operator=( coroutine_context const&); - intptr_t jump( coroutine_context &, intptr_t = 0, bool = true); + void * jump( coroutine_context &, void * = 0); stack_context & stack_ctx() { return palloc_.sctx; } diff --git a/boost/coroutine/detail/data.hpp b/boost/coroutine/detail/data.hpp new file mode 100644 index 0000000000..7c008fe831 --- /dev/null +++ b/boost/coroutine/detail/data.hpp @@ -0,0 +1,34 @@ + +// Copyright Oliver Kowalke 2009. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_COROUTINES_DETAIL_DATA_H +#define BOOST_COROUTINES_DETAIL_DATA_H + +#include <boost/config.hpp> + +#include <boost/coroutine/detail/coroutine_context.hpp> + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { +namespace coroutines { +namespace detail { + +struct data_t +{ + coroutine_context * from; + void * data; +}; + +}}} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_COROUTINES_DETAIL_DATA_H diff --git a/boost/coroutine/detail/flags.hpp b/boost/coroutine/detail/flags.hpp index 8d19757ee8..2078b62362 100644 --- a/boost/coroutine/detail/flags.hpp +++ b/boost/coroutine/detail/flags.hpp @@ -23,8 +23,7 @@ enum flag_t flag_running = 1 << 2, flag_complete = 1 << 3, flag_unwind_stack = 1 << 4, - flag_force_unwind = 1 << 5, - flag_preserve_fpu = 1 << 6 + flag_force_unwind = 1 << 5 }; struct unwind_t diff --git a/boost/coroutine/detail/pull_coroutine_impl.hpp b/boost/coroutine/detail/pull_coroutine_impl.hpp index 10ca597544..e35b7894e2 100644 --- a/boost/coroutine/detail/pull_coroutine_impl.hpp +++ b/boost/coroutine/detail/pull_coroutine_impl.hpp @@ -46,7 +46,7 @@ public: pull_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : + bool unwind) : flags_( 0), except_(), caller_( caller), @@ -54,12 +54,11 @@ public: result_( 0) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } pull_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu, + bool unwind, R * result) : flags_( 0), except_(), @@ -68,7 +67,6 @@ public: result_( result) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } virtual ~pull_coroutine_impl() {} @@ -79,9 +77,6 @@ public: bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -99,8 +94,7 @@ public: param_type to( unwind_t::force_unwind); caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_unwind_stack; BOOST_ASSERT( is_complete() ); @@ -115,11 +109,10 @@ public: flags_ |= flag_running; param_type to( this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; result_ = from->data; if ( from->do_unwind) throw forced_unwind(); @@ -163,7 +156,7 @@ public: pull_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : + bool unwind) : flags_( 0), except_(), caller_( caller), @@ -171,12 +164,11 @@ public: result_( 0) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } pull_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu, + bool unwind, R * result) : flags_( 0), except_(), @@ -185,7 +177,6 @@ public: result_( result) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } virtual ~pull_coroutine_impl() {} @@ -196,9 +187,6 @@ public: bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -216,8 +204,7 @@ public: param_type to( unwind_t::force_unwind); caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_unwind_stack; BOOST_ASSERT( is_complete() ); @@ -232,11 +219,10 @@ public: flags_ |= flag_running; param_type to( this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; result_ = from->data; if ( from->do_unwind) throw forced_unwind(); @@ -279,14 +265,13 @@ public: pull_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : + bool unwind) : flags_( 0), except_(), caller_( caller), callee_( callee) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } virtual ~pull_coroutine_impl() {} @@ -297,9 +282,6 @@ public: inline bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - inline bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - inline bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -317,8 +299,7 @@ public: param_type to( unwind_t::force_unwind); caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_unwind_stack; BOOST_ASSERT( is_complete() ); @@ -333,11 +314,10 @@ public: flags_ |= flag_running; param_type to( this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; if ( from->do_unwind) throw forced_unwind(); if ( except_) rethrow_exception( except_); diff --git a/boost/coroutine/detail/pull_coroutine_object.hpp b/boost/coroutine/detail/pull_coroutine_object.hpp index 57ae169d80..36918489de 100644 --- a/boost/coroutine/detail/pull_coroutine_object.hpp +++ b/boost/coroutine/detail/pull_coroutine_object.hpp @@ -78,8 +78,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -92,8 +91,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -111,7 +109,7 @@ public: base_t::flags_ |= flag_running; // create push_coroutine - typename PushCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); + typename PushCoro::synth_type b( & this->callee, & this->caller, false); PushCoro push_coro( synthesized_t::syntesized, b); try { fn_( push_coro); } @@ -125,8 +123,7 @@ public: typename base_t::param_type to; this->callee.jump( this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); } @@ -164,8 +161,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -178,8 +174,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -197,7 +192,7 @@ public: base_t::flags_ |= flag_running; // create push_coroutine - typename PushCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); + typename PushCoro::synth_type b( & this->callee, & this->caller, false); PushCoro push_coro( synthesized_t::syntesized, b); try { fn_( push_coro); } @@ -211,8 +206,7 @@ public: typename base_t::param_type to; this->callee.jump( this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); } @@ -250,8 +244,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -264,8 +257,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -283,7 +275,7 @@ public: base_t::flags_ |= flag_running; // create push_coroutine - typename PushCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); + typename PushCoro::synth_type b( & this->callee, & this->caller, false); PushCoro push_coro( synthesized_t::syntesized, b); try { fn_( push_coro); } @@ -297,8 +289,7 @@ public: typename base_t::param_type to; this->callee.jump( this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); } diff --git a/boost/coroutine/detail/pull_coroutine_synthesized.hpp b/boost/coroutine/detail/pull_coroutine_synthesized.hpp index 952d50c113..313de3c2dd 100644 --- a/boost/coroutine/detail/pull_coroutine_synthesized.hpp +++ b/boost/coroutine/detail/pull_coroutine_synthesized.hpp @@ -30,9 +30,9 @@ private: public: pull_coroutine_synthesized( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu, + bool unwind, R * result) : - impl_t( caller, callee, unwind, preserve_fpu, result) + impl_t( caller, callee, unwind, result) {} void destroy() {} @@ -47,9 +47,9 @@ private: public: pull_coroutine_synthesized( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu, + bool unwind, R * result) : - impl_t( caller, callee, unwind, preserve_fpu, result) + impl_t( caller, callee, unwind, result) {} void destroy() {} @@ -64,8 +64,8 @@ private: public: pull_coroutine_synthesized( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) + bool unwind) : + impl_t( caller, callee, unwind) {} inline void destroy() {} diff --git a/boost/coroutine/detail/push_coroutine_impl.hpp b/boost/coroutine/detail/push_coroutine_impl.hpp index 8ee2bd6f0e..b46bfa61a8 100644 --- a/boost/coroutine/detail/push_coroutine_impl.hpp +++ b/boost/coroutine/detail/push_coroutine_impl.hpp @@ -45,14 +45,13 @@ public: push_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : + bool unwind) : flags_( 0), except_(), caller_( caller), callee_( callee) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } bool force_unwind() const BOOST_NOEXCEPT @@ -61,9 +60,6 @@ public: bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -81,8 +77,7 @@ public: param_type to( unwind_t::force_unwind); caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_unwind_stack; BOOST_ASSERT( is_complete() ); @@ -97,11 +92,10 @@ public: flags_ |= flag_running; param_type to( const_cast< Arg * >( & arg), this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; if ( from->do_unwind) throw forced_unwind(); if ( except_) rethrow_exception( except_); @@ -115,11 +109,10 @@ public: flags_ |= flag_running; param_type to( const_cast< Arg * >( & arg), this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; if ( from->do_unwind) throw forced_unwind(); if ( except_) rethrow_exception( except_); @@ -142,14 +135,13 @@ public: push_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : + bool unwind) : flags_( 0), except_(), caller_( caller), callee_( callee) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } bool force_unwind() const BOOST_NOEXCEPT @@ -158,9 +150,6 @@ public: bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -178,8 +167,7 @@ public: param_type to( unwind_t::force_unwind); caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_unwind_stack; BOOST_ASSERT( is_complete() ); @@ -194,11 +182,10 @@ public: flags_ |= flag_running; param_type to( & arg, this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; if ( from->do_unwind) throw forced_unwind(); if ( except_) rethrow_exception( except_); @@ -221,14 +208,13 @@ public: push_coroutine_impl( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : + bool unwind) : flags_( 0), except_(), caller_( caller), callee_( callee) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } inline bool force_unwind() const BOOST_NOEXCEPT @@ -237,9 +223,6 @@ public: inline bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - inline bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - inline bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -257,8 +240,7 @@ public: param_type to( unwind_t::force_unwind); caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_unwind_stack; BOOST_ASSERT( is_complete() ); @@ -273,11 +255,10 @@ public: flags_ |= flag_running; param_type to( this); param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( caller_->jump( * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ &= ~flag_running; if ( from->do_unwind) throw forced_unwind(); if ( except_) rethrow_exception( except_); diff --git a/boost/coroutine/detail/push_coroutine_object.hpp b/boost/coroutine/detail/push_coroutine_object.hpp index 53d5c7710e..c3115ebe11 100644 --- a/boost/coroutine/detail/push_coroutine_object.hpp +++ b/boost/coroutine/detail/push_coroutine_object.hpp @@ -90,8 +90,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -104,8 +103,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -123,7 +121,7 @@ public: base_t::flags_ |= flag_running; // create push_coroutine - typename PullCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu(), result); + typename PullCoro::synth_type b( & this->callee, & this->caller, false, result); PullCoro pull_coro( synthesized_t::syntesized, b); try { fn_( pull_coro); } @@ -137,8 +135,7 @@ public: typename base_t::param_type to; this->callee.jump( this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); } @@ -176,8 +173,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -190,8 +186,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -209,7 +204,7 @@ public: base_t::flags_ |= flag_running; // create push_coroutine - typename PullCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu(), result); + typename PullCoro::synth_type b( & this->callee, & this->caller, false, result); PullCoro push_coro( synthesized_t::syntesized, b); try { fn_( push_coro); } @@ -223,8 +218,7 @@ public: typename base_t::param_type to; this->callee.jump( this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); } @@ -262,8 +256,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -276,8 +269,7 @@ public: ctx_t( palloc, this), base_t( & this->caller, & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -295,7 +287,7 @@ public: base_t::flags_ |= flag_running; // create push_coroutine - typename PullCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); + typename PullCoro::synth_type b( & this->callee, & this->caller, false); PullCoro push_coro( synthesized_t::syntesized, b); try { fn_( push_coro); } @@ -309,8 +301,7 @@ public: typename base_t::param_type to; this->callee.jump( this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); } diff --git a/boost/coroutine/detail/push_coroutine_synthesized.hpp b/boost/coroutine/detail/push_coroutine_synthesized.hpp index 306a841fc0..c10a468b9b 100644 --- a/boost/coroutine/detail/push_coroutine_synthesized.hpp +++ b/boost/coroutine/detail/push_coroutine_synthesized.hpp @@ -30,8 +30,8 @@ private: public: push_coroutine_synthesized( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) + bool unwind) : + impl_t( caller, callee, unwind) {} void destroy() {} @@ -46,8 +46,8 @@ private: public: push_coroutine_synthesized( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) + bool unwind) : + impl_t( caller, callee, unwind) {} void destroy() {} @@ -62,8 +62,8 @@ private: public: push_coroutine_synthesized( coroutine_context * caller, coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) + bool unwind) : + impl_t( caller, callee, unwind) {} inline void destroy() {} diff --git a/boost/coroutine/detail/symmetric_coroutine_impl.hpp b/boost/coroutine/detail/symmetric_coroutine_impl.hpp index 96d948a49c..b4066d8f78 100644 --- a/boost/coroutine/detail/symmetric_coroutine_impl.hpp +++ b/boost/coroutine/detail/symmetric_coroutine_impl.hpp @@ -36,13 +36,12 @@ public: typedef parameters< R > param_type; symmetric_coroutine_impl( preallocated const& palloc, - bool unwind, bool preserve_fpu) BOOST_NOEXCEPT : + bool unwind) BOOST_NOEXCEPT : flags_( 0), caller_(), callee_( trampoline< symmetric_coroutine_impl< R > >, palloc) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } virtual ~symmetric_coroutine_impl() {} @@ -53,9 +52,6 @@ public: bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -74,8 +70,7 @@ public: param_type to( unwind_t::force_unwind); caller_.jump( callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_running; flags_ &= ~flag_unwind_stack; @@ -97,11 +92,10 @@ public: flags_ &= ~flag_running; param_type to; param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( callee_.jump( caller_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ |= flag_running; if ( from->do_unwind) throw forced_unwind(); BOOST_ASSERT( from->data); @@ -149,8 +143,7 @@ protected: flags_ |= flag_running; caller_.jump( callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ); + to); flags_ &= ~flag_running; } @@ -165,11 +158,10 @@ protected: other->caller_ = caller_; flags_ &= ~flag_running; param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( callee_.jump( other->callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ) ) ); + to) ) ); flags_ |= flag_running; if ( from->do_unwind) throw forced_unwind(); BOOST_ASSERT( from->data); @@ -184,13 +176,12 @@ public: typedef parameters< R & > param_type; symmetric_coroutine_impl( preallocated const& palloc, - bool unwind, bool preserve_fpu) BOOST_NOEXCEPT : + bool unwind) BOOST_NOEXCEPT : flags_( 0), caller_(), callee_( trampoline< symmetric_coroutine_impl< R > >, palloc) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } virtual ~symmetric_coroutine_impl() {} @@ -201,9 +192,6 @@ public: bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -222,8 +210,7 @@ public: param_type to( unwind_t::force_unwind); caller_.jump( callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_running; flags_ &= ~flag_unwind_stack; @@ -245,11 +232,10 @@ public: flags_ &= ~flag_running; param_type to; param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( callee_.jump( caller_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ |= flag_running; if ( from->do_unwind) throw forced_unwind(); BOOST_ASSERT( from->data); @@ -297,8 +283,7 @@ protected: flags_ |= flag_running; caller_.jump( callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ); + to); flags_ &= ~flag_running; } @@ -313,11 +298,10 @@ protected: other->caller_ = caller_; flags_ &= ~flag_running; param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( callee_.jump( other->callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ) ) ); + to) ) ); flags_ |= flag_running; if ( from->do_unwind) throw forced_unwind(); BOOST_ASSERT( from->data); @@ -332,13 +316,12 @@ public: typedef parameters< void > param_type; symmetric_coroutine_impl( preallocated const& palloc, - bool unwind, bool preserve_fpu) BOOST_NOEXCEPT : + bool unwind) BOOST_NOEXCEPT : flags_( 0), caller_(), callee_( trampoline_void< symmetric_coroutine_impl< void > >, palloc) { if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; } virtual ~symmetric_coroutine_impl() {} @@ -349,9 +332,6 @@ public: inline bool unwind_requested() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_unwind_stack); } - inline bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - inline bool is_started() const BOOST_NOEXCEPT { return 0 != ( flags_ & flag_started); } @@ -370,8 +350,7 @@ public: param_type to( unwind_t::force_unwind); caller_.jump( callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_running; flags_ &= ~flag_unwind_stack; @@ -388,8 +367,7 @@ public: flags_ |= flag_running; caller_.jump( callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); + & to); flags_ &= ~flag_running; } @@ -401,11 +379,10 @@ public: flags_ &= ~flag_running; param_type to; param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( callee_.jump( caller_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); + & to) ) ); flags_ |= flag_running; if ( from->do_unwind) throw forced_unwind(); } @@ -454,11 +431,10 @@ protected: other->caller_ = caller_; flags_ &= ~flag_running; param_type * from( - reinterpret_cast< param_type * >( + static_cast< param_type * >( callee_.jump( other->callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ) ) ); + to) ) ); flags_ |= flag_running; if ( from->do_unwind) throw forced_unwind(); } diff --git a/boost/coroutine/detail/symmetric_coroutine_object.hpp b/boost/coroutine/detail/symmetric_coroutine_object.hpp index 0e528f9611..a19cd92232 100644 --- a/boost/coroutine/detail/symmetric_coroutine_object.hpp +++ b/boost/coroutine/detail/symmetric_coroutine_object.hpp @@ -56,8 +56,7 @@ public: preallocated const& palloc, StackAllocator const& stack_alloc) BOOST_NOEXCEPT : impl_t( palloc, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -68,8 +67,7 @@ public: preallocated const& palloc, StackAllocator const& stack_alloc) BOOST_NOEXCEPT : impl_t( palloc, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -100,8 +98,7 @@ public: typename impl_t::param_type to; impl_t::callee_.jump( impl_t::caller_, - reinterpret_cast< intptr_t >( & to), - impl_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "coroutine is complete"); } @@ -135,8 +132,7 @@ public: preallocated const& palloc, StackAllocator const& stack_alloc) BOOST_NOEXCEPT : impl_t( palloc, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -147,8 +143,7 @@ public: preallocated const& palloc, StackAllocator const& stack_alloc) BOOST_NOEXCEPT : impl_t( palloc, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -179,8 +174,7 @@ public: typename impl_t::param_type to; impl_t::callee_.jump( impl_t::caller_, - reinterpret_cast< intptr_t >( & to), - impl_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "coroutine is complete"); } @@ -214,8 +208,7 @@ public: preallocated const& palloc, StackAllocator const& stack_alloc) BOOST_NOEXCEPT : impl_t( palloc, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), fn_( fn), stack_ctx_( palloc.sctx), stack_alloc_( stack_alloc) @@ -226,8 +219,7 @@ public: preallocated const& palloc, StackAllocator const& stack_alloc) BOOST_NOEXCEPT : impl_t( palloc, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), + stack_unwind == attrs.do_unwind), #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES fn_( fn), #else @@ -258,8 +250,7 @@ public: typename impl_t::param_type to; impl_t::callee_.jump( impl_t::caller_, - reinterpret_cast< intptr_t >( & to), - impl_t::preserve_fpu() ); + & to); BOOST_ASSERT_MSG( false, "coroutine is complete"); } diff --git a/boost/coroutine/detail/trampoline.hpp b/boost/coroutine/detail/trampoline.hpp index 1cb3226d15..eb0c6c2378 100644 --- a/boost/coroutine/detail/trampoline.hpp +++ b/boost/coroutine/detail/trampoline.hpp @@ -9,9 +9,11 @@ #include <boost/assert.hpp> #include <boost/config.hpp> +#include <boost/context/detail/fcontext.hpp> #include <boost/cstdint.hpp> #include <boost/coroutine/detail/config.hpp> +#include <boost/coroutine/detail/data.hpp> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -22,37 +24,37 @@ namespace coroutines { namespace detail { template< typename Coro > -void trampoline( intptr_t vp) +void trampoline( context::detail::transfer_t t) { typedef typename Coro::param_type param_type; - BOOST_ASSERT( 0 != vp); - + data_t * data = static_cast< data_t * >( t.data); + data->from->ctx_ = t.fctx; param_type * param( - reinterpret_cast< param_type * >( vp) ); + static_cast< param_type * >( data->data) ); BOOST_ASSERT( 0 != param); BOOST_ASSERT( 0 != param->data); Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); + static_cast< Coro * >( param->coro) ); BOOST_ASSERT( 0 != coro); coro->run( param->data); } template< typename Coro > -void trampoline_void( intptr_t vp) +void trampoline_void( context::detail::transfer_t t) { typedef typename Coro::param_type param_type; - BOOST_ASSERT( 0 != vp); - + data_t * data = static_cast< data_t * >( t.data); + data->from->ctx_ = t.fctx; param_type * param( - reinterpret_cast< param_type * >( vp) ); + static_cast< param_type * >( data->data) ); BOOST_ASSERT( 0 != param); Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); + static_cast< Coro * >( param->coro) ); BOOST_ASSERT( 0 != coro); coro->run(); diff --git a/boost/coroutine/detail/trampoline_pull.hpp b/boost/coroutine/detail/trampoline_pull.hpp index 179024529d..1daa76db3b 100644 --- a/boost/coroutine/detail/trampoline_pull.hpp +++ b/boost/coroutine/detail/trampoline_pull.hpp @@ -9,9 +9,11 @@ #include <boost/assert.hpp> #include <boost/config.hpp> +#include <boost/context/detail/fcontext.hpp> #include <boost/cstdint.hpp> #include <boost/coroutine/detail/config.hpp> +#include <boost/coroutine/detail/data.hpp> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -22,18 +24,18 @@ namespace coroutines { namespace detail { template< typename Coro > -void trampoline_pull( intptr_t vp) +void trampoline_pull( context::detail::transfer_t t) { typedef typename Coro::param_type param_type; - BOOST_ASSERT( 0 != vp); - + data_t * data = static_cast< data_t * >( t.data); + data->from->ctx_ = t.fctx; param_type * param( - reinterpret_cast< param_type * >( vp) ); + static_cast< param_type * >( data->data) ); BOOST_ASSERT( 0 != param); Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); + static_cast< Coro * >( param->coro) ); BOOST_ASSERT( 0 != coro); coro->run(); diff --git a/boost/coroutine/detail/trampoline_push.hpp b/boost/coroutine/detail/trampoline_push.hpp index 448904456e..80f90d0518 100644 --- a/boost/coroutine/detail/trampoline_push.hpp +++ b/boost/coroutine/detail/trampoline_push.hpp @@ -11,11 +11,13 @@ #include <boost/assert.hpp> #include <boost/config.hpp> +#include <boost/context/detail/fcontext.hpp> #include <boost/cstdint.hpp> #include <boost/exception_ptr.hpp> #include <boost/move/move.hpp> #include <boost/coroutine/detail/config.hpp> +#include <boost/coroutine/detail/data.hpp> #include <boost/coroutine/detail/flags.hpp> #include <boost/coroutine/detail/parameters.hpp> #include <boost/coroutine/detail/setup.hpp> @@ -32,37 +34,37 @@ namespace coroutines { namespace detail { template< typename Coro > -void trampoline_push( intptr_t vp) +void trampoline_push( context::detail::transfer_t t) { typedef typename Coro::param_type param_type; - BOOST_ASSERT( vp); - + data_t * data = static_cast< data_t * >( t.data); + data->from->ctx_ = t.fctx; param_type * param( - reinterpret_cast< param_type * >( vp) ); + static_cast< param_type * >( data->data) ); BOOST_ASSERT( 0 != param); BOOST_ASSERT( 0 != param->data); Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); + static_cast< Coro * >( param->coro) ); BOOST_ASSERT( 0 != coro); coro->run( param->data); } template< typename Coro > -void trampoline_push_void( intptr_t vp) +void trampoline_push_void( context::detail::transfer_t t) { typedef typename Coro::param_type param_type; - BOOST_ASSERT( vp); - + data_t * data = static_cast< data_t * >( t.data); + data->from->ctx_ = t.fctx; param_type * param( - reinterpret_cast< param_type * >( vp) ); + static_cast< param_type * >( data->data) ); BOOST_ASSERT( 0 != param); Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); + static_cast< Coro * >( param->coro) ); BOOST_ASSERT( 0 != coro); coro->run(); diff --git a/boost/coroutine/flags.hpp b/boost/coroutine/flags.hpp index a8194c60ee..81940f30e5 100644 --- a/boost/coroutine/flags.hpp +++ b/boost/coroutine/flags.hpp @@ -16,12 +16,6 @@ enum flag_unwind_t no_stack_unwind }; -enum flag_fpu_t -{ - fpu_preserved = 0, - fpu_not_preserved -}; - }} #endif // BOOST_COROUTINES_FLAGS_H diff --git a/boost/coroutine/posix/segmented_stack_allocator.hpp b/boost/coroutine/posix/segmented_stack_allocator.hpp index 335e5789b4..49cee28cd2 100644 --- a/boost/coroutine/posix/segmented_stack_allocator.hpp +++ b/boost/coroutine/posix/segmented_stack_allocator.hpp @@ -23,14 +23,14 @@ // forward declaration for splitstack-functions defined in libgcc extern "C" { void *__splitstack_makecontext( std::size_t, - void * [BOOST_COROUTINES_SEGMENTS], + void * [BOOST_CONTEXT_SEGMENTS], std::size_t *); -void __splitstack_releasecontext( void * [BOOST_COROUTINES_SEGMENTS]); +void __splitstack_releasecontext( void * [BOOST_CONTEXT_SEGMENTS]); -void __splitstack_resetcontext( void * [BOOST_COROUTINES_SEGMENTS]); +void __splitstack_resetcontext( void * [BOOST_CONTEXT_SEGMENTS]); -void __splitstack_block_signals_context( void * [BOOST_COROUTINES_SEGMENTS], +void __splitstack_block_signals_context( void * [BOOST_CONTEXT_SEGMENTS], int * new_value, int * old_value); } diff --git a/boost/coroutine/stack_context.hpp b/boost/coroutine/stack_context.hpp index 1ca11eb4a8..433056f7a1 100644 --- a/boost/coroutine/stack_context.hpp +++ b/boost/coroutine/stack_context.hpp @@ -23,7 +23,7 @@ namespace coroutines { #if defined(BOOST_USE_SEGMENTED_STACKS) struct stack_context { - typedef void * segments_context[BOOST_COROUTINES_SEGMENTS]; + typedef void * segments_context[BOOST_CONTEXT_SEGMENTS]; std::size_t size; void * sp; |