Add atomic load/store operations on pointers
Added atomic operations on pointers. Also removed extra return statements on void functions.
This commit is contained in:
parent
1e1c4abcb7
commit
a4e361b5e5
@ -60,6 +60,7 @@ uint64_t atomic_add_uint64(uint64_t *variable, int64_t value);
|
||||
int atomic_load_int32(int *variable);
|
||||
int64_t atomic_load_int64(int64_t *variable);
|
||||
uint64_t atomic_load_uint64(uint64_t *variable);
|
||||
void* atomic_load_ptr(void **variable);
|
||||
|
||||
/**
|
||||
* Implementation of an atomic store operation for the GCC environment.
|
||||
@ -73,6 +74,7 @@ uint64_t atomic_load_uint64(uint64_t *variable);
|
||||
void atomic_store_int32(int *variable, int value);
|
||||
void atomic_store_int64(int64_t *variable, int64_t value);
|
||||
void atomic_store_uint64(uint64_t *variable, uint64_t value);
|
||||
void atomic_store_ptr(void **variable, void *value);
|
||||
|
||||
/**
|
||||
* @brief Impose a full memory barrier
|
||||
|
@ -80,6 +80,15 @@ uint64_t atomic_load_uint64(uint64_t *variable)
|
||||
#endif
|
||||
}
|
||||
|
||||
void* atomic_load_ptr(void **variable)
|
||||
{
|
||||
#ifdef MXS_USE_ATOMIC_BUILTINS
|
||||
return __atomic_load_n(variable, __ATOMIC_SEQ_CST);
|
||||
#else
|
||||
return __sync_fetch_and_or(variable, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void atomic_store_int32(int *variable, int value)
|
||||
{
|
||||
#ifdef MXS_USE_ATOMIC_BUILTINS
|
||||
@ -106,3 +115,12 @@ void atomic_store_uint64(uint64_t *variable, uint64_t value)
|
||||
__sync_lock_test_and_set(variable, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
void atomic_store_ptr(void **variable, void *value)
|
||||
{
|
||||
#ifdef MXS_USE_ATOMIC_BUILTINS
|
||||
__atomic_store_n(variable, value, __ATOMIC_SEQ_CST);
|
||||
#else
|
||||
__sync_lock_test_and_set(variable, value);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user