From: Andrew Nelless Date: Tue, 23 Feb 2016 15:15:56 +0000 (+0000) Subject: Hack in compatibility for Boost <= 1.55 X-Git-Tag: rec-4.0.0-alpha2~54^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9e89baf55b61e1101a1361ea87e468b347167f5;p=pdns Hack in compatibility for Boost <= 1.55 --- diff --git a/pdns/mtasker_fcontext.cc b/pdns/mtasker_fcontext.cc index dfe345529..77f473cf1 100644 --- a/pdns/mtasker_fcontext.cc +++ b/pdns/mtasker_fcontext.cc @@ -1,11 +1,35 @@ #include "mtasker_context.hh" #include #include +#include #include +#include +using boost::context::make_fcontext; + +#if BOOST_VERSION < 105600 +using fcontext_t = boost::context::fcontext_t*; + +static inline intptr_t +jump_fcontext (fcontext_t* const ofc, fcontext_t const nfc, + intptr_t const arg) { + if (*ofc) { + return boost::context::jump_fcontext (*ofc, nfc, arg); + } else { + boost::context::fcontext_t self; + *ofc = &self; + auto ret = boost::context::jump_fcontext (*ofc, nfc, arg); + *ofc = nullptr; + return ret; + } +} +#else using boost::context::fcontext_t; using boost::context::jump_fcontext; -using boost::context::make_fcontext; + +static_assert (std::is_pointer::value, + "Boost Context has changed the fcontext_t type again :-("); +#endif struct args_t { fcontext_t prev_ctx = nullptr; @@ -20,7 +44,8 @@ threadWrapper (intptr_t const xargs) { auto args = reinterpret_cast(xargs); auto ctx = args->self; auto work = args->work; - jump_fcontext (&ctx->uc_mcontext, args->prev_ctx, 0); + jump_fcontext (reinterpret_cast(&ctx->uc_mcontext), + static_cast(args->prev_ctx), 0); args = nullptr; try { @@ -31,7 +56,8 @@ threadWrapper (intptr_t const xargs) { } auto const next_ctx = ctx->uc_link->uc_mcontext; - jump_fcontext (&ctx->uc_mcontext, next_ctx, + jump_fcontext (reinterpret_cast(&ctx->uc_mcontext), + static_cast(next_ctx), static_cast(ctx->exception)); #ifdef NDEBUG __builtin_unreachable(); @@ -50,7 +76,8 @@ pdns_ucontext_t::~pdns_ucontext_t void pdns_swapcontext (pdns_ucontext_t& __restrict octx, pdns_ucontext_t const& __restrict ctx) { - if (jump_fcontext (&octx.uc_mcontext, ctx.uc_mcontext, 0)) { + if (jump_fcontext (reinterpret_cast(&octx.uc_mcontext), + static_cast(ctx.uc_mcontext), 0)) { std::rethrow_exception (ctx.exception); } } @@ -66,6 +93,7 @@ pdns_makecontext args_t args; args.self = &ctx; args.work = &start; - jump_fcontext (&args.prev_ctx, ctx.uc_mcontext, + jump_fcontext (reinterpret_cast(&args.prev_ctx), + static_cast(ctx.uc_mcontext), reinterpret_cast(&args)); }