File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,9 @@ function(check_cxx_atomics var)
1010 check_cxx_source_compiles("
1111#include <atomic>
1212#include <cstdint>
13+ #include <cstddef>
1314
14- #if defined(__s390x__) || defined(__mips__ )
15+ #if defined(__SIZEOF_INT128__ )
1516// Boost needs 16-byte atomics for tagged pointers.
1617// These are implemented via inline instructions on the platform
1718// if 16-byte alignment can be proven, and are delegated to libatomic
@@ -21,13 +22,26 @@ function(check_cxx_atomics var)
2122// We specifically test access via an otherwise unknown pointer here
2223// to ensure we get the most complex case. If this access can be
2324// done without libatomic, then all accesses can be done.
24- bool atomic16(std::atomic<unsigned __int128> *ptr)
25+ struct tagged_ptr {
26+ int* ptr;
27+ std::size_t tag;
28+ };
29+
30+ void atomic16(std::atomic<tagged_ptr> *ptr)
2531{
26- return *ptr != 0;
32+ tagged_ptr p{nullptr, 1};
33+ ptr->store(p);
34+ tagged_ptr f = ptr->load();
35+ tagged_ptr new_tag{nullptr, 0};
36+ ptr->compare_exchange_strong(f, new_tag);
2737}
2838#endif
2939
3040int main() {
41+ #if defined(__SIZEOF_INT128__)
42+ std::atomic<tagged_ptr> ptr;
43+ atomic16(&ptr);
44+ #endif
3145 std::atomic<uint8_t> w1;
3246 std::atomic<uint16_t> w2;
3347 std::atomic<uint32_t> w4;
You can’t perform that action at this time.
0 commit comments