[libcxx-commits] [libcxx] [libc++] Implement P2545R4 Read-Copy Update (RCU) (PR #175451)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Sep 19 11:59:44 PDT 2026


================
@@ -0,0 +1,242 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Watomic-alignment")
----------------
huixie90 wrote:

The CI warns that 16 bytes atomic operation is not lockfree (under some platforms) and this implementation uses 16 bytes atomic (which is lock free on my platform).

I have a different implementation that only uses 8 bytes atomics
https://github.com/llvm/llvm-project/pull/224853/changes/16a9863b2da5a2e32b39796aded5deb871357a18

The trick is to let the node itself to contain the tail

```
struct __rcu_node {
  using __cb_type        = void(__rcu_node*);
  __cb_type* __callback_ = [](__rcu_node*) {};
  __rcu_node* __next_    = nullptr;
  __rcu_node* __tail_if_atomic_head = nullptr;
};

```

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


More information about the libcxx-commits mailing list