]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_boost_asio_yield.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rgw / rgw_boost_asio_yield.h
1 //
2 // copy of needed macors from yield.hpp
3 //
4 // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
5 //
6 // Distributed under the Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 //
9
10 #ifndef RGW_BOOST_ASIO_YIELD_H
11 #define RGW_BOOST_ASIO_YIELD_H
12
13 #ifdef HAVE_BOOST_ASIO_COROUTINE
14 #include <boost/asio/yield.hpp>
15 #else
16 #define BOOST_ASIO_CORO_REENTER(c) \
17 switch (::boost::asio::detail::coroutine_ref _coro_value = c) \
18 case -1: if (_coro_value) \
19 { \
20 goto terminate_coroutine; \
21 terminate_coroutine: \
22 _coro_value = -1; \
23 goto bail_out_of_coroutine; \
24 bail_out_of_coroutine: \
25 break; \
26 } \
27 else case 0:
28
29 #define BOOST_ASIO_CORO_YIELD_IMPL(n) \
30 for (_coro_value = (n);;) \
31 if (_coro_value == 0) \
32 { \
33 case (n): ; \
34 break; \
35 } \
36 else \
37 switch (_coro_value ? 0 : 1) \
38 for (;;) \
39 case -1: if (_coro_value) \
40 goto terminate_coroutine; \
41 else for (;;) \
42 case 1: if (_coro_value) \
43 goto bail_out_of_coroutine; \
44 else case 0:
45
46 #define BOOST_ASIO_CORO_FORK_IMPL(n) \
47 for (_coro_value = -(n);; _coro_value = (n)) \
48 if (_coro_value == (n)) \
49 { \
50 case -(n): ; \
51 break; \
52 } \
53 else
54
55 #if defined(_MSC_VER)
56 # define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__COUNTER__ + 1)
57 # define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__COUNTER__ + 1)
58 #else // defined(_MSC_VER)
59 # define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__LINE__)
60 # define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__LINE__)
61 #endif // defined(_MSC_VER)
62
63 #ifndef reenter
64 # define reenter(c) BOOST_ASIO_CORO_REENTER(c)
65 #endif
66
67 #ifndef yield
68 # define yield BOOST_ASIO_CORO_YIELD
69 #endif
70
71 #ifndef fork
72 # define fork BOOST_ASIO_CORO_FORK
73 #endif
74
75 #endif // HAVE_BOOST_ASIO_COROUTINE
76
77 #endif // RGW_BOOST_ASIO_YIELD_H
78