Atomic functions. More...
#include <stdint.h>
Functions | |
const char * | cmx_atomic_implementation_name () |
current implementation | |
Get/Set operations | |
uint16_t | cmx_atomic_read_uint16 (volatile const uint16_t *ptr) |
Reads the value of type uint16_t at 'ptr'. | |
void | cmx_atomic_set_uint16 (volatile uint16_t *ptr, uint16_t val) |
Sets memory of type uint16_t at 'ptr' to value 'val'. | |
int32_t | cmx_atomic_read_int32 (volatile const int32_t *ptr) |
Reads the value of type int32_t at 'ptr'. | |
void | cmx_atomic_set_int32 (volatile int32_t *ptr, int32_t val) |
Sets memory of type int32_t at 'ptr' to value 'val'. | |
uint64_t | cmx_atomic_read_uint64 (volatile const uint64_t *ptr) |
Reads the value of type uint16_t at 'ptr'. | |
void | cmx_atomic_set_uint64 (volatile uint64_t *ptr, uint64_t val) |
Sets memory of type uint16_t at 'ptr' to value 'val'. | |
Atomic operations | |
int32_t | cmx_atomic_val_compare_and_swap_int32 (volatile int32_t *ptr, int32_t oldval, int32_t newval) |
CAS for a int32_t value. | |
Memory barriers. | |
void | cmx_atomic_smp_mb () |
Insert a full memory barrier. | |
void | cmx_atomic_smp_rmb () |
Insert a read memory barrier. | |
void | cmx_atomic_smp_wmb () |
Insert a write memory barrier. |
Atomic functions.
For reference see:
const char* cmx_atomic_implementation_name | ( | ) |
current implementation
Name of the implementation selected at compile-time.
int32_t cmx_atomic_read_int32 | ( | volatile const int32_t * | ptr | ) |
Reads the value of type int32_t at 'ptr'.
No memory barrier is generated by this function.
uint16_t cmx_atomic_read_uint16 | ( | volatile const uint16_t * | ptr | ) |
Reads the value of type uint16_t at 'ptr'.
uint64_t cmx_atomic_read_uint64 | ( | volatile const uint64_t * | ptr | ) |
Reads the value of type uint16_t at 'ptr'.
void cmx_atomic_set_int32 | ( | volatile int32_t * | ptr, | |
int32_t | val | |||
) |
Sets memory of type int32_t at 'ptr' to value 'val'.
No memory barrier generated by this function.
void cmx_atomic_set_uint16 | ( | volatile uint16_t * | ptr, | |
uint16_t | val | |||
) |
Sets memory of type uint16_t at 'ptr' to value 'val'.
void cmx_atomic_set_uint64 | ( | volatile uint64_t * | ptr, | |
uint64_t | val | |||
) |
Sets memory of type uint16_t at 'ptr' to value 'val'.
int32_t cmx_atomic_val_compare_and_swap_int32 | ( | volatile int32_t * | ptr, | |
int32_t | oldval, | |||
int32_t | newval | |||
) |
CAS for a int32_t value.
Compare a int32_t value pointed to by 'ptr' with 'oldval'. If they are the same, swap the value with 'newval'. returns always the value pointed to by 'ptr' before the operation.
A successful operation is: compare_and_swap(&val, oldval, newval) == oldval
ptr | pointer to the value | |
oldval | what to swap it with | |
newval | the value to compare it to |