Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/include Use ldrexb/strexb for ARMv6 and above p...



details:   https://anonhg.NetBSD.org/src/rev/09b227bba08b
branches:  trunk
changeset: 780198:09b227bba08b
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jul 15 08:26:21 2012 +0000

description:
Use ldrexb/strexb for ARMv6 and above platforms since
"swp{b} use is deprecated" for them.

diffstat:

 sys/arch/arm/include/lock.h |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r e666d56fdc73 -r 09b227bba08b sys/arch/arm/include/lock.h
--- a/sys/arch/arm/include/lock.h       Sun Jul 15 07:31:18 2012 +0000
+++ b/sys/arch/arm/include/lock.h       Sun Jul 15 08:26:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.17 2008/04/28 20:23:14 martin Exp $ */
+/*     $NetBSD: lock.h,v 1.18 2012/07/15 08:26:21 matt Exp $   */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -77,10 +77,22 @@
 static __inline int
 __swp(int __val, volatile unsigned char *__ptr)
 {
-
+#ifdef _ARM_ARCH_6
+       int __rv, __tmp;
+       __asm volatile(
+               "1:\t"
+               "ldrexb\t%[__rv], [%[__ptr]]"                   "\n\t"
+               "strexb\t%[__tmp], %[__val], [%[__ptr]]"        "\n\t"
+               "cmpeq\t%[__tmp], #0"                           "\n\t"
+               "bne 1b"
+           : [__rv] "=&r" (__rv), [__tmp] "=&r"(__tmp)
+           : [__val] "r" (__val), [__ptr] "r" (__ptr) : "memory");
+       return __rv;
+#else
        __asm volatile("swpb %0, %1, [%2]"
            : "=&r" (__val) : "r" (__val), "r" (__ptr) : "memory");
        return __val;
+#endif
 }
 #else
 static __inline int



Home | Main Index | Thread Index | Old Index