medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f6a2e3119f943016364602938f3579b9b965fdff
parent 71387bb4a03630a02783c875d1f31ee569e9aa04
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon May  2 20:52:26 +0100

Rename atomic_add/atomic_sub to atomic_add_fetch/atomic_sub_fetch

Diffstat:
benchmark.cc | 6+++---
platform_atomic.h | 8++++----
unix_atomic.h | 4++--
work_queue.cc | 4++--
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/benchmark.cc b/benchmark.cc @@ -26,12 +26,12 @@ ScopedTimer::ScopedTimer( u32 idx ) { ScopedTimer::~ScopedTimer() { u64 dt = __rdtsc() - initial_clock; - atomic_add_u64( &timers[ timer_idx ].total_clocks, dt ); - atomic_add_u64( &timers[ timer_idx ].num_calls, 1 ); + atomic_add_fetch_u64( &timers[ timer_idx ].total_clocks, dt ); + atomic_add_fetch_u64( &timers[ timer_idx ].num_calls, 1 ); } u32 benchmark_new_timer( const char * fn, const char * file, int line ) { - u32 idx = atomic_add_u32( &num_timers, 1 ) - 1; + u32 idx = atomic_add_fetch_u32( &num_timers, 1 ) - 1; assert( idx < MAX_TIMERS ); Timer info; diff --git a/platform_atomic.h b/platform_atomic.h @@ -9,11 +9,11 @@ } #define ATOMIC_FUNCTION_DEF( T ) \ - inline T atomic_add( atomic_##T * atom, T x ) { \ - return atomic_add_##T( atom, x ); \ + inline T atomic_add_fetch( atomic_##T * atom, T x ) { \ + return atomic_add_fetch_##T( atom, x ); \ } \ - inline T atomic_sub( atomic_##T * atom, T x ) { \ - return atomic_sub_##T( atom, x ); \ + inline T atomic_sub_fetch( atomic_##T * atom, T x ) { \ + return atomic_sub_fetch_##T( atom, x ); \ } \ inline T atomic_swap( atomic_##T * atom, T newval ) { \ return atomic_swap_##T( atom, newval ); \ diff --git a/unix_atomic.h b/unix_atomic.h @@ -7,10 +7,10 @@ #define write_barrier() asm volatile ( "" ::: "memory" ) #define ATOMIC_DEFS( T ) \ - inline T atomic_add_##T( atomic_##T * atom, T x ) { \ + inline T atomic_add_fetch_##T( atomic_##T * atom, T x ) { \ return __sync_add_and_fetch( &atom->v, x ); \ } \ - inline T atomic_sub_##T( atomic_##T * atom, T x ) { \ + inline T atomic_sub_fetch_##T( atomic_##T * atom, T x ) { \ return __sync_sub_and_fetch( &atom->v, x ); \ } \ inline T atomic_swap_##T( atomic_##T * atom, T x ) { \ diff --git a/work_queue.cc b/work_queue.cc @@ -19,7 +19,7 @@ static bool workqueue_step( u32 thread_id, WorkQueue * queue ) { const Job & job = queue->jobs[ current_head ]; job.callback( job.data, &queue->arenas[ thread_id ] ); - atomic_add_u16( &queue->jobs_completed, 1 ); + atomic_add_fetch_u16( &queue->jobs_completed, 1 ); } return true; @@ -35,7 +35,7 @@ static THREAD( workqueue_worker ) { u32 thread_id = info->thread_id; write_barrier(); - atomic_add_u32( info->started_threads, 1 ); + atomic_add_fetch_u32( info->started_threads, 1 ); for( ;; ) { if( !workqueue_step( thread_id, queue ) ) {