API Reference Manual  1.45.0
ODP ATOMIC

API Description

Atomic variables.

Atomic integers using relaxed memory ordering

Atomic integer types (odp_atomic_u32_t, odp_atomic_u64_t and odp_atomic_u128_t) can be used to implement e.g. shared counters. If not otherwise documented, operations in this API are implemented using RELAXED memory ordering (see memory order descriptions in the C11 specification). Relaxed operations do not provide synchronization or ordering for other memory accesses (initiated before or after the operation), only atomicity of the operation itself is guaranteed.

Operations with non-relaxed memory ordering

An operation with RELEASE memory ordering (odp_atomic_xxx_rel_xxx()) ensures that other threads loading the same atomic variable with ACQUIRE memory ordering see all stores (from the calling thread) that happened before this releasing store.

An operation with ACQUIRE memory ordering (odp_atomic_xxx_acq_xxx()) ensures that the calling thread sees all stores (done by the releasing thread) that happened before a RELEASE memory ordered store to the same atomic variable.

An operation with ACQUIRE-and-RELEASE memory ordering (odp_atomic_xxx_acq_rel_xxx()) combines the effects of ACQUIRE and RELEASE memory orders. A single operation acts as both an acquiring load and a releasing store.

Data Structures

union  odp_atomic_op_t
 Atomic operations. More...
 

Typedefs

typedef union odp_atomic_op_t odp_atomic_op_t
 Atomic operations. More...
 
typedef struct odp_atomic_u128_s odp_atomic_u128_t
 Atomic 128-bit unsigned integer. More...
 
typedef struct odp_atomic_u64_s odp_atomic_u64_t
 Atomic 64-bit unsigned integer. More...
 
typedef struct odp_atomic_u32_s odp_atomic_u32_t
 Atomic 32-bit unsigned integer. More...
 

Functions

void odp_atomic_init_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Initialize atomic uint32 variable. More...
 
uint32_t odp_atomic_load_u32 (odp_atomic_u32_t *atom)
 Load value of atomic uint32 variable. More...
 
void odp_atomic_store_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Store value to atomic uint32 variable. More...
 
uint32_t odp_atomic_fetch_add_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Fetch and add to atomic uint32 variable. More...
 
void odp_atomic_add_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Add to atomic uint32 variable. More...
 
uint32_t odp_atomic_fetch_sub_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Fetch and subtract from atomic uint32 variable. More...
 
void odp_atomic_sub_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Subtract from atomic uint32 variable. More...
 
uint32_t odp_atomic_fetch_inc_u32 (odp_atomic_u32_t *atom)
 Fetch and increment atomic uint32 variable. More...
 
void odp_atomic_inc_u32 (odp_atomic_u32_t *atom)
 Increment atomic uint32 variable. More...
 
uint32_t odp_atomic_fetch_dec_u32 (odp_atomic_u32_t *atom)
 Fetch and decrement atomic uint32 variable. More...
 
void odp_atomic_dec_u32 (odp_atomic_u32_t *atom)
 Decrement atomic uint32 variable. More...
 
void odp_atomic_max_u32 (odp_atomic_u32_t *atom, uint32_t new_max)
 Update maximum value of atomic uint32 variable. More...
 
void odp_atomic_min_u32 (odp_atomic_u32_t *atom, uint32_t new_min)
 Update minimum value of atomic uint32 variable. More...
 
int odp_atomic_cas_u32 (odp_atomic_u32_t *atom, uint32_t *old_val, uint32_t new_val)
 Compare and swap atomic uint32 variable. More...
 
uint32_t odp_atomic_xchg_u32 (odp_atomic_u32_t *atom, uint32_t new_val)
 Exchange value of atomic uint32 variable. More...
 
void odp_atomic_init_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Initialize atomic uint64 variable. More...
 
uint64_t odp_atomic_load_u64 (odp_atomic_u64_t *atom)
 Load value of atomic uint64 variable. More...
 
void odp_atomic_store_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Store value to atomic uint64 variable. More...
 
uint64_t odp_atomic_fetch_add_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Fetch and add to atomic uint64 variable. More...
 
