Page MenuHomePhabricator

[libc++] [C++2b] [P0943] Add stdatomic.h header.
Needs ReviewPublic

Authored by curdeius on Feb 19 2021, 4:54 AM.


Group Reviewers
Restricted Project

Diff Detail

Event Timeline

curdeius created this revision.Feb 19 2021, 4:54 AM
curdeius requested review of this revision.Feb 19 2021, 4:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2021, 4:54 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
curdeius edited the summary of this revision. (Show Details)Feb 19 2021, 4:55 AM
curdeius edited the summary of this revision. (Show Details)
curdeius updated this revision to Diff 324954.Feb 19 2021, 4:58 AM

Fix C++ includes in C.

Harbormaster completed remote builds in B89909: Diff 324953.
curdeius updated this revision to Diff 325006.Feb 19 2021, 9:07 AM

Guard stdatomic.h version test on libcpp-has-no-threads.

Mordante added inline comments.

Copy-paste of wchar.h.

curdeius added inline comments.Feb 19 2021, 9:14 AM

Thanks for pointing this. I'll fix it in the next revision.

jfb added a comment.Feb 19 2021, 10:04 AM

Does it line up property with ./clang/lib/Headers/stdatomic.h ? I think this other header might need some adjustment as well, for example the hosted/freestanding part.

I haven't found anything really different from
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.


Should I use ::_VSTD::atomic<T> or should we go for changing _VSTD to ::std? Or is it not worth the trouble?


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?

curdeius retitled this revision from [libc++] [c++2b] [P0943] Add stdatomic.h header. to [libc++] [C++2b] [P0943] Add stdatomic.h header..Feb 24 2021, 1:49 AM