Source-Changes-HG archive

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

[src/netbsd-7]: src/common/lib/libc Pull up following revision(s) (requested ...



details:   https://anonhg.NetBSD.org/src/rev/d88631d5a4a5
branches:  netbsd-7
changeset: 798554:d88631d5a4a5
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Nov 12 19:20:06 2014 +0000

description:
Pull up following revision(s) (requested by martin in ticket #218):
        common/lib/libc/arch/arm/atomic/Makefile.inc: revision 1.24-1.26
        common/lib/libc/arch/hppa/atomic/Makefile.inc: revision 1.13
        common/lib/libc/arch/mips/atomic/Makefile.inc: revision 1.13
        common/lib/libc/arch/sh3/atomic/Makefile.inc: revision 1.7
        common/lib/libc/arch/sparc/atomic/Makefile.inc: revision 1.18
        common/lib/libc/arch/vax/atomic/Makefile.inc: revision 1.7
        common/lib/libc/atomic/atomic_and_16_nv_cas.c: revision 1.2
        common/lib/libc/atomic/atomic_and_8_nv_cas.c: revision 1.2
        common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c: revision 1.1-1.2
        common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c: revision 1.1-1.2
        common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c: revision 1.1-1.2
        common/lib/libc/atomic/atomic_cas_by_cas32.c: revision 1.4
        common/lib/libc/atomic/atomic_op_namespace.h: revision 1.7
Add __sync_val_compare_and_swap_{1,2} aliases for _atomic_cas_{8,16}
--
Provide __atomic_compare_exchange_N (as needed for the C11 2011 <atomic>
ops) via the corresponding CAS.
--
Hook __atomic_compare_exchange_N into vax libc.
--
Provide __sync_and_and_fetch_2 and __sync_and_and_fetch_1 for pre-ARMv6,
they are needed for the C++ 2011 <atomic> stuff.
--
Add C++ 2011 <atomic> support functions.
--
Move the and_{16,8}_nv sources into the right (libc only) block.
--
Provide <atomic> C++ 2011 support functions for mips and sh3.
--
Provide C++ 2011 <atomic> support functions for hppa and arm.
--
Provide prototypes to fix build with clang.

diffstat:

 common/lib/libc/arch/arm/atomic/Makefile.inc                |   8 +-
 common/lib/libc/arch/hppa/atomic/Makefile.inc               |   7 +-
 common/lib/libc/arch/mips/atomic/Makefile.inc               |   7 +-
 common/lib/libc/arch/sh3/atomic/Makefile.inc                |   7 +-
 common/lib/libc/arch/sparc/atomic/Makefile.inc              |   7 +-
 common/lib/libc/arch/vax/atomic/Makefile.inc                |   7 +-
 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_c11_compare_exchange_cas_16.c |  55 +++++++++++++
 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c |  55 +++++++++++++
 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c  |  55 +++++++++++++
 common/lib/libc/atomic/atomic_cas_by_cas32.c                |   8 +-
 common/lib/libc/atomic/atomic_op_namespace.h                |   4 +-
 13 files changed, 312 insertions(+), 14 deletions(-)

diffs (truncated from 468 to 300 lines):

diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/arch/arm/atomic/Makefile.inc
--- a/common/lib/libc/arch/arm/atomic/Makefile.inc      Wed Nov 12 18:55:07 2014 +0000
+++ b/common/lib/libc/arch/arm/atomic/Makefile.inc      Wed Nov 12 19:20:06 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.23.2.1 2014/11/12 19:20:06 snj Exp $
 
 .ifnmake obj
 .include "${NETBSDSRCDIR}/common/lib/libc/arch/arm/features.mk"
@@ -24,7 +24,11 @@
                atomic_add_16_cas.c atomic_add_8_cas.c \
                atomic_swap_16_cas.c atomic_swap_8_cas.c \
                atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c \
-               atomic_load.c atomic_store.c
+               atomic_load.c atomic_store.c \
+               atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c    \
+               atomic_c11_compare_exchange_cas_32.c    \
+               atomic_c11_compare_exchange_cas_16.c    \
+               atomic_c11_compare_exchange_cas_8.c
 .endif
 
 .else
diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/arch/hppa/atomic/Makefile.inc
--- a/common/lib/libc/arch/hppa/atomic/Makefile.inc     Wed Nov 12 18:55:07 2014 +0000
+++ b/common/lib/libc/arch/hppa/atomic/Makefile.inc     Wed Nov 12 19:20:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.12 2014/02/22 10:23:24 skrll Exp $
+#      $NetBSD: Makefile.inc,v 1.12.4.1 2014/11/12 19:20:06 snj Exp $
 
 .if defined(LIB)
 
@@ -32,6 +32,9 @@
        atomic_and_16_cas.c atomic_and_8_cas.c                          \
        atomic_add_16_cas.c atomic_add_8_cas.c                          \
        atomic_swap_16_cas.c atomic_swap_8_cas.c                        \
-       atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c
+       atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c      \
+       atomic_c11_compare_exchange_cas_32.c                            \
+       atomic_c11_compare_exchange_cas_16.c                            \
+       atomic_c11_compare_exchange_cas_8.c
 .endif
 .endif
diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/arch/mips/atomic/Makefile.inc
--- a/common/lib/libc/arch/mips/atomic/Makefile.inc     Wed Nov 12 18:55:07 2014 +0000
+++ b/common/lib/libc/arch/mips/atomic/Makefile.inc     Wed Nov 12 19:20:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.12 2014/02/24 16:15:43 martin Exp $
+#      $NetBSD: Makefile.inc,v 1.12.4.1 2014/11/12 19:20:06 snj Exp $
 
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
        || ${LIB} == "rump")
@@ -46,7 +46,10 @@
        atomic_and_16_cas.c atomic_and_8_cas.c                          \
        atomic_add_16_cas.c atomic_add_8_cas.c                          \
        atomic_swap_16_cas.c atomic_swap_8_cas.c                        \
-       atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c
+       atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c      \
+       atomic_c11_compare_exchange_cas_32.c                            \
+       atomic_c11_compare_exchange_cas_16.c                            \
+       atomic_c11_compare_exchange_cas_8.c
 .endif
 
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "rump")
diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/arch/sh3/atomic/Makefile.inc
--- a/common/lib/libc/arch/sh3/atomic/Makefile.inc      Wed Nov 12 18:55:07 2014 +0000
+++ b/common/lib/libc/arch/sh3/atomic/Makefile.inc      Wed Nov 12 19:20:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.6 2014/02/22 12:12:30 martin Exp $
+#      $NetBSD: Makefile.inc,v 1.6.4.1 2014/11/12 19:20:06 snj Exp $
 
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
        || ${LIB} == "rump")
