#ifdef __GNUC__
#if __GNUC__*10 + __GNUC_MINOR__ >= 42
#if !defined WIN32 && (defined __i486__ || defined __i586__ || \
defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__)
#define WDMV_XADD __sync_fetch_and_add
#else
#include <ext/atomicity.h>
#define WDMV_XADD __gnu_cxx::__exchange_and_add
#endif
#else
#include <bits/atomicity.h>
#if __GNUC__*10 + __GNUC_MINOR__ >= 34
#define WDMV_XADD __gnu_cxx::__exchange_and_add
#else
#define WDMV_XADD __exchange_and_add
#endif
#endif
#elif (defined WIN32 || defined _WIN32)
#include <intrin.h>
#define WDMV_XADD(addr,delta) _InterlockedExchangeAdd((long volatile*)(addr), (delta))
#else
template<typename _Tp> static inline _Tp WDMV_XADD(_Tp* addr, _Tp delta)
{ int tmp = *addr; *addr += delta; return tmp; }
#endif
#define WDMV_INCREF(intvar) WDMV_XADD(intvar,1)
#define WDMV_DECREF(intvar) WDMV_XADD(intvar,-1)