Fix CheckCxxAtomic to detect more accurately
authorEric Long <i@hack3r.moe>
Mon, 9 Oct 2023 06:53:31 +0000 (07:53 +0100)
committerThomas Goirand <zigo@debian.org>
Mon, 9 Oct 2023 06:53:31 +0000 (07:53 +0100)
Last-Update: 2023-09-29

Some platforms like riscv64 does not have full support for atomic primitives,
yet passes the test. Adding operator++ fixes this issue.

Gbp-Pq: Name fix-CheckCxxAtomic-riscv64.patch

cmake/modules/CheckCxxAtomic.cmake

index 833977b758b24fc6748a622595386e0970cf5012..2a4154e3d8335b9586418fa3cbdbb876cf751270 100644 (file)
@@ -11,7 +11,8 @@ function(check_cxx_atomics var)
 #include <atomic>
 #include <cstdint>
 
-#if defined(__s390x__) || (defined(__mips__) && _MIPS_SIM ==_ABI64 )
+#if defined(__s390x__) || (defined(__mips__) && _MIPS_SIM ==_ABI64 ) \
+       || (defined __riscv && __riscv_xlen == 64)
 // Boost needs 16-byte atomics for tagged pointers.
 // These are implemented via inline instructions on the platform
 // if 16-byte alignment can be proven, and are delegated to libatomic
@@ -32,7 +33,7 @@ int main() {
   std::atomic<uint16_t> w2;
   std::atomic<uint32_t> w4;
   std::atomic<uint64_t> w8;
-  return w1 + w2 + w4 + w8;
+  return ++w1 + ++w2 + ++w4 + ++w8;
 }
 " ${var})
 endfunction(check_cxx_atomics)