X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ff008af237bba3e58012f637cbe8996f4450f031..ab26adc86e6198e65e20d6bf707a6011208111ce:/lib/base/object.h diff --git a/lib/base/object.h b/lib/base/object.h index ea08a771..f0e0e9a5 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -18,9 +18,15 @@ private: void operator=(const iObject &); protected: virtual ~iObject() { } +#ifdef SWIG + virtual void AddRef()=0; + virtual void Release()=0; +#endif public: +#ifndef SWIG virtual void AddRef()=0; virtual void Release()=0; +#endif }; #ifndef SWIG @@ -43,10 +49,10 @@ public: #if defined(OBJECT_DEBUG) extern int object_total_remaining; #define DECLARE_REF(x) \ - private:oRefCount ref; \ - eSingleLock ref_lock; \ public: void AddRef(); \ - void Release(); + void Release(); \ + private:oRefCount ref; \ + eSingleLock ref_lock; #define DEFINE_REF(c) \ void c::AddRef() \ { \ @@ -68,9 +74,9 @@ public: } #elif defined(__mips__) #define DECLARE_REF(x) \ - private: oRefCount ref; \ public: void AddRef(); \ - void Release(); + void Release(); \ + private: oRefCount ref; #define DEFINE_REF(c) \ void c::AddRef() \ { \ @@ -106,11 +112,11 @@ public: if (!ref) \ delete this; \ } - #elif defined(__ppc__) + #elif defined(__ppc__) || defined(__powerpc__) #define DECLARE_REF(x) \ - private: oRefCount ref; \ public: void AddRef(); \ - void Release(); + void Release(); \ + private: oRefCount ref; #define DEFINE_REF(c) \ void c::AddRef() \ { \ @@ -140,13 +146,35 @@ public: if (!ref) \ delete this; \ } + #elif defined(__i386__) || defined(__x86_64__) + #define DECLARE_REF(x) \ + public: void AddRef(); \ + void Release(); \ + private: oRefCount ref; + #define DEFINE_REF(c) \ + void c::AddRef() \ + { \ + __asm__ __volatile__( \ + " lock ; incl %0 \n" \ + : "=m" (ref.count) \ + : "m" (ref.count)); \ + } \ + void c::Release() \ + { \ + __asm__ __volatile__( \ + " lock ; decl %0 \n" \ + : "=m" (ref.count) \ + : "m" (ref.count)); \ + if (!ref) \ + delete this; \ + } #else #warning use non optimized implementation of refcounting. #define DECLARE_REF(x) \ - private:oRefCount ref; \ - eSingleLock ref_lock; \ public: void AddRef(); \ - void Release(); + void Release(); \ + private:oRefCount ref; \ + eSingleLock ref_lock; #define DEFINE_REF(c) \ void c::AddRef() \ { \ @@ -168,9 +196,6 @@ public: private: \ void AddRef(); \ void Release(); - class Object - { - }; #endif // SWIG #endif // __base_object_h