Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/matt-nb6-plus]: src/common/lib/libc/arch/arm/atomic Pull atomic ops from...
details: https://anonhg.NetBSD.org/src/rev/ae8b63fb8032
branches: matt-nb6-plus
changeset: 774504:ae8b63fb8032
user: matt <matt%NetBSD.org@localhost>
date: Tue Nov 27 23:42:34 2012 +0000
description:
Pull atomic ops from HEAD.
diffstat:
common/lib/libc/arch/arm/atomic/Makefile.inc | 38 +++++++++--
common/lib/libc/arch/arm/atomic/atomic_add_32.S | 12 +++-
common/lib/libc/arch/arm/atomic/atomic_add_64.S | 81 ++++++++++++++++++++++++
common/lib/libc/arch/arm/atomic/atomic_and_32.S | 12 +++-
common/lib/libc/arch/arm/atomic/atomic_and_64.S | 81 ++++++++++++++++++++++++
common/lib/libc/arch/arm/atomic/atomic_cas_32.S | 19 ++++-
common/lib/libc/arch/arm/atomic/atomic_cas_64.S | 69 ++++++++++++++++++++
common/lib/libc/arch/arm/atomic/atomic_cas_8.S | 56 +++++++--------
common/lib/libc/arch/arm/atomic/atomic_dec_32.S | 12 +++-
common/lib/libc/arch/arm/atomic/atomic_dec_64.S | 73 +++++++++++++++++++++
common/lib/libc/arch/arm/atomic/atomic_inc_32.S | 14 +++-
common/lib/libc/arch/arm/atomic/atomic_inc_64.S | 72 +++++++++++++++++++++
common/lib/libc/arch/arm/atomic/atomic_op_asm.h | 14 +++-
common/lib/libc/arch/arm/atomic/atomic_or_32.S | 12 +++-
common/lib/libc/arch/arm/atomic/atomic_or_64.S | 81 ++++++++++++++++++++++++
common/lib/libc/arch/arm/atomic/atomic_swap.S | 64 +++++++++++++++---
common/lib/libc/arch/arm/atomic/atomic_swap_64.S | 53 +++++++++++++++
common/lib/libc/arch/arm/atomic/membar_ops.S | 10 ++-
18 files changed, 712 insertions(+), 61 deletions(-)
diffs (truncated from 1031 to 300 lines):
diff -r 05563edaf7d6 -r ae8b63fb8032 common/lib/libc/arch/arm/atomic/Makefile.inc
--- a/common/lib/libc/arch/arm/atomic/Makefile.inc Tue Nov 27 22:18:49 2012 +0000
+++ b/common/lib/libc/arch/arm/atomic/Makefile.inc Tue Nov 27 23:42:34 2012 +0000
@@ -1,19 +1,43 @@
-# $NetBSD: Makefile.inc,v 1.8 2009/01/04 17:54:29 pooka Exp $
+# $NetBSD: Makefile.inc,v 1.8.12.1 2012/11/27 23:42:34 matt Exp $
+
+ARMV6= ${CPUFLAGS:M-march=armv7*} ${CPUFLAGS:M-mcpu=cortex*}
+ARMV6+= ${CPUFLAGS:M-march=armv6*} ${CPUFLAGS:M-mcpu=arm11*}
+ARMV6+= ${CFLAGS:M-march=armv7*:} ${CFLAGS:M-mcpu=cortex*}
+ARMV6+= ${CFLAGS:M-march=armv6*:} ${CFLAGS:M-mcpu=arm11*}
+ARMV6+= ${CPPFLAGS:M-march=armv7*:} ${CPPFLAGS:M-mcpu=cortex*}
+ARMV6+= ${CPPFLAGS:M-march=armv6*:} ${CPPFLAGS:M-mcpu=arm11*}
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|| ${LIB} == "rump")
-SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \
- atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
- atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \
- atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c
+.if empty(ARMV6)
+SRCS.atomic+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \
+ atomic_and_32_cas.c atomic_and_32_nv_cas.c \
+ atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
+ atomic_inc_32_cas.c atomic_inc_32_nv_cas.c \
+ atomic_or_32_cas.c atomic_or_32_nv_cas.c \
+ atomic_swap_32_cas.c membar_ops_nop.c
+.else
+SRCS.atomic+= atomic_add_32.S atomic_and_32.S atomic_cas_32.S
+SRCS.atomic+= atomic_dec_32.S atomic_inc_32.S atomic_or_32.S
+SRCS.atomic+= atomic_swap.S membar_ops.S
+SRCS.atomic+= atomic_add_64.S atomic_and_64.S atomic_cas_64.S
+SRCS.atomic+= atomic_dec_64.S atomic_inc_64.S atomic_or_64.S
+SRCS.atomic+= atomic_swap_64.S
+.endif
.endif
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
-SRCS+= atomic_init_testset.c
-SRCS+= atomic_cas_up.S
+.if empty(ARMV6)
+SRCS.atomic+= atomic_init_testset.c
+SRCS.atomic+= atomic_cas_up.S
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
+.else
+SRCS.atomic+= atomic_init_cas.c
+.endif
.endif
+
+SRCS+= ${SRCS.atomic}
diff -r 05563edaf7d6 -r ae8b63fb8032 common/lib/libc/arch/arm/atomic/atomic_add_32.S
--- a/common/lib/libc/arch/arm/atomic/atomic_add_32.S Tue Nov 27 22:18:49 2012 +0000
+++ b/common/lib/libc/arch/arm/atomic/atomic_add_32.S Tue Nov 27 23:42:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_add_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_add_32.S,v 1.2.24.1 2012/11/27 23:42:34 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -40,6 +40,11 @@
strex ip, r2, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return old value */
END(_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
@@ -57,6 +62,11 @@
strex r2, r0, [r3] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
diff -r 05563edaf7d6 -r ae8b63fb8032 common/lib/libc/arch/arm/atomic/atomic_add_64.S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/atomic/atomic_add_64.S Tue Nov 27 23:42:34 2012 +0000
@@ -0,0 +1,81 @@
+/* $NetBSD: atomic_add_64.S,v 1.3.4.2 2012/11/27 23:42:35 matt Exp $ */
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <matt%3am-software.com@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_add_64)
+ str r4, [sp, #-4]! /* save temporary */
+ mov r4, r0 /* need r0 for return value */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+1: ldrexd r0, [r4] /* load old value (to be returned) */
+ adds NLO, LO, NLO /* calculate new value */
+ adc NHI, HI, NHI /* calculate new value */
+ strexd ip, r2, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return old value */
+ END(_atomic_add_64)
+ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
+
+ENTRY_NP(_atomic_add_64_nv)
+ str r4, [sp, #-4]! /* save temporary */
+ mov r4, r0 /* need r0 for return value */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+1: ldrexd r0, [r4] /* load old value */
+ adds LO, LO, NLO /* calculate new value lo */
+ adc HI, HI, NHI /* calculate new value hi */
+ strexd ip, r0, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return new value */
+ END(_atomic_add_64_nv)
+ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
+
+#endif /* _ARM_ARCH_6 */
diff -r 05563edaf7d6 -r ae8b63fb8032 common/lib/libc/arch/arm/atomic/atomic_and_32.S
--- a/common/lib/libc/arch/arm/atomic/atomic_and_32.S Tue Nov 27 22:18:49 2012 +0000
+++ b/common/lib/libc/arch/arm/atomic/atomic_and_32.S Tue Nov 27 23:42:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_and_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_and_32.S,v 1.2.24.1 2012/11/27 23:42:35 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -40,6 +40,11 @@
strex ip, r2, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return old value */
END(_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
@@ -55,6 +60,11 @@
strex r2, r0, [r3] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
diff -r 05563edaf7d6 -r ae8b63fb8032 common/lib/libc/arch/arm/atomic/atomic_and_64.S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/atomic/atomic_and_64.S Tue Nov 27 23:42:34 2012 +0000
@@ -0,0 +1,81 @@
+/* $NetBSD: atomic_and_64.S,v 1.2.4.2 2012/11/27 23:42:35 matt Exp $ */
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <matt%3am-software.com@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_and_64)
+ str r4, [sp, #-4]! /* save temporary */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+ mov r4, r0 /* need r0 for return value */
+1: ldrexd r0, [r4] /* load old value (to be returned) */
+ and r2, r0, r2 /* calculate new value */
+ and r3, r1, r3 /* calculate new value */
+ strexd ip, r2, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return old value */
+ END(_atomic_and_64)
+ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64)
+
+ENTRY_NP(_atomic_and_64_nv)
+ str r4, [sp, #-4]! /* save temporary */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+ mov r4, r0 /* need r0 for return value */
+1: ldrexd r0, [r4] /* load old value */
+ and r0, r0, r2 /* calculate new value */
+ and r1, r1, r3 /* calculate new value */
+ strexd ip, r0, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return new value */
+ END(_atomic_and_64_nv)
+ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
+
+#endif /* _ARM_ARCH_6 */
diff -r 05563edaf7d6 -r ae8b63fb8032 common/lib/libc/arch/arm/atomic/atomic_cas_32.S
--- a/common/lib/libc/arch/arm/atomic/atomic_cas_32.S Tue Nov 27 22:18:49 2012 +0000
+++ b/common/lib/libc/arch/arm/atomic/atomic_cas_32.S Tue Nov 27 23:42:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_cas_32.S,v 1.2.24.1 2012/11/27 23:42:35 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -44,15 +44,28 @@
Home |
Main Index |
Thread Index |
Old Index