From b30e0dd8698333d95fe27b65728e4f8d6a5bf6c6 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 26 Aug 2014 11:16:56 +0200 Subject: [PATCH] Boost 1.56 compatibility fix. --- include/tool/coroutine.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/include/tool/coroutine.h b/include/tool/coroutine.h index 3385dece7d..76afe8d81b 100644 --- a/include/tool/coroutine.h +++ b/include/tool/coroutine.h @@ -28,6 +28,7 @@ #include #include +#include #include "delegate.h" @@ -88,6 +89,11 @@ public: if( m_saved ) delete m_saved; +#if BOOST_VERSION >= 105600 + if( m_self ) + delete m_self; +#endif + if( m_stack ) free( m_stack ); } @@ -101,7 +107,7 @@ public: */ void Yield() { - boost::context::jump_fcontext( m_self, m_saved, 0 ); + jump( m_self, m_saved, 0 ); } /** @@ -113,7 +119,7 @@ public: void Yield( ReturnType& aRetVal ) { m_retVal = aRetVal; - boost::context::jump_fcontext( m_self, m_saved, 0 ); + jump( m_self, m_saved, 0 ); } /** @@ -147,12 +153,17 @@ public: assert( m_saved == NULL ); m_args = &aArgs; +#if BOOST_VERSION >= 105600 + m_self = new boost::context::fcontext_t(); + *m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub ); +#else m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub ); +#endif m_saved = new boost::context::fcontext_t(); m_running = true; // off we go! - boost::context::jump_fcontext( m_saved, m_self, reinterpret_cast( this ) ); + jump( m_saved, m_self, reinterpret_cast( this ) ); return m_running; } @@ -165,7 +176,7 @@ public: */ bool Resume() { - boost::context::jump_fcontext( m_saved, m_self, 0 ); + jump( m_saved, m_self, 0 ); return m_running; } @@ -204,7 +215,18 @@ private: cor->m_running = false; // go back to wherever we came from. - boost::context::jump_fcontext( cor->m_self, cor->m_saved, 0 ); // reinterpret_cast( this )); + jump( cor->m_self, cor->m_saved, 0 ); // reinterpret_cast( this )); + } + + ///> Wrapper for jump_fcontext to assure compatibility between different boost versions + static inline intptr_t jump(boost::context::fcontext_t* aOld, boost::context::fcontext_t* aNew, + intptr_t aP, bool aPreserveFPU = true ) + { +#if BOOST_VERSION >= 105600 + return boost::context::jump_fcontext( aOld, *aNew, aP, aPreserveFPU ); +#else + return boost::context::jump_fcontext( aOld, aNew, aP, aPreserveFPU ); +#endif } template