Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/header/stdatomic.h"

From cppreference.com
< cpp‎ | header
m (dsc)
m (- std::atomic (though not providing std::atomic is unimplementable IMO); fmt)
Line 14: Line 14:
 
{{dsc inc | cpp/atomic/dsc ATOMIC_FLAG_INIT}}-->
 
{{dsc inc | cpp/atomic/dsc ATOMIC_FLAG_INIT}}-->
 
{{dsc h1|Types}}
 
{{dsc h1|Types}}
{{dsc inc | cpp/atomic/dsc atomic}}
 
 
{{dsc inc | cpp/atomic/dsc atomic_flag}}
 
{{dsc inc | cpp/atomic/dsc atomic_flag}}
 
{{dsc inc | cpp/atomic/dsc memory_order}}
 
{{dsc inc | cpp/atomic/dsc memory_order}}
Line 40: Line 39:
 
{{source|1=
 
{{source|1=
 
template<class T>
 
template<class T>
using __std_atomic = std::atomic<T>; // exposition only
+
  using __std_atomic = std::atomic<T>;       // exposition only
 +
 
 
#define _Atomic(T) __std_atomic<T>
 
#define _Atomic(T) __std_atomic<T>
  
#define ATOMIC_BOOL_LOCK_FREE /* see description */
+
#define ATOMIC_BOOL_LOCK_FREE // see description
#define ATOMIC_CHAR_LOCK_FREE /* see description */
+
#define ATOMIC_CHAR_LOCK_FREE // see description
#define ATOMIC_CHAR16_T_LOCK_FREE /* see description */
+
#define ATOMIC_CHAR16_T_LOCK_FREE // see description
#define ATOMIC_CHAR32_T_LOCK_FREE /* see description */
+
#define ATOMIC_CHAR32_T_LOCK_FREE // see description
#define ATOMIC_WCHAR_T_LOCK_FREE /* see description */
+
#define ATOMIC_WCHAR_T_LOCK_FREE // see description
#define ATOMIC_SHORT_LOCK_FREE /* see description */
+
#define ATOMIC_SHORT_LOCK_FREE // see description
#define ATOMIC_INT_LOCK_FREE /* see description */
+
#define ATOMIC_INT_LOCK_FREE // see description
#define ATOMIC_LONG_LOCK_FREE /* see description */
+
#define ATOMIC_LONG_LOCK_FREE // see description
#define ATOMIC_LLONG_LOCK_FREE /* see description */
+
#define ATOMIC_LLONG_LOCK_FREE // see description
#define ATOMIC_POINTER_LOCK_FREE /* see description */
+
#define ATOMIC_POINTER_LOCK_FREE // see description
  
using std::memory_order; // see description
+
using std::memory_order;               // see description
using std::memory_order_relaxed; // see description
+
using std::memory_order_relaxed;       // see description
using std::memory_order_consume; // see description
+
using std::memory_order_consume;       // see description
using std::memory_order_acquire; // see description
+
using std::memory_order_acquire;       // see description
using std::memory_order_release; // see description
+
using std::memory_order_release;       // see description
using std::memory_order_acq_rel; // see description
+
using std::memory_order_acq_rel;       // see description
using std::memory_order_seq_cst; // see description
+
using std::memory_order_seq_cst;       // see description
  
using std::atomic_flag; // see description
+
using std::atomic_flag;                 // see description
  
using std::atomic_bool; // see description
+
using std::atomic_bool;                 // see description
using std::atomic_char; // see description
+
using std::atomic_char;                 // see description
using std::atomic_schar; // see description
+
using std::atomic_schar;               // see description
using std::atomic_uchar; // see description
+
using std::atomic_uchar;               // see description
using std::atomic_short; // see description
+
using std::atomic_short;               // see description
using std::atomic_ushort; // see description
+
using std::atomic_ushort;               // see description
using std::atomic_int; // see description
+
using std::atomic_int;                 // see description
using std::atomic_uint; // see description
+
using std::atomic_uint;                 // see description
using std::atomic_long; // see description
+
using std::atomic_long;                 // see description
using std::atomic_ulong; // see description
+
using std::atomic_ulong;               // see description
using std::atomic_llong; // see description
+
using std::atomic_llong;               // see description
using std::atomic_ullong; // see description
+
using std::atomic_ullong;               // see description
using std::atomic_char8_t; // see description
+
using std::atomic_char8_t;             // see description
using std::atomic_char16_t; // see description
+
using std::atomic_char16_t;             // see description
using std::atomic_char32_t; // see description
+
using std::atomic_char32_t;             // see description
using std::atomic_wchar_t; // see description
+
using std::atomic_wchar_t;             // see description
using std::atomic_int8_t; // see description
+
using std::atomic_int8_t;               // see description
using std::atomic_uint8_t; // see description
+
using std::atomic_uint8_t;             // see description
using std::atomic_int16_t; // see description
+
using std::atomic_int16_t;             // see description
using std::atomic_uint16_t; // see description
+
using std::atomic_uint16_t;             // see description
using std::atomic_int32_t; // see description
+
using std::atomic_int32_t;             // see description
using std::atomic_uint32_t; // see description
+
using std::atomic_uint32_t;             // see description
using std::atomic_int64_t; // see description
+
using std::atomic_int64_t;             // see description
using std::atomic_uint64_t; // see description
+
using std::atomic_uint64_t;             // see description
using std::atomic_int_least8_t; // see description
+
using std::atomic_int_least8_t;         // see description
using std::atomic_uint_least8_t; // see description
+
using std::atomic_uint_least8_t;       // see description
using std::atomic_int_least16_t; // see description
+
using std::atomic_int_least16_t;       // see description
using std::atomic_uint_least16_t; // see description
+
using std::atomic_uint_least16_t;       // see description
using std::atomic_int_least32_t; // see description
+
using std::atomic_int_least32_t;       // see description
using std::atomic_uint_least32_t; // see description
+
using std::atomic_uint_least32_t;       // see description
using std::atomic_int_least64_t; // see description
+
using std::atomic_int_least64_t;       // see description
using std::atomic_uint_least64_t; // see description
+
using std::atomic_uint_least64_t;       // see description
using std::atomic_int_fast8_t; // see description
+
using std::atomic_int_fast8_t;         // see description
using std::atomic_uint_fast8_t; // see description
+
using std::atomic_uint_fast8_t;         // see description
using std::atomic_int_fast16_t; // see description
+
using std::atomic_int_fast16_t;         // see description
using std::atomic_uint_fast16_t; // see description
+
using std::atomic_uint_fast16_t;       // see description
using std::atomic_int_fast32_t; // see description
+
using std::atomic_int_fast32_t;         // see description
using std::atomic_uint_fast32_t; // see description
+
using std::atomic_uint_fast32_t;       // see description
using std::atomic_int_fast64_t; // see description
+
using std::atomic_int_fast64_t;         // see description
using std::atomic_uint_fast64_t; // see description
+
using std::atomic_uint_fast64_t;       // see description
using std::atomic_intptr_t; // see description
+
using std::atomic_intptr_t;             // see description
using std::atomic_uintptr_t; // see description
+
using std::atomic_uintptr_t;           // see description
using std::atomic_size_t; // see description
+
using std::atomic_size_t;               // see description
using std::atomic_ptrdiff_t; // see description
+
using std::atomic_ptrdiff_t;           // see description
using std::atomic_intmax_t; // see description
+
using std::atomic_intmax_t;             // see description
using std::atomic_uintmax_t; // see description
+
using std::atomic_uintmax_t;           // see description
  
using std::atomic_is_lock_free; // see description
+
using std::atomic_is_lock_free;                         // see description
using std::atomic_load; // see description
+
using std::atomic_load;                                 // see description
using std::atomic_load_explicit; // see description
+
using std::atomic_load_explicit;                       // see description
using std::atomic_store; // see description
+
using std::atomic_store;                               // see description
using std::atomic_store_explicit; // see description
+
using std::atomic_store_explicit;                       // see description
using std::atomic_exchange; // see description
+
using std::atomic_exchange;                             // see description
using std::atomic_exchange_explicit; // see description
+
using std::atomic_exchange_explicit;                   // see description
using std::atomic_compare_exchange_strong; // see description
+
using std::atomic_compare_exchange_strong;             // see description
using std::atomic_compare_exchange_strong_explicit; // see description
+
using std::atomic_compare_exchange_strong_explicit;     // see description
using std::atomic_compare_exchange_weak; // see description
+
using std::atomic_compare_exchange_weak;               // see description
using std::atomic_compare_exchange_weak_explicit; // see description
+
using std::atomic_compare_exchange_weak_explicit;       // see description
using std::atomic_fetch_add; // see description
+
using std::atomic_fetch_add;                           // see description
using std::atomic_fetch_add_explicit; // see description
+
using std::atomic_fetch_add_explicit;                   // see description
using std::atomic_fetch_sub; // see description
+
using std::atomic_fetch_sub;                           // see description
using std::atomic_fetch_sub_explicit; // see description
+
using std::atomic_fetch_sub_explicit;                   // see description
using std::atomic_fetch_or; // see description
+
using std::atomic_fetch_or;                             // see description
using std::atomic_fetch_or_explicit; // see description
+
using std::atomic_fetch_or_explicit;                   // see description
using std::atomic_fetch_and; // see description
+
using std::atomic_fetch_and;                           // see description
using std::atomic_fetch_and_explicit; // see description
+
using std::atomic_fetch_and_explicit;                   // see description
using std::atomic_flag_test_and_set; // see description
+
using std::atomic_flag_test_and_set;                   // see description
using std::atomic_flag_test_and_set_explicit; // see description
+
using std::atomic_flag_test_and_set_explicit;           // see description
using std::atomic_flag_clear; // see description
+
using std::atomic_flag_clear;                           // see description
using std::atomic_flag_clear_explicit; // see description
+
using std::atomic_flag_clear_explicit;                 // see description
  
using std::atomic_thread_fence; // see description
+
using std::atomic_thread_fence;                         // see description
using std::atomic_signal_fence; // see description
+
using std::atomic_signal_fence;                         // see description
 
}}
 
}}
  
 
{{langlinks|es|ja|ru|zh}}
 
