Skip to content

Atomic operations

Finalspace edited this page May 29, 2026 · 1 revision

This category contains functions for handling atomic operations, such as Add, Compare And/Or Exchange, Fences, Loads/Stores, etc. More...

Functions

Type Name
fpl_common_api void * fplAtomicAddAndFetchPtr (volatile void **dest, const intptr_t addend)
Adds the addend to destination pointer atomically and returns the result after the addition.
fpl_platform_api int32_t fplAtomicAddAndFetchS32 (volatile int32_t *dest, const int32_t addend)
Adds the addend to destination 32-bit signed integer atomically and returns the result after the addition.
fpl_platform_api int64_t fplAtomicAddAndFetchS64 (volatile int64_t *dest, const int64_t addend)
Adds the addend to destination 64-bit signed integer atomically and returns the result after the addition.
fpl_common_api size_t fplAtomicAddAndFetchSize (volatile size_t *dest, const size_t addend)
Adds the addend to destination size atomically and returns the result after the addition.
fpl_platform_api uint32_t fplAtomicAddAndFetchU32 (volatile uint32_t *dest, const uint32_t addend)
Adds the addend to destination 32-bit unsigned integer atomically and returns the result after the addition.
fpl_platform_api uint64_t fplAtomicAddAndFetchU64 (volatile uint64_t *dest, const uint64_t addend)
Adds the addend to destination 64-bit unsigned integer atomically and returns the result after the addition.
fpl_common_api void * fplAtomicCompareAndSwapPtr (volatile void **dest, const void *comparand, const void *exchange)
Compares a pointer with a comparand and swaps it when comparand matches the destination.
fpl_platform_api int32_t fplAtomicCompareAndSwapS32 (volatile int32_t *dest, const int32_t comparand, const int32_t exchange)
Compares a 32-bit signed integer with a comparand and swaps it when comparand matches the destination.
fpl_platform_api int64_t fplAtomicCompareAndSwapS64 (volatile int64_t *dest, const int64_t comparand, const int64_t exchange)
Compares a 64-bit signed integer with a comparand and swaps it when comparand matches the destination.
fpl_common_api size_t fplAtomicCompareAndSwapSize (volatile size_t *dest, const size_t comparand, const size_t exchange)
Compares a size with a comparand and swaps it when comparand matches the destination.
fpl_platform_api uint32_t fplAtomicCompareAndSwapU32 (volatile uint32_t *dest, const uint32_t comparand, const uint32_t exchange)
Compares a 32-bit unsigned integer with a comparand and swaps it when comparand matches the destination.
fpl_platform_api uint64_t fplAtomicCompareAndSwapU64 (volatile uint64_t *dest, const uint64_t comparand, const uint64_t exchange)
Compares a 64-bit unsigned integer with a comparand and swaps it when comparand matches the destination.
fpl_common_api void * fplAtomicExchangePtr (volatile void **target, const void *value)
Replaces a pointer with the given value atomically.
fpl_platform_api int32_t fplAtomicExchangeS32 (volatile int32_t *target, const int32_t value)
Replaces a 32-bit signed integer with the given value atomically.
fpl_platform_api int64_t fplAtomicExchangeS64 (volatile int64_t *target, const int64_t value)
Replaces a 64-bit signed integer with the given value atomically.
fpl_common_api size_t fplAtomicExchangeSize (volatile size_t *target, const size_t value)
Replaces a size with the given value atomically.
fpl_platform_api uint32_t fplAtomicExchangeU32 (volatile uint32_t *target, const uint32_t value)
Replaces a 32-bit unsigned integer with the given value atomically.
fpl_platform_api uint64_t fplAtomicExchangeU64 (volatile uint64_t *target, const uint64_t value)
Replaces a 64-bit unsigned integer with the given value atomically.
fpl_common_api void * fplAtomicFetchAndAddPtr (volatile void **dest, const intptr_t addend)
Adds a addend to the pointer atomically and returns the initial value before the add.
fpl_platform_api int32_t fplAtomicFetchAndAddS32 (volatile int32_t *value, const int32_t addend)
Adds a 32-bit signed integer to the value by the given addend atomically.
fpl_platform_api int64_t fplAtomicFetchAndAddS64 (volatile int64_t *value, const int64_t addend)
Adds a 64-bit signed integer to the value by the given addend atomically.
fpl_common_api size_t fplAtomicFetchAndAddSize (volatile size_t *dest, const size_t addend)
Adds a size to the value by the given addend atomically.
fpl_platform_api uint32_t fplAtomicFetchAndAddU32 (volatile uint32_t *value, const uint32_t addend)
Adds a 32-bit unsigned integer to the value by the given addend atomically.
fpl_platform_api uint64_t fplAtomicFetchAndAddU64 (volatile uint64_t *value, const uint64_t addend)
Adds a 64-bit unsigned integer to the value by the given addend atomically.
fpl_common_api void * fplAtomicIncrementPtr (volatile void **dest)
Increments/Advances the given pointer by one atomically.
fpl_platform_api int32_t fplAtomicIncrementS32 (volatile int32_t *dest)
Increments the given 32-bit signed integer by one atomically.
fpl_platform_api int64_t fplAtomicIncrementS64 (volatile int64_t *dest)
Increments the given 64-bit signed integer by one atomically.
fpl_common_api size_t fplAtomicIncrementSize (volatile size_t *dest)
Increments the given size by one atomically.
fpl_platform_api uint32_t fplAtomicIncrementU32 (volatile uint32_t *dest)
Increments the given 32-bit unsigned integer by one atomically.
fpl_platform_api uint64_t fplAtomicIncrementU64 (volatile uint64_t *dest)
Increments the given 64-bit unsigned integer by one atomically.
fpl_common_api bool fplAtomicIsCompareAndSwapPtr (volatile void **dest, const void *comparand, const void *exchange)
Compares a pointer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.
fpl_platform_api bool fplAtomicIsCompareAndSwapS32 (volatile int32_t *dest, const int32_t comparand, const int32_t exchange)
Compares a 32-bit signed integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.
fpl_platform_api bool fplAtomicIsCompareAndSwapS64 (volatile int64_t *dest, const int64_t comparand, const int64_t exchange)
Compares a 64-bit signed integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.
fpl_common_api bool fplAtomicIsCompareAndSwapSize (volatile size_t *dest, const size_t comparand, const size_t exchange)
Compares a size with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.
fpl_platform_api bool fplAtomicIsCompareAndSwapU32 (volatile uint32_t *dest, const uint32_t comparand, const uint32_t exchange)
Compares a 32-bit unsigned integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.
fpl_platform_api bool fplAtomicIsCompareAndSwapU64 (volatile uint64_t *dest, const uint64_t comparand, const uint64_t exchange)
Compares a 64-bit unsigned integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.
fpl_common_api void * fplAtomicLoadPtr (volatile void **source)
Loads the pointer value atomically and returns the value.
fpl_platform_api int32_t fplAtomicLoadS32 (volatile int32_t *source)
Loads the 32-bit signed value atomically and returns the value.
fpl_platform_api int64_t fplAtomicLoadS64 (volatile int64_t *source)
Loads the 64-bit signed value atomically and returns the value.
fpl_common_api size_t fplAtomicLoadSize (volatile size_t *source)
Loads the size value atomically and returns the value.
fpl_platform_api uint32_t fplAtomicLoadU32 (volatile uint32_t *source)
Loads the 32-bit unsigned value atomically and returns the value.
fpl_platform_api uint64_t fplAtomicLoadU64 (volatile uint64_t *source)
Loads the 64-bit unsigned value atomically and returns the value.
fpl_platform_api void fplAtomicReadFence (void)
Inserts a memory read fence/barrier.
fpl_platform_api void fplAtomicReadWriteFence (void)
Inserts a memory read and write fence/barrier.
fpl_common_api void fplAtomicStorePtr (volatile void **dest, const void *value)
Overwrites the pointer value atomically.
fpl_platform_api void fplAtomicStoreS32 (volatile int32_t *dest, const int32_t value)
Overwrites the 32-bit signed value atomically.
fpl_platform_api void fplAtomicStoreS64 (volatile int64_t *dest, const int64_t value)
Overwrites the 64-bit signed value atomically.
fpl_common_api void fplAtomicStoreSize (volatile size_t *dest, const size_t value)
Overwrites the size value atomically.
fpl_platform_api void fplAtomicStoreU32 (volatile uint32_t *dest, const uint32_t value)
Overwrites the 32-bit unsigned value atomically.
fpl_platform_api void fplAtomicStoreU64 (volatile uint64_t *dest, const uint64_t value)
Overwrites the 64-bit unsigned value atomically.
fpl_platform_api void fplAtomicWriteFence (void)
Inserts a memory write fence/barrier.

