[libcxx-commits] [PATCH] D97044: [libc++] [c++2b] [P0943] Add stdatomic.h header.

Marek Kurdej via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 24 00:24:11 PST 2021

curdeius added a comment.

I haven't found anything really different from https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdatomic.h.
There are some differences because e.g. `ATOMIC_VAR_INIT`, `atomic_init`, `kill_dependency` aren't mentioned in the paper, but nothing crucial IMO.
Concerning hosted/freestanding, I'm not sure I know what should be verified/done. The `clang/lib/Headers/stdatomic.h` just includes system's stdatomic.h in hosted env. when available.

What I am more afraid of is rather incompatibilities between C's `_Atomic` and C++'s `atomic`.
I haven't tested it extensively, but there were at least some differences in sizeof. And the standard (strongly) recommends to make them compatible (cf. https://eel.is/c++draft/stdatomic.h.syn#4).

Comment at: libcxx/include/stdatomic.h:133
+#define _Atomic(T) _VSTD::atomic<T>
Should I use `::_VSTD::atomic<T>` or should we go for changing `_VSTD` to `::std`? Or is it not worth the trouble?

Comment at: libcxx/test/std/atomics/stdatomic.h.syn/types.pass.cpp:21
+// #define ATOMIC_CHAR_LOCK_FREE see below
+// TODO: No ATOMIC_CHAR8_T_LOCK_FREE, but atomic_char8_t is present in synopis?? NB that atomic_char8_t is not in C11. See http://eel.is/c++draft/stdatomic.h.syn.
+// #define ATOMIC_CHAR16_T_LOCK_FREE see below
Anyone has an idea about this? Is this an omission in the standard (given that it includes `atomic_char8_t`) or it should match C11 and so omit both `ATOMIC_CHAR8_T_LOCK_FREE` and `atomic_char8_t`?

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list