{{langlinks|es|ja|ru|zh}}

Revision as of 01:24, 14 December 2020

 
 
Standard library headers
 

This header was originally in the C standard library.

This header is part of the atomic operations library.

It is unspecified whether <stdatomic.h> provides any declarations in namespace std.

Contents

Macros

(C++23)
compatibility macro such that _Atomic(T) is identical to std::atomic<T>
(function macro) [edit]

Types

the lock-free boolean atomic type
(class) [edit]
defines memory ordering constraints for the given atomic operation
(enum) [edit]
std::atomic<bool>
(typedef) [edit]
std::atomic<char>
(typedef) [edit]
std::atomic<signed char>
(typedef) [edit]
std::atomic<unsigned char>
(typedef) [edit]
std::atomic<short>
(typedef) [edit]
std::atomic<unsigned short>
(typedef) [edit]
std::atomic<int>
(typedef) [edit]
std::atomic<unsigned int>
(typedef) [edit]
std::atomic<long>
(typedef) [edit]
std::atomic<unsigned long>
(typedef) [edit]
std::atomic<long long>
(typedef) [edit]
std::atomic<unsigned long long>
(typedef) [edit]
std::atomic<char8_t>
(typedef) [edit]
std::atomic<char16_t>
(typedef) [edit]
std::atomic<char32_t>
(typedef) [edit]
std::atomic<wchar_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int8_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint8_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int16_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint16_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int32_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint32_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int64_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint64_t>
(typedef) [edit]
std::atomic<std::int_least8_t>
(typedef) [edit]
std::atomic<std::uint_least8_t>
(typedef) [edit]
std::atomic<std::int_least16_t>
(typedef) [edit]
std::atomic<std::uint_least16_t>
(typedef) [edit]
std::atomic<std::int_least32_t>
(typedef) [edit]
std::atomic<std::uint_least32_t>
(typedef) [edit]
std::atomic<std::int_least64_t>
(typedef) [edit]
std::atomic<std::uint_least64_t>
(typedef) [edit]
std::atomic<std::int_fast8_t>
(typedef) [edit]
std::atomic<std::uint_fast8_t>
(typedef) [edit]
std::atomic<std::int_fast16_t>
(typedef) [edit]
std::atomic<std::uint_fast16_t>
(typedef) [edit]
std::atomic<std::int_fast32_t>
(typedef) [edit]
std::atomic<std::uint_fast32_t>
(typedef) [edit]
std::atomic<std::int_fast64_t>
(typedef) [edit]
std::atomic<std::uint_fast64_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::intptr_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uintptr_t>
(typedef) [edit]
std::atomic<std::size_t>
(typedef) [edit]
std::atomic<std::ptrdiff_t>
(typedef) [edit]
std::atomic<std::intmax_t>
(typedef) [edit]
std::atomic<std::uintmax_t>
(typedef) [edit]