void odp_atomic_add_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Add to atomic uint64 variable. More...
 
uint64_t odp_atomic_fetch_sub_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Fetch and subtract from atomic uint64 variable. More...
 
void odp_atomic_sub_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Subtract from atomic uint64 variable. More...
 
uint64_t odp_atomic_fetch_inc_u64 (odp_atomic_u64_t *atom)
 Fetch and increment atomic uint64 variable. More...
 
void odp_atomic_inc_u64 (odp_atomic_u64_t *atom)
 Increment atomic uint64 variable. More...
 
uint64_t odp_atomic_fetch_dec_u64 (odp_atomic_u64_t *atom)
 Fetch and decrement atomic uint64 variable. More...
 
void odp_atomic_dec_u64 (odp_atomic_u64_t *atom)
 Decrement atomic uint64 variable. More...
 
void odp_atomic_max_u64 (odp_atomic_u64_t *atom, uint64_t new_max)
 Update maximum value of atomic uint64 variable. More...
 
void odp_atomic_min_u64 (odp_atomic_u64_t *atom, uint64_t new_min)
 Update minimum value of atomic uint64 variable. More...
 
int odp_atomic_cas_u64 (odp_atomic_u64_t *atom, uint64_t *old_val, uint64_t new_val)
 Compare and swap atomic uint64 variable. More...
 
uint64_t odp_atomic_xchg_u64 (odp_atomic_u64_t *atom, uint64_t new_val)
 Exchange value of atomic uint64 variable. More...
 
void odp_atomic_init_u128 (odp_atomic_u128_t *atom, odp_u128_t val)
 Initialize atomic odp_u128_t variable. More...
 
odp_u128_t odp_atomic_load_u128 (odp_atomic_u128_t *atom)
 Load value of atomic odp_u128_t variable. More...
 
void odp_atomic_store_u128 (odp_atomic_u128_t *atom, odp_u128_t val)
 Store value to atomic odp_u128_t variable. More...
 
int odp_atomic_cas_u128 (odp_atomic_u128_t *atom, odp_u128_t *old_val, odp_u128_t new_val)
 Compare and swap atomic odp_u128_t variable. More...
 
uint32_t odp_atomic_load_acq_u32 (odp_atomic_u32_t *atom)
 Load value of atomic uint32 variable using ACQUIRE memory ordering. More...
 
void odp_atomic_store_rel_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Store value to atomic uint32 variable using RELEASE memory ordering. More...
 
void odp_atomic_add_rel_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Add to atomic uint32 variable using RELEASE memory ordering. More...
 
void odp_atomic_sub_rel_u32 (odp_atomic_u32_t *atom, uint32_t val)
 Subtract from atomic uint32 variable using RELEASE memory ordering. More...
 
int odp_atomic_cas_acq_u32 (odp_atomic_u32_t *atom, uint32_t *old_val, uint32_t new_val)
 Compare and swap atomic uint32 variable using ACQUIRE memory ordering. More...
 
int odp_atomic_cas_rel_u32 (odp_atomic_u32_t *atom, uint32_t *old_val, uint32_t new_val)
 Compare and swap atomic uint32 variable using RELEASE memory ordering. More...
 
int odp_atomic_cas_acq_rel_u32 (odp_atomic_u32_t *atom, uint32_t *old_val, uint32_t new_val)
 Compare and swap atomic uint32 variable using ACQUIRE-and-RELEASE memory ordering. More...
 
uint64_t odp_atomic_load_acq_u64 (odp_atomic_u64_t *atom)
 Load value of atomic uint64 variable using ACQUIRE memory ordering. More...
 
void odp_atomic_store_rel_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Store value to atomic uint64 variable using RELEASE memory ordering. More...
 
void odp_atomic_add_rel_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Add to atomic uint64 variable using RELEASE memory ordering. More...
 
void odp_atomic_sub_rel_u64 (odp_atomic_u64_t *atom, uint64_t val)
 Subtract from atomic uint64 variable using RELEASE memory ordering. More...
 
