Rename atomic store and load functions
The atomic store and load functions are now called atomic_store_X and atomic_load_X where X is one of int32, int64 or uint64.
This commit is contained in:
parent
f91d415be1
commit
19cf8c489e
@ -45,9 +45,9 @@ uint64_t atomic_add_uint64(uint64_t *variable, int64_t value);
|
||||
* @param variable Pointer the the variable to load from
|
||||
* @return The stored value
|
||||
*/
|
||||
int atomic_read(int *variable);
|
||||
int64_t atomic_read_int64(int64_t *variable);
|
||||
uint64_t atomic_read_uint64(uint64_t *variable);
|
||||
int atomic_load_int32(int *variable);
|
||||
int64_t atomic_load_int64(int64_t *variable);
|
||||
uint64_t atomic_load_uint64(uint64_t *variable);
|
||||
|
||||
/**
|
||||
* Implementation of an atomic store operation for the GCC environment.
|
||||
@ -58,9 +58,9 @@ uint64_t atomic_read_uint64(uint64_t *variable);
|
||||
* @param variable Pointer the the variable to store to
|
||||
* @param value Value to be stored
|
||||
*/
|
||||
void atomic_write(int *variable, int value);
|
||||
void atomic_write_int64(int64_t *variable, int64_t value);
|
||||
void atomic_write_uint64(uint64_t *variable, uint64_t value);
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Impose a full memory barrier
|
||||
|
@ -32,32 +32,32 @@ uint64_t atomic_add_uint64(uint64_t *variable, int64_t value)
|
||||
return __sync_fetch_and_add(variable, value);
|
||||
}
|
||||
|
||||
int atomic_read(int *variable)
|
||||
int atomic_load_int32(int *variable)
|
||||
{
|
||||
return __atomic_load_n(variable, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
int64_t atomic_read_int64(int64_t *variable)
|
||||
int64_t atomic_load_int64(int64_t *variable)
|
||||
{
|
||||
return __atomic_load_n(variable, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
uint64_t atomic_read_uint64(uint64_t *variable)
|
||||
uint64_t atomic_load_uint64(uint64_t *variable)
|
||||
{
|
||||
return __atomic_load_n(variable, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
void atomic_write(int *variable, int value)
|
||||
void atomic_store_int32(int *variable, int value)
|
||||
{
|
||||
return __atomic_store_n(variable, value, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
void atomic_write_int64(int64_t *variable, int64_t value)
|
||||
void atomic_store_int64(int64_t *variable, int64_t value)
|
||||
{
|
||||
return __atomic_store_n(variable, value, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
void atomic_write_uint64(uint64_t *variable, uint64_t value)
|
||||
void atomic_store_uint64(uint64_t *variable, uint64_t value)
|
||||
{
|
||||
return __atomic_store_n(variable, value, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ void test_add(void* data)
|
||||
{
|
||||
int id = (size_t)data;
|
||||
|
||||
while (atomic_read(&running))
|
||||
while (atomic_load_int32(&running))
|
||||
{
|
||||
atomic_add(&expected, id);
|
||||
atomic_add(&expected, -id);
|
||||
ss_dassert(atomic_read(&expected) >= 0);
|
||||
ss_dassert(atomic_load_int32(&expected) >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,9 +42,9 @@ void test_load_store(void* data)
|
||||
{
|
||||
int id = (size_t)data;
|
||||
|
||||
while (atomic_read(&running))
|
||||
while (atomic_load_int32(&running))
|
||||
{
|
||||
if (atomic_read(&expected) % NTHR == id)
|
||||
if (atomic_load_int32(&expected) % NTHR == id)
|
||||
{
|
||||
ss_dassert(atomic_add(&expected, 1) % NTHR == id + 1);
|
||||
}
|
||||
@ -55,8 +55,8 @@ int run_test(void(*func)(void*))
|
||||
{
|
||||
THREAD threads[NTHR];
|
||||
|
||||
atomic_write(&expected, 0);
|
||||
atomic_write(&running, 1);
|
||||
atomic_store_int32(&expected, 0);
|
||||
atomic_store_int32(&running, 1);
|
||||
|
||||
for (int i = 0; i < NTHR; i++)
|
||||
{
|
||||
@ -67,14 +67,14 @@ int run_test(void(*func)(void*))
|
||||
}
|
||||
|
||||
thread_millisleep(2500);
|
||||
atomic_write(&running, 0);
|
||||
atomic_store_int32(&running, 0);
|
||||
|
||||
for (int i = 0; i < NTHR; i++)
|
||||
{
|
||||
thread_wait(threads[i]);
|
||||
}
|
||||
|
||||
return atomic_read(&expected);
|
||||
return atomic_load_int32(&expected);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
Loading…
x
Reference in New Issue
Block a user