[libcxx-commits] [libcxx] [libc++] Simplify features for detecting atomics' support. (PR #75553)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 29 14:25:00 PST 2024
================
@@ -183,25 +183,26 @@ def _getAndroidDeviceApi(cfg):
actions=[AddLinkFlag("-latomic")],
),
Feature(
- name="non-lockfree-atomics",
+ name="has-64-bit-atomics",
when=lambda cfg: sourceBuilds(
cfg,
"""
#include <atomic>
- struct Large { int storage[100]; };
+ struct Large { char storage[64/8]; };
std::atomic<Large> x;
- int main(int, char**) { (void)x.load(); return 0; }
+ int main(int, char**) { (void)x.load(); x.is_lockfree(); return 0; }
""",
),
),
Feature(
- name="has-64-bit-atomics",
+ name="has-128-bit-atomics",
when=lambda cfg: sourceBuilds(
cfg,
"""
#include <atomic>
- std::atomic_uint64_t x;
- int main(int, char**) { (void)x.load(); return 0; }
+ struct Large { char storage[128/8]; };
+ std::atomic<Large> x;
+ int main(int, char**) { (void)x.load(); x.is_lockfree(); return 0; }
----------------
var-const wrote:
In It's possible for `x.load()` to succeed and for `x.is_lockfree()` to fail (with a linker error, from what I've seen).
https://github.com/llvm/llvm-project/pull/75553
More information about the libcxx-commits
mailing list