53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
|
|
// 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_TRAMPOLINE_H
|
|
#define BOOST_COROUTINES_DETAIL_TRAMPOLINE_H
|
|
|
|
#include <cstddef>
|
|
|
|
#include <boost/assert.hpp>
|
|
#include <boost/config.hpp>
|
|
#include <boost/cstdint.hpp>
|
|
#include <boost/tuple/tuple.hpp>
|
|
|
|
#ifdef BOOST_HAS_ABI_HEADERS
|
|
# include BOOST_ABI_PREFIX
|
|
#endif
|
|
|
|
namespace boost {
|
|
namespace coroutines {
|
|
namespace detail {
|
|
|
|
template< typename Coroutine >
|
|
void trampoline1( intptr_t vp)
|
|
{
|
|
BOOST_ASSERT( vp);
|
|
|
|
reinterpret_cast< Coroutine * >( vp)->run();
|
|
}
|
|
|
|
template< typename Coroutine, typename Arg >
|
|
void trampoline2( intptr_t vp)
|
|
{
|
|
BOOST_ASSERT( vp);
|
|
|
|
tuple< Coroutine *, Arg > * tpl(
|
|
reinterpret_cast< tuple< Coroutine *, Arg > * >( vp) );
|
|
Coroutine * coro( get< 0 >( * tpl) );
|
|
Arg arg( get< 1 >( * tpl) );
|
|
|
|
coro->run( arg);
|
|
}
|
|
|
|
}}}
|
|
|
|
#ifdef BOOST_HAS_ABI_HEADERS
|
|
# include BOOST_ABI_SUFFIX
|
|
#endif
|
|
|
|
#endif // BOOST_COROUTINES_DETAIL_TRAMPOLINE_H
|