Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libc/atomic libc: Define __atomic_is_lock_free.
details: https://anonhg.NetBSD.org/src/rev/000831503e0a
branches: trunk
changeset: 374081:000831503e0a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Mar 30 15:03:35 2023 +0000
description:
libc: Define __atomic_is_lock_free.
Limited to architectures where it is actually needed by gcc for any
calls to stdatomic.h atomic_is_lock_free for now.
We should also add it to other architectures too, along with lockful
atomic r/m/w operations for sizes that can't be handled natively, but
that's a lot more work. It is also necessary for -fno-inline-atomics
but we're missing a lot of other symbols for that too, to be fixed.
For now, this should enable the OpenSSL build to complete on these
architectures again after I reverted a local change.
XXX pullup-10
diffstat:
common/lib/libc/arch/hppa/atomic/Makefile.inc | 5 +-
common/lib/libc/arch/m68k/atomic/Makefile.inc | 6 ++-
common/lib/libc/arch/mips/atomic/Makefile.inc | 5 +-
common/lib/libc/arch/sh3/atomic/Makefile.inc | 5 +-
common/lib/libc/arch/sparc/atomic/Makefile.inc | 5 +-
common/lib/libc/arch/vax/atomic/Makefile.inc | 5 +-
common/lib/libc/atomic/atomic_is_lock_free.c | 54 ++++++++++++++++++++++++++
7 files changed, 75 insertions(+), 10 deletions(-)
diffs (169 lines):
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/arch/hppa/atomic/Makefile.inc
--- a/common/lib/libc/arch/hppa/atomic/Makefile.inc Thu Mar 30 11:21:08 2023 +0000
+++ b/common/lib/libc/arch/hppa/atomic/Makefile.inc Thu Mar 30 15:03:35 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.14 2019/02/28 02:35:37 isaki Exp $
+# $NetBSD: Makefile.inc,v 1.15 2023/03/30 15:03:35 riastradh Exp $
.if defined(LIB)
@@ -36,6 +36,7 @@ SRCS+= atomic_xor_32_cas.c atomic_xor_16
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
+ atomic_c11_compare_exchange_cas_8.c \
+ atomic_is_lock_free.c
.endif
.endif
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/arch/m68k/atomic/Makefile.inc
--- a/common/lib/libc/arch/m68k/atomic/Makefile.inc Thu Mar 30 11:21:08 2023 +0000
+++ b/common/lib/libc/arch/m68k/atomic/Makefile.inc Thu Mar 30 15:03:35 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.15 2019/02/28 02:35:37 isaki Exp $
+# $NetBSD: Makefile.inc,v 1.16 2023/03/30 15:03:35 riastradh Exp $
#
# Note: The atomic operations here in these assembly files are atomic
@@ -57,3 +57,7 @@ CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP -D
.endif
.endif
+
+.if defined(LIB) && ${LIB} == "c"
+SRCS+= atomic_is_lock_free.c
+.endif
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/arch/mips/atomic/Makefile.inc
--- a/common/lib/libc/arch/mips/atomic/Makefile.inc Thu Mar 30 11:21:08 2023 +0000
+++ b/common/lib/libc/arch/mips/atomic/Makefile.inc Thu Mar 30 15:03:35 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.15 2021/04/25 22:45:16 christos Exp $
+# $NetBSD: Makefile.inc,v 1.16 2023/03/30 15:03:36 riastradh Exp $
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|| ${LIB} == "rump")
@@ -51,6 +51,9 @@ SRCS+= atomic_xor_32_cas.c atomic_xor_16
atomic_c11_compare_exchange_cas_32.c \
atomic_c11_compare_exchange_cas_16.c \
atomic_c11_compare_exchange_cas_8.c
+.if !${MACHINE_MIPS64}
+SRCS+= atomic_is_lock_free.c
+.endif
.endif
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "rump")
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/arch/sh3/atomic/Makefile.inc
--- a/common/lib/libc/arch/sh3/atomic/Makefile.inc Thu Mar 30 11:21:08 2023 +0000
+++ b/common/lib/libc/arch/sh3/atomic/Makefile.inc Thu Mar 30 15:03:35 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.8 2019/02/28 02:35:37 isaki Exp $
+# $NetBSD: Makefile.inc,v 1.9 2023/03/30 15:03:36 riastradh Exp $
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|| ${LIB} == "rump")
@@ -20,7 +20,8 @@ SRCS+= atomic_add_16_cas.c atomic_add_8_
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
+ atomic_c11_compare_exchange_cas_8.c \
+ atomic_is_lock_free.c
.endif
.endif
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/arch/sparc/atomic/Makefile.inc
--- a/common/lib/libc/arch/sparc/atomic/Makefile.inc Thu Mar 30 11:21:08 2023 +0000
+++ b/common/lib/libc/arch/sparc/atomic/Makefile.inc Thu Mar 30 15:03:35 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.23 2019/02/28 02:35:37 isaki Exp $
+# $NetBSD: Makefile.inc,v 1.24 2023/03/30 15:03:36 riastradh Exp $
.include <bsd.own.mk>
@@ -46,7 +46,8 @@ SRCS+= atomic_nand_16_cas.c atomic_nand_
atomic_c11_compare_exchange_cas_32.c \
atomic_c11_compare_exchange_cas_16.c \
atomic_c11_compare_exchange_cas_8.c \
- atomic_load.c atomic_store.c
+ atomic_load.c atomic_store.c \
+ atomic_is_lock_free.c
. endif
. if (${LIB} == "kern" || ${LIB} == "rump")
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/arch/vax/atomic/Makefile.inc
--- a/common/lib/libc/arch/vax/atomic/Makefile.inc Thu Mar 30 11:21:08 2023 +0000
+++ b/common/lib/libc/arch/vax/atomic/Makefile.inc Thu Mar 30 15:03:35 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.8 2019/02/28 02:35:38 isaki Exp $
+# $NetBSD: Makefile.inc,v 1.9 2023/03/30 15:03:36 riastradh Exp $
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|| ${LIB} == "rump")
@@ -20,7 +20,8 @@ SRCS+= atomic_add_16_cas.c atomic_add_8_
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
+ atomic_c11_compare_exchange_cas_8.c \
+ atomic_is_lock_free.c
.endif
.endif
diff -r b598f4c6bbfb -r 000831503e0a common/lib/libc/atomic/atomic_is_lock_free.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/atomic/atomic_is_lock_free.c Thu Mar 30 15:03:35 2023 +0000
@@ -0,0 +1,54 @@
+/* $NetBSD: atomic_is_lock_free.c,v 1.1 2023/03/30 15:03:36 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 <sys/cdefs.h>
+__RCSID("$NetBSD: atomic_is_lock_free.c,v 1.1 2023/03/30 15:03:36 riastradh Exp $");
+
+#include <sys/types.h>
+
+#include <sys/stdbool.h>
+
+bool
+__atomic_is_lock_free(size_t n, const volatile void *p __unused)
+{
+
+ switch (n) {
+ case 1:
+ return __atomic_always_lock_free(1, 0);
+ case 2:
+ return __atomic_always_lock_free(2, 0);
+ case 4:
+ return __atomic_always_lock_free(4, 0);
+ case 8:
+ return __atomic_always_lock_free(8, 0);
+ case 16:
+ return __atomic_always_lock_free(16, 0);
+ default:
+ return false;
+ }
+}
Home |
Main Index |
Thread Index |
Old Index