Detailed Description

This category contains functions for handling atomic operations, such as Add, Compare And/Or Exchange, Fences, Loads/Stores, etc.

See also: Atomics

Function Documentation

fplAtomicAddAndFetchPtr()

fpl_common_api void * fplAtomicAddAndFetchPtr ( volatile void ** dest, const intptr_t addend )

Adds the addend to destination pointer atomically and returns the result after the addition.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the value after the addition.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicAddAndFetchS32()

fpl_platform_api int32_t fplAtomicAddAndFetchS32 ( volatile int32_t * dest, const int32_t addend )

Adds the addend to destination 32-bit signed integer atomically and returns the result after the addition.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the value after the addition.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicAddAndFetchS64()

fpl_platform_api int64_t fplAtomicAddAndFetchS64 ( volatile int64_t * dest, const int64_t addend )

Adds the addend to destination 64-bit signed integer atomically and returns the result after the addition.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the value after the addition.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicAddAndFetchSize()

fpl_common_api size_t fplAtomicAddAndFetchSize ( volatile size_t * dest, const size_t addend )

Adds the addend to destination size atomically and returns the result after the addition.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the value after the addition.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicAddAndFetchU32()

fpl_platform_api uint32_t fplAtomicAddAndFetchU32 ( volatile uint32_t * dest, const uint32_t addend )