int odp_atomic_cas_acq_u64 (odp_atomic_u64_t *atom, uint64_t *old_val, uint64_t new_val)
 Compare and swap atomic uint64 variable using ACQUIRE memory ordering. More...
 
int odp_atomic_cas_rel_u64 (odp_atomic_u64_t *atom, uint64_t *old_val, uint64_t new_val)
 Compare and swap atomic uint64 variable using RELEASE memory ordering. More...
 
int odp_atomic_cas_acq_rel_u64 (odp_atomic_u64_t *atom, uint64_t *old_val, uint64_t new_val)
 Compare and swap atomic uint64 variable using ACQUIRE-and-RELEASE memory ordering. More...
 
int odp_atomic_lock_free_u64 (odp_atomic_op_t *atomic_op)
 Query which atomic uint64 operations are lock-free. More...
 
int odp_atomic_cas_acq_u128 (odp_atomic_u128_t *atom, odp_u128_t *old_val, odp_u128_t new_val)
 Compare and swap atomic odp_u128_t variable using ACQUIRE memory ordering. More...
 
int odp_atomic_cas_rel_u128 (odp_atomic_u128_t *atom, odp_u128_t *old_val, odp_u128_t new_val)
 Compare and swap atomic odp_u128_t variable using RELEASE memory ordering. More...
 
int odp_atomic_cas_acq_rel_u128 (odp_atomic_u128_t *atom, odp_u128_t *old_val, odp_u128_t new_val)
 Compare and swap atomic odp_u128_t variable using ACQUIRE-and-RELEASE memory ordering. More...
 
int odp_atomic_lock_free_u128 (odp_atomic_op_t *atomic_op)
 Query which atomic odp_atomic_u128_t operations are lock-free. More...
 

Typedef Documentation

◆ odp_atomic_op_t

Atomic operations.

Atomic operations listed in a bit field structure.

◆ odp_atomic_u128_t

Atomic 128-bit unsigned integer.

Atomic 128-bit unsigned integer

◆ odp_atomic_u64_t

Atomic 64-bit unsigned integer.

Atomic 64-bit unsigned integer

◆ odp_atomic_u32_t

Atomic 32-bit unsigned integer.

Atomic 32-bit unsigned integer

Function Documentation

◆ odp_atomic_init_u32()

void odp_atomic_init_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Initialize atomic uint32 variable.

Initializes the atomic variable with 'val'. This operation is not atomic. Application must ensure that there's no race condition while initializing the variable.

Parameters
atomPointer to atomic variable
valValue to initialize the variable with
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_atomic_perf.c, odp_cpu_bench.c, odp_dma_perf.c, odp_dmafwd.c, odp_icache_perf.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_pool_latency.c, odp_sched_perf.c, odp_simple_pipeline.c, odp_stress.c, odp_switch.c, odp_timer_perf.c, and odp_traffic_mgmt.c.

◆ odp_atomic_load_u32()

◆ odp_atomic_store_u32()

◆ odp_atomic_fetch_add_u32()

uint32_t odp_atomic_fetch_add_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Fetch and add to atomic uint32 variable.

Parameters
atomPointer to atomic variable
valValue to be added to the variable
Returns
Value of the variable before the addition
Examples
odp_atomic_perf.c, and odp_pktio_perf.c.

◆ odp_atomic_add_u32()

void odp_atomic_add_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Add to atomic uint32 variable.

Parameters
atomPointer to atomic variable
valValue to be added to the variable
Examples
odp_atomic_perf.c, odp_icache_perf.c, odp_ipfragreass.c, odp_packet_gen.c, odp_stress.c, and odp_timer_perf.c.

◆ odp_atomic_fetch_sub_u32()

uint32_t odp_atomic_fetch_sub_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Fetch and subtract from atomic uint32 variable.

Parameters
atomPointer to atomic variable
valValue to be subtracted from the variable
Returns
Value of the variable before the subtraction
Examples
odp_atomic_perf.c.

◆ odp_atomic_sub_u32()

void odp_atomic_sub_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Subtract from atomic uint32 variable.

Parameters
atomPointer to atomic variable
valValue to be subtracted from the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_fetch_inc_u32()

