update event info on service start
[enigma2.git] / lib / base / object.h
index ed7dda8d5957d1d9b47503426264085b5f11201a..adb5d67cbb0304a8bb85b3d0efc81fe9c14eec6d 100644 (file)
@@ -25,15 +25,14 @@ public:
        virtual void Release()=0;
 };
 
-class oRefCount
+struct oRefCount
 {
-       int ref;
-public:
-       oRefCount(): ref(0) { }
-       operator int&() { return ref; }
+       volatile int count;
+       oRefCount(): count(0) { }
+       operator volatile int&() { return count; }
        ~oRefCount() { 
 #ifdef OBJECT_DEBUG
-               if (ref) eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, ref); else eDebug("OBJECT_DEBUG refcount ok! (%p)", this); 
+               if (count) eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, ref); else eDebug("OBJECT_DEBUG refcount ok! (%p)", this); 
 #endif
        }
 };
@@ -57,10 +56,9 @@ public:
                                "               sc              %0, %1  # try to store, checking for atomicity  \n" \
                                "               .set    mips0                                                                                   \n" \
                                "               beqz    %0, 1b  # if not atomic (0), try again                  \n" \
-                               "               nop                             # branch-delay slot                                             \n" \
-                               : "=&r" (temp), "=m" ((int)ref) \
-                               : "m" ((int)ref) \
-                               : "memory"); \
+                               : "=&r" (temp), "=m" (ref.count) \
+                               : "m" (ref.count) \
+                               : ); \
                        } \
                        void c::Release() \
                        { \
@@ -74,10 +72,9 @@ public:
                                "               sc              %0, %1                          \n" \
                                "               .set    mips0                           \n" \
                                "               beqz    %0, 1b                          \n" \
-                               "               nop                                                     \n" \
-                               : "=&r" (temp), "=m" ((int)ref) \
-                               : "m" ((int)ref) \
-                               : "memory"); \
+                               : "=&r" (temp), "=m" (ref.count) \
+                               : "m" (ref.count) \
+                               : ); \
                                if (!ref) \
                                        delete this; \
                        }
@@ -93,11 +90,11 @@ public:
                                __asm__ __volatile__( \
                                "1:             lwarx   %0, 0, %3       \n" \
                                "               add             %0, %2, %0      \n" \
-                               "               dcbt    0, %3           \n" \
+                               "               dcbt    0, %3           # workaround for PPC405CR Errata\n" \
                                "               stwcx.  %0, 0, %3       \n" \
                                "               bne-    1b                      \n" \
-                               : "=&r" (temp), "=m" ((int)ref) \
-                               : "r" (1), "r" (&((int)ref)), "m" ((int)ref) \
+                               : "=&r" (temp), "=m" (ref.count) \
+                               : "r" (1), "r" (&ref.count), "m" (ref.count) \
                                : "cc"); \
                        } \
                        void c::Release() \
@@ -106,11 +103,11 @@ public:
                                __asm__ __volatile__( \
                                "1:             lwarx   %0, 0, %3       \n" \
                                "               subf    %0, %2, %0      \n" \
-                               "               dcbt    0, %3           \n" \
+                               "               dcbt    0, %3           # workaround for PPC405CR Errata\n" \
                                "               stwcx.  %0, 0, %3       \n" \
                                "               bne-    1b                      \n" \
-                               : "=&r" (temp), "=m" ((int)ref) \
-                               : "r" (1), "r" (&((int)ref)), "m" ((int)ref) \
+                               : "=&r" (temp), "=m" (ref.count) \
+                               : "r" (1), "r" (&ref.count), "m" (ref.count) \
                                : "cc"); \
                                if (!ref) \
                                        delete this; \
@@ -129,7 +126,7 @@ public:
                                        eSingleLocker l(ref_lock); \
                                        ++object_total_remaining; \
                                        ++ref; \
-                                       eDebug("OBJECT_DEBUG " #c "+%p now %d", this, (int)ref); \
+                                       eDebug("OBJECT_DEBUG " #c "+%p now %d", this, ref.count); \
                                } \
                                void c::Release() \
                                { \