Adds the addend to destination 32-bit unsigned integer atomically and returns the result after the addition.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the value after the addition.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicAddAndFetchU64()

fpl_platform_api uint64_t fplAtomicAddAndFetchU64 ( volatile uint64_t * dest, const uint64_t addend )

Adds the addend to destination 64-bit unsigned integer atomically and returns the result after the addition.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the value after the addition.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicCompareAndSwapPtr()

fpl_common_api void * fplAtomicCompareAndSwapPtr ( volatile void ** dest, const void * comparand, const void * exchange )

Compares a pointer with a comparand and swaps it when comparand matches the destination.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns the value of the destination before the swap, regardless of the result.

Note: Ensures that memory operations are completed in order.

Use

fplAtomicIsCompareAndSwapPtr() when you want to check if the exchange has happened or not.

See also: Compare-And-Swap

fplAtomicCompareAndSwapS32()

fpl_platform_api int32_t fplAtomicCompareAndSwapS32 ( volatile int32_t * dest, const int32_t comparand, const int32_t exchange )

Compares a 32-bit signed integer with a comparand and swaps it when comparand matches the destination.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns the value of the destination before the swap, regardless of the result.

Note: Ensures that memory operations are completed in order.

Use

fplAtomicIsCompareAndSwapS32() when you want to check if the exchange has happened or not.

See also: Compare-And-Swap

fplAtomicCompareAndSwapS64()

fpl_platform_api int64_t fplAtomicCompareAndSwapS64 ( volatile int64_t * dest, const int64_t comparand, const int64_t exchange )

Compares a 64-bit signed integer with a comparand and swaps it when comparand matches the destination.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns the value of the destination before the swap, regardless of the result.

Note: Ensures that memory operations are completed in order.

Use

fplAtomicIsCompareAndSwapS64() when you want to check if the exchange has happened or not.

