30 #ifndef IOT_ATOMIC_GENERIC_H_ 31 #define IOT_ATOMIC_GENERIC_H_ 37 #include "iot_atomic.h" 43 #if IOT_ATOMIC_GENERIC != 1 44 #error "Generic atomic implementation is not enabled." 80 extern void Iot_EnterCritical(
void );
81 extern void Iot_ExitCritical(
void );
103 uint32_t swapped = 0;
107 if( *pDestination == comparand )
109 *pDestination = newValue;
133 void * pOldValue = NULL;
136 pOldValue = *pDestination;
137 *pDestination = pNewValue;
162 uint32_t swapped = 0;
166 if( *pDestination == pComparand )
168 *pDestination = pNewValue;
188 static inline uint32_t
Atomic_Add_u32( uint32_t
volatile * pAugend,
192 uint32_t oldValue = 0;
196 *pAugend = oldValue + addend;
214 uint32_t subtrahend )
217 uint32_t oldValue = 0;
220 oldValue = *pMinuend;
221 *pMinuend = oldValue - subtrahend;
270 static inline uint32_t
Atomic_OR_u32( uint32_t
volatile * pOperand,
274 uint32_t oldValue = 0;
277 oldValue = *pOperand;
278 *pOperand = ( oldValue | mask );
299 uint32_t oldValue = 0;
302 oldValue = *pOperand;
303 *pOperand = ( oldValue ^ mask );
320 static inline uint32_t
Atomic_AND_u32( uint32_t
volatile * pOperand,
324 uint32_t oldValue = 0;
327 oldValue = *pOperand;
328 *pOperand = ( oldValue & mask );
349 uint32_t oldValue = 0;
352 oldValue = *pOperand;
353 *pOperand = ~( oldValue & mask );
static uint32_t Atomic_Add_u32(uint32_t volatile *pAugend, uint32_t addend)
Performs an atomic addition of the given values.
Definition: iot_atomic_generic.h:246
static uint32_t Atomic_CompareAndSwap_Pointer(void *volatile *pDestination, void *pNewValue, void *pComparand)
Performs an atomic compare-and-swap operation on the given pointers.
Definition: iot_atomic_generic.h:215
Threading and synchronization functions used by libraries in this SDK.
static uint32_t Atomic_AND_u32(uint32_t volatile *pOperand, uint32_t mask)
Performs an atomic bitwise AND of the given values.
Definition: iot_atomic_generic.h:378
static void * Atomic_Swap_Pointer(void *volatile *pDestination, void *pNewValue)
Atomically writes a pointer value to memory.
Definition: iot_atomic_generic.h:187
static uint32_t Atomic_CompareAndSwap_u32(uint32_t volatile *pDestination, uint32_t newValue, uint32_t comparand)
Performs an atomic compare-and-swap operation on the given values.
Definition: iot_atomic_generic.h:156
static uint32_t Atomic_XOR_u32(uint32_t volatile *pOperand, uint32_t mask)
Performs an atomic bitwise XOR of the given values.
Definition: iot_atomic_generic.h:353
static uint32_t Atomic_OR_u32(uint32_t volatile *pOperand, uint32_t mask)
Performs an atomic bitwise OR of the given values.
Definition: iot_atomic_generic.h:328
static uint32_t Atomic_NAND_u32(uint32_t volatile *pOperand, uint32_t mask)
Performs an atomic bitwise NAND of the given values.
Definition: iot_atomic_generic.h:403
static uint32_t Atomic_Increment_u32(uint32_t volatile *pAugend)
Atomically adds 1 to the given value.
Definition: iot_atomic_generic.h:295
static uint32_t Atomic_Decrement_u32(uint32_t volatile *pMinuend)
Atomically subtracts 1 from the given value.
Definition: iot_atomic_generic.h:311
static uint32_t Atomic_Subtract_u32(uint32_t volatile *pMinuend, uint32_t subtrahend)
Performs an atomic subtraction of the given values.
Definition: iot_atomic_generic.h:271