Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libc Provide __sync_and_and_fetch_2 and __sync_an...
details: https://anonhg.NetBSD.org/src/rev/ce732d4e8d36
branches: trunk
changeset: 803123:ce732d4e8d36
user: martin <martin%NetBSD.org@localhost>
date: Mon Oct 13 07:31:12 2014 +0000
description:
Provide __sync_and_and_fetch_2 and __sync_and_and_fetch_1 for pre-ARMv6,
they are needed for the C++ 2011 <atomic> stuff.
diffstat:
common/lib/libc/arch/arm/atomic/Makefile.inc | 5 +-
common/lib/libc/atomic/atomic_and_16_nv_cas.c | 53 +++++++++++++++++++++++++++
common/lib/libc/atomic/atomic_and_8_nv_cas.c | 53 +++++++++++++++++++++++++++
common/lib/libc/atomic/atomic_op_namespace.h | 4 +-
4 files changed, 112 insertions(+), 3 deletions(-)
diffs (151 lines):
diff -r bb8b871b3b03 -r ce732d4e8d36 common/lib/libc/arch/arm/atomic/Makefile.inc
--- a/common/lib/libc/arch/arm/atomic/Makefile.inc Mon Oct 13 06:57:08 2014 +0000
+++ b/common/lib/libc/arch/arm/atomic/Makefile.inc Mon Oct 13 07:31:12 2014 +0000
@@ -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 @@
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 \
diff -r bb8b871b3b03 -r ce732d4e8d36 common/lib/libc/atomic/atomic_and_16_nv_cas.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/atomic/atomic_and_16_nv_cas.c Mon Oct 13 07:31:12 2014 +0000
@@ -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)
diff -r bb8b871b3b03 -r ce732d4e8d36 common/lib/libc/atomic/atomic_and_8_nv_cas.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/atomic/atomic_and_8_nv_cas.c Mon Oct 13 07:31:12 2014 +0000
@@ -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)
diff -r bb8b871b3b03 -r ce732d4e8d36 common/lib/libc/atomic/atomic_op_namespace.h
--- a/common/lib/libc/atomic/atomic_op_namespace.h Mon Oct 13 06:57:08 2014 +0000
+++ b/common/lib/libc/atomic/atomic_op_namespace.h Mon Oct 13 07:31:12 2014 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index