Module Name: src
Committed By: martin
Date: Mon Oct 13 07:31:12 UTC 2014
Modified Files:
src/common/lib/libc/arch/arm/atomic: Makefile.inc
src/common/lib/libc/atomic: atomic_op_namespace.h
Added Files:
src/common/lib/libc/atomic: atomic_and_16_nv_cas.c
atomic_and_8_nv_cas.c
Log Message:
Provide __sync_and_and_fetch_2 and __sync_and_and_fetch_1 for pre-ARMv6,
they are needed for the C++ 2011 <atomic> stuff.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/common/lib/libc/arch/arm/atomic/Makefile.inc
cvs rdiff -u -r0 -r1.2 src/common/lib/libc/atomic/atomic_and_16_nv_cas.c \
src/common/lib/libc/atomic/atomic_and_8_nv_cas.c
cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/atomic/atomic_op_namespace.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.23 src/common/lib/libc/arch/arm/atomic/Makefile.inc:1.24
--- src/common/lib/libc/arch/arm/atomic/Makefile.inc:1.23 Sat Jul 5 20:44:46 2014
+++ src/common/lib/libc/arch/arm/atomic/Makefile.inc Mon Oct 13 07:31:12 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.23 2014/07/05 20:44:46 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.24 2014/10/13 07:31:12 martin Exp $
.ifnmake obj
.include "${NETBSDSRCDIR}/common/lib/libc/arch/arm/features.mk"
@@ -13,7 +13,8 @@ SRCS.atomic+= atomic_add_32_cas.c atomic
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
+ atomic_swap_32_cas.c membar_ops_nop.c \
+ atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c
.if ${LIB} == "c"
SRCS.atomic+= atomic_xor_32_cas.c atomic_xor_16_cas.c atomic_xor_8_cas.c \
Index: src/common/lib/libc/atomic/atomic_op_namespace.h
diff -u src/common/lib/libc/atomic/atomic_op_namespace.h:1.6 src/common/lib/libc/atomic/atomic_op_namespace.h:1.7
--- src/common/lib/libc/atomic/atomic_op_namespace.h:1.6 Sat Feb 22 17:08:30 2014
+++ src/common/lib/libc/atomic/atomic_op_namespace.h Mon Oct 13 07:31:12 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_op_namespace.h,v 1.6 2014/02/22 17:08:30 martin Exp $ */
+/* $NetBSD: atomic_op_namespace.h,v 1.7 2014/10/13 07:31:12 martin Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,6 +57,8 @@
#define atomic_and_uint_nv _atomic_and_uint_nv
#define atomic_and_ulong_nv _atomic_and_ulong_nv
#define atomic_and_64_nv _atomic_and_64_nv
+#define atomic_and_16_nv _atomic_and_16_nv
+#define atomic_and_8_nv _atomic_and_8_nv
#define atomic_or_32 _atomic_or_32
#define atomic_or_uint _atomic_or_uint
Added files:
Index: src/common/lib/libc/atomic/atomic_and_16_nv_cas.c
diff -u /dev/null src/common/lib/libc/atomic/atomic_and_16_nv_cas.c:1.2
--- /dev/null Mon Oct 13 07:31:12 2014
+++ src/common/lib/libc/atomic/atomic_and_16_nv_cas.c Mon Oct 13 07:31:12 2014
@@ -0,0 +1,53 @@
+/* $NetBSD: atomic_and_16_nv_cas.c,v 1.2 2014/10/13 07:31:12 martin Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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_namespace.h"
+
+#include <sys/atomic.h>
+
+uint16_t atomic_and_16_nv(volatile uint16_t *addr, uint16_t val);
+
+uint16_t
+atomic_and_16_nv(volatile uint16_t *addr, uint16_t val)
+{
+ uint16_t old, new;
+
+ do {
+ old = *addr;
+ new = old & val;
+ } while (atomic_cas_16(addr, old, new) != old);
+
+ return (new);
+}
+
+#undef atomic_and_16_nv
+atomic_op_alias(atomic_and_16_nv,_atomic_and_16_nv)
+crt_alias(__sync_and_and_fetch_2,_atomic_and_16_nv)
Index: src/common/lib/libc/atomic/atomic_and_8_nv_cas.c
diff -u /dev/null src/common/lib/libc/atomic/atomic_and_8_nv_cas.c:1.2
--- /dev/null Mon Oct 13 07:31:12 2014
+++ src/common/lib/libc/atomic/atomic_and_8_nv_cas.c Mon Oct 13 07:31:12 2014
@@ -0,0 +1,53 @@
+/* $NetBSD: atomic_and_8_nv_cas.c,v 1.2 2014/10/13 07:31:12 martin Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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_namespace.h"
+
+#include <sys/atomic.h>
+
+uint8_t atomic_and_8_nv(volatile uint8_t *addr, uint8_t val);
+
+uint8_t
+atomic_and_8_nv(volatile uint8_t *addr, uint8_t val)
+{
+ uint8_t old, new;
+
+ do {
+ old = *addr;
+ new = old & val;
+ } while (atomic_cas_8(addr, old, new) != old);
+
+ return (new);
+}
+
+#undef atomic_and_8_nv
+atomic_op_alias(atomic_and_8_nv,_atomic_and_8_nv)
+crt_alias(__sync_and_and_fetch_1,_atomic_and_8_nv)