12 #ifndef ROOT_TAtomicCountGcc
13 #define ROOT_TAtomicCountGcc
31 #ifndef ROOT_TAtomicCount
32 # error This should be #included only by TAtomicCount.h. Please #include TAtomicCount.h.
33 #endif //ROOT_TAtomicCount
35 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) || \
36 (defined(__APPLE_CC__) && __APPLE_CC__ > 5000 && !defined(MAC_OS_X_VERSION_10_6))
37 #include <bits/atomicity.h>
39 #include <ext/atomicity.h>
44 #if defined(__GLIBCXX__) // g++ 3.4+
46 using __gnu_cxx::__atomic_add;
47 using __gnu_cxx::__exchange_and_add;
54 mutable _Atomic_word fCnt;
56 TAtomicCount(
const TAtomicCount &);
57 TAtomicCount &operator=(
const TAtomicCount &);
60 explicit TAtomicCount(Long_t v) : fCnt(v) { }
61 void operator++() { __atomic_add(&fCnt, 1); }
62 Long_t operator--() {
return __exchange_and_add(&fCnt, -1) - 1; }
63 operator long()
const {
return __exchange_and_add(&fCnt, 0); }
66 #ifdef _GLIBCXX_WRITE_MEM_BARRIER
67 #if !(defined(__INTEL_COMPILER) && defined(__ia64__)) //ICC doesn't support inline asm on IA-64
68 _GLIBCXX_WRITE_MEM_BARRIER;
72 Long_t Get()
const {
return __exchange_and_add(&fCnt, 0); }