See also: Compare-And-Swap

fplAtomicCompareAndSwapSize()

fpl_common_api size_t fplAtomicCompareAndSwapSize ( volatile size_t * dest, const size_t comparand, const size_t exchange )

Compares a size with a comparand and swaps it when comparand matches the destination.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns the value of the destination before the swap, regardless of the result.

Note: Ensures that memory operations are completed in order.

Use

fplAtomicIsCompareAndSwapSize() when you want to check if the exchange has happened or not.

See also: Compare-And-Swap

fplAtomicCompareAndSwapU32()

fpl_platform_api uint32_t fplAtomicCompareAndSwapU32 ( volatile uint32_t * dest, const uint32_t comparand, const uint32_t exchange )

Compares a 32-bit unsigned integer with a comparand and swaps it when comparand matches the destination.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns the value of the destination before the swap, regardless of the result.

Note: Ensures that memory operations are completed in order.

Use

fplAtomicIsCompareAndSwapU32() when you want to check if the exchange has happened or not.

See also: Compare-And-Swap

fplAtomicCompareAndSwapU64()

fpl_platform_api uint64_t fplAtomicCompareAndSwapU64 ( volatile uint64_t * dest, const uint64_t comparand, const uint64_t exchange )

Compares a 64-bit unsigned integer with a comparand and swaps it when comparand matches the destination.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns the value of the destination before the swap, regardless of the result.

Note: Ensures that memory operations are completed in order.

Use

fplAtomicIsCompareAndSwapU64() when you want to check if the exchange has happened or not.

See also: Compare-And-Swap

fplAtomicExchangePtr()

fpl_common_api void * fplAtomicExchangePtr ( volatile void ** target, const void * value )

Replaces a pointer with the given value atomically.

Parameters

Direction Parameter Description
[in,out] target The target value to write into.
[in] value The source value used for exchange.

Returns: Returns the initial value before the replacement.

Note: Ensures that memory operations are completed in order.

See also: Exchange

fplAtomicExchangeS32()

fpl_platform_api int32_t fplAtomicExchangeS32 ( volatile int32_t * target, const int32_t value )

Replaces a 32-bit signed integer with the given value atomically.

Parameters

Direction Parameter Description
[in,out] target The target value to write into.
[in] value The source value used for exchange.

Returns: Returns the initial value before the replacement.

Note: Ensures that memory operations are completed in order.

See also: Exchange

fplAtomicExchangeS64()

fpl_platform_api int64_t fplAtomicExchangeS64 ( volatile int64_t * target, const int64_t value )

Replaces a 64-bit signed integer with the given value atomically.

Parameters

Direction Parameter Description
[in,out] target The target value to write into.
[in] value The source value used for exchange.

Returns: Returns the initial value before the replacement.

Note: Ensures that memory operations are completed in order.

See also: Exchange

fplAtomicExchangeSize()

fpl_common_api size_t fplAtomicExchangeSize ( volatile size_t * target, const size_t value )

Replaces a size with the given value atomically.

Parameters

Direction Parameter Description
[in,out] target The target value to write into.
[in] value The source value used for exchange.

Returns: Returns the initial value before the replacement.

Note: Ensures that memory operations are completed in order.

See also: Exchange

fplAtomicExchangeU32()

fpl_platform_api uint32_t fplAtomicExchangeU32 ( volatile uint32_t * target, const uint32_t value )

Replaces a 32-bit unsigned integer with the given value atomically.

Parameters

Direction Parameter Description
[in,out] target The target value to write into.
[in] value The source value used for exchange.

Returns: Returns the initial value before the replacement.

Note: Ensures that memory operations are completed in order.

See also: Exchange

fplAtomicExchangeU64()

fpl_platform_api uint64_t fplAtomicExchangeU64 ( volatile uint64_t * target, const uint64_t value )

Replaces a 64-bit unsigned integer with the given value atomically.

Parameters

Direction Parameter Description
[in,out] target The target value to write into.
[in] value The source value used for exchange.

