| From: | Greg Burd <greg(at)burd(dot)me> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Cc: | zhong950419(at)gmail(dot)com, greg(at)burd(dot)me, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Trying out <stdatomic.h> |
| Date: | 2026-10-21 19:16:56 |
| Message-ID: | atkB3a-Ed_od6FMZ@floki |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, 20 Oct 2026 20:56:45 -0400, shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> Hi Greg,
Hi Shihao,
Thanks very much for testing this on macOS arm64 and for two very
specific reports -- both were real, and both are fixed in v9 attached
(rebased on master df64d6e984b).
>
> 1. The header has a C++23 branch, and that branch fails to build
> when an extension includes it inside extern "C", which is the usual
> way:
>
> extern "C" {
> #include "postgres.h"
> #include "storage/lwlock.h"
> }
>
> clang 17 failed with "templates must have C++ linkage".
Confirmed and fixed.
> 2. pg_atomic_test_set_flag_impl uses atomic_fetch_and_explicit(). On
> x86 clang turns that into a lock cmpxchg loop, while master uses a
> single xchg.
>
> Maybe use atomic_exchange_explicit(ptr, 0, memory_order_acquire) ?
Adopted, thank you. Exchange is the better way to write it regardless.
> Thanks,
> Shihao
best.
-greg
| Attachment | Content-Type | Size |
|---|---|---|
| v9-0003-NOT-FOR-MERGE.-yet.-Remove-traditional-atomics-us.patch | text/plain | 88.6 KB |
| v9-0001-Add-an-opt-in-C11-stdatomic.h-implementation-of-t.patch | text/plain | 65.0 KB |
| v9-0002-NOT-FOR-MERGE-Add-atomics-benchmark-harness.patch | text/plain | 91.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Bharath Rupireddy | 2026-10-21 19:15:00 | Re: Introduce XID age based replication slot invalidation |