RTEMS
Macros | Typedefs | Functions
Atomic Operations CPU

Atomic Operations CPU API. More...

Macros

#define _RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC
 
#define CPU_ATOMIC_ORDER_RELAXED   memory_order_relaxed
 
#define CPU_ATOMIC_ORDER_ACQUIRE   memory_order_acquire
 
#define CPU_ATOMIC_ORDER_RELEASE   memory_order_release
 
#define CPU_ATOMIC_ORDER_ACQ_REL   memory_order_acq_rel
 
#define CPU_ATOMIC_ORDER_SEQ_CST   memory_order_seq_cst
 
#define CPU_ATOMIC_INITIALIZER_UINT(value)   ATOMIC_VAR_INIT( value )
 
#define CPU_ATOMIC_INITIALIZER_ULONG(value)   ATOMIC_VAR_INIT( value )
 
#define CPU_ATOMIC_INITIALIZER_UINTPTR(value)   ATOMIC_VAR_INIT( value )
 
#define CPU_ATOMIC_INITIALIZER_FLAG   ATOMIC_FLAG_INIT
 

Typedefs

typedef atomic_uint CPU_atomic_Uint
 
typedef atomic_ulong CPU_atomic_Ulong
 
typedef atomic_uintptr_t CPU_atomic_Uintptr
 
typedef atomic_flag CPU_atomic_Flag
 
typedef memory_order CPU_atomic_Order
 

Functions

static void _CPU_atomic_Fence (CPU_atomic_Order order)
 Sets up a cpu fence. More...
 
static void _CPU_atomic_Init_uint (CPU_atomic_Uint *obj, unsigned int desired)
 Initializes Uint. More...
 
static void _CPU_atomic_Init_ulong (CPU_atomic_Ulong *obj, unsigned long desired)
 Initializes Ulong. More...
 
static void _CPU_atomic_Init_uintptr (CPU_atomic_Uintptr *obj, uintptr_t desired)
 Initializes Uintptr. More...
 
static unsigned int _CPU_atomic_Load_uint (const CPU_atomic_Uint *obj, CPU_atomic_Order order)
 Loads value of Uint considering the order. More...
 
static unsigned long _CPU_atomic_Load_ulong (const CPU_atomic_Ulong *obj, CPU_atomic_Order order)
 Loads value of Ulong considering the order. More...
 
static uintptr_t _CPU_atomic_Load_uintptr (const CPU_atomic_Uintptr *obj, CPU_atomic_Order order)
 Loads value of Uintptr considering the order. More...
 
static void _CPU_atomic_Store_uint (CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order)
 Stores a value to Uint considering the order. More...
 
static void _CPU_atomic_Store_ulong (CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order)
 Stores a value to Ulong considering the order. More...
 
static void _CPU_atomic_Store_uintptr (CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order)
 Stores a value to Uintptr considering the order. More...
 
static unsigned int _CPU_atomic_Fetch_add_uint (CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order)
 Fetches current value of Uint and adds a value to the stored value. More...
 
static unsigned long _CPU_atomic_Fetch_add_ulong (CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order)
 Fetches current value of Ulong and adds a value to the stored value. More...
 
static uintptr_t _CPU_atomic_Fetch_add_uintptr (CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order)
 Fetches current value of Uintptr and adds a value to the stored value. More...
 
static unsigned int _CPU_atomic_Fetch_sub_uint (CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order)
 Fetches current value of Uint and subtracts a value from the stored value. More...
 
static unsigned long _CPU_atomic_Fetch_sub_ulong (CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order)
 Fetches current value of Ulong and subtracts a value from the stored value. More...
 
static uintptr_t _CPU_atomic_Fetch_sub_uintptr (CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order)
 Fetches current value of Uintptr and subtracts a value from the stored value. More...
 
static unsigned int _CPU_atomic_Fetch_or_uint (CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order)
 Fetches current value of Uint and ORs a value with the stored value. More...
 
static unsigned long _CPU_atomic_Fetch_or_ulong (CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order)
 Fetches current value of Ulong and ORs a value with the stored value. More...
 
static uintptr_t _CPU_atomic_Fetch_or_uintptr (CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order)
 Fetches current value of Uintptr and ORs a value with the stored value. More...
 
static unsigned int _CPU_atomic_Fetch_and_uint (CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order)
 Fetches current value of Uint and ANDs a value with the stored value. More...
 
static unsigned long _CPU_atomic_Fetch_and_ulong (CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order)
 Fetches current value of Ulong and ANDs a value with the stored value. More...
 
static uintptr_t _CPU_atomic_Fetch_and_uintptr (CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order)
 Fetches current value of Uintptr and ANDs a value with the stored value. More...
 
