uppsrc_Core_Mt.h.diff
uppsrc/Core/Mt.h 2014-10-15 11:23:27.000000000 +0400 | ||
---|---|---|
277 | 277 |
#endif |
278 | 278 | |
279 | 279 |
#ifdef PLATFORM_POSIX |
280 | ||
280 |
#if !(defined(PLATFORM_BSD) && defined(__clang__)) |
|
281 | 281 |
typedef _Atomic_word Atomic; |
282 |
#else |
|
283 |
typedef int Atomic; |
|
284 |
#endif |
|
282 | 285 | |
283 |
inline int AtomicXAdd(volatile Atomic& t, int incr) { using namespace __gnu_cxx; return __exchange_and_add(&t, incr); } |
|
286 |
inline int AtomicXAdd(volatile Atomic& t, int incr) |
|
287 |
{ |
|
288 |
#if !(defined(PLATFORM_BSD) && defined(__clang__)) |
|
289 |
using namespace __gnu_cxx; |
|
290 |
return __exchange_and_add(&t, incr); |
|
291 |
#else |
|
292 |
return __sync_fetch_and_add(&t, incr); |
|
293 |
#endif |
|
294 |
} |
|
284 | 295 | |
285 | 296 |
inline int AtomicInc(volatile Atomic& t) { return AtomicXAdd(t, +1) + 1; } |
286 | 297 |
inline int AtomicDec(volatile Atomic& t) { return AtomicXAdd(t, -1) - 1; } |