From 4b6f19109cd4bbab23af49e953537d1919348a0a Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Tue, 4 Jul 2006 12:06:02 +0000 Subject: [PATCH] add atomic versions of AddRef / Release for ppc .. used by refcounting '/home/ghost/hdb/7025_rootfs/enigma2-1.0-r0/enigma2/lib/base' --- lib/base/object.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/base/object.h b/lib/base/object.h index f93f4257..38a6dd35 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -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; \ -- 2.30.2