[libcxx-commits] [libcxx] [libcxx] Implementation of non lock-free atomic shared_ptr (PR #194215)

Vladislav Semykin via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 26 05:53:03 PDT 2026


ViNN280801 wrote:

Thank you for the review!

All suggestions have been applied:
- `_NOEXCEPT` ---> `noexcept` throughout;
- `[[nodiscard]]` added to `is_lock_free()` for both specializations;
- test guards changed to `REQUIRES: std-at-least-c++20`;
- status pages, feature-test macro, and version header updated.

**P0718R2 coverage:**
- `atomic<shared_ptr<T>>` and `atomic<weak_ptr<T>>` - complete;
- `wait`/`notify_one`/`notify_all` (P1135R6) - complete;
- LWG 3661 (`constinit atomic<shared_ptr<T>> a(nullptr)`) - complete;
- LWG 3893 (`a = nullptr`) - complete.

**Limitations of this implementation:** This is a lock-based implementation (`is_always_lock_free == false`).  `memory_order` parameters are accepted but the spinlock effectively enforces seq_cst semantics throughout. A lock-free follow-up (DWCAS or hazard-pointer based) is currenlty under investigation.

I'll also rebase on top of #87111 once it's reopened.

**Regression testing after changes**:

```bash
ninja -C build check-cxx
```

```log
[7/8] Running libcxx tests
llvm-lit: /home/loveit0/Documents/Prog/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) All available features: add-latomic-workaround, buildhost=linux, c++26, c++experimental, can-create-symlinks, character-conversion-warnings, clang, clang-23, clang-23.0, clang-23.0.0, diagnose-if-support, enable-benchmarks=dry-run, gcc-style-warnings, has-1024-bit-atomics, has-64-bit-atomics, has-fblocks, has-fconstexpr-steps, has-unix-headers, host-has-gdb-with-python, large_tests, libcpp-abi-version=1, libcpp-hardening-mode=none, libcpp-has-no-availability-markup, libcpp-has-thread-api-pthread, linux, locale.en_US.UTF-8, locale.ru_RU.UTF-8, long_tests, objective-c++, optimization=none, std-at-least-c++03, std-at-least-c++11, std-at-least-c++14, std-at-least-c++17, std-at-least-c++20, std-at-least-c++23, std-at-least-c++26, stdlib=libc++, stdlib=llvm-libc++, target=x86_64-unknown-linux-gnu, verify-support

Testing Time: 1121.51s

Total Discovered Tests: 11409
  Unsupported      :  1029 (9.02%)
  Passed           : 10353 (90.74%)
  Expectedly Failed:    27 (0.24%)
./build/bin/llvm-lit -sv build/runtimes/runtimes-bins/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic
llvm-lit: /home/loveit0/Documents/Prog/llvm-project/libcxx/utils/libcxx/test/config.py:24: note: (llvm-libc++-shared.cfg.in) All available features: add-latomic-workaround, buildhost=linux, c++26, c++experimental, can-create-symlinks, character-conversion-warnings, clang, clang-23, clang-23.0, clang-23.0.0, diagnose-if-support, enable-benchmarks=run, gcc-style-warnings, has-1024-bit-atomics, has-64-bit-atomics, has-fblocks, has-fconstexpr-steps, has-unix-headers, host-has-gdb-with-python, large_tests, libcpp-abi-version=1, libcpp-hardening-mode=none, libcpp-has-no-availability-markup, libcpp-has-thread-api-pthread, linux, locale.en_US.UTF-8, locale.ru_RU.UTF-8, long_tests, objective-c++, optimization=none, std-at-least-c++03, std-at-least-c++11, std-at-least-c++14, std-at-least-c++17, std-at-least-c++20, std-at-least-c++23, std-at-least-c++26, stdlib=libc++, stdlib=llvm-libc++, target=x86_64-unknown-linux-gnu, verify-support

Testing Time: 1.35s

Total Discovered Tests: 18
  Passed: 18 (100.00%)
```

Also, I added necessary headers for Armv7 and Armv8 in tests, but how to correctly handle `Timeout: Reached timeout of 1500 seconds` on AIX (64 bit) and FreeBSD 13 amd64?


https://github.com/llvm/llvm-project/pull/194215


More information about the libcxx-commits mailing list