needed fix
[enigma2.git] / lib / base / object.h
index 7f823223f1f862cf5ddddc5207d8288fcb831c13..1723a885d994c9188815a58d2207590b7af38daf 100644 (file)
@@ -7,9 +7,7 @@
 
 //#define OBJECT_DEBUG
 
-#ifdef OBJECT_DEBUG
-       #include <lib/base/eerror.h>
-#endif
+#include <lib/base/eerror.h>
 
 typedef int RESULT;
 
@@ -108,7 +106,7 @@ public:
                                if (!ref) \
                                        delete this; \
                        }
-       #elif defined(__ppc__)
+       #elif defined(__ppc__) || defined(__powerpc__)
                #define DECLARE_REF(x)                  \
                        private: oRefCount ref;         \
                        public: void AddRef();          \
@@ -142,6 +140,28 @@ public:
                                if (!ref) \
                                        delete this; \
                        }
+       #elif defined(__i386__) || defined(__x86_64__)
+               #define DECLARE_REF(x)                  \
+                       private: oRefCount ref;         \
+                       public: void AddRef();          \
+                                       void Release();
+               #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)                  \