add lock for smp safety
[enigma2.git] / lib / base / object.h
index ea08a771939fa2a8a7f931dca2846344d5504688..67a4606c90b7c2280c9523520276b095838e6df8 100644 (file)
@@ -106,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();          \
@@ -140,6 +140,28 @@ public:
                                if (!ref) \
                                        delete this; \
                        }
+       #elif defined(__i386__)
+               #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)                  \