Module Name:    src
Committed By:   matt
Date:           Sat Feb 15 10:27:44 UTC 2014

Modified Files:
        src/common/lib/libc/arch/arm/atomic [matt-nb5-mips64]: Makefile.inc
            atomic_op_asm.h
Added Files:
        src/common/lib/libc/arch/arm/atomic [matt-nb5-mips64]: atomic_add_64.S
            atomic_and_64.S atomic_cas_64.S atomic_dec_64.S atomic_inc_64.S
            atomic_or_64.S

Log Message:
Add 64-bit atomic ops if ARMv6+


To generate a diff of this commit:
cvs rdiff -u -r1.7.8.1 -r1.7.8.2 \
    src/common/lib/libc/arch/arm/atomic/Makefile.inc
cvs rdiff -u -r0 -r1.10.2.2 \
    src/common/lib/libc/arch/arm/atomic/atomic_add_64.S
cvs rdiff -u -r0 -r1.9.2.2 \
    src/common/lib/libc/arch/arm/atomic/atomic_and_64.S \
    src/common/lib/libc/arch/arm/atomic/atomic_inc_64.S \
    src/common/lib/libc/arch/arm/atomic/atomic_or_64.S
cvs rdiff -u -r0 -r1.5.2.2 \
    src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S
cvs rdiff -u -r0 -r1.7.2.2 \
    src/common/lib/libc/arch/arm/atomic/atomic_dec_64.S
cvs rdiff -u -r1.2 -r1.2.12.1 \
    src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/arm/atomic/Makefile.inc
diff -u src/common/lib/libc/arch/arm/atomic/Makefile.inc:1.7.8.1 src/common/lib/libc/arch/arm/atomic/Makefile.inc:1.7.8.2
--- src/common/lib/libc/arch/arm/atomic/Makefile.inc:1.7.8.1	Thu Dec 19 01:12:39 2013
+++ src/common/lib/libc/arch/arm/atomic/Makefile.inc	Sat Feb 15 10:27:44 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.7.8.1 2013/12/19 01:12:39 matt Exp $
+#	$NetBSD: Makefile.inc,v 1.7.8.2 2014/02/15 10:27:44 matt Exp $
 
 ARMV6= ${CPUFLAGS:M-march=armv7*} ${CPUFLAGS:M-mcpu=cortex*}
 ARMV6+= ${CPUFLAGS:M-march=armv6*} ${CPUFLAGS:M-mcpu=arm11*}
@@ -19,6 +19,8 @@ SRCS+=	atomic_add_32_cas.c atomic_add_32
 .else
 SRCS+=	atomic_add_32.S atomic_and_32.S atomic_cas_32.S
 SRCS+=	atomic_dec_32.S atomic_inc_32.S atomic_or_32.S
+SRCS+=	atomic_add_64.S atomic_and_64.S atomic_cas_64.S
+SRCS+=	atomic_dec_64.S atomic_inc_64.S atomic_or_64.S
 SRCS+=	atomic_swap.S membar_ops.S
 .endif
 .endif

Index: src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h
diff -u src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h:1.2 src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h:1.2.12.1
--- src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h:1.2	Sat Aug 16 07:12:39 2008
+++ src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h	Sat Feb 15 10:27:44 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_op_asm.h,v 1.2 2008/08/16 07:12:39 matt Exp $	*/
+/*	$NetBSD: atomic_op_asm.h,v 1.2.12.1 2014/02/15 10:27:44 matt Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -51,4 +51,20 @@
 
 #endif /* _KERNEL */
 
+#ifdef __ARMEB__
+#define HI	r0
+#define LO	r1
+#define NHI	r2
+#define NLO	r3
+#define THI	r4
+#define TLO	r5
+#else
+#define LO	r0
+#define HI	r1
+#define NLO	r2
+#define NHI	r3
+#define TLO	r4
+#define THI	r5
+#endif
+
 #endif /* _ATOMIC_OP_ASM_H_ */

