26 #if __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 )
27 #define GCC_USEDEMANGLE
30 #ifdef GCC_USEDEMANGLE
35 #if defined(__APPLE__)
37 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
38 #include <libkern/OSAtomic.h>
41 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
42 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
43 # include <ext/atomicity.h>
45 # include <bits/atomicity.h>
54 #if defined(__GLIBCXX__) // g++ 3.4+
56 using __gnu_cxx::__atomic_add;
57 using __gnu_cxx::__exchange_and_add;
100 ::operator
new(
size_t n)
107 ::operator
new[](
size_t n)
114 ::operator
delete(
void* m)
121 ::operator
delete[](
void* m, size_t)
137 this->PrintHeader(os, indent);
139 this->PrintTrailer(os, indent);
163 #if (defined(WIN32) || defined(_WIN32))
164 InterlockedIncrement(&m_ReferenceCount);
167 #elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
168 #if defined (__LP64__) && __LP64__
169 OSAtomicIncrement64Barrier(&m_ReferenceCount);
171 OSAtomicIncrement32Barrier(&m_ReferenceCount);
175 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
176 __atomic_add(&m_ReferenceCount, 1);
180 m_ReferenceCountLock.Lock();
182 m_ReferenceCountLock.Unlock();
198 #if (defined(WIN32) || defined(_WIN32))
199 if ( InterlockedDecrement(&m_ReferenceCount) <= 0 )
205 #elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
206 #if defined (__LP64__) && __LP64__
207 if ( OSAtomicDecrement64Barrier(&m_ReferenceCount) <= 0 )
212 if ( OSAtomicDecrement32Barrier(&m_ReferenceCount) <= 0 )
219 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
220 if ( __exchange_and_add(&m_ReferenceCount, -1) <= 1 )
227 m_ReferenceCountLock.Lock();
229 m_ReferenceCountLock.Unlock();
231 if ( tmpReferenceCount <= 0)
246 m_ReferenceCountLock.Lock();
248 m_ReferenceCountLock.Unlock();
269 if(m_ReferenceCount > 0 && !std::uncaught_exception())
277 itkWarningMacro(
"Trying to delete object with non-zero reference count.");
290 #ifdef GCC_USEDEMANGLE
291 char const * mangledName =
typeid(*this).name();
293 char* unmangled = abi::__cxa_demangle(mangledName, 0, 0, &status);
295 os << indent <<
"RTTI typeinfo: ";
309 os << indent <<
"RTTI typeinfo: " <<
typeid( *this ).name() << std::endl;
311 os << indent <<
"Reference Count: " << m_ReferenceCount << std::endl;
322 os << indent << this->GetNameOfClass() <<
" (" <<
this <<
")\n";