Skip to content

File atomic.h

FileList > FreeRTOS > include > atomic.h

Go to the source code of this file.

FreeRTOS atomic operation support. More...

  • #include <stdint.h>

Public Static Functions

Type Name
portFORCE_INLINE uint32_t Atomic_AND_u32 (uint32_t volatile * pulDestination, uint32_t ulValue)
Performs an atomic AND operation on the specified values.
portFORCE_INLINE uint32_t Atomic_Add_u32 (uint32_t volatile * pulAddend, uint32_t ulCount)
Atomically adds count to the value of the specified pointer points to.
portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32 (void *volatile * ppvDestination, void * pvExchange, void * pvComparand)
Performs an atomic compare-and-swap operation on the specified pointer values.
portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32 (uint32_t volatile * pulDestination, uint32_t ulExchange, uint32_t ulComparand)
Performs an atomic compare-and-swap operation on the specified values.
portFORCE_INLINE uint32_t Atomic_Decrement_u32 (uint32_t volatile * pulAddend)
Atomically decrements the value of the specified pointer points to.
portFORCE_INLINE uint32_t Atomic_Increment_u32 (uint32_t volatile * pulAddend)
Atomically increments the value of the specified pointer points to.
portFORCE_INLINE uint32_t Atomic_NAND_u32 (uint32_t volatile * pulDestination, uint32_t ulValue)
Performs an atomic NAND operation on the specified values.
portFORCE_INLINE uint32_t Atomic_OR_u32 (uint32_t volatile * pulDestination, uint32_t ulValue)
Performs an atomic OR operation on the specified values.
portFORCE_INLINE uint32_t Atomic_Subtract_u32 (uint32_t volatile * pulAddend, uint32_t ulCount)
Atomically subtracts count from the value of the specified pointer pointers to.
portFORCE_INLINE void * Atomic_SwapPointers_p32 (void *volatile * ppvDestination, void * pvExchange)
Atomically sets the address pointed to by *ppvDestination to the value of *pvExchange.
portFORCE_INLINE uint32_t Atomic_XOR_u32 (uint32_t volatile * pulDestination, uint32_t ulValue)
Performs an atomic XOR operation on the specified values.

Macros

Type Name
define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U
define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U
define ATOMIC_ENTER_CRITICAL () portENTER_CRITICAL()
define ATOMIC_EXIT_CRITICAL () portEXIT_CRITICAL()
define portFORCE_INLINE

Detailed Description

This file implements atomic functions by disabling interrupts globally. Implementations with architecture specific atomic instructions can be provided under each compiler directory.

Public Static Functions Documentation

function Atomic_AND_u32

Performs an atomic AND operation on the specified values.

static portFORCE_INLINE uint32_t Atomic_AND_u32 (
    uint32_t volatile * pulDestination,
    uint32_t ulValue
) 

Atomic AND

Parameters:

  • pulDestination Pointer to memory location from where value is to be loaded and written back to.
  • ulValue Value to be ANDed with *pulDestination.

Returns:

The original value of *pulDestination.

function Atomic_Add_u32

Atomically adds count to the value of the specified pointer points to.

static portFORCE_INLINE uint32_t Atomic_Add_u32 (
    uint32_t volatile * pulAddend,
    uint32_t ulCount
) 

Atomic add

Parameters:

  • pulAddend Pointer to memory location from where value is to be loaded and written back to.
  • ulCount Value to be added to *pulAddend.

Returns:

previous *pulAddend value.

function Atomic_CompareAndSwapPointers_p32

Performs an atomic compare-and-swap operation on the specified pointer values.

static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32 (
    void *volatile * ppvDestination,
    void * pvExchange,
    void * pvComparand
) 

Atomic compare-and-swap (pointers)

Parameters:

  • ppvDestination Pointer to memory location from where a pointer value is to be loaded and checked.
  • pvExchange If condition meets, write this value to memory.
  • pvComparand Swap condition.

Returns:

Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.

Note:

This function only swaps *ppvDestination with pvExchange, if previous *ppvDestination value equals pvComparand.

function Atomic_CompareAndSwap_u32

Performs an atomic compare-and-swap operation on the specified values.

