From 8ab8b2fef97e3bf10148e471c4c12215c505f1af Mon Sep 17 00:00:00 2001 From: Eric Long Date: Thu, 8 Sep 2022 01:49:43 +0800 Subject: [PATCH] chore(cmake): Fix CheckAtomic.cmake to check sub-word atomics Platforms like riscv64 does have 32-bit or 64-bit atomics, but not 8-bit or 16-bit. Modified `check_working_cxx_atomics` to check sub-word atomics as well. --- cmake/CheckAtomic.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/CheckAtomic.cmake b/cmake/CheckAtomic.cmake index 609e230d4..718183b15 100644 --- a/cmake/CheckAtomic.cmake +++ b/cmake/CheckAtomic.cmake @@ -27,9 +27,12 @@ function(check_working_cxx_atomics varname) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11") CHECK_CXX_SOURCE_COMPILES(" #include -std::atomic x; +#include +std::atomic x1; +std::atomic x2; +std::atomic x3; int main() { - return x; + return ++x1 + ++x2 + ++x3; } " ${varname}) set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})