9 #ifndef G3D_ATOMICINT32_H
10 #define G3D_ATOMICINT32_H
16 # include <libkern/OSAtomic.h>
31 # if defined(G3D_WINDOWS)
33 # elif defined(G3D_OSX)
73 # if defined(G3D_WINDOWS)
75 return InterlockedExchangeAdd(&m_value, x);
77 # elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
80 asm volatile (
"lock; xaddl %0,%1"
81 :
"=r"(old),
"=m"(m_value)
82 :
"0"(
x),
"m"(m_value)
86 # elif defined(G3D_OSX)
89 OSAtomicAdd32(x, &m_value);
101 # if defined(G3D_WINDOWS)
103 InterlockedIncrement(&m_value);
104 # elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
106 # elif defined(G3D_OSX)
108 OSAtomicIncrement32(&m_value);
114 # if defined(G3D_WINDOWS)
116 return InterlockedDecrement(&m_value);
117 # elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
120 asm volatile (
"lock; decl %1;\n\t"
126 # elif defined(G3D_OSX)
128 return OSAtomicDecrement32(&m_value);
143 # if defined(G3D_WINDOWS)
144 return InterlockedCompareExchange(&m_value, exchange, comperand);
145 # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX)
149 asm volatile (
"lock; cmpxchgl %1, %2"
151 :
"r" (exchange),
"m" (
m_value),
"0"(comperand)
void operator=(const AtomicInt32 &x)
Definition: AtomicInt32.h:62
Definition: AtomicInt32.h:29
void increment()
Definition: AtomicInt32.h:100
AtomicInt32()
Definition: AtomicInt32.h:43
AtomicInt32(const int32 x)
Definition: AtomicInt32.h:46
volatile int32 m_value
Definition: AtomicInt32.h:36
int32 decrement()
Definition: AtomicInt32.h:113
AtomicInt32(const AtomicInt32 &x)
Definition: AtomicInt32.h:51
const AtomicInt32 & operator=(const int32 x)
Definition: AtomicInt32.h:56
int32 value() const
Definition: AtomicInt32.h:67
int32 add(const int32 x)
Definition: AtomicInt32.h:72
int32_t int32
Definition: g3dmath.h:167
int32 compareAndSet(const int32 comperand, const int32 exchange)
Definition: AtomicInt32.h:142
signed int int32_t
Definition: stdint.h:77
int32 sub(const int32 x)
Definition: AtomicInt32.h:96
G3D::int16 x
Definition: Vector2int16.h:37