static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32 (
    uint32_t volatile * pulDestination,
    uint32_t ulExchange,
    uint32_t ulComparand
) 

Atomic compare-and-swap

Parameters:

  • pulDestination Pointer to memory location from where value is to be loaded and checked.
  • ulExchange If condition meets, write this value to memory.
  • ulComparand Swap condition.

Returns:

Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.

Note:

This function only swaps *pulDestination with ulExchange, if previous *pulDestination value equals ulComparand.

function Atomic_Decrement_u32

Atomically decrements the value of the specified pointer points to.

static portFORCE_INLINE uint32_t Atomic_Decrement_u32 (
    uint32_t volatile * pulAddend
) 

Atomic decrement

Parameters:

  • pulAddend Pointer to memory location from where value is to be loaded and written back to.

Returns:

*pulAddend value before decrement.

function Atomic_Increment_u32

Atomically increments the value of the specified pointer points to.

static portFORCE_INLINE uint32_t Atomic_Increment_u32 (
    uint32_t volatile * pulAddend
) 

Atomic increment

Parameters:

  • pulAddend Pointer to memory location from where value is to be loaded and written back to.

Returns:

*pulAddend value before increment.

function Atomic_NAND_u32

Performs an atomic NAND operation on the specified values.

static portFORCE_INLINE uint32_t Atomic_NAND_u32 (
    uint32_t volatile * pulDestination,
    uint32_t ulValue
) 

Atomic NAND

Parameters:

  • pulDestination Pointer to memory location from where value is to be loaded and written back to.
  • ulValue Value to be NANDed with *pulDestination.

Returns:

The original value of *pulDestination.

function Atomic_OR_u32

Performs an atomic OR operation on the specified values.

static portFORCE_INLINE uint32_t Atomic_OR_u32 (
    uint32_t volatile * pulDestination,
    uint32_t ulValue
) 

Atomic OR

Parameters:

  • pulDestination Pointer to memory location from where value is to be loaded and written back to.
  • ulValue Value to be ORed with *pulDestination.

Returns:

The original value of *pulDestination.

function Atomic_Subtract_u32

Atomically subtracts count from the value of the specified pointer pointers to.

static portFORCE_INLINE uint32_t Atomic_Subtract_u32 (
    uint32_t volatile * pulAddend,
    uint32_t ulCount
) 

Atomic subtract

Parameters:

  • pulAddend Pointer to memory location from where value is to be loaded and written back to.
  • ulCount Value to be subtract from *pulAddend.

Returns:

previous *pulAddend value.

function Atomic_SwapPointers_p32

Atomically sets the address pointed to by *ppvDestination to the value of *pvExchange.

static portFORCE_INLINE void * Atomic_SwapPointers_p32 (
    void *volatile * ppvDestination,
    void * pvExchange
) 

Atomic swap (pointers)

Parameters:

  • ppvDestination Pointer to memory location from where a pointer value is to be loaded and written back to.
  • pvExchange Pointer value to be written to *ppvDestination.

Returns:

The initial value of *ppvDestination.

function Atomic_XOR_u32

Performs an atomic XOR operation on the specified values.

static portFORCE_INLINE uint32_t Atomic_XOR_u32 (
    uint32_t volatile * pulDestination,
    uint32_t ulValue
) 

Atomic XOR

Parameters:

  • pulDestination Pointer to memory location from where value is to be loaded and written back to.
  • ulValue Value to be XORed with *pulDestination.

Returns:

The original value of *pulDestination.

Macro Definition Documentation

define ATOMIC_COMPARE_AND_SWAP_FAILURE

#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U

Compare and swap failed, did not swap.

define ATOMIC_COMPARE_AND_SWAP_SUCCESS

#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U

Compare and swap succeeded, swapped.

define ATOMIC_ENTER_CRITICAL

#define ATOMIC_ENTER_CRITICAL (

) portENTER_CRITICAL()

define ATOMIC_EXIT_CRITICAL

#define ATOMIC_EXIT_CRITICAL (

) portEXIT_CRITICAL()

define portFORCE_INLINE

#define portFORCE_INLINE 

The documentation for this class was generated from the following file fw/rbcx-coprocessor/lib/FreeRTOS/include/atomic.h