Use common code for atomic_add().

This commit is contained in:
counterpoint
2015-05-12 16:50:37 +01:00
parent fec1e66a5c
commit 492918c72c
3 changed files with 4 additions and 19 deletions

View File

@ -29,6 +29,7 @@
#include <skygw_types.h>
#include <sys/time.h>
#include "skygw_utils.h"
#include "atomic.h"
#if defined(MLIST)
@ -71,23 +72,6 @@ static void mlist_free_memory(mlist_t* ml, char* name);
static void thread_free_memory(skygw_thread_t* th, char* name);
/** End of static function declarations */
int atomic_add(
int *variable,
int value)
{
#ifdef __GNUC__
return (int) __sync_fetch_and_add (variable, value);
#else
asm volatile(
"lock; xaddl %%eax, %2;"
:"=a" (value)
: "a" (value), "m" (*variable)
: "memory" );
return value;
#endif
}
/** mutexed list, mlist */
#if defined(MLIST)