Skip to content

Commit aa37e20

Browse files
Set alignment to max for sbo buffer.
1 parent d6a844d commit aa37e20

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

include/boost/cobalt/op.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace boost::cobalt
2121

2222

2323
template<typename ... Args>
24-
struct [[nodiscard]] op
24+
struct [[nodiscard]] alignas(alignof(std::max_align_t)) op
2525
{
2626
virtual void ready(cobalt::handler<Args...>) {};
2727
virtual void initiate(cobalt::completion_handler<Args...> complete) = 0 ;
@@ -57,6 +57,7 @@ struct [[nodiscard]] op
5757
resource_type *resource;
5858

5959
template<typename Promise>
60+
BOOST_COBALT_MSVC_NOINLINE
6061
bool await_suspend(std::coroutine_handle<Promise> h
6162
#if defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
6263
, const boost::source_location & loc = BOOST_CURRENT_LOCATION
@@ -91,19 +92,15 @@ struct [[nodiscard]] op
9192
return await_resume(as_result_tag{}).value(loc);
9293
}
9394

94-
#if defined(_MSC_VER)
95-
BOOST_NOINLINE
96-
#endif
95+
BOOST_COBALT_MSVC_NOINLINE
9796
auto await_resume(const struct as_tuple_tag &)
9897
{
9998
if (init_ep)
10099
std::rethrow_exception(init_ep);
101100
return *std::move(result);
102101
}
103102

104-
#if defined(_MSC_VER)
105-
BOOST_NOINLINE
106-
#endif
103+
BOOST_COBALT_MSVC_NOINLINE
107104
auto await_resume(const struct as_result_tag &)
108105
{
109106
if (init_ep)
@@ -114,7 +111,7 @@ struct [[nodiscard]] op
114111

115112
struct awaitable : awaitable_base
116113
{
117-
char buffer[BOOST_COBALT_SBO_BUFFER_SIZE];
114+
alignas(alignof(std::max_align_t)) char buffer[BOOST_COBALT_SBO_BUFFER_SIZE];
118115
detail::sbo_resource resource{buffer, sizeof(buffer)};
119116

120117
awaitable(op<Args...> * op_) : awaitable_base(op_, &resource) {}

0 commit comments

Comments
 (0)