Returns: Returns the initial value before the replacement.

Note: Ensures that memory operations are completed in order.

See also: Exchange

fplAtomicFetchAndAddPtr()

fpl_common_api void * fplAtomicFetchAndAddPtr ( volatile void ** dest, const intptr_t addend )

Adds a addend to the pointer atomically and returns the initial value before the add.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the initial value before the add.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicFetchAndAddS32()

fpl_platform_api int32_t fplAtomicFetchAndAddS32 ( volatile int32_t * value, const int32_t addend )

Adds a 32-bit signed integer to the value by the given addend atomically.

Parameters

Direction Parameter Description
[in,out] value The target value to add to.
[in] addend The value used for adding.

Returns: Returns the initial value before the add.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicFetchAndAddS64()

fpl_platform_api int64_t fplAtomicFetchAndAddS64 ( volatile int64_t * value, const int64_t addend )

Adds a 64-bit signed integer to the value by the given addend atomically.

Parameters

Direction Parameter Description
[in,out] value The target value to add to.
[in] addend The value used for adding.

Returns: Returns the initial value before the add.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicFetchAndAddSize()

fpl_common_api size_t fplAtomicFetchAndAddSize ( volatile size_t * dest, const size_t addend )

Adds a size to the value by the given addend atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to add to.
[in] addend The value used for adding.

Returns: Returns the initial value before the add.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicFetchAndAddU32()

fpl_platform_api uint32_t fplAtomicFetchAndAddU32 ( volatile uint32_t * value, const uint32_t addend )

Adds a 32-bit unsigned integer to the value by the given addend atomically.

Parameters

Direction Parameter Description
[in,out] value The target value to add to.
[in] addend The value used for adding.

Returns: Returns the initial value before the add.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicFetchAndAddU64()

fpl_platform_api uint64_t fplAtomicFetchAndAddU64 ( volatile uint64_t * value, const uint64_t addend )

Adds a 64-bit unsigned integer to the value by the given addend atomically.

Parameters

Direction Parameter Description
[in,out] value The target value to add to.
[in] addend The value used for adding.

Returns: Returns the initial value before the add.

Note: Ensures that memory operations are completed in order.

See also: Fetch-And-Add (Add)

fplAtomicIncrementPtr()

fpl_common_api void * fplAtomicIncrementPtr ( volatile void ** dest)

Increments/Advances the given pointer by one atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to increment to.

Returns: Returns the next address, after the increment.

Note: Ensures that memory operations are completed in order.

See also: Add-And-Fetch (Increment)

fplAtomicIncrementS32()

fpl_platform_api int32_t fplAtomicIncrementS32 ( volatile int32_t * dest)

Increments the given 32-bit signed integer by one atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to increment to.

Returns: Returns the value after the increment.

Note: Ensures that memory operations are completed in order.

See also: Add-And-Fetch (Increment)

fplAtomicIncrementS64()

fpl_platform_api int64_t fplAtomicIncrementS64 ( volatile int64_t * dest)

Increments the given 64-bit signed integer by one atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to increment to.

Returns: Returns the value after the increment.

Note: Ensures that memory operations are completed in order.

See also: Add-And-Fetch (Increment)

fplAtomicIncrementSize()

fpl_common_api size_t fplAtomicIncrementSize ( volatile size_t * dest)

Increments the given size by one atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to increment to.

Returns: Returns the value after the increment.

Note: Ensures that memory operations are completed in order.

See also: Add-And-Fetch (Increment)

fplAtomicIncrementU32()

fpl_platform_api uint32_t fplAtomicIncrementU32 ( volatile uint32_t * dest)

Increments the given 32-bit unsigned integer by one atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to increment to.

Returns: Returns the value after the increment.

Note: Ensures that memory operations are completed in order.

See also: Add-And-Fetch (Increment)

fplAtomicIncrementU64()

fpl_platform_api uint64_t fplAtomicIncrementU64 ( volatile uint64_t * dest)

Increments the given 64-bit unsigned integer by one atomically.

Parameters

