diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-02-28 17:29:06 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-02-28 17:29:06 +0100 |
commit | c3be0d4ad83e4b16d1599ec4a0c96c4df8aa58c7 (patch) | |
tree | 3e04c14089a233702cd1f80120f1a69698fbb436 /sal/osl | |
parent | 9a0fa777e2f5d757fb0a11db34e3fe28e938b0d9 (diff) |
lp#726529: arm optimizations for ARM 6/7 and gcc < 4.6
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/unx/interlck.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c index 6345279680b3..8109f6eba10d 100644 --- a/sal/osl/unx/interlck.c +++ b/sal/osl/unx/interlck.c @@ -29,6 +29,7 @@ #include "system.h" +#include <osl/armarch.h> #include <osl/interlck.h> #include <osl/diagnose.h> @@ -36,6 +37,42 @@ #error please use asm/interlck_sparc.s #elif defined ( SOLARIS) && defined ( X86 ) #error please use asm/interlck_x86.s +#elif defined ( ARM ) && (( __GNUC__ < 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ < 6 ))) && ( __ARM_ARCH__ >= 6) +oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) +{ + register oslInterlockedCount nCount __asm__ ("r1"); + int nResult; + + __asm__ __volatile__ ( +"1: ldrex %0, [%3]\n" +" add %0, %0, #1\n" +" strex %1, %0, [%3]\n" +" teq %1, #0\n" +" bne 1b" + : "=&r" (nCount), "=&r" (nResult), "=m" (*pCount) + : "r" (pCount) + : "memory"); + + return nCount; +} + +oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) +{ + register oslInterlockedCount nCount __asm__ ("r1"); + int nResult; + + __asm__ __volatile__ ( +"0: ldrex %0, [%3]\n" +" sub %0, %0, #1\n" +" strex %1, %0, [%3]\n" +" teq %1, #0\n" +" bne 0b" + : "=&r" (nCount), "=&r" (nResult), "=m" (*pCount) + : "r" (pCount) + : "memory"); + + return nCount; +} #elif defined ( GCC ) && ( defined ( X86 ) || defined ( X86_64 ) ) /* That's possible on x86-64 too since oslInterlockedCount is a sal_Int32 */ |