Skip to content

Commit 20c41d3

Browse files
committed
Merge 2020-11 LWG Motion 8
2 parents 04c217b + a99ab80 commit 20c41d3

File tree

5 files changed

+145
-7
lines changed

5 files changed

+145
-7
lines changed

source/atomics.tex

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
\ref{atomics.types.generic} & Class template \tcode{atomic} & \\
2121
\ref{atomics.nonmembers} & Non-member functions & \\
2222
\ref{atomics.flag} & Flag type and operations & \\
23-
\ref{atomics.fences} & Fences & \\
23+
\ref{atomics.fences} & Fences & \\ \rowsep
24+
\ref{stdatomic.h.syn} & C compatibility & \tcode{<stdatomic.h>} \\
2425
\end{libsumtab}
2526

2627
\rSec1[atomics.syn]{Header \tcode{<atomic>} synopsis}
@@ -3702,3 +3703,140 @@
37023703
that \tcode{atomic_thread_fence} would have inserted are not emitted.
37033704
\end{note}
37043705
\end{itemdescr}
3706+
3707+
\rSec1[stdatomic.h.syn]{C compatibility}
3708+
3709+
The header \libheaderdef{stdatomic.h} provides the following definitions:
3710+
3711+
\begin{codeblock}
3712+
template<class T>
3713+
using @\exposid{std-atomic}@ = std::atomic<T>; // exposition only
3714+
3715+
#define _Atomic(T) @\exposid{std-atomic}@<T>
3716+
3717+
#define ATOMIC_BOOL_LOCK_FREE @\seebelow@
3718+
#define ATOMIC_CHAR_LOCK_FREE @\seebelow@
3719+
#define ATOMIC_CHAR16_T_LOCK_FREE @\seebelow@
3720+
#define ATOMIC_CHAR32_T_LOCK_FREE @\seebelow@
3721+
#define ATOMIC_WCHAR_T_LOCK_FREE @\seebelow@
3722+
#define ATOMIC_SHORT_LOCK_FREE @\seebelow@
3723+
#define ATOMIC_INT_LOCK_FREE @\seebelow@
3724+
#define ATOMIC_LONG_LOCK_FREE @\seebelow@
3725+
#define ATOMIC_LLONG_LOCK_FREE @\seebelow@
3726+
#define ATOMIC_POINTER_LOCK_FREE @\seebelow@
3727+
3728+
using std::@\libglobal{memory_order}@ // \seebelow
3729+
using std::@\libglobal{memory_order_relaxed}@ // \seebelow
3730+
using std::@\libglobal{memory_order_consume}@ // \seebelow
3731+
using std::@\libglobal{memory_order_acquire}@ // \seebelow
3732+
using std::@\libglobal{memory_order_release}@ // \seebelow
3733+
using std::@\libglobal{memory_order_acq_rel}@ // \seebelow
3734+
using std::@\libglobal{memory_order_seq_cst}@ // \seebelow
3735+
3736+
using std::@\libglobal{atomic_flag}@ // \seebelow
3737+
3738+
using std::@\libglobal{atomic_bool}@ // \seebelow
3739+
using std::@\libglobal{atomic_char}@ // \seebelow
3740+
using std::@\libglobal{atomic_schar}@ // \seebelow
3741+
using std::@\libglobal{atomic_uchar}@ // \seebelow
3742+
using std::@\libglobal{atomic_short}@ // \seebelow
3743+
using std::@\libglobal{atomic_ushort}@ // \seebelow
3744+
using std::@\libglobal{atomic_int}@ // \seebelow
3745+
using std::@\libglobal{atomic_uint}@ // \seebelow
3746+
using std::@\libglobal{atomic_long}@ // \seebelow
3747+
using std::@\libglobal{atomic_ulong}@ // \seebelow
3748+
using std::@\libglobal{atomic_llong}@ // \seebelow
3749+
using std::@\libglobal{atomic_ullong}@ // \seebelow
3750+
using std::@\libglobal{atomic_char8_t}@ // \seebelow
3751+
using std::@\libglobal{atomic_char16_t}@ // \seebelow
3752+
using std::@\libglobal{atomic_char32_t}@ // \seebelow
3753+
using std::@\libglobal{atomic_wchar_t}@ // \seebelow
3754+
using std::@\libglobal{atomic_int8_t}@ // \seebelow
3755+
using std::@\libglobal{atomic_uint8_t}@ // \seebelow
3756+
using std::@\libglobal{atomic_int16_t}@ // \seebelow
3757+
using std::@\libglobal{atomic_uint16_t}@ // \seebelow
3758+
using std::@\libglobal{atomic_int32_t}@ // \seebelow
3759+
using std::@\libglobal{atomic_uint32_t}@ // \seebelow
3760+
using std::@\libglobal{atomic_int64_t}@ // \seebelow
3761+
using std::@\libglobal{atomic_uint64_t}@ // \seebelow
3762+
using std::@\libglobal{atomic_int_least8_t}@ // \seebelow
3763+
using std::@\libglobal{atomic_uint_least8_t}@ // \seebelow
3764+
using std::@\libglobal{atomic_int_least16_t}@ // \seebelow
3765+
using std::@\libglobal{atomic_uint_least16_t}@ // \seebelow
3766+
using std::@\libglobal{atomic_int_least32_t}@ // \seebelow
3767+
using std::@\libglobal{atomic_uint_least32_t}@ // \seebelow
3768+
using std::@\libglobal{atomic_int_least64_t}@ // \seebelow
3769+
using std::@\libglobal{atomic_uint_least64_t}@ // \seebelow
3770+
using std::@\libglobal{atomic_int_fast8_t}@ // \seebelow
3771+
using std::@\libglobal{atomic_uint_fast8_t}@ // \seebelow
3772+
using std::@\libglobal{atomic_int_fast16_t}@ // \seebelow
3773+
using std::@\libglobal{atomic_uint_fast16_t}@ // \seebelow
3774+
using std::@\libglobal{atomic_int_fast32_t}@ // \seebelow
3775+
using std::@\libglobal{atomic_uint_fast32_t}@ // \seebelow
3776+
using std::@\libglobal{atomic_int_fast64_t}@ // \seebelow
3777+
using std::@\libglobal{atomic_uint_fast64_t}@ // \seebelow
3778+
using std::@\libglobal{atomic_intptr_t}@ // \seebelow
3779+
using std::@\libglobal{atomic_uintptr_t}@ // \seebelow
3780+
using std::@\libglobal{atomic_size_t}@ // \seebelow
3781+
using std::@\libglobal{atomic_ptrdiff_t}@ // \seebelow
3782+
using std::@\libglobal{atomic_intmax_t}@ // \seebelow
3783+
using std::@\libglobal{atomic_uintmax_t}@ // \seebelow
3784+
3785+
using std::@\libglobal{atomic_is_lock_free}@ // \seebelow
3786+
using std::@\libglobal{atomic_load}@ // \seebelow
3787+
using std::@\libglobal{atomic_load_explicit}@ // \seebelow
3788+
using std::@\libglobal{atomic_store}@ // \seebelow
3789+
using std::@\libglobal{atomic_store_explicit}@ // \seebelow
3790+
using std::@\libglobal{atomic_exchange}@ // \seebelow
3791+
using std::@\libglobal{atomic_exchange_explicit}@ // \seebelow
3792+
using std::@\libglobal{atomic_compare_exchange_strong}@ // \seebelow
3793+
using std::@\libglobal{atomic_compare_exchange_strong_explicit}@ // \seebelow
3794+
using std::@\libglobal{atomic_compare_exchange_weak}@ // \seebelow
3795+
using std::@\libglobal{atomic_compare_exchange_weak_explicit}@ // \seebelow
3796+
using std::@\libglobal{atomic_fetch_add}@ // \seebelow
3797+
using std::@\libglobal{atomic_fetch_add_explicit}@ // \seebelow
3798+
using std::@\libglobal{atomic_fetch_sub}@ // \seebelow
3799+
using std::@\libglobal{atomic_fetch_sub_explicit}@ // \seebelow
3800+
using std::@\libglobal{atomic_fetch_or}@ // \seebelow
3801+
using std::@\libglobal{atomic_fetch_or_explicit}@ // \seebelow
3802+
using std::@\libglobal{atomic_fetch_and}@ // \seebelow
3803+
using std::@\libglobal{atomic_fetch_and_explicit}@ // \seebelow
3804+
using std::@\libglobal{atomic_flag_test_and_set}@ // \seebelow
3805+
using std::@\libglobal{atomic_flag_test_and_set_explicit}@ // \seebelow
3806+
using std::@\libglobal{atomic_flag_clear}@ // \seebelow
3807+
using std::@\libglobal{atomic_flag_clear_explicit}@ // \seebelow
3808+
3809+
using std::@\libglobal{atomic_thread_fence}@ // \seebelow
3810+
using std::@\libglobal{atomic_signal_fence}@ // \seebelow
3811+
\end{codeblock}
3812+
3813+
\pnum
3814+
Each \grammarterm{using-declaration} for some name $A$ in the synopsis above
3815+
makes available the same entity as \tcode{std::$A$}
3816+
declared in \libheaderrefx{atomic}{atomics.syn}.
3817+
Each macro listed above other than \tcode{_Atomic(T)}
3818+
is defined as in \libheader{atomic}.
3819+
It is unspecified whether \libheader{stdatomic.h} makes available
3820+
any declarations in namespace \tcode{std}.
3821+
3822+
\pnum
3823+
Each of the \grammarterm{using-declaration}s for
3824+
\tcode{int$N$_t}, \tcode{uint$N$_t}, \tcode{intptr_t}, and \tcode{uintptr_t}
3825+
listed above is defined if and only if the implementation defines
3826+
the corresponding typedef name in \ref{atomics.syn}.
3827+
3828+
\pnum
3829+
Neither the \tcode{_Atomic} macro,
3830+
nor any of the non-macro global namespace declarations,
3831+
are provided by any \Cpp{} standard library header
3832+
other than \libheader{stdatomic.h}.
3833+
3834+
\pnum
3835+
\recommended
3836+
Implementations should ensure
3837+
that C and \Cpp{} representations of atomic objects are compatible,
3838+
so that the same object can be accessed as both an \tcode{_Atomic(T)}
3839+
from C code and an \tcode{atomic<T>} from \Cpp{} code.
3840+
The representations should be the same, and
3841+
the mechanisms used to ensure atomicity and memory ordering
3842+
should be compatible.