Direction Parameter Description
[in,out] dest The target value to increment to.

Returns: Returns the value after the increment.

Note: Ensures that memory operations are completed in order.

See also: Add-And-Fetch (Increment)

fplAtomicIsCompareAndSwapPtr()

fpl_common_api bool fplAtomicIsCompareAndSwapPtr ( volatile void ** dest, const void * comparand, const void * exchange )

Compares a pointer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns true when the exchange happened, false otherwise.

Note: Ensures that memory operations are completed in order.

See also: Compare-And-Swap

fplAtomicIsCompareAndSwapS32()

fpl_platform_api bool fplAtomicIsCompareAndSwapS32 ( volatile int32_t * dest, const int32_t comparand, const int32_t exchange )

Compares a 32-bit signed integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns true when the exchange happened, false otherwise.

Note: Ensures that memory operations are completed in order.

See also: Compare-And-Swap

fplAtomicIsCompareAndSwapS64()

fpl_platform_api bool fplAtomicIsCompareAndSwapS64 ( volatile int64_t * dest, const int64_t comparand, const int64_t exchange )

Compares a 64-bit signed integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns true when the exchange happened, false otherwise.

Note: Ensures that memory operations are completed in order.

See also: Compare-And-Swap

fplAtomicIsCompareAndSwapSize()

fpl_common_api bool fplAtomicIsCompareAndSwapSize ( volatile size_t * dest, const size_t comparand, const size_t exchange )

Compares a size with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns true when the exchange happened, false otherwise.

Note: Ensures that memory operations are completed in order.

See also: Compare-And-Swap

fplAtomicIsCompareAndSwapU32()

fpl_platform_api bool fplAtomicIsCompareAndSwapU32 ( volatile uint32_t * dest, const uint32_t comparand, const uint32_t exchange )

Compares a 32-bit unsigned integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns true when the exchange happened, false otherwise.

Note: Ensures that memory operations are completed in order.

See also: Compare-And-Swap

fplAtomicIsCompareAndSwapU64()

fpl_platform_api bool fplAtomicIsCompareAndSwapU64 ( volatile uint64_t * dest, const uint64_t comparand, const uint64_t exchange )

Compares a 64-bit unsigned integer with a comparand and swaps it when comparand matches the destination and returns a bool indicating the result.

Parameters

Direction Parameter Description
[in,out] dest The target value to write into.
[in] comparand The value to compare with.
[in] exchange The value to exchange with.

Returns: Returns true when the exchange happened, false otherwise.

Note: Ensures that memory operations are completed in order.

See also: Compare-And-Swap

fplAtomicLoadPtr()

fpl_common_api void * fplAtomicLoadPtr ( volatile void ** source)

Loads the pointer value atomically and returns the value.

Note: Ensures that memory operations are completed before the reading.

This may use a CAS instruction when there are no suitable compiler intrinsics found.

Parameters

Direction Parameter Description
[in] source The source value to read from.

Returns: Returns the atomically loaded source value

See also: Load

fplAtomicLoadS32()

fpl_platform_api int32_t fplAtomicLoadS32 ( volatile int32_t * source)

Loads the 32-bit signed value atomically and returns the value.

Parameters

Direction Parameter Description
[in] source The source value to read from.

Returns: Returns the atomically loaded source value

Note: Ensures that memory operations are completed before the reading.

This may use a CAS instruction when there are no suitable compiler intrinsics found.

See also: Load

fplAtomicLoadS64()

fpl_platform_api int64_t fplAtomicLoadS64 ( volatile int64_t * source)

Loads the 64-bit signed value atomically and returns the value.

Parameters

Direction Parameter Description
[in] source The source value to read from.

Returns: Returns the atomically loaded source value

Note: Ensures that memory operations are completed before the reading.

This may use a CAS instruction when there are no suitable compiler intrinsics found.

See also: Load

fplAtomicLoadSize()

fpl_common_api size_t fplAtomicLoadSize ( volatile size_t * source)

Loads the size value atomically and returns the value.

