Version 2.0.0-0

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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 Top

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