Max 5 API Reference
00001 // ext_atomic.h copyright 2008 cycling '74 00002 00003 #ifndef __EXT_ATOMIC_H__ 00004 #define __EXT_ATOMIC_H__ 00005 00006 #ifdef MAC_VERSION 00007 00008 #include <libkern/OSAtomic.h> 00009 typedef int t_int32_atomic; 00010 00011 #define ATOMIC_INCREMENT(pv) OSAtomicIncrement32(pv) 00012 #define ATOMIC_INCREMENT_BARRIER(pv) OSAtomicIncrement32Barrier(pv) 00013 00014 #define ATOMIC_DECREMENT(pv) OSAtomicDecrement32(pv) 00015 #define ATOMIC_DECREMENT_BARRIER(pv) OSAtomicDecrement32Barrier(pv) 00016 00017 #else // WIN_VERSION 00018 00019 #include <intrin.h> 00020 typedef volatile long t_int32_atomic; 00021 00022 #pragma intrinsic (_InterlockedIncrement) 00023 #pragma intrinsic (_InterlockedDecrement) 00024 00025 /** Use this routine for incrementing a global counter using a threadsafe and multiprocessor safe method. 00026 @ingroup threading 00027 @param pv pointer to the (int) counter. 00028 */ 00029 00030 // on windows I don't think there are non-barrier atomic increment / decrement functions 00031 // perhaps could be done with inline assembly? 00032 00033 #define ATOMIC_INCREMENT(pv) (_InterlockedIncrement(pv)) 00034 #define ATOMIC_INCREMENT_BARRIER(pv) (_InterlockedIncrement(pv)) 00035 00036 00037 /** Use this routine for decrementing a global counter using a threadsafe and multiprocessor safe method. 00038 @ingroup threading 00039 @param pv pointer to the (int) counter. 00040 */ 00041 #define ATOMIC_DECREMENT(pv) (_InterlockedDecrement(pv)) 00042 #define ATOMIC_DECREMENT_BARRIER(pv) (_InterlockedDecrement(pv)) 00043 00044 #endif // WIN_VERSION 00045 00046 00047 #endif // __EXT_ATOMIC_H__
Copyright © 2008, Cycling '74