Note: Ensures that memory operations are completed before the reading.

This may use a CAS instruction when there are no suitable compiler intrinsics found.

Parameters

Direction Parameter Description
[in] source The source value to read from.

Returns: Returns the atomically loaded source value

See also: Load

fplAtomicLoadU32()

fpl_platform_api uint32_t fplAtomicLoadU32 ( volatile uint32_t * source)

Loads the 32-bit unsigned value atomically and returns the value.

Parameters

Direction Parameter Description
[in] source The source value to read from.

Returns: Returns the atomically loaded source value

Note: Ensures that memory operations are completed before the reading.

This may use a CAS instruction when there are no suitable compiler intrinsics found.

See also: Load

fplAtomicLoadU64()

fpl_platform_api uint64_t fplAtomicLoadU64 ( volatile uint64_t * source)

Loads the 64-bit unsigned value atomically and returns the value.

Parameters

Direction Parameter Description
[in] source The source value to read from.

Returns: Returns the atomically loaded source value

Note: Ensures that memory operations are completed before the reading.

This may use a CAS instruction when there are no suitable compiler intrinsics found.

See also: Load

fplAtomicReadFence()

fpl_platform_api void fplAtomicReadFence ( void )

Inserts a memory read fence/barrier.

Note: This will complete previous reads before future reads and prevents the compiler from reordering memory reads across this fence.

See also: Memory Barriers

fplAtomicReadWriteFence()

fpl_platform_api void fplAtomicReadWriteFence ( void )

Inserts a memory read and write fence/barrier.

Note: This will complete previous reads and writes before future reads and writes and prevents the compiler from reordering memory access across this fence.

See also: Memory Barriers

fplAtomicStorePtr()

fpl_common_api void fplAtomicStorePtr ( volatile void ** dest, const void * value )

Overwrites the pointer value atomically.

Parameters

Direction Parameter Description
[out] dest The destination to write to.
[in] value The value to exchange with.

Note: Ensures that memory operations are completed before the write.

See also: Store

fplAtomicStoreS32()

fpl_platform_api void fplAtomicStoreS32 ( volatile int32_t * dest, const int32_t value )

Overwrites the 32-bit signed value atomically.

Parameters

Direction Parameter Description
[out] dest The destination to write to.
[in] value The value to exchange with.

Note: Ensures that memory operations are completed before the write.

See also: Store

fplAtomicStoreS64()

fpl_platform_api void fplAtomicStoreS64 ( volatile int64_t * dest, const int64_t value )

Overwrites the 64-bit signed value atomically.

Parameters

Direction Parameter Description
[out] dest The destination to write to.
[in] value The value to exchange with.

Note: Ensures that memory operations are completed before the write.

See also: Store

fplAtomicStoreSize()

fpl_common_api void fplAtomicStoreSize ( volatile size_t * dest, const size_t value )

Overwrites the size value atomically.

Parameters

Direction Parameter Description
[out] dest The destination to write to.
[in] value The value to exchange with.

Note: Ensures that memory operations are completed before the write.

See also: Store

fplAtomicStoreU32()

fpl_platform_api void fplAtomicStoreU32 ( volatile uint32_t * dest, const uint32_t value )

Overwrites the 32-bit unsigned value atomically.

Parameters

Direction Parameter Description
[out] dest The destination to write to.
[in] value The value to exchange with.

Note: Ensures that memory operations are completed before the write.

See also: Store

fplAtomicStoreU64()

fpl_platform_api void fplAtomicStoreU64 ( volatile uint64_t * dest, const uint64_t value )

Overwrites the 64-bit unsigned value atomically.

Parameters

Direction Parameter Description
[out] dest The destination to write to.
[in] value The value to exchange with.

Note: Ensures that memory operations are completed before the write.

See also: Store

fplAtomicWriteFence()

fpl_platform_api void fplAtomicWriteFence ( void )

Inserts a memory write fence/barrier.

Note: This will complete previous writes before future writes and prevents the compiler from reordering memory writes across this fence.

See also: Memory Barriers

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally