summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/linuxthreads/sysdeps/arm/pt-machine.h')
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/pt-machine.h36
1 files changed, 10 insertions, 26 deletions
diff --git a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
index fc17e9bc7..3250961cf 100644
--- a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
@@ -28,36 +28,20 @@
# define PT_EI __extern_always_inline
#endif
-#if defined(__thumb2__)
-PT_EI long int ldrex(int *spinlock)
-{
- long int ret;
- __asm__ __volatile__(
- "ldrex %0, [%1]\n"
- : "=r"(ret)
- : "r"(spinlock) : "memory");
- return ret;
-}
-
-PT_EI long int strex(int val, int *spinlock)
-{
- long int ret;
- __asm__ __volatile__(
- "strex %0, %1, [%2]\n"
- : "=r"(ret)
- : "r" (val), "r"(spinlock) : "memory");
- return ret;
-}
-
+#if __ARM_ARCH >= 7 || defined(__thumb2__)
/* Spinlock implementation; required. */
PT_EI long int
testandset (int *spinlock)
{
- register unsigned int ret;
-
- do {
- ret = ldrex(spinlock);
- } while (strex(1, spinlock));
+ unsigned int ret, tmp, val = 1;
+
+ __asm__ __volatile__ (
+"0: ldrex %0, [%2] \n"
+" strex %1, %3, [%2] \n"
+" cmp %1, #0 \n"
+" bne 0b"
+ : "=&r" (ret), "=&r" (tmp)
+ : "r" (spinlock), "r" (val) : "memory", "cc");
return ret;
}