source/compatibility.tex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,9 +2674,7 @@
26742674

26752675
\pnum
26762676
There are no \Cpp{} headers for the C standard library's headers
2677-
\libnoheader{stdatomic.h},
2678-
\libnoheader{stdnoreturn.h},
2679-
and \libnoheader{threads.h},
2677+
\libnoheader{stdnoreturn.h} and \libnoheader{threads.h},
26802678
nor are these headers from the C standard library headers themselves part of \Cpp{}.
26812679

26822680
\pnum

source/future.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,18 @@
243243
\libheaderdef{signal.h} \\
244244
\libheader{stdalign.h} \\
245245
\libheaderdef{stdarg.h} \\
246+
\libheader{stdatomic.h} \\
246247
\libheader{stdbool.h} \\
247248
\libheaderdef{stddef.h} \\
248-
\libheaderdef{stdint.h} \\
249249
\columnbreak
250+
\libheaderdef{stdint.h} \\
250251
\libheaderdef{stdio.h} \\
251252
\libheaderdef{stdlib.h} \\
252253
\libheaderdef{string.h} \\
253254
\libheader{tgmath.h} \\
254255
\libheaderdef{time.h} \\
255-
\libheaderdef{uchar.h} \\
256256
\columnbreak
257+
\libheaderdef{uchar.h} \\
257258
\libheaderdef{wchar.h} \\
258259
\libheaderdef{wctype.h} \\
259260
\end{multicolfloattable}
@@ -365,6 +366,7 @@
365366
\libdeprheaderref{complex.h},
366367
\libdeprheaderref{iso646.h},
367368
\libdeprheaderref{stdalign.h},\newline
369+
\libheaderref{stdatomic.h},
368370
\libdeprheaderref{stdbool.h}, and
369371
\libdeprheaderref{tgmath.h},
370372
each of

source/lib-intro.tex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,6 @@
10131013
\begin{footnote}
10141014
It is intentional that there is no \Cpp{} header
10151015
for any of these C headers:
1016-
\libnoheader{stdatomic.h},
10171016
\libnoheader{stdnoreturn.h},
10181017
\libnoheader{threads.h}.
10191018
\end{footnote}

source/support.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@
675675
#define @\defnlibxname{cpp_lib_ssize}@ 201902L // also in \libheader{iterator}
676676
#define @\defnlibxname{cpp_lib_stacktrace}@ 202011L // also in \libheader{stacktrace}
677677
#define @\defnlibxname{cpp_lib_starts_ends_with}@ 201711L // also in \libheader{string}, \libheader{string_view}
678+
#define @\defnlibxname{cpp_lib_stdatomic_h}@ 202011L // also in \libheader{stdatomic.h}
678679
#define @\defnlibxname{cpp_lib_string_contains}@ 202011L // also in \libheader{string}, \libheader{string_view}
679680
#define @\defnlibxname{cpp_lib_string_udls}@ 201304L // also in \libheader{string}
680681
#define @\defnlibxname{cpp_lib_string_view}@ 201803L // also in \libheader{string}, \libheader{string_view}

0 commit comments

Comments
 (0)