0% found this document useful (0 votes)
87 views3 pages

Atomic Operations Library - Cppreference

The document summarizes the C11 atomic operations library, which provides functions and macros for performing lock-free atomic operations on data shared between threads. It defines types like atomic_flag and memory_order for controlling memory access ordering, and provides functions for atomically loading, storing, exchanging, and operating on values of atomic types. The library is defined in the header file <stdatomic.h>.

Uploaded by

IoakeimTziakos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views3 pages

Atomic Operations Library - Cppreference

The document summarizes the C11 atomic operations library, which provides functions and macros for performing lock-free atomic operations on data shared between threads. It defines types like atomic_flag and memory_order for controlling memory access ordering, and provides functions for atomically loading, storing, exchanging, and operating on values of atomic types. The library is defined in the header file <stdatomic.h>.

Uploaded by

IoakeimTziakos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Atomic operations library

If the macro cons tant __STDC_NO_ATOMICS__(C11) is dened by the compiler, the header
<stdatomic.h>, the keyword _Atomic, and all of the names lis ted here are not provided.

Types
Dened in header <stdatomic.h>

denes memory ordering cons traints


memory_order(C11) (enum)
lock-free atomic boolean ag
atomic_flag(C11) (struc t)

Macros
Dened in header <stdatomic.h>

ATOMIC_BOOL_LOCK_FREE
ATOMIC_CHAR_LOCK_FREE
ATOMIC_CHAR16_T_LOCK_FREE
ATOMIC_CHAR32_T_LOCK_FREE
ATOMIC_WCHAR_T_LOCK_FREE
indicates that the given atomic type is lock-free
(C11)
(mac ro c onstant)
ATOMIC_SHORT_LOCK_FREE
ATOMIC_INT_LOCK_FREE
ATOMIC_LONG_LOCK_FREE
ATOMIC_LLONG_LOCK_FREE
ATOMIC_POINTER_LOCK_FREE
ATOMIC_FLAG_INIT(C11)
ATOMIC_VAR_INIT(C11)
kill_dependency(C11)

initializes a new atomic_flag


(mac ro c onstant)

initializes a new atomic object


(func tion mac ro)

breaks a dependency chain for memory_order_consume


(func tion mac ro)

Functions
Dened in header <stdatomic.h>

atomic_flag_test_and_set
(C11)
atomic_flag_test_and_set_explicit
atomic_flag_clear
(C11)
atomic_flag_clear_explicit
atomic_init(C11)
atomic_is_lock_free(C11)

s ets an atomic_ag to true and returns the old


value
(func tion)

s ets an atomic_ag to fals e


(func tion)

initializes an exis ting atomic object


(func tion)

indicates whether the atomic object is lock-free


(func tion)

atomic_store
(C11)
atomic_store_explicit

s tores a value in an atomic object

atomic_load
(C11)
atomic_load_explicit

reads a value from an atomic object

atomic_exchange
(C11)
atomic_exchange_explicit

s waps a value with the value of an atomic object

atomic_compare_exchange_strong
atomic_compare_exchange_strong_explicit
(C11)
atomic_compare_exchange_weak
atomic_compare_exchange_weak_explicit

s waps a value with the an atomic object if the old


value is what is expected, otherwis e reads the
old value

atomic_fetch_add
(C11)
atomic_fetch_add_explicit

atomic addition

atomic_fetch_sub
(C11)
atomic_fetch_sub_explicit

atomic s ubtraction

atomic_fetch_or
(C11)
atomic_fetch_or_explicit

atomic logical OR

atomic_fetch_xor
(C11)
atomic_fetch_xor_explicit

atomic logical exclus ive OR

(func tion)
(func tion)
(func tion)

(func tion)
(func tion)
(func tion)
(func tion)
(func tion)

atomic logical AND


(func tion)

atomic_fetch_and
(C11)
atomic_fetch_and_explicit
atomic_thread_fence(C11)

(func tion)

generic memory order-dependent fence


s ynchronization primitive
(func tion)

atomic_signal_fence(C11)

fence between a thread and a s ignal handler


executed in the s ame thread
(func tion)

Types
The s tandard library oers convenience typedefs for the core language atomic types .
Typedef name

Full type name

atomic_bool

_Atomic _Bool

atomic_char

_Atomic char

atomic_schar

_Atomic signed char

atomic_uchar

_Atomic unsigned char

atomic_short

_Atomic short

atomic_ushort

_Atomic unsigned short

atomic_int

_Atomic int

atomic_uint

_Atomic unsigned int

atomic_long

_Atomic long

atomic_ulong

_Atomic unsigned long

atomic_llong

_Atomic long long

atomic_ullong

_Atomic unsigned long long

atomic_char16_t

_Atomic char16_t

atomic_char32_t

_Atomic char32_t

atomic_wchar_t

_Atomic wchar_t

atomic_int_least8_t

_Atomic int_least8_t

atomic_uint_least8_t

_Atomic uint_least8_t

atomic_int_least16_t

_Atomic int_least16_t

atomic_uint_least16_t _Atomic uint_least16_t


atomic_int_least32_t

_Atomic int_least32_t

atomic_uint_least32_t _Atomic uint_least32_t


atomic_int_least64_t

_Atomic int_least64_t

atomic_uint_least64_t _Atomic uint_least64_t


atomic_int_fast8_t

_Atomic int_fast8_t

atomic_uint_fast8_t

_Atomic uint_fast8_t

atomic_int_fast16_t

_Atomic int_fast16_t

atomic_uint_fast16_t

_Atomic uint_fast16_t

atomic_int_fast32_t

_Atomic int_fast32_t

atomic_uint_fast32_t

_Atomic uint_fast32_t

atomic_int_fast64_t

_Atomic int_fast64_t

atomic_uint_fast64_t

_Atomic uint_fast64_t

atomic_intptr_t

_Atomic intptr_t

atomic_uintptr_t

_Atomic uintptr_t

atomic_size_t

_Atomic size_t

atomic_ptrdiff_t

_Atomic ptrdiff_t

atomic_intmax_t

_Atomic intmax_t

atomic_uintmax_t

_Atomic uintmax_t

References
C11 s tandard (ISO/IEC 9899:2011):
7.17 Atomics <s tdatomic.h> (p: 273-286)

7.31.8 Atomics <s tdatomic.h> (p: 455-456)

See also
C++ documentation for Atomic operations library
Retrieved from "http://en.c ppreferenc e.c om/mwiki/index.php?title=c /atomic & oldid=83361"

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy