PFUNC
1.0
|
Implements atomic operations on PODs. More...
#include <pfunc/config.h>
#include <pfunc/environ.hpp>
#include <stdint.h>
#include <pfunc/asm/x86.h>
Go to the source code of this file.
Defines | |
#define | PFUNC_STATIC_CAST(T, expr) (T)(expr) |
#define | PFUNC_CONST_CAST(T, expr) (T)(expr) |
#define | PFUNC_DYNAMIC_CAST(T, expr) (T)(expr) |
#define | PFUNC_REINTERPRET_CAST(T, expr) (T)(expr) |
Typedefs | |
typedef _int32 | int32_t |
typedef _int16 | int16_t |
typedef _int8 | int8_t |
Functions | |
static PFUNC_INLINE int8_t | pfunc_compare_and_swap_8 (volatile void *dest, int8_t exchg, int8_t comprnd) |
Compare and Swap an 8-bit memory location. | |
static PFUNC_INLINE int16_t | pfunc_compare_and_swap_16 (volatile void *dest, int16_t exchg, int16_t comprnd) |
Compare and Swap an 16-bit memory location. | |
static PFUNC_INLINE int32_t | pfunc_compare_and_swap_32 (volatile void *dest, int32_t exchg, int32_t comprnd) |
Compare and Swap an 32-bit memory location. | |
static PFUNC_INLINE int8_t | pfunc_fetch_and_store_8 (volatile void *location, int8_t new_val) |
Atomically fetches 8-bit value from memory and stores a new value. | |
static PFUNC_INLINE int16_t | pfunc_fetch_and_store_16 (volatile void *location, int16_t new_val) |
Atomically fetches 16-bit value from memory and stores a new value. | |
static PFUNC_INLINE int32_t | pfunc_fetch_and_store_32 (volatile void *location, int32_t new_val) |
Atomically fetches 32-bit value from memory and stores a new value. | |
static PFUNC_INLINE int8_t | pfunc_fetch_and_add_8 (volatile void *location, int8_t addend) |
Atomically fetches 8-bit value from memory and adds to it. | |
static PFUNC_INLINE int16_t | pfunc_fetch_and_add_16 (volatile void *location, int16_t addend) |
Atomically fetches 16-bit value from memory and adds to it. | |
static PFUNC_INLINE int32_t | pfunc_fetch_and_add_32 (volatile void *location, int32_t addend) |
Atomically fetches 32-bit value from memory and adds to it. | |
static PFUNC_INLINE int8_t | pfunc_read_with_fence_8 (volatile void *location) |
Read an 8-bit value and insert a fence after the read. | |
static PFUNC_INLINE int16_t | pfunc_read_with_fence_16 (volatile void *location) |
Read an 16-bit value and insert a fence after the read. | |
static PFUNC_INLINE int32_t | pfunc_read_with_fence_32 (volatile void *location) |
Read an 32-bit value and insert a fence after the read. | |
static PFUNC_INLINE void | pfunc_write_with_fence_8 (volatile void *location, int8_t value) |
Write an 8-bit value and insert a fence before the write. | |
static PFUNC_INLINE void | pfunc_write_with_fence_16 (volatile void *location, int16_t value) |
Write an 16-bit value and insert a fence before the write. | |
static PFUNC_INLINE void | pfunc_write_with_fence_32 (volatile void *location, int32_t value) |
Write an 32-bit value and insert a fence before the write. |
Implements atomic operations on PODs.
#define PFUNC_CONST_CAST | ( | T, | |
expr | |||
) | (T)(expr) |
#define PFUNC_DYNAMIC_CAST | ( | T, | |
expr | |||
) | (T)(expr) |
#define PFUNC_REINTERPRET_CAST | ( | T, | |
expr | |||
) | (T)(expr) |
#define PFUNC_STATIC_CAST | ( | T, | |
expr | |||
) | (T)(expr) |
typedef _int16 int16_t |
typedef _int32 int32_t |
typedef _int8 int8_t |
static PFUNC_INLINE int16_t pfunc_compare_and_swap_16 | ( | volatile void * | dest, |
int16_t | exchg, | ||
int16_t | comprnd | ||
) | [static] |
Compare and Swap an 16-bit memory location.
dest | Pointer to the memory location of the operand |
exchg | The new value to which dest has to be set if successful |
comprnd | The value that is compared to the memory location |
if (*dest == comprnd) { *dest = exchg; return exchg; } else { return *dest; }
static PFUNC_INLINE int32_t pfunc_compare_and_swap_32 | ( | volatile void * | dest, |
int32_t | exchg, | ||
int32_t | comprnd | ||
) | [static] |
Compare and Swap an 32-bit memory location.
dest | Pointer to the memory location of the operand |
exchg | The new value to which dest has to be set if successful |
comprnd | The value that is compared to the memory location |
if (*dest == comprnd) { *dest = exchg; return exchg; } else { return *dest; }
static PFUNC_INLINE int8_t pfunc_compare_and_swap_8 | ( | volatile void * | dest, |
int8_t | exchg, | ||
int8_t | comprnd | ||
) | [static] |
Compare and Swap an 8-bit memory location.
dest | Pointer to the memory location of the operand |
exchg | The new value to which dest has to be set if successful |
comprnd | The value that is compared to the memory location |
if (*dest == comprnd) { *dest = exchg; return exchg; } else { return *dest; }
static PFUNC_INLINE int16_t pfunc_fetch_and_add_16 | ( | volatile void * | location, |
int16_t | addend | ||
) | [static] |
Atomically fetches 16-bit value from memory and adds to it.
location | Pointer to memory location |
addend | The increment to the memory location. |
result = *location;
*location += addend;
return result;
static PFUNC_INLINE int32_t pfunc_fetch_and_add_32 | ( | volatile void * | location, |
int32_t | addend | ||
) | [static] |
Atomically fetches 32-bit value from memory and adds to it.
location | Pointer to memory location |
addend | The increment to the memory location. |
result = *location;
*location += addend;
return result;
static PFUNC_INLINE int8_t pfunc_fetch_and_add_8 | ( | volatile void * | location, |
int8_t | addend | ||
) | [static] |
Atomically fetches 8-bit value from memory and adds to it.
location | Pointer to memory location |
addend | The increment to the memory location. |
result = *location;
*location += addend;
return result;
static PFUNC_INLINE int16_t pfunc_fetch_and_store_16 | ( | volatile void * | location, |
int16_t | new_val | ||
) | [static] |
Atomically fetches 16-bit value from memory and stores a new value.
location | Pointer to memory location |
new_val | The new value to be atomically written in |
result = *location;
*location = new_val;
return result;
static PFUNC_INLINE int32_t pfunc_fetch_and_store_32 | ( | volatile void * | location, |
int32_t | new_val | ||
) | [static] |
Atomically fetches 32-bit value from memory and stores a new value.
location | Pointer to memory location |
new_val | The new value to be atomically written in |
result = *location;
*location = new_val;
return result;
static PFUNC_INLINE int8_t pfunc_fetch_and_store_8 | ( | volatile void * | location, |
int8_t | new_val | ||
) | [static] |
Atomically fetches 8-bit value from memory and stores a new value.
location | Pointer to memory location |
new_val | The new value to be atomically written in |
result = *location;
*location = new_val;
return result;
static PFUNC_INLINE int16_t pfunc_read_with_fence_16 | ( | volatile void * | location | ) | [static] |
Read an 16-bit value and insert a fence after the read.
location | The memory from which to read |
static PFUNC_INLINE int32_t pfunc_read_with_fence_32 | ( | volatile void * | location | ) | [static] |
Read an 32-bit value and insert a fence after the read.
location | The memory from which to read |
static PFUNC_INLINE int8_t pfunc_read_with_fence_8 | ( | volatile void * | location | ) | [static] |
Read an 8-bit value and insert a fence after the read.
location | The memory from which to read |
static PFUNC_INLINE void pfunc_write_with_fence_16 | ( | volatile void * | location, |
int16_t | value | ||
) | [static] |
Write an 16-bit value and insert a fence before the write.
location | The memory to write to |
value | The value to write |
static PFUNC_INLINE void pfunc_write_with_fence_32 | ( | volatile void * | location, |
int32_t | value | ||
) | [static] |
Write an 32-bit value and insert a fence before the write.
location | The memory to write to |
value | The value to write |
static PFUNC_INLINE void pfunc_write_with_fence_8 | ( | volatile void * | location, |
int8_t | value | ||
) | [static] |
Write an 8-bit value and insert a fence before the write.
location | The memory to write to |
value | The value to write |