diff --git a/async_simple/Executor.h b/async_simple/Executor.h index 5e6feaf9b..3e6874e00 100644 --- a/async_simple/Executor.h +++ b/async_simple/Executor.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "async_simple/MoveWrapper.h" #include "async_simple/experimental/coroutine.h" diff --git a/async_simple/coro/Lazy.h b/async_simple/coro/Lazy.h index bbd9e355c..23f07efe2 100644 --- a/async_simple/coro/Lazy.h +++ b/async_simple/coro/Lazy.h @@ -140,8 +140,12 @@ class LazyPromiseBase { template class LazyPromise : public LazyPromiseBase { public: - static_assert(alignof(T) <= alignof(::max_align_t), +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-alignof-expression" + static_assert(alignof(T) <= alignof(std::max_align_t), "async_simple doesn't allow Lazy with over aligned object"); +#endif LazyPromise() noexcept {} ~LazyPromise() noexcept {} diff --git a/async_simple/coro/Semaphore.h b/async_simple/coro/Semaphore.h index d8ed443ec..f4ae50296 100644 --- a/async_simple/coro/Semaphore.h +++ b/async_simple/coro/Semaphore.h @@ -17,6 +17,7 @@ #define ASYNC_SIMPLE_CORO_SEMAHORE_H #include +#include #include "async_simple/coro/ConditionVariable.h" #include "async_simple/coro/SpinLock.h" diff --git a/async_simple/experimental/coroutine.h b/async_simple/experimental/coroutine.h index b01bfccc6..de60ee67f 100644 --- a/async_simple/experimental/coroutine.h +++ b/async_simple/experimental/coroutine.h @@ -57,7 +57,8 @@ template struct hash>; // And the outdated is available for clang only(need to // exclude msvc). #if (__cplusplus <= 201703L && !defined(_MSC_VER)) || \ - (defined(__clang__) && defined(__GLIBCXX__)) + (defined(__clang__) && defined(__GLIBCXX__) && \ + (__GLIBCXX__ < 20210408)) #define USE_SELF_DEFINED_COROUTINE #endif diff --git a/async_simple/uthread/Async.h b/async_simple/uthread/Async.h index a8c6ccae6..c3556a449 100644 --- a/async_simple/uthread/Async.h +++ b/async_simple/uthread/Async.h @@ -36,6 +36,7 @@ #include #include +#include #include "async_simple/uthread/Uthread.h" namespace async_simple { diff --git a/async_simple/util/ThreadPool.h b/async_simple/util/ThreadPool.h index 52073e1e0..c3bb75002 100644 --- a/async_simple/util/ThreadPool.h +++ b/async_simple/util/ThreadPool.h @@ -30,8 +30,10 @@ #include #include #include +#include #include "async_simple/util/Queue.h" + namespace async_simple::util { class ThreadPool { public: @@ -186,7 +188,7 @@ inline ThreadPool::ERROR_TYPE ThreadPool::scheduleById(std::function fn, } } - id = rand() % _threadNum; + id = std::rand() % _threadNum; _queues[id].push( WorkItem{/*canSteal = */ _enableWorkSteal, std::move(fn)}); } else {