Support C++23 atomic shims#941
Conversation
In C++23, libc++'s <stdatomic.h> exposes std::atomic-based APIs instead of the C atomic interfaces that libdispatch's shim expects. That makes the existing _Atomic storage incompatible with atomic_load_explicit(), atomic_fetch_*(), and related calls when libdispatch is compiled as C++. Route libdispatch's internal atomic operations through private _dispatch_atomic_* aliases. Clang C++23 keeps _Atomic storage and uses __c11_atomic_* builtins directly. GCC C++23 uses plain storage with __atomic_* builtins so the shim does not depend on public <stdatomic.h> names in that mode. C and older C++ modes continue to use <stdatomic.h>.
|
ibdispatch is a C library, not a C++ library, so I'm not sure I understand why this should be needed. |
|
libdispatch is primarily a C library, but this repo does compile C++ code, including |
|
The C23/C++23 atomic incompatibility is real. It was also mentioned in the Hacker News comment:
This repository exposes that problem in practice. As I noted earlier, although libdispatch is primarily a C library, this repository does compile C++ code, including I suggest that the maintainers reconsider this issue/PR. |
In C++23, libc++'s
<stdatomic.h>exposesstd::atomic-based APIs instead of the C atomic interfaces that libdispatch's shim expects. That makes the existing_Atomicstorage incompatible withatomic_load_explicit(),atomic_fetch_*(), and related calls whenlibdispatchis compiled as C++.Route
libdispatch's internal atomic operations through private_dispatch_atomic_*aliases. Clang C++23 keeps_Atomicstorage and uses__c11_atomic_*builtins directly. GCC C++23 uses plain storage with__atomic_*builtins so the shim does not depend on public<stdatomic.h>names in that mode. C and older C++ modes continue to use<stdatomic.h>.Fixes #940.