26 #ifndef TAGLIB_REFCOUNTER_H
27 #define TAGLIB_REFCOUNTER_H
33 # include <libkern/OSAtomic.h>
34 # define TAGLIB_ATOMIC_MAC
35 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
38 # define TAGLIB_ATOMIC_WIN
39 #elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
40 && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
41 defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
42 && !defined(__INTEL_COMPILER)
43 # define TAGLIB_ATOMIC_GCC
44 #elif defined(__ia64) && defined(__INTEL_COMPILER)
45 # include <ia64intrin.h>
46 # define TAGLIB_ATOMIC_GCC
49 #ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
63 virtual ~RefCounter();
70 class RefCounterPrivate;
78 RefCounterOld() : refCount(1) {}
80 #ifdef TAGLIB_ATOMIC_MAC
81 void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); }
82 bool deref() {
return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); }
83 int32_t count() {
return refCount; }
85 volatile int32_t refCount;
86 #elif defined(TAGLIB_ATOMIC_WIN)
87 void ref() { InterlockedIncrement(&refCount); }
88 bool deref() {
return ! InterlockedDecrement(&refCount); }
89 long count() {
return refCount; }
91 volatile long refCount;
92 #elif defined(TAGLIB_ATOMIC_GCC)
93 void ref() { __sync_add_and_fetch(&refCount, 1); }
94 bool deref() {
return ! __sync_sub_and_fetch(&refCount, 1); }
95 int count() {
return refCount; }
97 volatile int refCount;
99 void ref() { refCount++; }
100 bool deref() {
return ! --refCount; }
101 int count() {
return refCount; }
109 #endif // DO_NOT_DOCUMENT
unsigned int uint
Definition: taglib.h:66
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41