Added files:

Index: src/common/lib/libc/arch/arm/atomic/atomic_add_64.S
diff -u /dev/null src/common/lib/libc/arch/arm/atomic/atomic_add_64.S:1.10.2.2
--- /dev/null	Sat Feb 15 10:27:45 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_add_64.S	Sat Feb 15 10:27:44 2014
@@ -0,0 +1,54 @@
+/*	$NetBSD: atomic_add_64.S,v 1.10.2.2 2014/02/15 10:27:44 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>
+ *
+ * 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_nv)
+	push	{r4}
+	mov	r4, r0			/* need r0 for return value */
+	mov	r3, r2
+	mov	r2, r1
+1:	ldrexd	r0, [r4]		/* load old value */
+	adds	LO, LO, NLO		/* calculate new value (return value) */
+	adc	HI, HI, NHI		/* calculate new value (return value) */
+	strexd	ip, r0, [r4]		/* try to store */
+	cmp	ip, #0			/*   succeed? */
+	bne	1b			/*     no, try again? */
+	pop	{r4}
+	bx	lr			/* return new value */
+END(_atomic_add_64_nv)
+ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
+ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64_nv)
+STRONG_ALIAS(_atomic_add_64,_atomic_add_64_nv)
+
+#endif /* _ARM_ARCH_6 */

Index: src/common/lib/libc/arch/arm/atomic/atomic_and_64.S
diff -u /dev/null src/common/lib/libc/arch/arm/atomic/atomic_and_64.S:1.9.2.2
--- /dev/null	Sat Feb 15 10:27:45 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_and_64.S	Sat Feb 15 10:27:44 2014
@@ -0,0 +1,53 @@
+/*	$NetBSD: atomic_and_64.S,v 1.9.2.2 2014/02/15 10:27:44 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>
+ *
+ * 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_nv)
+	push	{r4}
+	mov	r4, r0			/* need r0 for return value */
+	mov	r3, r2
+	mov	r2, r1
+1:	ldrexd	r0, [r4]		/* load old value */
+	and	LO, LO, NLO		/* calculate new value (return value) */
+	and	HI, HI, NHI		/* calculate new value (return value) */
+	strexd	ip, r0, [r4]		/* try to store */
+	cmp	ip, #0			/*   succeed? */
+	bne	1b			/*     no, try again? */
+	pop	{r4}
+	bx	lr			/* return new value */
+END(_atomic_and_64_nv)
+ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
+ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64_nv)
+
+#endif /* _ARM_ARCH_6 */
Index: src/common/lib/libc/arch/arm/atomic/atomic_inc_64.S
diff -u /dev/null src/common/lib/libc/arch/arm/atomic/atomic_inc_64.S:1.9.2.2
--- /dev/null	Sat Feb 15 10:27:45 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_inc_64.S	Sat Feb 15 10:27:44 2014
@@ -0,0 +1,50 @@
+/*	$NetBSD: atomic_inc_64.S,v 1.9.2.2 2014/02/15 10:27:44 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>
+ *
+ * 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_inc_64_nv)
+	mov	r3, r0			/* need r0 for return value */
+1:	ldrexd	r0, [r3]		/* load old value */
+	adds	LO, LO, #1		/* calculate new value (return value) */
+	adc	HI, HI, #0		/* calculate new value (return value) */
+	strexd	ip, r0, [r3]		/* try to store */
+	cmp	ip, #0			/*   succeed? */
+	bne	1b			/*     no, try again? */
+	bx	lr			/* return new value */
+END(_atomic_inc_64_nv)
+ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
+ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64_nv)
+STRONG_ALIAS(_atomic_inc_64,_atomic_inc_64_nv)
+
+#endif /* _ARM_ARCH_6 */
Index: src/common/lib/libc/arch/arm/atomic/atomic_or_64.S
diff -u /dev/null src/common/lib/libc/arch/arm/atomic/atomic_or_64.S:1.9.2.2
--- /dev/null	Sat Feb 15 10:27:45 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_or_64.S	Sat Feb 15 10:27:44 2014
@@ -0,0 +1,54 @@
+/*	$NetBSD: atomic_or_64.S,v 1.9.2.2 2014/02/15 10:27:44 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>
+ *
+ * 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_or_64_nv)
+	push	{r4}
+	mov	r4, r0			/* need r0 for return value */
+	mov	r3, r2
+	mov	r2, r1
+1:	ldrexd	r0, [r4]		/* load old value */
+	orr	LO, LO, NLO		/* calculate new value (return value) */
+	orr	HI, HI, NHI		/* calculate new value (return value) */
+	strexd	ip, r0, [r4]		/* try to store */
+	cmp	ip, #0			/*   succeed? */
+	bne	1b			/*     no, try again? */
+	pop	{r4}
+	bx	lr			/* return new value */
+END(_atomic_or_64_nv)
+ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
+ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64_nv)
+STRONG_ALIAS(_atomic_or_64,_atomic_or_64_nv)
+
+#endif /* _ARM_ARCH_6 */