uint32_t odp_atomic_fetch_inc_u32 ( odp_atomic_u32_t atom)

Fetch and increment atomic uint32 variable.

Parameters
atomPointer to atomic variable
Returns
Value of the variable before the increment
Examples
odp_atomic_perf.c.

◆ odp_atomic_inc_u32()

void odp_atomic_inc_u32 ( odp_atomic_u32_t atom)

Increment atomic uint32 variable.

Parameters
atomPointer to atomic variable
Examples
odp_atomic_perf.c, odp_packet_gen.c, odp_timer_perf.c, and odp_traffic_mgmt.c.

◆ odp_atomic_fetch_dec_u32()

uint32_t odp_atomic_fetch_dec_u32 ( odp_atomic_u32_t atom)

Fetch and decrement atomic uint32 variable.

Parameters
atomPointer to atomic variable
Returns
Value of the variable before the subtraction
Examples
odp_atomic_perf.c, and odp_sched_perf.c.

◆ odp_atomic_dec_u32()

void odp_atomic_dec_u32 ( odp_atomic_u32_t atom)

Decrement atomic uint32 variable.

Parameters
atomPointer to atomic variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_max_u32()

void odp_atomic_max_u32 ( odp_atomic_u32_t atom,
uint32_t  new_max 
)

Update maximum value of atomic uint32 variable.

Compares value of atomic variable to the new maximum value. If the new value is greater than the current value, writes the new value into the variable.

Parameters
atomPointer to atomic variable
new_maxNew maximum value to be written into the atomic variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_min_u32()

void odp_atomic_min_u32 ( odp_atomic_u32_t atom,
uint32_t  new_min 
)

Update minimum value of atomic uint32 variable.

Compares value of atomic variable to the new minimum value. If the new value is less than the current value, writes the new value into the variable.

Parameters
atomPointer to atomic variable
new_minNew minimum value to be written into the atomic variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_u32()

int odp_atomic_cas_u32 ( odp_atomic_u32_t atom,
uint32_t *  old_val,
uint32_t  new_val 
)

Compare and swap atomic uint32 variable.

Compares value of atomic variable to the value pointed by 'old_val'. If the values are equal, the operation writes 'new_val' into the atomic variable and returns success. The operation returns failure only when the values are not equal (strong CAS operation). The current value of atomic variable is written into 'old_val' on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_xchg_u32()

uint32_t odp_atomic_xchg_u32 ( odp_atomic_u32_t atom,
uint32_t  new_val 
)

Exchange value of atomic uint32 variable.

Atomically replaces the value of atomic variable with the new value. Returns the old value.

Parameters
atomPointer to atomic variable
new_valNew value of the atomic variable
Returns
Value of the variable before the operation
Examples
odp_atomic_perf.c.

◆ odp_atomic_init_u64()

void odp_atomic_init_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Initialize atomic uint64 variable.

Initializes the atomic variable with 'val'. This operation is not atomic. Application must ensure that there's no race condition while initializing the variable.

Parameters
atomPointer to atomic variable
valValue to initialize the variable with
Examples
odp_atomic_perf.c, odp_classifier.c, odp_sched_perf.c, odp_stress.c, odp_switch.c, and odp_timer_accuracy.c.

◆ odp_atomic_load_u64()

uint64_t odp_atomic_load_u64 ( odp_atomic_u64_t atom)

Load value of atomic uint64 variable.

Parameters
atomPointer to atomic variable
Returns
Value of the variable
Examples
odp_atomic_perf.c, odp_classifier.c, odp_sched_perf.c, odp_switch.c, and odp_timer_accuracy.c.

◆ odp_atomic_store_u64()

void odp_atomic_store_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Store value to atomic uint64 variable.

Parameters
atomPointer to atomic variable
valValue to store in the variable
Examples
odp_atomic_perf.c, and odp_switch.c.

◆ odp_atomic_fetch_add_u64()

uint64_t odp_atomic_fetch_add_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Fetch and add to atomic uint64 variable.

