find_package(Boost COMPONENTS context)
set(Boost_FOUND 1) # This component is optional
if(Boost_CONTEXT_FOUND)
- if (Boost_VERSION LESS 105600)
- message("Found Boost.Context API v1")
- set(HAVE_BOOST_CONTEXTS 1)
- elseif(Boost_VERSION LESS 106100)
- message("Found Boost.Context API v2")
- set(HAVE_BOOST_CONTEXTS 2)
- else()
- message(" WARNING : our implementation of Boost context factory is not compatible with Boost >=1.61 yet.")
- set(HAVE_BOOST_CONTEXTS 0)
- endif()
+ message("Found Boost.Context")
+ set(HAVE_BOOST_CONTEXTS 1)
else()
message (" boost : found.")
message (" boost-context: missing. Install libboost-context-dev for this optional feature.")
// BoostContext
-void BoostContext::smx_ctx_boost_wrapper(std::intptr_t arg)
+void BoostContext::smx_ctx_boost_wrapper(BoostContext::ctx_arg_type arg)
{
+#if BOOST_VERSION < 106100
BoostContext* context = reinterpret_cast<BoostContext*>(arg);
+#else
+ static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
+ BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
+#endif
(*context)();
context->stop();
}
{
#if BOOST_VERSION < 105600
boost::context::jump_fcontext(from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
-#else
+#elif BOOST_VERSION < 106100
boost::context::jump_fcontext(&from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
+#else
+ BoostContext* ctx[2] = {from, to};
+ boost::context::detail::transfer_t arg = boost::context::detail::jump_fcontext(to->fc_, ctx);
+ static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
#endif
}
#else
void* stack = this->stack_;
#endif
- this->fc_ = boost::context::make_fcontext(
- stack,
- smx_context_usable_stack_size,
- smx_ctx_boost_wrapper);
+#if BOOST_VERSION < 106100
+ this->fc_ = boost::context::make_fcontext(stack, smx_context_usable_stack_size, smx_ctx_boost_wrapper);
+#else
+ this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_usable_stack_size, smx_ctx_boost_wrapper);
+#endif
} else {
#if BOOST_VERSION < 105600
this->fc_ = new boost::context::fcontext_t();
#define SIMGRID_SIMIX_BOOST_CONTEXT_HPP
#include <boost/version.hpp>
+#if BOOST_VERSION < 106100
#include <boost/context/fcontext.hpp>
+#else
+#include <boost/context/detail/fcontext.hpp>
+#endif
#include <functional>
#include <vector>
#if BOOST_VERSION < 105600
boost::context::fcontext_t* fc_ = nullptr;
-#else
+ typedef intptr_t ctx_arg_type;
+#elif BOOST_VERSION < 106100
boost::context::fcontext_t fc_;
+ typedef intptr_t ctx_arg_type;
+#else
+ boost::context::detail::fcontext_t fc_;
+ typedef boost::context::detail::transfer_t ctx_arg_type;
#endif
- static void smx_ctx_boost_wrapper(intptr_t);
+ static void smx_ctx_boost_wrapper(ctx_arg_type);
static void smx_ctx_boost_jump_fcontext(BoostContext*, BoostContext*);
void* stack_ = nullptr;