|
20 | 20 | \ref{atomics.types.generic} & Class template \tcode{atomic} & \\
|
21 | 21 | \ref{atomics.nonmembers} & Non-member functions & \\
|
22 | 22 | \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>} \\ |
24 | 25 | \end{libsumtab}
|
25 | 26 |
|
26 | 27 | \rSec1[atomics.syn]{Header \tcode{<atomic>} synopsis}
|
|
3702 | 3703 | that \tcode{atomic_thread_fence} would have inserted are not emitted.
|
3703 | 3704 | \end{note}
|
3704 | 3705 | \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. |
0 commit comments