Skip to content

Commit

Permalink
Convert make_fcontext etc into true C++ symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
rdoeffinger committed Oct 8, 2024
1 parent d7eb07d commit 068bed6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/boost/context/detail/fcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ struct transfer_t {
void * data;
};

extern "C" BOOST_CONTEXT_DECL
transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp);
extern "C" BOOST_CONTEXT_DECL
fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
BOOST_CONTEXT_DECL transfer_t jump_fcontext( fcontext_t const to, void * vp);
BOOST_CONTEXT_DECL fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );

// based on an idea of Giovanni Derreta
extern "C" BOOST_CONTEXT_DECL
transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) );
BOOST_CONTEXT_DECL transfer_t ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) );

}}}

Expand Down
30 changes: 30 additions & 0 deletions src/posix/stack_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern "C" {

#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/context/detail/fcontext.hpp>

#if !defined (SIGSTKSZ)
# define SIGSTKSZ (32768) // 32kb minimum allowable stack
Expand All @@ -35,6 +36,35 @@ extern "C" {
# include BOOST_ABI_PREFIX
#endif

extern "C"
boost::context::detail::transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( boost::context::detail::fcontext_t const to, void * vp);
extern "C"
boost::context::detail::fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( boost::context::detail::transfer_t) );

// based on an idea of Giovanni Derreta
extern "C"
boost::context::detail::transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( boost::context::detail::fcontext_t const to, void * vp, boost::context::detail::transfer_t (* fn)( boost::context::detail::transfer_t) );

namespace boost {
namespace context {
namespace detail {

transfer_t jump_fcontext( fcontext_t const to, void * vp)
{
return ::jump_fcontext(to, vp);
}

fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) )
{
return ::make_fcontext(sp, size, fn);
}

transfer_t ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) )
{
return ::ontop_fcontext(to, vp, fn);
}
}}}

namespace {

std::size_t pagesize() BOOST_NOEXCEPT_OR_NOTHROW {
Expand Down

0 comments on commit 068bed6

Please sign in to comment.