summaryrefslogtreecommitdiff
path: root/sal/osl/unx/interlck.c
diff options
context:
space:
mode:
authorJani Monoses <jani.monoses@canonical.com>2011-03-09 10:06:16 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-03-09 10:06:16 +0100
commit11db8cce4928a6510341d97bb28d100068037987 (patch)
tree15ca7069c1408b05311cecb6d9fef2ed9994544b /sal/osl/unx/interlck.c
parentaa4a5a276b3e694b7d73c57b23f3a331d2d14bfe (diff)
lp#726529: using the Linaro gcc 4.5 generated code instead
* this adds memory barriers to the asm code block making it SMP-safe
Diffstat (limited to 'sal/osl/unx/interlck.c')
-rw-r--r--sal/osl/unx/interlck.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c
index 7cf09b902cd9..826592a495a6 100644
--- a/sal/osl/unx/interlck.c
+++ b/sal/osl/unx/interlck.c
@@ -40,6 +40,8 @@
#elif defined ( ARM ) && (( __GNUC__ < 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ < 6 ))) && ( __ARM_ARCH__ >= 6)
// assembler implementation for gcc <4.6 on arm
// originally contributed by Eric Bachard / OOo4Kids
+// replaced with the asm code generated by Linaro gcc 4.5
+// which includes memory barriers to make it SMP-safe
// #i117017# and lp#726529
oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount)
{
@@ -47,11 +49,13 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount*
int nResult;
__asm__ __volatile__ (
+" dmb\n"
"1: ldrex %0, [%3]\n"
" add %0, %0, #1\n"
" strex %1, %0, [%3]\n"
" teq %1, #0\n"
-" bne 1b"
+" bne 1b\n"
+" dmb\n"
: "=&r" (nCount), "=&r" (nResult), "=m" (*pCount)
: "r" (pCount)
: "memory");
@@ -65,11 +69,13 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount*
int nResult;
__asm__ __volatile__ (
+" dmb\n"
"0: ldrex %0, [%3]\n"
" sub %0, %0, #1\n"
" strex %1, %0, [%3]\n"
" teq %1, #0\n"
-" bne 0b"
+" bne 0b\n"
+" dmb\n"
: "=&r" (nCount), "=&r" (nResult), "=m" (*pCount)
: "r" (pCount)
: "memory");