File 2019-cmake-modules-CheckCxxAtomic.cmake.patch of Package ceph-ceph-15.2.17

diff --git a/cmake/modules/CheckCxxAtomic.cmake b/cmake/modules/CheckCxxAtomic.cmake
index f2d89cf3e0b..8bbeaa09f36 100644
--- a/cmake/modules/CheckCxxAtomic.cmake
+++ b/cmake/modules/CheckCxxAtomic.cmake
@@ -10,8 +10,9 @@ function(check_cxx_atomics var)
     check_cxx_source_compiles("
 #include <atomic>
 #include <cstdint>
+#include <cstddef>
 
-#if __s390x__
+#if defined(__SIZEOF_INT128__)
 // 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
@@ -21,13 +22,27 @@ function(check_cxx_atomics var)
 // We specifically test access via an otherwise unknown pointer here
 // to ensure we get the most complex case.  If this access can be
 // done without libatomic, then all accesses can be done.
-bool atomic16(std::atomic<unsigned __int128> *ptr)
+struct tagged_ptr {
+  int* ptr;
+  std::size_t tag;
+};
+
+void atomic16(std::atomic<tagged_ptr> *ptr) __attribute__ ((used));
+void atomic16(std::atomic<tagged_ptr> *ptr)
 {
-  return *ptr != 0;
+  tagged_ptr p{nullptr, 1};
+  ptr->store(p);
+  tagged_ptr f = ptr->load();
+  tagged_ptr new_tag{nullptr, 0};
+  ptr->compare_exchange_strong(f, new_tag);
 }
 #endif
 
 int main() {
+#if defined(__SIZEOF_INT128__)
+  std::atomic<tagged_ptr> ptr;
+  atomic16(&ptr);
+#endif
   std::atomic<uint8_t> w1;
   std::atomic<uint16_t> w2;
   std::atomic<uint32_t> w4;
openSUSE Build Service is sponsored by