Functions

checks if the atomic type's operations are lock-free
(function template) [edit]
atomically replaces the value of the atomic object with a non-atomic argument
(function template) [edit]
atomically obtains the value stored in an atomic object
(function template) [edit]
atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic
(function template) [edit]
atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not
(function template) [edit]
adds a non-atomic value to an atomic object and obtains the previous value of the atomic
(function template) [edit]
subtracts a non-atomic value from an atomic object and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of bitwise AND with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of bitwise OR with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of bitwise XOR with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
atomically sets the flag to true and returns its previous value
(function) [edit]
atomically sets the value of the flag to false
(function) [edit]
generic memory order-dependent fence synchronization primitive
(function) [edit]
fence between a thread and a signal handler executed in the same thread
(function) [edit]

Synopsis

template<class T>
  using __std_atomic = std::atomic<T>;        // exposition only
 
#define _Atomic(T) __std_atomic<T>
 
#define ATOMIC_BOOL_LOCK_FREE // see description
#define ATOMIC_CHAR_LOCK_FREE // see description
#define ATOMIC_CHAR16_T_LOCK_FREE // see description
#define ATOMIC_CHAR32_T_LOCK_FREE // see description
#define ATOMIC_WCHAR_T_LOCK_FREE // see description
#define ATOMIC_SHORT_LOCK_FREE // see description
#define ATOMIC_INT_LOCK_FREE // see description
#define ATOMIC_LONG_LOCK_FREE // see description
#define ATOMIC_LLONG_LOCK_FREE // see description
#define ATOMIC_POINTER_LOCK_FREE // see description
 