static unsigned int _CPU_atomic_Exchange_uint (CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order)
 Fetches current value of Uint and sets its value. More...
 
static unsigned long _CPU_atomic_Exchange_ulong (CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order)
 Fetches current value of Ulong and sets its value. More...
 
static uintptr_t _CPU_atomic_Exchange_uintptr (CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order)
 Fetches current value of Uintptr and sets its value. More...
 
static bool _CPU_atomic_Compare_exchange_uint (CPU_atomic_Uint *obj, unsigned int *expected, unsigned int desired, CPU_atomic_Order succ, CPU_atomic_Order fail)
 Checks if value of Uint is as expected. More...
 
static bool _CPU_atomic_Compare_exchange_ulong (CPU_atomic_Ulong *obj, unsigned long *expected, unsigned long desired, CPU_atomic_Order succ, CPU_atomic_Order fail)
 Checks if value of Ulong is as expected. More...
 
static bool _CPU_atomic_Compare_exchange_uintptr (CPU_atomic_Uintptr *obj, uintptr_t *expected, uintptr_t desired, CPU_atomic_Order succ, CPU_atomic_Order fail)
 Checks if value of Uintptr is as expected. More...
 
static void _CPU_atomic_Flag_clear (CPU_atomic_Flag *obj, CPU_atomic_Order order)
 Clears the atomic flag. More...
 
static bool _CPU_atomic_Flag_test_and_set (CPU_atomic_Flag *obj, CPU_atomic_Order order)
 Returns current flag state and sets it. More...
 

Detailed Description

Atomic Operations CPU API.

Function Documentation

◆ _CPU_atomic_Compare_exchange_uint()

static bool _CPU_atomic_Compare_exchange_uint ( CPU_atomic_Uint *  obj,
unsigned int *  expected,
unsigned int  desired,
CPU_atomic_Order  succ,
CPU_atomic_Order  fail 
)
inlinestatic

Checks if value of Uint is as expected.

This method checks if the value of obj is equal to the value of expected. If this is the case, the value of obj is changed to desired. Otherwise, the value of obj is changed to expected.

Parameters
[in,out]objThe CPU atomic Uint to operate upon.
[in,out]expectedThe expected value of obj. If obj has a different value, expected is changed to the actual value of obj.
desiredThe new value of obj if the old value of obj was as expected.
succThe order if it is successful.
failThe order if it fails.
Return values
trueThe old value of obj was as expected.
falseThe old value of obj was not as expected.

Definition at line 799 of file cpustdatomic.h.

◆ _CPU_atomic_Compare_exchange_uintptr()

static bool _CPU_atomic_Compare_exchange_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t *  expected,
uintptr_t  desired,
CPU_atomic_Order  succ,
CPU_atomic_Order  fail 
)
inlinestatic

Checks if value of Uintptr is as expected.

This method checks if the value of obj is equal to the value of expected. If this is the case, the value of obj is changed to desired. Otherwise, the value of obj is changed to expected.

Parameters
[in,out]objThe CPU atomic Uintptr to operate upon.
[in,out]expectedThe expected value of obj. If obj has a different value, expected is changed to the actual value of obj.
desiredThe new value of obj if the old value of obj was as expected.
succThe order if it is successful.
failThe order if it fails.
Return values
trueThe old value of obj was as expected.
falseThe old value of obj was not as expected.

Definition at line 887 of file cpustdatomic.h.

◆ _CPU_atomic_Compare_exchange_ulong()

static bool _CPU_atomic_Compare_exchange_ulong ( CPU_atomic_Ulong *  obj,
unsigned long *  expected,
unsigned long  desired,
CPU_atomic_Order  succ,
CPU_atomic_Order  fail 
)
inlinestatic

Checks if value of Ulong is as expected.

This method checks if the value of obj is equal to the value of expected. If this is the case, the value of obj is changed to desired. Otherwise, the value of obj is changed to expected.

Parameters
[in,out]objThe CPU atomic Ulong to operate upon.
[in,out]expectedThe expected value of obj. If obj has a different value, expected is changed to the actual value of obj.
desiredThe new value of obj if the old value of obj was as expected.
succThe order if it is successful.
failThe order if it fails.
Return values
trueThe old value of obj was as expected.
falseThe old value of obj was not as expected.

Definition at line 843 of file cpustdatomic.h.

◆ _CPU_atomic_Exchange_uint()

