#define ATOMIC_SIZE 32
#ifdef SSE2_PRESENT
- #if defined(__GNUC__)
+ #if defined(__APPLE__)
+ #include <libkern/OSAtomic.h>
+ #define ALIGN(var) var __attribute__((__aligned__(16)))
+ #define ATOMIC(var) var __attribute__((__aligned__(32)))
+ #define MEMORY_BARRIER (_mm_sfence())
+ #define ATOMIC_COUNTER volatile int32_t
+ #define ATOMIC_INCREMENT(counter) (OSAtomicIncrement32Barrier(&(counter))
+ #define ATOMIC_DECREMENT(counter) (OSAtomicDecrement32Barrier(&(counter))
+ #define ATOMIC_ADD(counter, val) ((void)OSAtomicAdd32Barrier((val), &(counter)))
+ #elif defined(__GNUC__)
#define ALIGN(var) var __attribute__((__aligned__(16)))
#define ATOMIC(var) var __attribute__((__aligned__(32)))
#define MEMORY_BARRIER (_mm_sfence())
#define ATOMIC_COUNTER volatile LONG
#define ATOMIC_INCREMENT(counter) (InterlockedIncrement(&(counter)))
#define ATOMIC_DECREMENT(counter) (InterlockedDecrement(&(counter)))
- #define ATOMIC_ADD(counter, val) (InterlockedExchangeAdd(&(counter), (val)))
+ #define ATOMIC_ADD(counter, val) ((void)InterlockedExchangeAdd(&(counter), (val)))
#endif
#endif