Lely core libraries 2.3.4
|
This header file is part of the C11 and POSIX compatibility library; it includes <stdatomic.h>
, if it exists, and defines any missing functionality.
More...
Go to the source code of this file.
Data Structures | |
struct | atomic_flag |
An atomic type providing the classic test-and-set functionality. More... | |
Macros | |
#define | ATOMIC_FLAG_INIT |
The static initializer used to initialize an atomic_flag to the clear state. | |
#define | ATOMIC_VAR_INIT(value) |
The static initializer for an atomic object of a type that is initialization-compatible with value. | |
#define | atomic_init(obj, value) atomic_store_explicit(obj, value, memory_order_relaxed) |
Initializes the atomic object at obj with the value value. More... | |
#define | kill_dependency(y) |
Terminates a dependency chain; the argument does not carry a dependency to the return value. | |
#define | atomic_is_lock_free(obj) (__atomic_is_lock_free(sizeof((obj)->_value_), &(obj)->_value_)) |
Indicates the lock-free property of integer and address atomic types. More... | |
#define | atomic_store(object, desired) (atomic_store_explicit((object), (desired), memory_order_seq_cst)) |
Equivalent to atomic_store_explicit(object, desired, memory_order_seq_cst). | |
#define | atomic_store_explicit(object, desired, order) (__atomic_store_n(&(object)->_value_, (desired), (order))) |
Atomically replaces the value at object with the value of desired. More... | |
#define | atomic_load(object) (atomic_load_explicit((object), memory_order_seq_cst)) |
Equivalent to atomic_load_explicit(object, memory_order_seq_cst). | |
#define | atomic_load_explicit(object, order) (__atomic_load_n(&(object)->_value_, (order))) |
Atomically returns the value at object. More... | |
#define | atomic_exchange(object, desired) (atomic_exchange_explicit((object), (desired), memory_order_seq_cst)) |
Equivalent to atomic_exchange_explicit(object, desired,
memory_order_seq_cst). | |
#define | atomic_exchange_explicit(object, desired, order) (__atomic_exchange_n(&(object)->_value_, (desired), (order))) |
Atomically replaces the value at object with desired. More... | |
#define | atomic_compare_exchange_strong(object, expected, desired) |
Equivalent to atomic_compare_exchange_strong_explicit(object, expected,
desired, memory_order_seq_cst, memory_order_seq_cst). | |
#define | atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) |
Atomically compares the value at object for equality with that at expected, and if true, replaces the value at object with desired, and if false, updates the value at expected with the value at object. More... | |
#define | atomic_compare_exchange_weak(object, expected, desired) |
Equivalent to atomic_compare_exchange_weak_explicit(object, expected,
desired, memory_order_seq_cst, memory_order_seq_cst). | |
#define | atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) |
Equivalent to atomic_compare_exchange_strong_explicit(), except that a weak compare-and-exchange may fail spuriously. More... | |
#define | atomic_fetch_add(object, operand) (atomic_fetch_add_explicit((object), (operand), memory_order_seq_cst)) |
Equivalent to atomic_fetch_add_explicit(object, operand,
memory_order_seq_cst). | |
#define | atomic_fetch_add_explicit(object, operand, order) (__atomic_fetch_add(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object + operand . More... | |
#define | atomic_fetch_sub(object, operand) (atomic_fetch_sub_explicit((object), (operand), memory_order_seq_cst)) |
Equivalent to atomic_fetch_sub_explicit(object, operand,
memory_order_seq_cst). | |
#define | atomic_fetch_sub_explicit(object, operand, order) (__atomic_fetch_sub(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object - operand . More... | |
#define | atomic_fetch_or(object, operand) (atomic_fetch_or_explicit((object), (operand), memory_order_seq_cst)) |
Equivalent to atomic_fetch_or_explicit(object, operand,
memory_order_seq_cst). | |
#define | atomic_fetch_or_explicit(object, operand, order) (__atomic_fetch_or(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object | operand . More... | |
#define | atomic_fetch_xor(object, operand) (atomic_fetch_xor_explicit((object), (operand), memory_order_seq_cst)) |
Equivalent to atomic_fetch_xor_explicit(object, operand,
memory_order_seq_cst). | |
#define | atomic_fetch_xor_explicit(object, operand, order) (__atomic_fetch_xor(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object ^ operand . More... | |
#define | atomic_fetch_and(object, operand) (atomic_fetch_and_explicit((object), (operand), memory_order_seq_cst)) |
Equivalent to atomic_fetch_and_explicit(object, operand,
memory_order_seq_cst). | |
#define | atomic_fetch_and_explicit(object, operand, order) (__atomic_fetch_and(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object & operand . More... | |
Enumerations | |
enum | memory_order { memory_order_relaxed = 0 , memory_order_consume = 1 , memory_order_acquire = 2 , memory_order_release = 3 , memory_order_acq_rel = 4 , memory_order_seq_cst = 5 } |
An enumerated type identifying memory constraints. More... | |
Functions | |
void | atomic_thread_fence (memory_order order) |
Inserts a fence with semantics according to order. | |
void | atomic_signal_fence (memory_order order) |
Equivalent to atomic_thread_fence(order) , except that the resulting ordering constraints are established only between a thread and a signal handler executing in the same thread. | |
ATOMIC_BOOL_TYPE | atomic_flag_test_and_set_explicit (volatile atomic_flag *object, memory_order order) |
Atomically sets the value at object to true. More... | |
ATOMIC_BOOL_TYPE | atomic_flag_test_and_set (volatile atomic_flag *object) |
Equivalent to #atomic_flag_test_and_set_explicit(object,
memory_order_seq_cst). | |
void | atomic_flag_clear_explicit (volatile atomic_flag *object, memory_order order) |
Atomically sets the value at object to false. More... | |
void | atomic_flag_clear (volatile atomic_flag *object) |
Equivalent to #atomic_flag_test_and_set_explicit(object,
memory_order_seq_cst). | |
This header file is part of the C11 and POSIX compatibility library; it includes <stdatomic.h>
, if it exists, and defines any missing functionality.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file stdatomic.h.
#define atomic_init | ( | obj, | |
value | |||
) | atomic_store_explicit(obj, value, memory_order_relaxed) |
Initializes the atomic object at obj with the value value.
Note that this function does not avoid data races.
Definition at line 222 of file stdatomic.h.
#define atomic_is_lock_free | ( | obj | ) | (__atomic_is_lock_free(sizeof((obj)->_value_), &(obj)->_value_)) |
Indicates the lock-free property of integer and address atomic types.
Definition at line 267 of file stdatomic.h.
#define atomic_store_explicit | ( | object, | |
desired, | |||
order | |||
) | (__atomic_store_n(&(object)->_value_, (desired), (order))) |
Atomically replaces the value at object with the value of desired.
Memory is affected according to order.
Definition at line 325 of file stdatomic.h.
#define atomic_load_explicit | ( | object, | |
order | |||
) | (__atomic_load_n(&(object)->_value_, (order))) |
Atomically returns the value at object.
Memory is affected according to order.
Definition at line 344 of file stdatomic.h.
#define atomic_exchange_explicit | ( | object, | |
desired, | |||
order | |||
) | (__atomic_exchange_n(&(object)->_value_, (desired), (order))) |
Atomically replaces the value at object with desired.
Memory is affected according to order.
Definition at line 368 of file stdatomic.h.
#define atomic_compare_exchange_strong_explicit | ( | object, | |
expected, | |||
desired, | |||
success, | |||
failure | |||
) |
Atomically compares the value at object for equality with that at expected, and if true, replaces the value at object with desired, and if false, updates the value at expected with the value at object.
Further, if the comparison is true, memory is affected according to the value of success, and if the comparison is false, memory is affected according to the value of failure.
Definition at line 405 of file stdatomic.h.
#define atomic_compare_exchange_weak_explicit | ( | object, | |
expected, | |||
desired, | |||
success, | |||
failure | |||
) |
Equivalent to atomic_compare_exchange_strong_explicit(), except that a weak compare-and-exchange may fail spuriously.
That is, even when the contents of memory referred to by expected and object are equal, it may return zero and store back to expected the same memory contents that were there before.
The spurious failure enables implementation of compare-and-exchange on a broader class of machines. When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable.
Definition at line 452 of file stdatomic.h.
#define atomic_fetch_add_explicit | ( | object, | |
operand, | |||
order | |||
) | (__atomic_fetch_add(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object + operand
.
Memory is affected according to order.
Definition at line 480 of file stdatomic.h.
#define atomic_fetch_sub_explicit | ( | object, | |
operand, | |||
order | |||
) | (__atomic_fetch_sub(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object - operand
.
Memory is affected according to order.
Definition at line 504 of file stdatomic.h.
#define atomic_fetch_or_explicit | ( | object, | |
operand, | |||
order | |||
) | (__atomic_fetch_or(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object | operand
.
Memory is affected according to order.
Definition at line 528 of file stdatomic.h.
#define atomic_fetch_xor_explicit | ( | object, | |
operand, | |||
order | |||
) | (__atomic_fetch_xor(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object ^ operand
.
Memory is affected according to order.
Definition at line 552 of file stdatomic.h.
#define atomic_fetch_and_explicit | ( | object, | |
operand, | |||
order | |||
) | (__atomic_fetch_and(&(object)->_value_, (operand), (order))) |
Atomically replaces the value at object with *object & operand
.
Memory is affected according to order.
Definition at line 576 of file stdatomic.h.
enum memory_order |
An enumerated type identifying memory constraints.
Definition at line 126 of file stdatomic.h.
|
inline |
Atomically sets the value at object to true.
Memory is affected according to order.
Definition at line 643 of file stdatomic.h.
|
inline |
Atomically sets the value at object to false.
Memory is affected according to order.
Definition at line 656 of file stdatomic.h.