26 #ifndef TAGLIB_REFCOUNTER_H
27 #define TAGLIB_REFCOUNTER_H
33 # define OSATOMIC_DEPRECATED 0
34 # include <libkern/OSAtomic.h>
35 # define TAGLIB_ATOMIC_MAC
36 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
41 # define TAGLIB_ATOMIC_WIN
42 #elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
43 && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
44 defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
45 && !defined(__INTEL_COMPILER)
46 # define TAGLIB_ATOMIC_GCC
47 #elif defined(__ia64) && defined(__INTEL_COMPILER)
48 # include <ia64intrin.h>
49 # define TAGLIB_ATOMIC_GCC
52 #ifndef DO_NOT_DOCUMENT
66 virtual ~RefCounter();
73 class RefCounterPrivate;
81 RefCounterOld() : refCount(1) {}
83 #ifdef TAGLIB_ATOMIC_MAC
84 void ref() { OSAtomicIncrement32Barrier(
const_cast<int32_t*
>(&refCount)); }
85 bool deref() {
return ! OSAtomicDecrement32Barrier(
const_cast<int32_t*
>(&refCount)); }
86 int32_t count() {
return refCount; }
88 volatile int32_t refCount;
89 #elif defined(TAGLIB_ATOMIC_WIN)
90 void ref() { InterlockedIncrement(&refCount); }
91 bool deref() {
return ! InterlockedDecrement(&refCount); }
92 long count() {
return refCount; }
94 volatile long refCount;
95 #elif defined(TAGLIB_ATOMIC_GCC)
96 void ref() { __sync_add_and_fetch(&refCount, 1); }
97 bool deref() {
return ! __sync_sub_and_fetch(&refCount, 1); }
98 int count() {
return refCount; }
100 volatile int refCount;
102 void ref() { refCount++; }
103 bool deref() {
return ! --refCount; }
104 int count() {
return refCount; }
106 unsigned int refCount;
#define TAGLIB_EXPORT
Definition: taglib_export.h:40