add atomic versions of AddRef / Release for ppc .. used by refcounting
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 4 Jul 2006 12:06:02 +0000 (12:06 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 4 Jul 2006 12:06:02 +0000 (12:06 +0000)
'/home/ghost/hdb/7025_rootfs/enigma2-1.0-r0/enigma2/lib/base'

lib/base/object.h

index f93f425..38a6dd3 100644 (file)
@@ -79,6 +79,40 @@ public:
                                if (!ref) \
                                        delete this; \
                        }
+       #elif defined(__ppc__)
+               #define DECLARE_REF(x)                  \
+                       private: oRefCount ref;         \
+                       public: void AddRef();          \
+                                       void Release();
+               #define DEFINE_REF(c) \
+                       void c::AddRef() \
+                       { \
+                               int temp; \
+                               __asm__ __volatile__( \
+                               "1:             lwarx   %0, 0, %3       \n" \
+                               "               add             %0, %2, %0      \n" \
+                               "               dcbt    0, %3           \n" \
+                               "               stwcx.  %0, 0, %3       \n" \
+                               "               bne-    1b                      \n" \
+                               : "=&r" (temp), "=m" ((int)ref) \
+                               : "r" (1), "r" (&((int)ref)), "m" ((int)ref) \
+                               : "cc"); \
+                       } \
+                       void c::Release() \
+                       { \
+                               int temp; \
+                               __asm__ __volatile__( \
+                               "1:             lwarx   %0, 0, %3       \n" \
+                               "               subf    %0, %2, %0      \n" \
+                               "               dcbt    0, %3           \n" \
+                               "               stwcx.  %0, 0, %3       \n" \
+                               "               bne-    1b                      \n" \
+                               : "=&r" (temp), "=m" ((int)ref) \
+                               : "r" (1), "r" (&((int)ref)), "m" ((int)ref) \
+                               : "cc"); \
+                               if (!ref) \
+                                       delete this; \
+                       }
        #else
                #define DECLARE_REF(x)                  \
                        private:oRefCount ref;  \