@@ -16,7 +16,10 @@
        atomic_or_16_cas.c atomic_or_8_cas.c    \
        atomic_xor_32_cas.c atomic_xor_16_cas.c atomic_xor_8_cas.c      \
        atomic_swap_16_cas.c atomic_swap_8_cas.c \
-       atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c
+       atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c      \
+       atomic_c11_compare_exchange_cas_32.c    \
+       atomic_c11_compare_exchange_cas_16.c    \
+       atomic_c11_compare_exchange_cas_8.c
 .endif
 
 .endif
diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/arch/sparc/atomic/Makefile.inc
--- a/common/lib/libc/arch/sparc/atomic/Makefile.inc    Wed Nov 12 18:55:07 2014 +0000
+++ b/common/lib/libc/arch/sparc/atomic/Makefile.inc    Wed Nov 12 19:20:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.17 2014/02/21 16:21:02 martin Exp $
+#      $NetBSD: Makefile.inc,v 1.17.4.1 2014/11/12 19:20:06 snj Exp $
 
 .include <bsd.own.mk>
 
@@ -34,7 +34,10 @@
        atomic_cas_16_cas.c atomic_cas_8_cas.c          \
        atomic_sub_16_cas.c atomic_sub_8_cas.c          \
        atomic_or_16_cas.c atomic_or_8_cas.c            \
-       atomic_swap_16_cas.c atomic_swap_8_cas.c
+       atomic_swap_16_cas.c atomic_swap_8_cas.c        \
+       atomic_c11_compare_exchange_cas_32.c            \
+       atomic_c11_compare_exchange_cas_16.c            \
+       atomic_c11_compare_exchange_cas_8.c
 .  endif
 
 .  if (${LIB} == "kern" || ${LIB} == "rump")
diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/arch/vax/atomic/Makefile.inc
--- a/common/lib/libc/arch/vax/atomic/Makefile.inc      Wed Nov 12 18:55:07 2014 +0000
+++ b/common/lib/libc/arch/vax/atomic/Makefile.inc      Wed Nov 12 19:20:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.6 2014/02/22 08:53:33 martin Exp $
+#      $NetBSD: Makefile.inc,v 1.6.4.1 2014/11/12 19:20:06 snj Exp $
 
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
        || ${LIB} == "rump")
@@ -16,7 +16,10 @@
        atomic_and_16_cas.c atomic_and_8_cas.c  \
        atomic_nand_32_cas.c atomic_nand_16_cas.c atomic_nand_8_cas.c   \
        atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c      \
-       atomic_swap_16_cas.c atomic_swap_8_cas.c
+       atomic_swap_16_cas.c atomic_swap_8_cas.c \
+       atomic_c11_compare_exchange_cas_32.c    \
+       atomic_c11_compare_exchange_cas_16.c    \
+       atomic_c11_compare_exchange_cas_8.c
 .endif
 
 .endif
diff -r c5a7bc84f8b0 -r d88631d5a4a5 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     Wed Nov 12 19:20:06 2014 +0000
@@ -0,0 +1,53 @@
+/*     $NetBSD: atomic_and_16_nv_cas.c,v 1.2.2.2 2014/11/12 19:20:06 snj 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 c5a7bc84f8b0 -r d88631d5a4a5 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      Wed Nov 12 19:20:06 2014 +0000
@@ -0,0 +1,53 @@
+/*     $NetBSD: atomic_and_8_nv_cas.c,v 1.2.2.2 2014/11/12 19:20:06 snj 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 c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c       Wed Nov 12 19:20:06 2014 +0000
@@ -0,0 +1,55 @@
+/*     $NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.2.2.2 2014/11/12 19:20:06 snj Exp $   */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Martin Husemann.
+ *
+ * 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"
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <stdbool.h>
+#endif
+#include <sys/atomic.h>
+
+bool __atomic_compare_exchange_2(volatile uint16_t *, uint16_t *, uint16_t,
+    bool, int, int);
+
+bool
+__atomic_compare_exchange_2(volatile uint16_t *mem,
+    uint16_t *expected, uint16_t desired,
+    bool weak, int success, int failure)
+{
+       uint16_t old = *expected;
+
+       /*
+        * Ignore the details (weak, memory model on success and failure)
+        * and just do the cas. If we get here the compiler couldn't
+        * do better and it mostly will not matter at all.
+        */
+       return atomic_cas_16(mem, old, desired) == old;
+}
diff -r c5a7bc84f8b0 -r d88631d5a4a5 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c



Home | Main Index | Thread Index | Old Index