Chris@16
|
1
|
Chris@16
|
2 // Copyright Oliver Kowalke 2009.
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6
|
Chris@16
|
7 #ifndef BOOST_COROUTINES_DETAIL_TRAMPOLINE_H
|
Chris@16
|
8 #define BOOST_COROUTINES_DETAIL_TRAMPOLINE_H
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/assert.hpp>
|
Chris@16
|
11 #include <boost/config.hpp>
|
Chris@16
|
12 #include <boost/cstdint.hpp>
|
Chris@101
|
13
|
Chris@101
|
14 #include <boost/coroutine/detail/config.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 #ifdef BOOST_HAS_ABI_HEADERS
|
Chris@16
|
17 # include BOOST_ABI_PREFIX
|
Chris@16
|
18 #endif
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost {
|
Chris@16
|
21 namespace coroutines {
|
Chris@16
|
22 namespace detail {
|
Chris@16
|
23
|
Chris@101
|
24 template< typename Coro >
|
Chris@101
|
25 void trampoline( intptr_t vp)
|
Chris@16
|
26 {
|
Chris@101
|
27 typedef typename Coro::param_type param_type;
|
Chris@16
|
28
|
Chris@101
|
29 BOOST_ASSERT( 0 != vp);
|
Chris@101
|
30
|
Chris@101
|
31 param_type * param(
|
Chris@101
|
32 reinterpret_cast< param_type * >( vp) );
|
Chris@101
|
33 BOOST_ASSERT( 0 != param);
|
Chris@101
|
34 BOOST_ASSERT( 0 != param->data);
|
Chris@101
|
35
|
Chris@101
|
36 Coro * coro(
|
Chris@101
|
37 reinterpret_cast< Coro * >( param->coro) );
|
Chris@101
|
38 BOOST_ASSERT( 0 != coro);
|
Chris@101
|
39
|
Chris@101
|
40 coro->run( param->data);
|
Chris@16
|
41 }
|
Chris@16
|
42
|
Chris@101
|
43 template< typename Coro >
|
Chris@101
|
44 void trampoline_void( intptr_t vp)
|
Chris@16
|
45 {
|
Chris@101
|
46 typedef typename Coro::param_type param_type;
|
Chris@16
|
47
|
Chris@101
|
48 BOOST_ASSERT( 0 != vp);
|
Chris@16
|
49
|
Chris@101
|
50 param_type * param(
|
Chris@101
|
51 reinterpret_cast< param_type * >( vp) );
|
Chris@101
|
52 BOOST_ASSERT( 0 != param);
|
Chris@101
|
53
|
Chris@101
|
54 Coro * coro(
|
Chris@101
|
55 reinterpret_cast< Coro * >( param->coro) );
|
Chris@101
|
56 BOOST_ASSERT( 0 != coro);
|
Chris@101
|
57
|
Chris@101
|
58 coro->run();
|
Chris@16
|
59 }
|
Chris@16
|
60
|
Chris@16
|
61 }}}
|
Chris@16
|
62
|
Chris@16
|
63 #ifdef BOOST_HAS_ABI_HEADERS
|
Chris@16
|
64 # include BOOST_ABI_SUFFIX
|
Chris@16
|
65 #endif
|
Chris@16
|
66
|
Chris@16
|
67 #endif // BOOST_COROUTINES_DETAIL_TRAMPOLINE_H
|