reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
lf_atomic.h File Reference
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

int lf_atomic_fetch_add (int *ptr, int val)
 This file defines the LF atomic API. These functions will have platform-dependent implementations.
 
int64_t lf_atomic_fetch_add64 (int64_t *ptr, int64_t val)
 Atomically fetch 64-bit integer from memory and add a value to it. Return the value that was previously in memory.
 
int lf_atomic_add_fetch (int *ptr, int val)
 Atomically fetch an integer from memory and add a value to it. Return the new value of the memory.
 
int64_t lf_atomic_add_fetch64 (int64_t *ptr, int64_t val)
 Atomically fetch a 64-bit integer from memory and add a value to it. Return the new value of the memory.
 
bool lf_atomic_bool_compare_and_swap (int *ptr, int oldval, int newval)
 Atomically perform a compare-and-swap operation on a 32 bit integer in memory. If the value in memory is equal to oldval replace it with newval and return true. If not return false.
 
bool lf_atomic_bool_compare_and_swap64 (int64_t *ptr, int64_t oldval, int64_t newval)
 Atomically perform a compare-and-swap operation on a 64 bit integer in memory. If the value in memory is equal to oldval replace it with newval and return true. If not return false.
 
int lf_atomic_val_compare_and_swap (int *ptr, int oldval, int newval)
 Atomically perform a compare-and-swap operation on an integer in memory. If the value in memory is equal to oldval replace it with newval. Return the content of the memory before the potential swap operation is performed.
 
int64_t lf_atomic_val_compare_and_swap64 (int64_t *ptr, int64_t oldval, int64_t newval)
 Atomically perform a compare-and-swap operation on a 64 bit integer in memory. If the value in memory is equal to oldval replace it with newval. Return the content of the memory before the potential swap operation is performed.
 

Function Documentation

◆ lf_atomic_add_fetch()

int lf_atomic_add_fetch ( int * ptr,
int val )

Atomically fetch an integer from memory and add a value to it. Return the new value of the memory.

Parameters
ptrA pointer to the memory location.
valThe value to be added.
Returns
The new value in memory.

◆ lf_atomic_add_fetch64()

int64_t lf_atomic_add_fetch64 ( int64_t * ptr,
int64_t val )

Atomically fetch a 64-bit integer from memory and add a value to it. Return the new value of the memory.

Parameters
ptrA pointer to the memory location.
valThe value to be added.
Returns
The new value in memory.

◆ lf_atomic_bool_compare_and_swap()

bool lf_atomic_bool_compare_and_swap ( int * ptr,
int oldval,
int newval )

Atomically perform a compare-and-swap operation on a 32 bit integer in memory. If the value in memory is equal to oldval replace it with newval and return true. If not return false.

Parameters
ptrA pointer to the memory location.
oldvalThe value to compare with.
newvalThe value to swap in.
Returns
Whether a swap was performed or not.

◆ lf_atomic_bool_compare_and_swap64()

bool lf_atomic_bool_compare_and_swap64 ( int64_t * ptr,
int64_t oldval,
int64_t newval )

Atomically perform a compare-and-swap operation on a 64 bit integer in memory. If the value in memory is equal to oldval replace it with newval and return true. If not return false.

Parameters
ptrA pointer to the memory location.
oldvalThe value to compare with.
newvalThe value to swap in.
Returns
Whether a swap was performed or not.

◆ lf_atomic_fetch_add()

int lf_atomic_fetch_add ( int * ptr,
int val )

This file defines the LF atomic API. These functions will have platform-dependent implementations.

Author
Erling Rennemo Jellum

Atomically fetch an integer from memory and add a value to it. Return the value that was previously in memory.

Parameters
ptrA pointer to the memory location.
valThe value to be added.
Returns
The value previously in memory.

◆ lf_atomic_fetch_add64()

int64_t lf_atomic_fetch_add64 ( int64_t * ptr,
int64_t val )

Atomically fetch 64-bit integer from memory and add a value to it. Return the value that was previously in memory.

Parameters
ptrA pointer to the memory location.
valThe value to be added.
Returns
The value previously in memory.

◆ lf_atomic_val_compare_and_swap()

int lf_atomic_val_compare_and_swap ( int * ptr,
int oldval,
int newval )

Atomically perform a compare-and-swap operation on an integer in memory. If the value in memory is equal to oldval replace it with newval. Return the content of the memory before the potential swap operation is performed.

Parameters
ptrA pointer to the memory location.
oldvalThe value to compare with.
newvalThe value to swap in.
Returns
The value in memory prior to the swap.

◆ lf_atomic_val_compare_and_swap64()

int64_t lf_atomic_val_compare_and_swap64 ( int64_t * ptr,
int64_t oldval,
int64_t newval )

Atomically perform a compare-and-swap operation on a 64 bit integer in memory. If the value in memory is equal to oldval replace it with newval. Return the content of the memory before the potential swap operation is performed.

Parameters
ptrA pointer to the memory location.
oldvalThe value to compare with.
newvalThe value to swap in.
Returns
The value in memory prior to the swap.