Index: src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S
diff -u /dev/null src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S:1.5.2.2
--- /dev/null	Sat Feb 15 10:27:45 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S	Sat Feb 15 10:27:44 2014
@@ -0,0 +1,59 @@
+/*	$NetBSD: atomic_cas_64.S,v 1.5.2.2 2014/02/15 10:27:44 matt Exp $	*/
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>
+ *
+ * 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"
+
+#if defined(_ARM_ARCH_6)
+/*
+ * ARMv6 has load-exclusive/store-exclusive which works for both user
+ * and kernel.
+ */
+ENTRY_NP(_atomic_cas_64)
+	push	{r4-r6}
+	mov	r3, r2
+	mov	r2, r1
+	ldr	r4, [sp, #0]
+	ldr	r5, [sp, #4]
+	mov	r6, r0			/* we need r0 for return value */
+1:
+	ldrexd	r0, [r6]		/* load old value */
+	cmp	r0, r2			/*   compare? */
+	cmpeq	r1, r3			/*   compare? */
+	bne	2f			/*     return if different */
+	strexd	ip, r4, [r6]		/* store new value */
+	cmp	ip, #0			/*   succeed? */
+	bne	1b			/*     nope, try again. */
+2:	pop	{r4-r6}
+	bx	lr			/*    yes, return. */
+END(_atomic_cas_64)
+
+ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
+
+#endif /* _ARM_ARCH_6 */

Index: src/common/lib/libc/arch/arm/atomic/atomic_dec_64.S
diff -u /dev/null src/common/lib/libc/arch/arm/atomic/atomic_dec_64.S:1.7.2.2
--- /dev/null	Sat Feb 15 10:27:45 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_dec_64.S	Sat Feb 15 10:27:44 2014
@@ -0,0 +1,50 @@
+/*	$NetBSD: atomic_dec_64.S,v 1.7.2.2 2014/02/15 10:27:44 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>
+ *
+ * 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_dec_64_nv)
+	mov	r3, r0			/* need r0 for return value */
+1:	ldrexd	r0, [r3]		/* load old value */
+	subs	LO, LO, #1		/* calculate new value (return value) */
+	sbc	HI, HI, #0		/* calculate new value (return value) */
+	strexd	ip, r0, [r3]		/* try to store */
+	cmp	ip, #0			/*   succeed? */
+	bne	1b			/*     no, try again? */
+	bx	lr			/* return new value */
+END(_atomic_dec_64_nv)
+ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
+ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64_nv)
+STRONG_ALIAS(_atomic_dec_64,_atomic_dec_64_nv)
+
+#endif /* _ARM_ARCH_6 */

Reply via email to