Atomic Reference

File
XSFoundation/include/XS/Functions/Atomic.h
Author
Jean-David Gadina - www.xs-labs.com
Copyright
© (c) 2020 - Jean-David Gadina - www.xs-labs.com
Date
Sunday, September 27, 2020
Includes

Overview

Atomic functions

Tasks

XSAtomicAdd32

Atomically adds to a 32 bits value

XS_EXPORT int32_t XSAtomicAdd32( int32_t amount, volatile int32_t *value );

Parameters
  • amount
    The amount to add
  • value
    The 32 bits value to modify
Return value

The new value

XSAtomicAdd64

Atomically adds to a 64 bits value

XS_EXPORT int64_t XSAtomicAdd64( int64_t amount, volatile int64_t *value );

Parameters
  • amount
    The amount to add
  • value
    The 64 bits value to modify
Return value

The new value

XSAtomicCompareAndSwap32

Atomically compares and swaps a 32 bits value

XS_EXPORT bool XSAtomicCompareAndSwap32( int32_t oldValue, int32_t newValue, volatile int32_t *value );

Parameters
  • oldValue
    The 32 bits value to test
  • newValue
    The 32 bits value to swap
  • value
    The 32 bits value to compare and swap
Return value

True if the comparison was equal and the swap occured

XSAtomicCompareAndSwap64

Atomically compares and swaps a 64 bits value

XS_EXPORT bool XSAtomicCompareAndSwap64( int64_t oldValue, int64_t newValue, volatile int64_t *value );

Parameters
  • oldValue
    The 64 bits value to test
  • newValue
    The 64 bits value to swap
  • value
    The 64 bits value to compare and swap
Return value

True if the comparison was equal and the swap occured

XSAtomicCompareAndSwapPointer

Atomically compares and swaps a pointer value

XS_EXPORT bool XSAtomicCompareAndSwapPointer( void *oldValue, void *newValue, void *volatile * value );

Parameters
  • oldValue
    The pointer value to test
  • newValue
    The pointer value to swap
  • value
    The pointer value to compare and swap
Return value

True if the comparison was equal and the swap occured

XSAtomicDecrement32

Atomically decrements a 32 bits value

XS_EXPORT int32_t XSAtomicDecrement32( volatile int32_t *value );

Parameters
  • value
    The 32 bits value to decrement
Return value

The new value

XSAtomicDecrement64

Atomically decrements a 64 bits value

XS_EXPORT int64_t XSAtomicDecrement64( volatile int64_t *value );

Parameters
  • value
    The 64 bits value to decrement
Return value

The new value

XSAtomicIncrement32

Atomically increments a 32 bits value

XS_EXPORT int32_t XSAtomicIncrement32( volatile int32_t *value );

Parameters
  • value
    The 32 bits value to increment
Return value

The new value

XSAtomicIncrement64

Atomically increments a 64 bits value

XS_EXPORT int64_t XSAtomicIncrement64( volatile int64_t *value );

Parameters
  • value
    The 64 bits value to increment
Return value

The new value

XSAtomicRead32

Atomically reads a 32 bits value

XS_EXPORT int32_t XSAtomicRead32( volatile int32_t *value );

Parameters
  • value
    The 32 bits value to read
Return value

The 32 bits value

XSAtomicRead64

Atomically reads a 64 bits value

XS_EXPORT int64_t XSAtomicRead64( volatile int64_t *value );

Parameters
  • value
    The 64 bits value to read
Return value

The 64 bits value

XSAtomicWrite32

Atomically writes a 32 bits value

XS_EXPORT void XSAtomicWrite32( int32_t newValue, volatile int32_t *value );

Parameters
  • newValue
    The new 32 bits value to write
  • value
    The 32 bits value to modify

XSAtomicWrite64

Atomically writes a 64 bits value

XS_EXPORT void XSAtomicWrite64( int64_t newValue, volatile int64_t *value );

Parameters
  • newValue
    The new 64 bits value to write
  • value
    The 64 bits value to modify