Parameters
atomPointer to atomic variable
valValue to be added to the variable
Returns
Value of the variable before the addition
Examples
odp_atomic_perf.c.

◆ odp_atomic_add_u64()

void odp_atomic_add_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Add to atomic uint64 variable.

Parameters
atomPointer to atomic variable
valValue to be added to the variable
Examples
odp_atomic_perf.c, odp_classifier.c, and odp_sched_perf.c.

◆ odp_atomic_fetch_sub_u64()

uint64_t odp_atomic_fetch_sub_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Fetch and subtract from atomic uint64 variable.

Parameters
atomPointer to atomic variable
valValue to be subtracted from the variable
Returns
Value of the variable before the subtraction
Examples
odp_atomic_perf.c.

◆ odp_atomic_sub_u64()

void odp_atomic_sub_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Subtract from atomic uint64 variable.

Parameters
atomPointer to atomic variable
valValue to be subtracted from the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_fetch_inc_u64()

uint64_t odp_atomic_fetch_inc_u64 ( odp_atomic_u64_t atom)

Fetch and increment atomic uint64 variable.

Parameters
atomPointer to atomic variable
Returns
Value of the variable before the increment
Examples
odp_atomic_perf.c, odp_stress.c, and odp_timer_accuracy.c.

◆ odp_atomic_inc_u64()

void odp_atomic_inc_u64 ( odp_atomic_u64_t atom)

Increment atomic uint64 variable.

Parameters
atomPointer to atomic variable
Examples
odp_atomic_perf.c, odp_classifier.c, and odp_timer_accuracy.c.

◆ odp_atomic_fetch_dec_u64()

uint64_t odp_atomic_fetch_dec_u64 ( odp_atomic_u64_t atom)

Fetch and decrement atomic uint64 variable.

Parameters
atomPointer to atomic variable
Returns
Value of the variable before the decrement
Examples
odp_atomic_perf.c.

◆ odp_atomic_dec_u64()

void odp_atomic_dec_u64 ( odp_atomic_u64_t atom)

Decrement atomic uint64 variable.

Parameters
atomPointer to atomic variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_max_u64()

void odp_atomic_max_u64 ( odp_atomic_u64_t atom,
uint64_t  new_max 
)

Update maximum value of atomic uint64 variable.

Compares value of atomic variable to the new maximum value. If the new value is greater than the current value, writes the new value into the variable.

Parameters
atomPointer to atomic variable
new_maxNew maximum value to be written into the atomic variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_min_u64()

void odp_atomic_min_u64 ( odp_atomic_u64_t atom,
uint64_t  new_min 
)

Update minimum value of atomic uint64 variable.

Compares value of atomic variable to the new minimum value. If the new value is less than the current value, writes the new value into the variable.

Parameters
atomPointer to atomic variable
new_minNew minimum value to be written into the atomic variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_u64()

int odp_atomic_cas_u64 ( odp_atomic_u64_t atom,
uint64_t *  old_val,
uint64_t  new_val 
)

Compare and swap atomic uint64 variable.

Compares value of atomic variable to the value pointed by 'old_val'. If the values are equal, the operation writes 'new_val' into the atomic variable and returns success. The operation returns failure only when the values are not equal (strong CAS operation). The current value of atomic variable is written into 'old_val' on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_xchg_u64()

uint64_t odp_atomic_xchg_u64 ( odp_atomic_u64_t atom,
uint64_t  new_val 
)

Exchange value of atomic uint64 variable.

Atomically replaces the value of atomic variable with the new value. Returns the old value.

Parameters
atomPointer to atomic variable
new_valNew value of the atomic variable
Returns
Value of the variable before the operation
Examples
odp_atomic_perf.c.

◆ odp_atomic_init_u128()

void odp_atomic_init_u128 ( odp_atomic_u128_t atom,
odp_u128_t  val 
)

Initialize atomic odp_u128_t variable.

Initializes the atomic variable with 'val'. This operation is not atomic. Application must ensure that there's no race condition while initializing the variable.

Parameters
atomPointer to atomic variable
valValue to initialize the variable with
Examples
odp_atomic_perf.c, and odp_ipfragreass.c.

◆ odp_atomic_load_u128()

odp_u128_t odp_atomic_load_u128 ( odp_atomic_u128_t atom)

Load value of atomic odp_u128_t variable.

Parameters
atomPointer to atomic variable
Returns
Value of the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_store_u128()

void odp_atomic_store_u128 ( odp_atomic_u128_t atom,
odp_u128_t  val 
)

Store value to atomic odp_u128_t variable.

Parameters
atomPointer to atomic variable
valValue to store in the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_u128()

int odp_atomic_cas_u128 ( odp_atomic_u128_t atom,
odp_u128_t old_val,
odp_u128_t  new_val 
)

Compare and swap atomic odp_u128_t variable.

Compares value of atomic variable to the value pointed by 'old_val'. If the values are equal, the operation writes 'new_val' into the atomic variable and returns success. The operation returns failure only when the values are not equal (strong CAS operation). The current value of atomic variable is written into 'old_val' on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_load_acq_u32()

uint32_t odp_atomic_load_acq_u32 ( odp_atomic_u32_t atom)

Load value of atomic uint32 variable using ACQUIRE memory ordering.

Otherwise identical to odp_atomic_load_u32() but ensures ACQUIRE memory ordering.

Parameters
atomPointer to atomic variable
Returns
Value of the variable
Examples
odp_atomic_perf.c, and odp_timer_perf.c.

◆ odp_atomic_store_rel_u32()

void odp_atomic_store_rel_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Store value to atomic uint32 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_store_u32() but ensures RELEASE memory ordering.

Parameters
atomPointer to atomic variable
valValue to store in the variable
Examples
odp_atomic_perf.c, and odp_timer_perf.c.

◆ odp_atomic_add_rel_u32()

void odp_atomic_add_rel_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Add to atomic uint32 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_add_u32() but ensures RELEASE memory ordering.

Parameters
atomPointer to atomic variable
valValue to be added to the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_sub_rel_u32()

void odp_atomic_sub_rel_u32 ( odp_atomic_u32_t atom,
uint32_t  val 
)

Subtract from atomic uint32 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_sub_u32() but ensures RELEASE memory ordering.

Parameters
atomPointer to atomic variable
valValue to be subtracted from the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_acq_u32()

int odp_atomic_cas_acq_u32 ( odp_atomic_u32_t atom,
uint32_t *  old_val,
uint32_t  new_val 
)

Compare and swap atomic uint32 variable using ACQUIRE memory ordering.

Otherwise identical to odp_atomic_cas_u32() but ensures ACQUIRE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_rel_u32()

int odp_atomic_cas_rel_u32 ( odp_atomic_u32_t atom,
uint32_t *  old_val,
uint32_t  new_val 
)

Compare and swap atomic uint32 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_cas_u32() but ensures RELEASE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_acq_rel_u32()

int odp_atomic_cas_acq_rel_u32 ( odp_atomic_u32_t atom,
uint32_t *  old_val,
uint32_t  new_val 
)

Compare and swap atomic uint32 variable using ACQUIRE-and-RELEASE memory ordering.

Otherwise identical to odp_atomic_cas_u32() but ensures ACQUIRE-and-RELEASE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_load_acq_u64()

uint64_t odp_atomic_load_acq_u64 ( odp_atomic_u64_t atom)

Load value of atomic uint64 variable using ACQUIRE memory ordering.

Otherwise identical to odp_atomic_load_u64() but ensures ACQUIRE memory ordering.

Parameters
atomPointer to atomic variable
Returns
Value of the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_store_rel_u64()

void odp_atomic_store_rel_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Store value to atomic uint64 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_store_u64() but ensures RELEASE memory ordering.

Parameters
atomPointer to atomic variable
valValue to store in the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_add_rel_u64()

void odp_atomic_add_rel_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Add to atomic uint64 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_add_u64() but ensures RELEASE memory ordering.

Parameters
atomPointer to atomic variable
valValue to be added to the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_sub_rel_u64()

void odp_atomic_sub_rel_u64 ( odp_atomic_u64_t atom,
uint64_t  val 
)

