// public members
////////////////////////////////////////////////////////////////////////////////
+// BIC change to RefCounter
template <class Key, class T>
template <class KeyP, class TP>
-class Map<Key, T>::MapPrivate : public RefCounter
+class Map<Key, T>::MapPrivate : public RefCounterOld
{
public:
- MapPrivate() : RefCounter() {}
+ MapPrivate() : RefCounterOld() {}
#ifdef WANT_CLASS_INSTANTIATION_OF_MAP
- MapPrivate(const std::map<class KeyP, class TP>& m) : RefCounter(), map(m) {}
+ MapPrivate(const std::map<class KeyP, class TP>& m) : RefCounterOld(), map(m) {}
std::map<class KeyP, class TP> map;
#else
- MapPrivate(const std::map<KeyP, TP>& m) : RefCounter(), map(m) {}
+ MapPrivate(const std::map<KeyP, TP>& m) : RefCounterOld(), map(m) {}
std::map<KeyP, TP> map;
#endif
};
#include "taglib_export.h"
#include "taglib.h"
+#ifdef __APPLE__
+# include <libkern/OSAtomic.h>
+# define TAGLIB_ATOMIC_MAC
+#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define NOMINMAX
+# include <windows.h>
+# define TAGLIB_ATOMIC_WIN
+#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
+ && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
+ defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
+ && !defined(__INTEL_COMPILER)
+# define TAGLIB_ATOMIC_GCC
+#elif defined(__ia64) && defined(__INTEL_COMPILER)
+# include <ia64intrin.h>
+# define TAGLIB_ATOMIC_GCC
+#endif
+
#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
/*!
* \internal
*/
namespace TagLib
{
+
class TAGLIB_EXPORT RefCounter
{
public:
class RefCounterPrivate;
RefCounterPrivate *d;
};
+
+ // BIC this old class is needed by tlist.tcc and tmap.tcc
+ class RefCounterOld
+ {
+ public:
+ RefCounterOld() : refCount(1) {}
+
+#ifdef TAGLIB_ATOMIC_MAC
+ void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); }
+ bool deref() { return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); }
+ int32_t count() { return refCount; }
+ private:
+ volatile int32_t refCount;
+#elif defined(TAGLIB_ATOMIC_WIN)
+ void ref() { InterlockedIncrement(&refCount); }
+ bool deref() { return ! InterlockedDecrement(&refCount); }
+ long count() { return refCount; }
+ private:
+ volatile long refCount;
+#elif defined(TAGLIB_ATOMIC_GCC)
+ void ref() { __sync_add_and_fetch(&refCount, 1); }
+ bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); }
+ int count() { return refCount; }
+ private:
+ volatile int refCount;
+#else
+ void ref() { refCount++; }
+ bool deref() { return ! --refCount; }
+ int count() { return refCount; }
+ private:
+ uint refCount;
+#endif
+ };
+
}
#endif // DO_NOT_DOCUMENT
#endif
+