20 #ifndef __JackAtomic_linux__
21 #define __JackAtomic_linux__
23 #include "JackTypes.h"
27 static inline int CAS(
register UInt32 value,
register UInt32 newvalue,
register volatile void* addr)
37 " stwcx. %3, 0, %1 \n"
46 :
"r" (addr),
"r" (value),
"r" (newvalue),
"r" (tmp)
53 #if defined(__i386__) || defined(__x86_64__)
55 #define LOCK "lock ; "
57 static inline char CAS(
volatile UInt32 value, UInt32 newvalue,
volatile void* addr)
60 __asm__ __volatile__ (
62 LOCK
"cmpxchg %2, (%1) \n\t"
65 :
"c" (addr),
"d" (newvalue),
"a" (value)
75 #if !defined(__i386__) && !defined(__x86_64__) && !defined(__PPC__)
78 static inline char CAS(
volatile UInt32 value, UInt32 newvalue,
volatile void* addr)
80 return __sync_bool_compare_and_swap ((UInt32*)addr, value, newvalue);