Subtract from atomic uint64 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_sub_u64() but ensures RELEASE memory ordering.

Parameters
atomPointer to atomic variable
valValue to be subtracted from the variable
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_acq_u64()

int odp_atomic_cas_acq_u64 ( odp_atomic_u64_t atom,
uint64_t *  old_val,
uint64_t  new_val 
)

Compare and swap atomic uint64 variable using ACQUIRE memory ordering.

Otherwise identical to odp_atomic_cas_u64() but ensures ACQUIRE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_rel_u64()

int odp_atomic_cas_rel_u64 ( odp_atomic_u64_t atom,
uint64_t *  old_val,
uint64_t  new_val 
)

Compare and swap atomic uint64 variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_cas_u64() but ensures RELEASE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_acq_rel_u64()

int odp_atomic_cas_acq_rel_u64 ( odp_atomic_u64_t atom,
uint64_t *  old_val,
uint64_t  new_val 
)

Compare and swap atomic uint64 variable using ACQUIRE-and-RELEASE memory ordering.

Otherwise identical to odp_atomic_cas_u64() but ensures ACQUIRE-and-RELEASE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_lock_free_u64()

int odp_atomic_lock_free_u64 ( odp_atomic_op_t atomic_op)

Query which atomic uint64 operations are lock-free.

Lock-free implementations have higher performance and scale better than implementations using locks. User can decide to use e.g. uint32 atomic variables instead of uint64 to optimize performance on platforms that implement a performance critical operation using locks.

Init operations (e.g. odp_atomic_init_u64()) are not atomic. This function clears the op.init bit but will never set it to one.

Parameters
atomic_opPointer to atomic operation structure for storing operation flags. All bits are initialized to zero during the operation. The parameter is ignored when NULL.
Return values
0None of the operations are lock-free
1Some of the operations are lock-free
2All operations are lock-free
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_acq_u128()

int odp_atomic_cas_acq_u128 ( odp_atomic_u128_t atom,
odp_u128_t old_val,
odp_u128_t  new_val 
)

Compare and swap atomic odp_u128_t variable using ACQUIRE memory ordering.

Otherwise identical to odp_atomic_cas_u128() but ensures ACQUIRE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_rel_u128()

int odp_atomic_cas_rel_u128 ( odp_atomic_u128_t atom,
odp_u128_t old_val,
odp_u128_t  new_val 
)

Compare and swap atomic odp_u128_t variable using RELEASE memory ordering.

Otherwise identical to odp_atomic_cas_u128() but ensures RELEASE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_cas_acq_rel_u128()

int odp_atomic_cas_acq_rel_u128 ( odp_atomic_u128_t atom,
odp_u128_t old_val,
odp_u128_t  new_val 
)

Compare and swap atomic odp_u128_t variable using ACQUIRE-and-RELEASE memory ordering.

Otherwise identical to odp_atomic_cas_u128() but ensures ACQUIRE-and-RELEASE memory ordering on success. Memory ordering is RELAXED on failure.

Parameters
atomPointer to atomic variable
[in,out]old_valPointer to the old value of the atomic variable. Operation updates this value on failure.
new_valNew value to be written into the atomic variable
Returns
0 on failure, !0 on success
Examples
odp_atomic_perf.c.

◆ odp_atomic_lock_free_u128()

int odp_atomic_lock_free_u128 ( odp_atomic_op_t atomic_op)

Query which atomic odp_atomic_u128_t operations are lock-free.

Lock-free implementations have higher performance and scale better than implementations using locks.

Init operations (e.g. odp_atomic_init_u128()) are not atomic. This function clears the op.init bit but will never set it to one.

Note: 128-bit atomic API includes only init, load, store and CAS operations.

Parameters
atomic_opPointer to atomic operation structure for storing operation flags. All bits are initialized to zero during the operation. The parameter is ignored when NULL.
Return values
0None of the 128-bit atomic operations are lock-free
1Some of the 128-bit atomic operations are lock-free
2All 128-bit atomic operations are lock-free
Examples
odp_atomic_perf.c.