ceph/0019-cmake-modules-CheckCxxAtomic.cmake.patch
Kaleb S. KEITHLEY 0434611ff3 ceph-17.2.1 GA
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2022-06-23 17:13:37 -04:00

44 lines
1.4 KiB
Diff

--- ceph-17.2.0-359-gb2fe9ec8/cmake/modules/CheckCxxAtomic.cmake.orig 2022-06-03 08:45:32.341075140 -0400
+++ ceph-17.2.0-359-gb2fe9ec8/cmake/modules/CheckCxxAtomic.cmake 2022-06-03 08:46:47.195775813 -0400
@@ -10,8 +10,9 @@
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
+#include <cstddef>
-#if defined(__s390x__) || defined(__mips__)
+#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 @@
// 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;