Shared Persistent Heap Data Environment Manual
1.1.0
|
Type and functions for SAS atomic operations. More...
#include <sched.h>
#include "sasatom_generic.h"
Go to the source code of this file.
Macros | |
#define | sas_write_barrier() __arch_sas_write_barrier() |
#define | sas_read_barrier() __arch_sas_read_barrier() |
#define | sas_full_barrier() __arch_sas_full_barrier() |
#define | sas_code_barrier() __asm ("" ::: "memory") |
Typedefs | |
typedef unsigned int | sas_spin_lock_t |
typedef void * | sas_lock_ptr_t |
Functions | |
static void * | sas_fetch_and_add_ptr (void **pointer, long int delta) |
static long int | sas_fetch_and_add (long *pointer, long int delta) |
static long int | sas_fetch_and_and (unsigned int *pointer, int delta) |
static long int | sas_fetch_and_and_long (unsigned long *pointer, long int delta) |
static long int | sas_fetch_and_or (unsigned int *pointer, int delta) |
static long int | sas_fetch_and_or_long (unsigned long *pointer, long int delta) |
static int | sas_compare_and_swap (volatile long int *p, long int oldval, long int newval) |
static long int | sas_atomic_swap (long int *p, long int replace) |
static void | sas_atomic_inc (long int *p) |
static void | sas_atomic_dec (long int *p) |
static void | sas_spin_lock_init (volatile sas_spin_lock_t *lock) |
static void | sas_spin_lock (volatile sas_spin_lock_t *lock) |
static int | sas_spin_trylock (volatile sas_spin_lock_t *lock) |
static void | sas_spin_unlock (volatile sas_spin_lock_t *lock) |
static void | sas_lock_ptr_init (volatile sas_lock_ptr_t *lock) |
static void * | sas_lock_ptr (volatile sas_lock_ptr_t *lock) |
static void | sas_set_unlocked_ptr (volatile sas_lock_ptr_t *lock, sas_lock_ptr_t newptr) |
static void | sas_set_locked_ptr (volatile sas_lock_ptr_t *lock, sas_lock_ptr_t newptr) |
static int | sas_trylock_ptr (volatile sas_lock_ptr_t *lock) |
static void | sas_unlock_ptr (volatile sas_lock_ptr_t *lock) |
static void | sas_spin_lock_with_yield (volatile sas_spin_lock_t *lock) |
static void | sas_lock_ptr_with_yield (volatile sas_lock_ptr_t *lock) |
static long | sas_atomic_inc_long (volatile long *value) |
static long | sas_atomic_dec_long (volatile long *value) |
Type and functions for SAS atomic operations.
This file contains generic SAS atomic functions. Architecture specific code is in its correpondent header ('sasatom_ppc.h' for PowerPC32 and PowerPC64, 'sasatom_i386.h' for i386, and 'sasatom_x86_64.h' for X86_64). The 'sasatom_generic.h' header is provided as reference implementation and it is not garanted to work correctly.
#define sas_code_barrier | ( | ) | __asm ("" ::: "memory") |
Memory barrier for compiler code motion.
#define sas_full_barrier | ( | ) | __arch_sas_full_barrier() |
Memory barrier for both load/store operations.
#define sas_read_barrier | ( | ) | __arch_sas_read_barrier() |
Memory barrier for load operations.
#define sas_write_barrier | ( | ) | __arch_sas_write_barrier() |
Memory barrier for store operations.
typedef void* sas_lock_ptr_t |
Pointer to sas_spin_lock_t type
typedef unsigned int sas_spin_lock_t |
Spinlock type used on sas_spin_xxx functions
|
inlinestatic |
Atomic decrement, performing { (*p)– }
|
inlinestatic |
Atomically decrements value by 1.
|
inlinestatic |
Atomic increment, performing { (*p)++ }
|
inlinestatic |
Atomically increments value by 1.
|
inlinestatic |
Atomic swap operation.
Performs the atomic operation: { tmp = *p; *p = tmp; return tmp }
|
inlinestatic |
Atomic compare and swap operation.
Performs the atomic operation: { *p == oldval ? *p = newval : *p; return *p }
Returns oldval.
|
inlinestatic |
Atomic fetch and add operation on memory pointer.
Performs the atomic operation: { tmp = *pointer; *pointer = tmp + delta; return *pointer }
Returns *pointer before update.
|
inlinestatic |
Atomic fetch and add operation on memory referenced by pointer.
Performs the atomic operation: { tmp = **pointer; **pointer = tmp + delta; return *pointer }
Returns *pointer before update.
|
inlinestatic |
Atomic fetch and and operation on memory pointer of int type.
Performs the atomic operation: { tmp = *pointer; *pointer = tmp & delta; return *pointer }
Returns *pointer before update.
|
inlinestatic |
Atomic fetch and and operation on memory pointer of long type.
Performs the atomic operation: { tmp = *pointer; *pointer = tmp & delta; return *pointer }
Returns *pointer before update.
|
inlinestatic |
Atomic fetch and or operation on memory pointer of int type.
Performs the atomic operation: { tmp = *pointer; *pointer = tmp | delta; return *pointer }
Returns *pointer before update.
|
inlinestatic |
Atomic fetch and or operation on memory pointer of long type.
Performs the atomic operation: { tmp = *pointer; *pointer = tmp | delta; return *pointer }
Returns *pointer before update.
|
inlinestatic |
Locks the spinlock pointer lock and returns its unlocked value.
|
inlinestatic |
Initializes the spinlock pointer lock so it can be used with lock and unlock functions.
|
inlinestatic |
The function tried 4 times to lock lock pointer and if it fails it calls 'sched_yield' returning with another lock try.
|
inlinestatic |
Spins over lock lock until it is locked then swap its value with newptr locked value.
|
inlinestatic |
Spins over spinlock pointer lock until it is unlocked then swap its value with newptr locked value.
|
inlinestatic |
Locks the spinlock lock.
The function uses a busylock algorithm in the form: while ({tmp = *lock; *lock = 1; });
|
inlinestatic |
Initializes the spinlock lock so it can be used with lock and unlock functions.
|
inlinestatic |
The function tries 4 times to lock lock and if it fails it calls 'sched_yield' returning with another lock try.
|
inlinestatic |
Try to lock the spinlock lock.
It returns if the lock lock can not be locked.
Returns 1 if the spinlock was locked, 0 otherwise.
|
inlinestatic |
Unlocks the spinlock lock reseting it to initial value.
|
inlinestatic |
The function tried to lock lock. If the operation is successful the function return 0 or 1 otherwise.
|
inlinestatic |
Unlocks the spinlock lock.