static unsigned int _CPU_atomic_Exchange_uint ( CPU_atomic_Uint *  obj,
unsigned int  desired,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uint and sets its value.

Parameters
[in,out]objThe CPU atomic Uint to get the value from and set the value to desired.
argThe value to set for obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the exchange with desired.

Definition at line 704 of file cpustdatomic.h.

◆ _CPU_atomic_Exchange_uintptr()

static uintptr_t _CPU_atomic_Exchange_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  desired,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uintptr and sets its value.

Parameters
[in,out]objThe CPU atomic Uintptr to get the value from and set the value to desired.
argThe value to set for obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the exchange with desired.

Definition at line 762 of file cpustdatomic.h.

◆ _CPU_atomic_Exchange_ulong()

static unsigned long _CPU_atomic_Exchange_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  desired,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Ulong and sets its value.

Parameters
[in,out]objThe CPU atomic Ulong to get the value from and set the value to desired.
argThe value to set for obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the exchange with desired.

Definition at line 733 of file cpustdatomic.h.

◆ _CPU_atomic_Fence()

static void _CPU_atomic_Fence ( CPU_atomic_Order  order)
inlinestatic

Sets up a cpu fence.

Parameters
[out]orderThe order for the fence.

Definition at line 149 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_add_uint()

static unsigned int _CPU_atomic_Fetch_add_uint ( CPU_atomic_Uint *  obj,
unsigned int  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uint and adds a value to the stored value.

Parameters
[in,out]objThe CPU atomic Uint to get the value from and add arg to.
argThe value to add to obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the addition of arg.

Definition at line 356 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_add_uintptr()

static uintptr_t _CPU_atomic_Fetch_add_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uintptr and adds a value to the stored value.

Parameters
[in,out]objThe CPU atomic Uintptr to get the value from and add arg to.
argThe value to add to obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the addition of arg.

Definition at line 414 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_add_ulong()

static unsigned long _CPU_atomic_Fetch_add_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Ulong and adds a value to the stored value.

Parameters
[in,out]objThe CPU atomic Ulong to get the value from and add arg to.
argThe value to add to obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the addition of arg.

Definition at line 385 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_and_uint()

static unsigned int _CPU_atomic_Fetch_and_uint ( CPU_atomic_Uint *  obj,
unsigned int  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uint and ANDs a value with the stored value.

Parameters
[in,out]objThe CPU atomic Uint to get the value from and AND arg to.
argThe value to AND with obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the AND operation with arg.

Definition at line 617 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_and_uintptr()

static uintptr_t _CPU_atomic_Fetch_and_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uintptr and ANDs a value with the stored value.

Parameters
[in,out]objThe CPU atomic Uintptr to get the value from and AND arg to.
argThe value to AND with obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the AND operation with arg.

Definition at line 675 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_and_ulong()

static unsigned long _CPU_atomic_Fetch_and_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Ulong and ANDs a value with the stored value.

Parameters
[in,out]objThe CPU atomic Ulong to get the value from and AND arg to.
argThe value to AND with obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the AND operation with arg.

Definition at line 646 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_or_uint()

static unsigned int _CPU_atomic_Fetch_or_uint ( CPU_atomic_Uint *  obj,
unsigned int  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uint and ORs a value with the stored value.

Parameters
[in,out]objThe CPU atomic Uint to get the value from and OR arg to.
argThe value to OR with obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the OR operation with arg.

Definition at line 530 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_or_uintptr()

static uintptr_t _CPU_atomic_Fetch_or_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uintptr and ORs a value with the stored value.

Parameters
[in,out]objThe CPU atomic Uintptr to get the value from and OR arg to.
argThe value to OR with obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the OR operation with arg.

Definition at line 588 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_or_ulong()

static unsigned long _CPU_atomic_Fetch_or_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Ulong and ORs a value with the stored value.

Parameters
[in,out]objThe CPU atomic Ulong to get the value from and OR arg to.
argThe value to OR with obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the OR operation with arg.

Definition at line 559 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_sub_uint()

static unsigned int _CPU_atomic_Fetch_sub_uint ( CPU_atomic_Uint *  obj,
unsigned int  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uint and subtracts a value from the stored value.

Parameters
[in,out]objThe CPU atomic Uint to get the value from and subtract arg from.
argThe value to subtract from obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the subtraction of arg.

Definition at line 443 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_sub_uintptr()

static uintptr_t _CPU_atomic_Fetch_sub_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Uintptr and subtracts a value from the stored value.

Parameters
[in,out]objThe CPU atomic Uintptr to get the value from and subtract arg from.
argThe value to subtract from obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the subtraction of arg.

Definition at line 501 of file cpustdatomic.h.

◆ _CPU_atomic_Fetch_sub_ulong()

static unsigned long _CPU_atomic_Fetch_sub_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  arg,
CPU_atomic_Order  order 
)
inlinestatic

Fetches current value of Ulong and subtracts a value from the stored value.

Parameters
[in,out]objThe CPU atomic Ulong to get the value from and subtract arg from.
argThe value to subtract from obj.
orderThe atomic order for the operation.
Returns
The value of obj prior to the subtraction of arg.

Definition at line 472 of file cpustdatomic.h.

◆ _CPU_atomic_Flag_clear()

static void _CPU_atomic_Flag_clear ( CPU_atomic_Flag *  obj,
CPU_atomic_Order  order 
)
inlinestatic

Clears the atomic flag.

Parameters
[out]objThe atomic flag to be cleared.
orderThe atomic order for the operation.

Definition at line 920 of file cpustdatomic.h.

◆ _CPU_atomic_Flag_test_and_set()

static bool _CPU_atomic_Flag_test_and_set ( CPU_atomic_Flag *  obj,
CPU_atomic_Order  order 
)
inlinestatic

Returns current flag state and sets it.

Parameters
[in,out]objThe atomic flag to be set.
orderThe atomic order for the operation.
Return values
trueobj was set prior to this operation.
falseobj was not set prior to this operation.

Definition at line 941 of file cpustdatomic.h.

◆ _CPU_atomic_Init_uint()

static void _CPU_atomic_Init_uint ( CPU_atomic_Uint *  obj,
unsigned int  desired 
)
inlinestatic

Initializes Uint.

Parameters
[out]objThe CPU atomic Uint to initialize.
desiredThe desired value for obj.

Definition at line 167 of file cpustdatomic.h.

◆ _CPU_atomic_Init_uintptr()

static void _CPU_atomic_Init_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  desired 
)
inlinestatic

Initializes Uintptr.

Parameters
[out]objThe CPU atomic Uintptr to initialize.
desiredThe desired value for obj.

Definition at line 201 of file cpustdatomic.h.

◆ _CPU_atomic_Init_ulong()

static void _CPU_atomic_Init_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  desired 
)
inlinestatic

Initializes Ulong.

Parameters
[out]objThe CPU atomic Ulong to initialize.
desiredThe desired value for obj.

Definition at line 184 of file cpustdatomic.h.

◆ _CPU_atomic_Load_uint()

static unsigned int _CPU_atomic_Load_uint ( const CPU_atomic_Uint *  obj,
CPU_atomic_Order  order 
)
inlinestatic

Loads value of Uint considering the order.

Parameters
objThe CPU atomic Uint to get the value from.
orderThe atomic order for getting the value.
Returns
The value of obj considering the order.

Definition at line 220 of file cpustdatomic.h.

◆ _CPU_atomic_Load_uintptr()

static uintptr_t _CPU_atomic_Load_uintptr ( const CPU_atomic_Uintptr *  obj,
CPU_atomic_Order  order 
)
inlinestatic

Loads value of Uintptr considering the order.

Parameters
objThe CPU atomic Uintptr to get the value from.
orderThe atomic order for getting the value.
Returns
The value of obj considering the order.

Definition at line 270 of file cpustdatomic.h.

◆ _CPU_atomic_Load_ulong()

static unsigned long _CPU_atomic_Load_ulong ( const CPU_atomic_Ulong *  obj,
CPU_atomic_Order  order 
)
inlinestatic

Loads value of Ulong considering the order.

Parameters
objThe CPU atomic Ulong to get the value from.
orderThe atomic order for getting the value.
Returns
The value of obj considering the order.

Definition at line 245 of file cpustdatomic.h.

◆ _CPU_atomic_Store_uint()

static void _CPU_atomic_Store_uint ( CPU_atomic_Uint *  obj,
unsigned int  desired,
CPU_atomic_Order  order 
)
inlinestatic

Stores a value to Uint considering the order.

Parameters
[out]objThe CPU atomic Uint to store a value in.
desiredThe desired value for obj.
orderThe atomic order for storing the value.

Definition at line 294 of file cpustdatomic.h.

◆ _CPU_atomic_Store_uintptr()

static void _CPU_atomic_Store_uintptr ( CPU_atomic_Uintptr *  obj,
uintptr_t  desired,
CPU_atomic_Order  order 
)
inlinestatic

Stores a value to Uintptr considering the order.

Parameters
[out]objThe CPU atomic Uintptr to store a value in.
desiredThe desired value for obj.
orderThe atomic order for storing the value.

Definition at line 334 of file cpustdatomic.h.

◆ _CPU_atomic_Store_ulong()

static void _CPU_atomic_Store_ulong ( CPU_atomic_Ulong *  obj,
unsigned long  desired,
CPU_atomic_Order  order 
)
inlinestatic

Stores a value to Ulong considering the order.

Parameters
[out]objThe CPU atomic Ulong to store a value in.
desiredThe desired value for obj.
orderThe atomic order for storing the value.

Definition at line 314 of file cpustdatomic.h.