using std::memory_order;                // see description
using std::memory_order_relaxed;        // see description
using std::memory_order_consume;        // see description
using std::memory_order_acquire;        // see description
using std::memory_order_release;        // see description
using std::memory_order_acq_rel;        // see description
using std::memory_order_seq_cst;        // see description
 
using std::atomic_flag;                 // see description
 
using std::atomic_bool;                 // see description
using std::atomic_char;                 // see description
using std::atomic_schar;                // see description
using std::atomic_uchar;                // see description
using std::atomic_short;                // see description
using std::atomic_ushort;               // see description
using std::atomic_int;                  // see description
using std::atomic_uint;                 // see description
using std::atomic_long;                 // see description
using std::atomic_ulong;                // see description
using std::atomic_llong;                // see description
using std::atomic_ullong;               // see description
using std::atomic_char8_t;              // see description
using std::atomic_char16_t;             // see description
using std::atomic_char32_t;             // see description
using std::atomic_wchar_t;              // see description
using std::atomic_int8_t;               // see description
using std::atomic_uint8_t;              // see description
using std::atomic_int16_t;              // see description
using std::atomic_uint16_t;             // see description
using std::atomic_int32_t;              // see description
using std::atomic_uint32_t;             // see description
using std::atomic_int64_t;              // see description
using std::atomic_uint64_t;             // see description
using std::atomic_int_least8_t;         // see description
using std::atomic_uint_least8_t;        // see description
using std::atomic_int_least16_t;        // see description
using std::atomic_uint_least16_t;       // see description
using std::atomic_int_least32_t;        // see description
using std::atomic_uint_least32_t;       // see description
using std::atomic_int_least64_t;        // see description
using std::atomic_uint_least64_t;       // see description
using std::atomic_int_fast8_t;          // see description
using std::atomic_uint_fast8_t;         // see description
using std::atomic_int_fast16_t;         // see description
using std::atomic_uint_fast16_t;        // see description
using std::atomic_int_fast32_t;         // see description
using std::atomic_uint_fast32_t;        // see description
using std::atomic_int_fast64_t;         // see description
using std::atomic_uint_fast64_t;        // see description
using std::atomic_intptr_t;             // see description
using std::atomic_uintptr_t;            // see description
using std::atomic_size_t;               // see description
using std::atomic_ptrdiff_t;            // see description
using std::atomic_intmax_t;             // see description
using std::atomic_uintmax_t;            // see description
 
using std::atomic_is_lock_free;                         // see description
using std::atomic_load;                                 // see description
using std::atomic_load_explicit;                        // see description
using std::atomic_store;                                // see description
using std::atomic_store_explicit;                       // see description
using std::atomic_exchange;                             // see description
using std::atomic_exchange_explicit;                    // see description
using std::atomic_compare_exchange_strong;              // see description
using std::atomic_compare_exchange_strong_explicit;     // see description
using std::atomic_compare_exchange_weak;                // see description
using std::atomic_compare_exchange_weak_explicit;       // see description
using std::atomic_fetch_add;                            // see description
using std::atomic_fetch_add_explicit;                   // see description
using std::atomic_fetch_sub;                            // see description
using std::atomic_fetch_sub_explicit;                   // see description
using std::atomic_fetch_or;                             // see description
using std::atomic_fetch_or_explicit;                    // see description
using std::atomic_fetch_and;                            // see description
using std::atomic_fetch_and_explicit;                   // see description
using std::atomic_flag_test_and_set;                    // see description
using std::atomic_flag_test_and_set_explicit;           // see description
using std::atomic_flag_clear;                           // see description
using std::atomic_flag_clear_explicit;                  // see description
 
using std::atomic_thread_fence;                         // see description
using std::atomic_signal_fence;                         // see description