diff options
author | Jani Monoses <jani.monoses@canonical.com> | 2011-01-28 15:04:26 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-01-28 15:04:26 +0000 |
commit | 5b3360fa4556c58e594d5eef6470bbaf2bc1174d (patch) | |
tree | 2a19aa935944c0e7e728c61a3ac35e7b5ee50295 /sal/osl | |
parent | 31a8176ab66fec013e72167910642143e2f86c89 (diff) |
use gcc builtins for POWERPC and ARM cases if we have GCC
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/unx/interlck.c | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c index f8630c97a4f1..f47ad99beed8 100644 --- a/sal/osl/unx/interlck.c +++ b/sal/osl/unx/interlck.c @@ -94,47 +94,16 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* return --nCount; } -#elif defined ( GCC ) && defined ( POWERPC ) && !defined( AIX ) - -/*****************************************************************************/ -/* osl_incrementInterlockedCount */ -/*****************************************************************************/ +#elif defined ( GCC ) oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) { - /* "addi" doesn't work with r0 as second parameter */ - register oslInterlockedCount nCount __asm__ ("r4"); - - __asm__ __volatile__ ( - "1: lwarx %0,0,%2\n\t" - " addi %0,%0,1\n\t" - " stwcx. %0,0,%2\n\t" - " bne- 1b\n\t" - " isync" - : "=&r" (nCount), "=m" (*pCount) - : "r" (pCount) - : "memory"); - - return nCount; + return __sync_add_and_fetch(pCount, 1); } oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) { - /* "subi" doesn't work with r0 as second parameter */ - register oslInterlockedCount nCount __asm__ ("r4"); - - __asm__ __volatile__ ( - "1: lwarx %0,0,%2\n\t" - " subi %0,%0,1\n\t" - " stwcx. %0,0,%2\n\t" - " bne- 1b\n\t" - " isync" - : "=&r" (nCount), "=m" (*pCount) - : "r" (pCount) - : "memory"); - - return nCount; + return __sync_sub_and_fetch(pCount, 1); } - #else /* use only if nothing else works, expensive due to single mutex for all reference counts */ |