Commit ffd51f40 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook GitHub Bot

Make Coroutine.h compatible with libstdc++

Summary: Add support for both <coroutine> and <experimental/coroutine> headers. Also add support for __cpp_impl_coroutine (which is required by the standard).

Reviewed By: yfeldblum

Differential Revision: D26745085

fbshipit-source-id: 0bf932e2e30d5b105b1559d817563946fcd3b573
parent 30ba5616
......@@ -562,7 +562,8 @@ constexpr auto kCpplibVer = 0;
// <experimental/coroutine> which will conflict with anyone who wants to load
// the LLVM implementation of coroutines on Windows.
#define FOLLY_HAS_COROUTINES 0
#elif __cpp_coroutines >= 201703L && __has_include(<experimental/coroutine>)
#elif (__cpp_coroutines >= 201703L || __cpp_impl_coroutine >= 201902L) && \
(__has_include(<coroutine>) || __has_include(<experimental/coroutine>))
#define FOLLY_HAS_COROUTINES 1
// This is mainly to workaround bugs triggered by LTO, when stack allocated
// variables in await_suspend end up on a coroutine frame.
......
......@@ -27,7 +27,11 @@
#if FOLLY_HAS_COROUTINES
#if __has_include(<coroutine>)
#include <coroutine>
#else
#include <experimental/coroutine>
#endif
#endif // FOLLY_HAS_COROUTINES
......@@ -43,13 +47,19 @@
namespace folly::coro {
using std::experimental::coroutine_handle;
using std::experimental::coroutine_traits;
using std::experimental::noop_coroutine;
using std::experimental::noop_coroutine_handle;
using std::experimental::noop_coroutine_promise;
using std::experimental::suspend_always;
using std::experimental::suspend_never;
#if __has_include(<coroutine>)
namespace impl = std;
#else
namespace impl = std::experimental;
#endif
using impl::coroutine_handle;
using impl::coroutine_traits;
using impl::noop_coroutine;
using impl::noop_coroutine_handle;
using impl::noop_coroutine_promise;
using impl::suspend_always;
using impl::suspend_never;
// ready_awaitable
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment