CVS commit: src/common/lib/libc/gmon
Module Name:src Committed By: ryo Date: Sat Aug 14 17:38:44 UTC 2021 Modified Files: src/common/lib/libc/gmon: mcount.c Log Message: don't include "opt_multiprocessor.h" inside an ifdef to work "make depend" properly. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/common/lib/libc/gmon/mcount.c 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/gmon/mcount.c diff -u src/common/lib/libc/gmon/mcount.c:1.14 src/common/lib/libc/gmon/mcount.c:1.15 --- src/common/lib/libc/gmon/mcount.c:1.14 Tue Aug 27 22:48:53 2019 +++ src/common/lib/libc/gmon/mcount.c Sat Aug 14 17:38:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mcount.c,v 1.14 2019/08/27 22:48:53 kamil Exp $ */ +/* $NetBSD: mcount.c,v 1.15 2021/08/14 17:38:44 ryo Exp $ */ /* * Copyright (c) 2003, 2004 Wasabi Systems, Inc. @@ -64,19 +64,19 @@ * SUCH DAMAGE. */ -/* If building a standalone libkern, don't include mcount. */ -#if (!defined(_KERNEL) || defined(GPROF)) && !defined(_STANDALONE) - #ifdef _KERNEL_OPT #include "opt_multiprocessor.h" #endif +/* If building a standalone libkern, don't include mcount. */ +#if (!defined(_KERNEL) || defined(GPROF)) && !defined(_STANDALONE) + #include #if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS) #if 0 static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: mcount.c,v 1.14 2019/08/27 22:48:53 kamil Exp $"); +__RCSID("$NetBSD: mcount.c,v 1.15 2021/08/14 17:38:44 ryo Exp $"); #endif #endif
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Sun Aug 8 07:17:18 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: __aarch64_lse.S Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S 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/aarch64/atomic/__aarch64_lse.S diff -u src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S:1.1 src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S:1.1 Tue Apr 27 09:14:24 2021 +++ src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S Sun Aug 8 07:17:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: __aarch64_lse.S,v 1.1 2021/04/27 09:14:24 skrll Exp $ */ +/* $NetBSD: __aarch64_lse.S,v 1.2 2021/08/08 07:17:18 skrll Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -204,4 +204,3 @@ ENTRY_NP(INSN_FUNC) 2: b 1b END(INSN_FUNC) #endif -
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Thu Jul 29 10:29:05 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_add_16.S atomic_add_32.S atomic_add_64.S atomic_add_8.S atomic_and_16.S atomic_and_32.S atomic_and_64.S atomic_and_8.S atomic_cas_16.S atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S atomic_nand_16.S atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S atomic_op_asm.h atomic_or_16.S atomic_or_32.S atomic_or_64.S atomic_or_8.S atomic_sub_16.S atomic_sub_32.S atomic_sub_64.S atomic_sub_8.S atomic_swap_16.S atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S atomic_xor_16.S atomic_xor_32.S atomic_xor_64.S atomic_xor_8.S Log Message: As we're providing the legacy gcc __sync built-in functions for atomic memory access we might as well get the memory barriers right... >From the gcc documentation: In most cases, these built-in functions are considered a full barrier. That is, no memory operand is moved across the operation, either forward or backward. Further, instructions are issued as necessary to prevent the processor from speculating loads across the operation and from queuing stores after the operation. type __sync_lock_test_and_set (type *ptr, type value, ...) This built-in function is not a full barrier, but rather an acquire barrier. This means that references after the operation cannot move to (or be speculated to) before the operation, but previous memory stores may not be globally visible yet, and previous memory loads may not yet be satisfied. void __sync_lock_release (type *ptr, ...) This built-in function is not a full barrier, but rather a release barrier. This means that all previous memory stores are globally visible, and all previous memory loads have been satisfied, but following memory reads are not prevented from being speculated to before the barrier. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_add_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_add_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_add_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_and_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_and_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_and_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_and_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_or_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_or_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_or_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_sub_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_sub_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_sub_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_sub_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_xor_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_xor_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_xor_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_xor_8.S cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S cvs rdiff -u -r1.5 -r1.6 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h cvs rdiff -u -r1.4 -r1.5 \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/aarch64/atomic/atomic_or_64.S 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/aarch64/atomic/atomic_add_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S Thu Jul 29 10:29:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_16.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: atomic_add_16.S,v 1.2 2021/07/29 10:29:05 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -33,14 +33,16 @@ ATOMIC_OP16(add, add) +SYNC_FETCH_OP16(add, add) +
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: simonb Date: Wed Jul 28 08:01:10 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_op_asm.h Log Message: #define consistency. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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/atomic_op_asm.h diff -u src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h:1.9 src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h:1.10 --- src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h:1.9 Wed Jul 28 07:32:20 2021 +++ src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h Wed Jul 28 08:01:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_op_asm.h,v 1.9 2021/07/28 07:32:20 skrll Exp $ */ +/* $NetBSD: atomic_op_asm.h,v 1.10 2021/07/28 08:01:10 simonb Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -75,11 +75,11 @@ #endif #ifdef _ARM_ARCH_7 -#define DMB dmb ish +#define DMB dmb ish #define DMBST dmb ishst #else -#define DMB mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */ -#define DMBST DMB +#define DMB mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */ +#define DMBST DMB #endif #endif /* _ATOMIC_OP_ASM_H_ */
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Wed Jul 28 07:32:20 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_add_16.S atomic_add_32.S atomic_add_64.S atomic_add_8.S atomic_and_16.S atomic_and_32.S atomic_and_64.S atomic_and_8.S atomic_cas_16.S atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S atomic_dec_32.S atomic_dec_64.S atomic_inc_32.S atomic_inc_64.S atomic_nand_16.S atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S atomic_op_asm.h atomic_or_16.S atomic_or_32.S atomic_or_64.S atomic_or_8.S atomic_sub_64.S atomic_swap.S atomic_swap_16.S atomic_swap_64.S atomic_xor_16.S atomic_xor_32.S atomic_xor_64.S atomic_xor_8.S membar_ops.S sync_bool_compare_and_swap_1.S sync_bool_compare_and_swap_2.S sync_bool_compare_and_swap_4.S sync_bool_compare_and_swap_8.S sync_fetch_and_add_8.S sync_fetch_and_and_8.S sync_fetch_and_nand_8.S sync_fetch_and_or_8.S sync_fetch_and_sub_8.S sync_fetch_and_xor_8.S Log Message: Remove memory barriers from the atomic_ops(3) atomic operations. They're not needed for correctness. Add the correct memory barriers to the gcc legacy __sync built-in functions for atomic memory access. From the gcc documentation: In most cases, these built-in functions are considered a full barrier. That is, no memory operand is moved across the operation, either forward or backward. Further, instructions are issued as necessary to prevent the processor from speculating loads across the operation and from queuing stores after the operation. type __sync_lock_test_and_set (type *ptr, type value, ...) This built-in function is not a full barrier, but rather an acquire barrier. This means that references after the operation cannot move to (or be speculated to) before the operation, but previous memory stores may not be globally visible yet, and previous memory loads may not yet be satisfied. void __sync_lock_release (type *ptr, ...) This built-in function is not a full barrier, but rather a release barrier. This means that all previous memory stores are globally visible, and all previous memory loads have been satisfied, but following memory reads are not prevented from being speculated to before the barrier. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/arm/atomic/atomic_add_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_add_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_and_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_and_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_sub_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_8.S \ src/common/lib/libc/arch/arm/atomic/sync_bool_compare_and_swap_8.S cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/arch/arm/atomic/atomic_add_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_and_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_32.S cvs rdiff -u -r1.13 -r1.14 \ src/common/lib/libc/arch/arm/atomic/atomic_add_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S cvs rdiff -u -r1.12 -r1.13 \ src/common/lib/libc/arch/arm/atomic/atomic_and_64.S cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/arm/atomic/atomic_cas_16.S cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/atomic/atomic_cas_32.S cvs rdiff -u -r1.11 -r1.12 \ src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/atomic/atomic_cas_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_dec_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_inc_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_op_asm.h \ src/common/lib/libc/arch/arm/atomic/membar_ops.S cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/arm/atomic/atomic_dec_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_64.S cvs rdiff -u -r1.10 -r1.11 \ src/common/lib/libc/arch/arm/atomic/atomic_inc_64.S cvs rdiff -u -r1.18 -r1.19 src/common/lib/libc/arch/arm/atomic/atomic_swap.S cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/arm/atomic/sync_bool_compare_and_swap_1.S \ src/common/lib/libc/arch/arm/atomic/sync_bool_compare_and_swap_2.S \ src/common/lib/libc/arch/arm/atomic/sync_bool_compare_and_swap_4.S cvs rdiff -u -r1.5 -r1.6 \
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Sat Jul 10 06:53:40 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_add_16.S atomic_add_32.S atomic_add_64.S atomic_add_8.S atomic_and_16.S atomic_and_32.S atomic_and_64.S atomic_and_8.S atomic_dec_32.S atomic_dec_64.S atomic_inc_32.S atomic_inc_64.S atomic_nand_16.S atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S atomic_or_16.S atomic_or_32.S atomic_or_64.S atomic_or_8.S atomic_sub_64.S atomic_swap.S atomic_swap_16.S atomic_xor_16.S atomic_xor_32.S atomic_xor_64.S atomic_xor_8.S membar_ops.S Log Message: s/ifdef _ARM_ARCH_6/if defined(_ARM_ARCH_6)/ for consistency. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/arm/atomic/atomic_add_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_add_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_and_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_and_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_8.S \ src/common/lib/libc/arch/arm/atomic/atomic_sub_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_8.S cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/atomic/atomic_add_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_and_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_32.S cvs rdiff -u -r1.12 -r1.13 \ src/common/lib/libc/arch/arm/atomic/atomic_add_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_64.S cvs rdiff -u -r1.11 -r1.12 \ src/common/lib/libc/arch/arm/atomic/atomic_and_64.S cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/arch/arm/atomic/atomic_dec_32.S \ src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_64.S cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/atomic/atomic_dec_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_inc_32.S \ src/common/lib/libc/arch/arm/atomic/membar_ops.S cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/arch/arm/atomic/atomic_inc_64.S cvs rdiff -u -r1.17 -r1.18 src/common/lib/libc/arch/arm/atomic/atomic_swap.S 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/atomic_add_16.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_add_16.S:1.3 src/common/lib/libc/arch/arm/atomic/atomic_add_16.S:1.4 --- src/common/lib/libc/arch/arm/atomic/atomic_add_16.S:1.3 Mon Jun 23 21:53:45 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_add_16.S Sat Jul 10 06:53:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_16.S,v 1.3 2014/06/23 21:53:45 joerg Exp $ */ +/* $NetBSD: atomic_add_16.S,v 1.4 2021/07/10 06:53:40 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "atomic_op_asm.h" -#ifdef _ARM_ARCH_6 +#if defined(_ARM_ARCH_6) ENTRY_NP(_atomic_sub_16) negs r1, r1 Index: src/common/lib/libc/arch/arm/atomic/atomic_add_8.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_add_8.S:1.3 src/common/lib/libc/arch/arm/atomic/atomic_add_8.S:1.4 --- src/common/lib/libc/arch/arm/atomic/atomic_add_8.S:1.3 Mon Jun 23 21:53:45 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_add_8.S Sat Jul 10 06:53:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_8.S,v 1.3 2014/06/23 21:53:45 joerg Exp $ */ +/* $NetBSD: atomic_add_8.S,v 1.4 2021/07/10 06:53:40 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "atomic_op_asm.h" -#ifdef _ARM_ARCH_6 +#if defined(_ARM_ARCH_6) ENTRY_NP(_atomic_sub_8) negs r1, r1 Index: src/common/lib/libc/arch/arm/atomic/atomic_and_16.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_and_16.S:1.3 src/common/lib/libc/arch/arm/atomic/atomic_and_16.S:1.4 --- src/common/lib/libc/arch/arm/atomic/atomic_and_16.S:1.3 Mon Jun 23 21:53:45 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_and_16.S Sat Jul 10 06:53:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_and_16.S,v 1.3 2014/06/23 21:53:45 joerg Exp $ */ +/* $NetBSD: atomic_and_16.S,v 1.4 2021/07/10 06:53:40 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "atomic_op_asm.h" -#ifdef _ARM_ARCH_6 +#if defined(_ARM_ARCH_6) ENTRY_NP(_atomic_and_16) mov ip, r0 Index: src/common/lib/libc/arch/arm/atomic/atomic_and_8.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_and_8.S:1.3 src/common/lib/libc/arch/arm/atomic/atomic_and_8.S:1.4 ---
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Tue Jul 6 08:31:41 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_nand_16.S Log Message: One more s/pte/ptr/ To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S 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/aarch64/atomic/atomic_nand_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.4 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.3 Sun Jul 4 06:55:47 2021 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S Tue Jul 6 08:31:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_16.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */ +/* $NetBSD: atomic_nand_16.S,v 1.4 2021/07/06 08:31:41 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_16) mov x4, x0 1: ldxrh w0, [x4] /* load old value (*ptr) */ and w3, w0, w1 /* w3 = (*ptr & value) */ - mvn w3, w3 /* w3 = ~(*pte & value) */ + mvn w3, w3 /* w3 = ~(*ptr & value) */ stxrh w2, w3, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again */ ret/* return old value */ @@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_16_nv) mov x4, x0 /* need r0 for return value */ 1: ldxrh w0, [x4] /* load old value (*ptr) */ and w0, w0, w1 /* w0 = (*ptr & value) */ - mvn w0, w0 /* w0 = ~(*pte & value), return value */ + mvn w0, w0 /* w0 = ~(*ptr & value), return value */ stxrh w2, w0, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again? */ ret/* return new value */
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Mon Jul 5 08:50:31 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S Log Message: typo in comment s/pte/ptr/ To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S 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/aarch64/atomic/atomic_nand_32.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.4 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.3 Sun Jul 4 06:55:47 2021 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S Mon Jul 5 08:50:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_32.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */ +/* $NetBSD: atomic_nand_32.S,v 1.4 2021/07/05 08:50:31 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_32) mov x4, x0 1: ldxr w0, [x4] /* load old value (to be returned) */ and w3, w0, w1 /* w3 = (*ptr & value) */ - mvn w3, w3 /* x3 = ~(*pte & value) */ + mvn w3, w3 /* x3 = ~(*ptr & value) */ stxr w2, w3, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again */ ret/* return old value */ @@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_32_nv) mov x4, x0 /* need r0 for return value */ 1: ldxr w0, [x4] /* load old value (*ptr) */ and w0, w0, w1 /* x0 = (*ptr & value) */ - mvn w0, w0 /* x0 = ~(*pte & value), return value */ + mvn w0, w0 /* x0 = ~(*ptr & value), return value */ stxr w2, w0, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again? */ ret/* return new value */ Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.4 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.3 Sun Jul 4 06:55:47 2021 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S Mon Jul 5 08:50:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_64.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */ +/* $NetBSD: atomic_nand_64.S,v 1.4 2021/07/05 08:50:31 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_64) mov x4, x0 1: ldxr x0, [x4] /* load old value (*ptr) */ and x2, x0, x1 /* x2 = (*ptr & value) */ - mvn x2, x2 /* x2 = ~(*pte & value) */ + mvn x2, x2 /* x2 = ~(*ptr & value) */ stxr w3, x2, [x4] /* try to store */ cbnz w3, 2f /* succeed? no, try again */ ret/* return old value */ @@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_64_nv) mov x4, x0 /* need r0 for return value */ 1: ldxr x0, [x4] /* load old value (*ptr) */ and x0, x0, x1 /* x0 = (*ptr & value) */ - mvn x0, x0 /* x0 = ~(*pte & value), return value */ + mvn x0, x0 /* x0 = ~(*ptr & value), return value */ stxr w3, x0, [x4] /* try to store */ cbnz w3, 2f /* succeed? no, try again? */ ret/* return new value */ Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S:1.4 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S:1.3 Sun Jul 4 06:55:47 2021 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S Mon Jul 5 08:50:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_8.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */ +/* $NetBSD: atomic_nand_8.S,v 1.4 2021/07/05 08:50:31 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_8) mov x4, x0 1: ldxrb w0, [x4] /* load old value (*ptr) */ and w3, w0, w1 /* w3 = (*ptr & value) */ - mvn w3, w3 /* w3 = ~(*pte & value) */ + mvn w3, w3 /* w3 = ~(*ptr & value) */ stxrb w2, w3, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again */ ret/* return old value */ @@ -57,7 +57,7 @@ ENTRY_NP(_atomic_nand_8_nv) mov x4, x0 /* need r0 for return value */ 1: ldxrb w0, [x4] /* load old value (*ptr) */ and w0, w0, w1 /* w0 = (*ptr & value) */ - mvn w0, w0 /* w0 = ~(*pte & value), return value */ + mvn w0, w0 /* w0 = ~(*ptr & value), return value */ stxrb w2, w0, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again? */ ret/* return new value */
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Sun Jul 4 06:55:47 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_nand_16.S atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S Log Message: Fix the logic operation for atomic_nand_{8,16,32,64} >From the gcc docs the operations are as follows { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand yes, this is really rather strange. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S 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/aarch64/atomic/atomic_nand_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S Sun Jul 4 06:55:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_nand_16.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,11 +31,14 @@ #include "atomic_op_asm.h" +/* + * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand + */ ENTRY_NP(_atomic_nand_16) mov x4, x0 -1: ldxrh w0, [x4] /* load old value (to be returned) */ - mvn w3, w0 /* complement source */ - and w3, w3, w1 /* calculate new value */ +1: ldxrh w0, [x4] /* load old value (*ptr) */ + and w3, w0, w1 /* w3 = (*ptr & value) */ + mvn w3, w3 /* w3 = ~(*pte & value) */ stxrh w2, w3, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again */ ret/* return old value */ @@ -47,11 +50,15 @@ ATOMIC_OP_ALIAS(atomic_nand_ushort,_atom STRONG_ALIAS(__sync_fetch_and_nand_2,_atomic_nand_16) STRONG_ALIAS(_atomic_nand_ushort,_atomic_nand_16) + +/* + * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand + */ ENTRY_NP(_atomic_nand_16_nv) mov x4, x0 /* need r0 for return value */ -1: ldxrh w0, [x4] /* load old value */ - mvn w0, w0 /* complement source */ - and w0, w0, w1 /* calculate new value (return value) */ +1: ldxrh w0, [x4] /* load old value (*ptr) */ + and w0, w0, w1 /* w0 = (*ptr & value) */ + mvn w0, w0 /* w0 = ~(*pte & value), return value */ stxrh w2, w0, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again? */ ret/* return new value */ Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S Sun Jul 4 06:55:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_nand_32.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,11 +31,14 @@ #include "atomic_op_asm.h" +/* + * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand + */ ENTRY_NP(_atomic_nand_32) mov x4, x0 1: ldxr w0, [x4] /* load old value (to be returned) */ - mvn w3, w0 /* complement source */ - and w3, w3, w1 /* calculate new value */ + and w3, w0, w1 /* w3 = (*ptr & value) */ + mvn w3, w3 /* x3 = ~(*pte & value) */ stxr w2, w3, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again */ ret/* return old value */ @@ -47,11 +50,15 @@ ATOMIC_OP_ALIAS(atomic_nand_uint,_atomic STRONG_ALIAS(__sync_fetch_and_nand_4,_atomic_nand_32) STRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32) + +/* + * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand + */ ENTRY_NP(_atomic_nand_32_nv) mov x4, x0 /* need r0 for return value */ -1: ldxr w0, [x4] /* load old value */ - mvn w0, w0 /* complement source */ - and w0, w0, w1 /* calculate new value (return value) */ +1: ldxr w0, [x4] /* load old value (*ptr) */ + and w0, w0, w1 /* x0 = (*ptr & value) */ + mvn w0, w0 /* x0 = ~(*pte & value), return value */ stxr w2, w0, [x4] /* try to store */ cbnz w2, 2f /* succeed? no, try again? */ ret/* return new value */ Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.2 Wed Aug 12 12:59:57 2020 +++
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Tue Jun 29 06:28:07 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_cas_8.S Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/atomic/atomic_cas_8.S 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/atomic_cas_8.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_cas_8.S:1.7 src/common/lib/libc/arch/arm/atomic/atomic_cas_8.S:1.8 --- src/common/lib/libc/arch/arm/atomic/atomic_cas_8.S:1.7 Tue Mar 4 16:15:28 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_cas_8.S Tue Jun 29 06:28:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_8.S,v 1.7 2014/03/04 16:15:28 matt Exp $ */ +/* $NetBSD: atomic_cas_8.S,v 1.8 2021/06/29 06:28:07 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -55,7 +55,7 @@ ENTRY_NP(_atomic_cas_8) mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */ #endif 2: RET/* return. */ - END(_atomic_cas_8) +END(_atomic_cas_8) ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8) STRONG_ALIAS(_atomic_cas_char,_atomic_cas_8)
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Mon Jun 28 09:00:45 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_add_64.S atomic_and_64.S atomic_nand_64.S atomic_or_64.S atomic_sub_64.S atomic_swap_64.S atomic_xor_64.S Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 \ src/common/lib/libc/arch/arm/atomic/atomic_add_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_or_64.S cvs rdiff -u -r1.10 -r1.11 \ src/common/lib/libc/arch/arm/atomic/atomic_and_64.S cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/arm/atomic/atomic_xor_64.S cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/arm/atomic/atomic_sub_64.S cvs rdiff -u -r1.12 -r1.13 \ src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S 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/atomic_add_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_add_64.S:1.11 src/common/lib/libc/arch/arm/atomic/atomic_add_64.S:1.12 --- src/common/lib/libc/arch/arm/atomic/atomic_add_64.S:1.11 Tue Mar 4 16:15:28 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_add_64.S Mon Jun 28 09:00:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_64.S,v 1.11 2014/03/04 16:15:28 matt Exp $ */ +/* $NetBSD: atomic_add_64.S,v 1.12 2021/06/28 09:00:45 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -33,7 +33,7 @@ #ifdef _ARM_ARCH_6 ENTRY_NP(_atomic_add_64_nv) - push {r3,r4} /* save temporary */ + push {r3, r4} /* save temporary */ mov ip, r0 /* need r0 for return value */ #ifndef __ARM_EABI__ mov r3, r2 @@ -50,7 +50,7 @@ ENTRY_NP(_atomic_add_64_nv) #else mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */ #endif - pop {r3,r4} /* restore temporary */ + pop {r3, r4} /* restore temporary */ RET/* return new value */ END(_atomic_add_64_nv) Index: src/common/lib/libc/arch/arm/atomic/atomic_or_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_or_64.S:1.11 src/common/lib/libc/arch/arm/atomic/atomic_or_64.S:1.12 --- src/common/lib/libc/arch/arm/atomic/atomic_or_64.S:1.11 Sun Sep 15 14:55:04 2019 +++ src/common/lib/libc/arch/arm/atomic/atomic_or_64.S Mon Jun 28 09:00:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_64.S,v 1.11 2019/09/15 14:55:04 skrll Exp $ */ +/* $NetBSD: atomic_or_64.S,v 1.12 2021/06/28 09:00:45 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -33,7 +33,7 @@ #ifdef _ARM_ARCH_6 ENTRY_NP(_atomic_or_64_nv) - push {r3,r4} /* save temporary */ + push {r3, r4} /* save temporary */ #ifndef __ARM_EABI__ mov r3, r2 mov r2, r1 @@ -50,7 +50,7 @@ ENTRY_NP(_atomic_or_64_nv) #else mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */ #endif - pop {r3,r4} /* restore temporary */ + pop {r3, r4} /* restore temporary */ RET/* return new value */ END(_atomic_or_64_nv) Index: src/common/lib/libc/arch/arm/atomic/atomic_and_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_and_64.S:1.10 src/common/lib/libc/arch/arm/atomic/atomic_and_64.S:1.11 --- src/common/lib/libc/arch/arm/atomic/atomic_and_64.S:1.10 Tue Mar 4 16:15:28 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_and_64.S Mon Jun 28 09:00:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_and_64.S,v 1.10 2014/03/04 16:15:28 matt Exp $ */ +/* $NetBSD: atomic_and_64.S,v 1.11 2021/06/28 09:00:45 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -33,7 +33,7 @@ #ifdef _ARM_ARCH_6 ENTRY_NP(_atomic_and_64_nv) - push {r3,r4} /* save temporary */ + push {r3, r4} /* save temporary */ #ifndef __ARM_EABI__ mov r3, r2 mov r2, r1 @@ -50,7 +50,7 @@ ENTRY_NP(_atomic_and_64_nv) #else mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */ #endif - pop {r3,r4} /* restore temporary */ + pop {r3, r4} /* restore temporary */ RET/* return new value */ END(_atomic_and_64_nv) Index: src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S:1.4 src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S:1.5 --- src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S:1.4 Fri Dec 11 12:41:10 2015 +++ src/common/lib/libc/arch/arm/atomic/atomic_nand_64.S Mon Jun 28 09:00:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_64.S,v 1.4 2015/12/11 12:41:10 skrll Exp $ */ +/* $NetBSD: atomic_nand_64.S,v 1.5 2021/06/28 09:00:45 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. @@ -33,7 +33,7 @@ #ifdef _ARM_ARCH_6 ENTRY_NP(_atomic_nand_64_nv) - push {r3,r4} /* save temporary */ + push {r3, r4} /* save temporary */ #ifndef __ARM_EABI__ mov r3, r2 mov r2, r1 @@ -52,7 +52,7 @@ ENTRY_NP(_atomic_nand_64_nv) #else mcr p15, 0, r4, c7, c10, 5 /*
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: rillig Date: Sun May 16 09:43:39 UTC 2021 Modified Files: src/common/lib/libc/string: memmem.c Log Message: memmem: remove unreachable return statement To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/string/memmem.c 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/string/memmem.c diff -u src/common/lib/libc/string/memmem.c:1.3 src/common/lib/libc/string/memmem.c:1.4 --- src/common/lib/libc/string/memmem.c:1.3 Mon Oct 15 19:32:48 2018 +++ src/common/lib/libc/string/memmem.c Sun May 16 09:43:39 2021 @@ -25,7 +25,7 @@ #if 0 __FBSDID("$FreeBSD: head/lib/libc/string/memmem.c 315468 2017-03-18 00:53:24Z emaste $"); #else -__RCSID("$NetBSD: memmem.c,v 1.3 2018/10/15 19:32:48 christos Exp $"); +__RCSID("$NetBSD: memmem.c,v 1.4 2021/05/16 09:43:39 rillig Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -63,7 +63,6 @@ static char *fourbyte_memmem(const unsig for (h += 4, k -= 4; k; k--, hw = hw << 8 | *h++) if (hw == nw) return __UNCONST(h - 4); return hw == nw ? __UNCONST(h - 4) : 0; - return 0; } #define MAX(a,b) ((a)>(b)?(a):(b))
CVS commit: src/common/lib/libc
Module Name:src Committed By: skrll Date: Tue Apr 27 09:14:24 UTC 2021 Modified Files: src/common/lib/libc: Makefile.inc src/common/lib/libc/arch/aarch64/atomic: Makefile.inc Added Files: src/common/lib/libc/arch/aarch64/atomic: __aarch64_lse.S Removed Files: src/common/lib/libc/arch/aarch64/atomic: __aarch64_swp1_acq.S __aarch64_swp1_acq_rel.S __aarch64_swp1_rel.S __aarch64_swp1_relax.S __aarch64_swp2_acq.S __aarch64_swp2_acq_rel.S __aarch64_swp2_rel.S __aarch64_swp2_relax.S __aarch64_swp4_acq.S __aarch64_swp4_acq_rel.S __aarch64_swp4_rel.S __aarch64_swp4_relax.S __aarch64_swp8_acq.S __aarch64_swp8_acq_rel.S __aarch64_swp8_rel.S __aarch64_swp8_relax.S Log Message: Provide all the LSE operation fuctions. The use of LSE instructions is currently disabled. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/common/lib/libc/Makefile.inc cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc cvs rdiff -u -r0 -r1.1 \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S cvs rdiff -u -r1.1 -r0 \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_relax.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_relax.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_relax.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_relax.S 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/Makefile.inc diff -u src/common/lib/libc/Makefile.inc:1.20 src/common/lib/libc/Makefile.inc:1.21 --- src/common/lib/libc/Makefile.inc:1.20 Thu Apr 30 03:28:18 2020 +++ src/common/lib/libc/Makefile.inc Tue Apr 27 09:14:24 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.20 2020/04/30 03:28:18 riastradh Exp $ +# $NetBSD: Makefile.inc,v 1.21 2021/04/27 09:14:24 skrll Exp $ .include @@ -44,5 +44,6 @@ COMMON_ARCHDIR=${COMMON_DIR}/arch/${COMM CPPFLAGS+=-I${COMMON_DIR}/quad -I${COMMON_DIR}/string .if defined(COMMON_ARCHSUBDIR) CPPFLAGS+=-I${COMMON_ARCHDIR}/string +CPPFLAGS+=-I${COMMON_ARCHDIR}/atomic .endif CPPFLAGS+=-I${COMMON_DIR}/hash/sha3 Index: src/common/lib/libc/arch/aarch64/atomic/Makefile.inc diff -u src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.3 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.4 --- src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.3 Wed Apr 21 16:23:47 2021 +++ src/common/lib/libc/arch/aarch64/atomic/Makefile.inc Tue Apr 27 09:14:24 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.3 2021/04/21 16:23:47 skrll Exp $ +# $NetBSD: Makefile.inc,v 1.4 2021/04/27 09:14:24 skrll Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ || ${LIB} == "rump") @@ -12,13 +12,24 @@ SRCS.atomic+= atomic_dec_32.S atomic_dec SRCS.atomic+= atomic_inc_32.S atomic_inc_64.S SRCS.atomic+= membar_ops.S #and cas nand or sub swap xor -.for op in swp +.for op in swp cas clr set eor add .for sz in 1 2 4 8 -.for ar in relax acq rel acq_rel -SRCS.atomic+= __aarch64_${op}${sz}_${ar}.S +.for ar in _relax _acq _rel _acq_rel +__aarch64_${op}${sz}${ar}.S: __aarch64_lse.S + ${_MKTARGET_CREATE} + printf '#define OP ${op}\n#define OP_${op}\n#define SZ ${sz}\n#define AR ${ar}\n#define AR${ar}\n#include "__aarch64_lse.S"\n' > ${.TARGET} +SRCS.gen+= __aarch64_${op}${sz}${ar}.S .endfor .endfor .endfor +.for op in casp +.for ar in _relax _acq _rel _acq_rel +__aarch64_${op}${ar}.S: __aarch64_lse.S + ${_MKTARGET_CREATE} + printf '#define OP ${op}\n#define OP_${op}\n#define AR ${ar}\n#define AR${ar}\n#include "__aarch64_lse.S"\n' > ${.TARGET} +SRCS.gen+= __aarch64_${op}${ar}.S +.endfor +.endfor #.for op in add and nand or sub xor #SRCS.atomic+= sync_fetch_and_${op}_8.S #.endfor @@ -30,4 +41,5 @@ SRCS.atomic+= __aarch64_${op}${sz}_${ar} SRCS.atomic+= atomic_init_cas.c -SRCS+= ${SRCS.atomic} +SRCS+= ${SRCS.atomic} ${SRCS.gen} +CLEANFILES+= ${SRCS.gen} Added files: Index: src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S diff -u /dev/null
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Tue Apr 27 05:40:29 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: membar_ops.S Log Message: Improve the membar_ops barriers - no need to use dsb and wait for completion. Also, we only to act on the inner shareability domain. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/arm/atomic/membar_ops.S 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/membar_ops.S diff -u src/common/lib/libc/arch/arm/atomic/membar_ops.S:1.6 src/common/lib/libc/arch/arm/atomic/membar_ops.S:1.7 --- src/common/lib/libc/arch/arm/atomic/membar_ops.S:1.6 Fri Mar 28 21:32:41 2014 +++ src/common/lib/libc/arch/arm/atomic/membar_ops.S Tue Apr 27 05:40:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: membar_ops.S,v 1.6 2014/03/28 21:32:41 skrll Exp $ */ +/* $NetBSD: membar_ops.S,v 1.7 2021/04/27 05:40:29 skrll Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -34,10 +34,10 @@ ENTRY_NP(_membar_producer) #ifdef _ARM_ARCH_7 - dsb + dmb ishst #else mov r0, #0 - mcr p15, 0, r0, c7, c10, 4 /* Data Synchronization Barrier */ + mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */ #endif RET END(_membar_producer) @@ -47,7 +47,7 @@ STRONG_ALIAS(_membar_write,_membar_produ ENTRY_NP(_membar_sync) #ifdef _ARM_ARCH_7 - dmb + dmb ish #else mov r0, #0 mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Mon Apr 26 21:40:21 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_swap.S atomic_swap_16.S atomic_swap_64.S Log Message: Add the appropriate memory barrier before the lock is cleared in __sync_lock_release_{1,2,4,8}. That is, all reads and write for in inner shareability domain before the lock clear store. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/common/lib/libc/arch/arm/atomic/atomic_swap.S cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S cvs rdiff -u -r1.11 -r1.12 \ src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S 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/atomic_swap.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.16 src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.17 --- src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.16 Sat Apr 24 20:34:34 2021 +++ src/common/lib/libc/arch/arm/atomic/atomic_swap.S Mon Apr 26 21:40:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap.S,v 1.16 2021/04/24 20:34:34 skrll Exp $ */ +/* $NetBSD: atomic_swap.S,v 1.17 2021/04/26 21:40:21 skrll Exp $ */ /*- * Copyright (c) 2007,2012 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ STRONG_ALIAS(_atomic_swap_ptr,_atomic_sw ENTRY_NP(__sync_lock_release_4) mov r1, #0 #ifdef _ARM_ARCH_7 - dmb + dmb ishst #else mcr p15, 0, r1, c7, c10, 5 /* data memory barrier */ #endif @@ -129,7 +129,7 @@ STRONG_ALIAS(_atomic_swap_uchar,_atomic_ ENTRY_NP(__sync_lock_release_1) mov r1, #0 #ifdef _ARM_ARCH_7 - dmb + dmb ishst #else mcr p15, 0, r1, c7, c10, 5 /* data memory barrier */ #endif Index: src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S:1.4 src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S:1.5 --- src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S:1.4 Sun May 17 20:57:11 2015 +++ src/common/lib/libc/arch/arm/atomic/atomic_swap_16.S Mon Apr 26 21:40:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_16.S,v 1.4 2015/05/17 20:57:11 justin Exp $ */ +/* $NetBSD: atomic_swap_16.S,v 1.5 2021/04/26 21:40:21 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -58,6 +58,11 @@ STRONG_ALIAS(_atomic_swap_ushort,_atomic #if (!defined(_KERNEL) || !defined(_RUMPKERNEL)) && !defined(_STANDALONE) ENTRY_NP(__sync_lock_release_2) mov r1, #0 +#ifdef _ARM_ARCH_7 + dmb ishst +#else + mcr p15, 0, r1, c7, c10, 5 /* data memory barrier */ +#endif strh r1, [r0] RET END(__sync_lock_release_2) Index: src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S:1.11 src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S:1.12 --- src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S:1.11 Sat Apr 24 20:34:34 2021 +++ src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S Mon Apr 26 21:40:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_64.S,v 1.11 2021/04/24 20:34:34 skrll Exp $ */ +/* $NetBSD: atomic_swap_64.S,v 1.12 2021/04/26 21:40:21 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -57,6 +57,11 @@ CRT_ALIAS(__atomic_exchange_8,_atomic_sw ENTRY_NP(__sync_lock_release_8) mov r2, #0 mov r3, #0 +#ifdef _ARM_ARCH_7 + dmb ishst +#else + mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */ +#endif strd r2, r3, [r0] RET END(__sync_lock_release_8)
CVS commit: src/common/lib/libc/arch/mips/atomic
Module Name:src Committed By: christos Date: Sun Apr 25 22:45:16 UTC 2021 Modified Files: src/common/lib/libc/arch/mips/atomic: Makefile.inc Log Message: use ${MACHINE_MIPS64} To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/common/lib/libc/arch/mips/atomic/Makefile.inc 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/mips/atomic/Makefile.inc diff -u src/common/lib/libc/arch/mips/atomic/Makefile.inc:1.14 src/common/lib/libc/arch/mips/atomic/Makefile.inc:1.15 --- src/common/lib/libc/arch/mips/atomic/Makefile.inc:1.14 Wed Feb 27 21:35:37 2019 +++ src/common/lib/libc/arch/mips/atomic/Makefile.inc Sun Apr 25 18:45:16 2021 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile.inc,v 1.14 2019/02/28 02:35:37 isaki Exp $ +# $NetBSD: Makefile.inc,v 1.15 2021/04/25 22:45:16 christos Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ || ${LIB} == "rump") -.if ${MACHINE_ARCH:Mmips64*} == "" +.if !${MACHINE_MIPS64} SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \ atomic_and_32_cas.c atomic_and_32_nv_cas.c \ atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ @@ -30,7 +30,7 @@ SRCS+= membar_ops.S .if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread") -.if ${MACHINE_ARCH:Mmips64*} == "" +.if !${MACHINE_MIPS64} SRCS+= atomic_init_testset.c atomic_cas_up.S .else SRCS+= atomic_cas.S atomic_init_cas.c atomic_cas_by_cas32.c
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Sat Apr 24 20:34:34 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_swap.S atomic_swap_64.S Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/common/lib/libc/arch/arm/atomic/atomic_swap.S cvs rdiff -u -r1.10 -r1.11 \ src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S 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/atomic_swap.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.15 src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.16 --- src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.15 Sat Apr 24 20:29:04 2021 +++ src/common/lib/libc/arch/arm/atomic/atomic_swap.S Sat Apr 24 20:34:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap.S,v 1.15 2021/04/24 20:29:04 skrll Exp $ */ +/* $NetBSD: atomic_swap.S,v 1.16 2021/04/24 20:34:34 skrll Exp $ */ /*- * Copyright (c) 2007,2012 The NetBSD Foundation, Inc. @@ -15,7 +15,7 @@ * 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 Index: src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S:1.10 src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S:1.11 --- src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S:1.10 Sun May 17 20:57:11 2015 +++ src/common/lib/libc/arch/arm/atomic/atomic_swap_64.S Sat Apr 24 20:34:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_64.S,v 1.10 2015/05/17 20:57:11 justin Exp $ */ +/* $NetBSD: atomic_swap_64.S,v 1.11 2021/04/24 20:34:34 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -14,7 +14,7 @@ * 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
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Sat Apr 24 20:29:04 UTC 2021 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_swap.S Log Message: Fix __sync_lock_release_4 to actually zeroise the whole 4bytes/32bits. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/common/lib/libc/arch/arm/atomic/atomic_swap.S 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/atomic_swap.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.14 src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.15 --- src/common/lib/libc/arch/arm/atomic/atomic_swap.S:1.14 Sun May 17 20:57:11 2015 +++ src/common/lib/libc/arch/arm/atomic/atomic_swap.S Sat Apr 24 20:29:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap.S,v 1.14 2015/05/17 20:57:11 justin Exp $ */ +/* $NetBSD: atomic_swap.S,v 1.15 2021/04/24 20:29:04 skrll Exp $ */ /*- * Copyright (c) 2007,2012 The NetBSD Foundation, Inc. @@ -92,7 +92,7 @@ ENTRY_NP(__sync_lock_release_4) #else mcr p15, 0, r1, c7, c10, 5 /* data memory barrier */ #endif - strb r1, [r0] + str r1, [r0] RET END(__sync_lock_release_4) #endif
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Wed Apr 21 16:23:47 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: Makefile.inc atomic_swap_16.S atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S Added Files: src/common/lib/libc/arch/aarch64/atomic: __aarch64_swp1_acq.S __aarch64_swp1_acq_rel.S __aarch64_swp1_rel.S __aarch64_swp1_relax.S __aarch64_swp2_acq.S __aarch64_swp2_acq_rel.S __aarch64_swp2_rel.S __aarch64_swp2_relax.S __aarch64_swp4_acq.S __aarch64_swp4_acq_rel.S __aarch64_swp4_rel.S __aarch64_swp4_relax.S __aarch64_swp8_acq.S __aarch64_swp8_acq_rel.S __aarch64_swp8_rel.S __aarch64_swp8_relax.S Removed Files: src/common/lib/libc/arch/aarch64/atomic: atomic_swap_acq_16.S atomic_swap_acq_32.S atomic_swap_acq_64.S atomic_swap_acq_8.S atomic_swap_acq_rel_16.S atomic_swap_acq_rel_32.S atomic_swap_acq_rel_64.S atomic_swap_acq_rel_8.S atomic_swap_rel_16.S atomic_swap_rel_32.S atomic_swap_rel_64.S atomic_swap_rel_8.S Log Message: Do previous differently as the API is different. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc cvs rdiff -u -r0 -r1.1 \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_relax.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_relax.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_relax.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_acq.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_acq_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_rel.S \ src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_relax.S cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S cvs rdiff -u -r1.1 -r0 \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S 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/aarch64/atomic/Makefile.inc diff -u src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.3 --- src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2 Wed Apr 21 07:31:37 2021 +++ src/common/lib/libc/arch/aarch64/atomic/Makefile.inc Wed Apr 21 16:23:47 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.2 2021/04/21 07:31:37 skrll Exp $ +# $NetBSD: Makefile.inc,v 1.3 2021/04/21 16:23:47 skrll Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ || ${LIB} == "rump") @@ -12,10 +12,10 @@ SRCS.atomic+= atomic_dec_32.S atomic_dec SRCS.atomic+= atomic_inc_32.S atomic_inc_64.S SRCS.atomic+= membar_ops.S #and cas nand or sub swap xor -.for op in swap -.for sz in 8 16 32 64 -.for ar in acq rel acq_rel -SRCS.atomic+= atomic_${op}_${ar}_${sz}.S +.for op in swp +.for sz in 1 2 4 8 +.for ar in relax acq rel acq_rel +SRCS.atomic+= __aarch64_${op}${sz}_${ar}.S .endfor .endfor .endfor Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.4 --- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3 Wed Apr 21 07:31:37 2021
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Wed Apr 21 07:31:38 UTC 2021 Modified Files: src/common/lib/libc/arch/aarch64/atomic: Makefile.inc atomic_swap_16.S atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S Added Files: src/common/lib/libc/arch/aarch64/atomic: atomic_swap_acq_16.S atomic_swap_acq_32.S atomic_swap_acq_64.S atomic_swap_acq_8.S atomic_swap_acq_rel_16.S atomic_swap_acq_rel_32.S atomic_swap_acq_rel_64.S atomic_swap_acq_rel_8.S atomic_swap_rel_16.S atomic_swap_rel_32.S atomic_swap_rel_64.S atomic_swap_rel_8.S Log Message: Provide some more operations that are part of compiler lse.S. This is incomplete, but at least covers all the atomic_swap ops and allows the aa64 kernel to link with gcc 10. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S cvs rdiff -u -r0 -r1.1 \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S 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/aarch64/atomic/Makefile.inc diff -u src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.1 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2 --- src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/Makefile.inc Wed Apr 21 07:31:37 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:35 matt Exp $ +# $NetBSD: Makefile.inc,v 1.2 2021/04/21 07:31:37 skrll Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ || ${LIB} == "rump") @@ -11,6 +11,14 @@ SRCS.atomic+= atomic_${op}_${sz}.S SRCS.atomic+= atomic_dec_32.S atomic_dec_64.S SRCS.atomic+= atomic_inc_32.S atomic_inc_64.S SRCS.atomic+= membar_ops.S +#and cas nand or sub swap xor +.for op in swap +.for sz in 8 16 32 64 +.for ar in acq rel acq_rel +SRCS.atomic+= atomic_${op}_${ar}_${sz}.S +.endfor +.endfor +.endfor #.for op in add and nand or sub xor #SRCS.atomic+= sync_fetch_and_${op}_8.S #.endfor Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S Wed Apr 21 07:31:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_swap_16.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -43,6 +43,7 @@ END(_atomic_swap_16) ATOMIC_OP_ALIAS(atomic_swap_16,_atomic_swap_16) ATOMIC_OP_ALIAS(atomic_swap_short,_atomic_swap_16) ATOMIC_OP_ALIAS(atomic_swap_ushort,_atomic_swap_16) +ATOMIC_OP_ALIAS(__aarch64_swp2_relax,_atomic_swap_16) STRONG_ALIAS(__sync_lock_test_and_set_2,_atomic_swap_16) STRONG_ALIAS(_atomic_swap_short,_atomic_swap_16) STRONG_ALIAS(_atomic_swap_ushort,_atomic_swap_16) Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S Wed Apr 21 07:31:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_swap_32.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -42,6 +42,7 @@ END(_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32) +ATOMIC_OP_ALIAS(__aarch64_swp4_relax,_atomic_swap_32)
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: simonb Date: Mon Apr 19 01:12:10 UTC 2021 Modified Files: src/common/lib/libc/string: memset2.c Log Message: Add CVS ID line. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/string/memset2.c 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/string/memset2.c diff -u src/common/lib/libc/string/memset2.c:1.9 src/common/lib/libc/string/memset2.c:1.10 --- src/common/lib/libc/string/memset2.c:1.9 Sat Apr 17 21:43:47 2021 +++ src/common/lib/libc/string/memset2.c Mon Apr 19 01:12:10 2021 @@ -1,3 +1,5 @@ +/* $NetBSD: memset2.c,v 1.10 2021/04/19 01:12:10 simonb Exp $ */ + /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +31,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: memset2.c,v 1.9 2021/04/17 21:43:47 mrg Exp $"); +__RCSID("$NetBSD: memset2.c,v 1.10 2021/04/19 01:12:10 simonb Exp $"); #endif /* LIBC_SCCS and not lint */ #include
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: mrg Date: Sat Apr 17 21:43:47 UTC 2021 Modified Files: src/common/lib/libc/string: memset2.c Log Message: avoid redefinition warning for __OPTIMIZE_SIZE__. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/string/memset2.c 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/string/memset2.c diff -u src/common/lib/libc/string/memset2.c:1.8 src/common/lib/libc/string/memset2.c:1.9 --- src/common/lib/libc/string/memset2.c:1.8 Sat Apr 17 08:06:58 2021 +++ src/common/lib/libc/string/memset2.c Sat Apr 17 21:43:47 2021 @@ -29,7 +29,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: memset2.c,v 1.8 2021/04/17 08:06:58 simonb Exp $"); +__RCSID("$NetBSD: memset2.c,v 1.9 2021/04/17 21:43:47 mrg Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -47,7 +47,8 @@ __RCSID("$NetBSD: memset2.c,v 1.8 2021/0 #include #include -#define __OPTIMIZE_SIZE__ /* other code path is very broken */ +#undef __OPTIMIZE_SIZE__ +#define __OPTIMIZE_SIZE__ 1 /* other code path is very broken */ #ifdef TEST #include
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: simonb Date: Sat Apr 17 08:06:58 UTC 2021 Modified Files: src/common/lib/libc/string: memset2.c Log Message: Use __register_t instead of uregister_t - this is available to all ports and both userland and kernel. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/string/memset2.c 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/string/memset2.c diff -u src/common/lib/libc/string/memset2.c:1.7 src/common/lib/libc/string/memset2.c:1.8 --- src/common/lib/libc/string/memset2.c:1.7 Sat Apr 17 06:02:35 2021 +++ src/common/lib/libc/string/memset2.c Sat Apr 17 08:06:58 2021 @@ -29,7 +29,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: memset2.c,v 1.7 2021/04/17 06:02:35 simonb Exp $"); +__RCSID("$NetBSD: memset2.c,v 1.8 2021/04/17 08:06:58 simonb Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -60,11 +60,9 @@ __RCSID("$NetBSD: memset2.c,v 1.7 2021/0 #undef memset /* - * Assume uregister_t is the widest non-synthetic unsigned type. + * Assume __register_t is the widest non-synthetic unsigned type. */ -typedef uregister_t memword_t; - -__CTASSERT((~(memword_t)0U >> 1) != ~(memword_t)0U); +typedef __register_t memword_t; #ifdef BZERO static inline
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: simonb Date: Sat Apr 17 06:02:35 UTC 2021 Modified Files: src/common/lib/libc/string: memset2.c Log Message: Cast the fill value to unsigned char so that the "fill" value used for full-word fills isn't garbage. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/string/memset2.c 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/string/memset2.c diff -u src/common/lib/libc/string/memset2.c:1.6 src/common/lib/libc/string/memset2.c:1.7 --- src/common/lib/libc/string/memset2.c:1.6 Sat Apr 17 05:57:11 2021 +++ src/common/lib/libc/string/memset2.c Sat Apr 17 06:02:35 2021 @@ -29,7 +29,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: memset2.c,v 1.6 2021/04/17 05:57:11 simonb Exp $"); +__RCSID("$NetBSD: memset2.c,v 1.7 2021/04/17 06:02:35 simonb Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -97,7 +97,7 @@ memset(void *addr, int c, size_t len) * The conditional at the end prevents GCC from complaing about * shift count >= width of type */ - fill = c; + fill = (unsigned char)c; fill |= fill << 8; fill |= fill << 16; fill |= fill << (sizeof(c) < sizeof(fill) ? 32 : 0);
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: simonb Date: Sat Apr 17 05:57:11 UTC 2021 Modified Files: src/common/lib/libc/string: memset2.c Log Message: Disable the larger/faster code path. While the optimised code path was indeed quicker, it nonetheless failed to actually fill all the requested memory with the specified value much of the time if a non-aligned start address was used. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/string/memset2.c 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/string/memset2.c diff -u src/common/lib/libc/string/memset2.c:1.5 src/common/lib/libc/string/memset2.c:1.6 --- src/common/lib/libc/string/memset2.c:1.5 Fri Mar 2 16:22:27 2012 +++ src/common/lib/libc/string/memset2.c Sat Apr 17 05:57:11 2021 @@ -29,7 +29,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: memset2.c,v 1.5 2012/03/02 16:22:27 apb Exp $"); +__RCSID("$NetBSD: memset2.c,v 1.6 2021/04/17 05:57:11 simonb Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -47,6 +47,8 @@ __RCSID("$NetBSD: memset2.c,v 1.5 2012/0 #include #include +#define __OPTIMIZE_SIZE__ /* other code path is very broken */ + #ifdef TEST #include #define _DIAGASSERT(a) assert(a)
CVS commit: src/common/lib/libc/arch/arm/gen
Module Name:src Committed By: dholland Date: Fri Dec 11 09:02:33 UTC 2020 Modified Files: src/common/lib/libc/arch/arm/gen: byte_swap_4.S Log Message: arm bswap32: fix fatal typo in thumb code (PR 55854) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/gen/byte_swap_4.S 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/gen/byte_swap_4.S diff -u src/common/lib/libc/arch/arm/gen/byte_swap_4.S:1.8 src/common/lib/libc/arch/arm/gen/byte_swap_4.S:1.9 --- src/common/lib/libc/arch/arm/gen/byte_swap_4.S:1.8 Wed Dec 9 02:46:57 2020 +++ src/common/lib/libc/arch/arm/gen/byte_swap_4.S Fri Dec 11 09:02:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: byte_swap_4.S,v 1.8 2020/12/09 02:46:57 dholland Exp $ */ +/* $NetBSD: byte_swap_4.S,v 1.9 2020/12/11 09:02:33 dholland Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -46,7 +46,7 @@ ENTRY(FUNC) eor r0, r0, r1, lsr #8 /* a.d.c.b ^ 0.db.0.db -> a.b.c.d */ #else movs r3, #16 - lsls r1, r0, #8 /* d.c.b.a -> c.b.a.0 /* + lsls r1, r0, #8 /* d.c.b.a -> c.b.a.0 */ lsrs r0, r0, #8 /* d.c.b.a -> 0.d.c.b */ rors r1, r3 /* c.b.a.0 -> a.0.c.b */ rors r0, r3 /* 0.d.c.b -> c.b.0.d */
CVS commit: src/common/lib/libc/arch/arm/gen
Module Name:src Committed By: dholland Date: Wed Dec 9 02:46:57 UTC 2020 Modified Files: src/common/lib/libc/arch/arm/gen: byte_swap_4.S Log Message: arm bswap32: Improve the comments showing the byte flow. It's confusing to use 1-4 for bytes 1-4 and then 0 for literal zero, so use a-d for bytes 1-4. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/gen/byte_swap_4.S 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/gen/byte_swap_4.S diff -u src/common/lib/libc/arch/arm/gen/byte_swap_4.S:1.7 src/common/lib/libc/arch/arm/gen/byte_swap_4.S:1.8 --- src/common/lib/libc/arch/arm/gen/byte_swap_4.S:1.7 Mon Aug 19 03:44:47 2013 +++ src/common/lib/libc/arch/arm/gen/byte_swap_4.S Wed Dec 9 02:46:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: byte_swap_4.S,v 1.7 2013/08/19 03:44:47 matt Exp $ */ +/* $NetBSD: byte_swap_4.S,v 1.8 2020/12/09 02:46:57 dholland Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -40,21 +40,21 @@ ENTRY(FUNC) #ifdef _ARM_ARCH_6 rev r0, r0 #elif !defined(__thumb__) - eor r1, r0, r0, ror #16 /* 4.3.2.1 -> 42.31.42.31 */ - bic r1, r1, #0x00FF /* 42.31.42.31 -> 42.0.42.31 */ - mov r0, r0, ror #8 /* 4.3.2.1 -> 1.4.3.2 */ - eor r0, r0, r1, lsr #8 /* 1.4.3.2 ^ 0.42.0.42 -> 1.2.3.4 */ + eor r1, r0, r0, ror #16 /* d.c.b.a -> db.ca.db.ca */ + bic r1, r1, #0x00FF /* db.ca.db.ca -> db.0.db.ca */ + mov r0, r0, ror #8 /* d.c.b.a -> a.d.c.b */ + eor r0, r0, r1, lsr #8 /* a.d.c.b ^ 0.db.0.db -> a.b.c.d */ #else movs r3, #16 - lsls r1, r0, #8 /* 4.3.2.1 -> 3.2.1.0 /* - lsrs r0, r0, #8 /* 4.3.2.1 -> 0.4.3.2 */ - rors r1, r3 /* 3.2.1.0 -> 1.0.3.2 */ - rors r0, r3 /* 0.4.3.2 -> 3.2.0.4 */ - lsrs r1, r1, #8 /* 1.0.3.2 -> 0.1.0.3 */ - lsls r1, r1, #8 /* 0.1.0.3 -> 1.0.3.0 */ - lsls r0, r0, #8 /* 3.2.0.4 -> 2.0.4.0 */ - lsrs r0, r0, #8 /* 2.0.4.0 -> 0.2.0.4 */ - orrs r0, r0, r1 /* 1.0.3.0 | 0.2.0.4 -> 1.2.3.4 */ + lsls r1, r0, #8 /* d.c.b.a -> c.b.a.0 /* + lsrs r0, r0, #8 /* d.c.b.a -> 0.d.c.b */ + rors r1, r3 /* c.b.a.0 -> a.0.c.b */ + rors r0, r3 /* 0.d.c.b -> c.b.0.d */ + lsrs r1, r1, #8 /* a.0.c.b -> 0.a.0.c */ + lsls r1, r1, #8 /* 0.a.0.c -> a.0.c.0 */ + lsls r0, r0, #8 /* c.b.0.d -> b.0.d.0 */ + lsrs r0, r0, #8 /* b.0.d.0 -> 0.b.0.d */ + orrs r0, r0, r1 /* a.0.c.0 | 0.b.0.d -> a.b.c.d */ #endif RET END(FUNC)
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Tue Oct 13 21:22:12 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/atomic: membar_ops.S Log Message: Use the correct barriers - all of membar_{sync,producer,consumer} have less scope than before. LGTM from riastradh To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/atomic/membar_ops.S 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/aarch64/atomic/membar_ops.S diff -u src/common/lib/libc/arch/aarch64/atomic/membar_ops.S:1.1 src/common/lib/libc/arch/aarch64/atomic/membar_ops.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/membar_ops.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/membar_ops.S Tue Oct 13 21:22:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: membar_ops.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: membar_ops.S,v 1.2 2020/10/13 21:22:12 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,24 +32,28 @@ #include "atomic_op_asm.h" ENTRY_NP(_membar_producer) - dsb sy + dmb ishst ret END(_membar_producer) ATOMIC_OP_ALIAS(membar_producer,_membar_producer) ATOMIC_OP_ALIAS(membar_write,_membar_producer) STRONG_ALIAS(_membar_write,_membar_producer) +ENTRY_NP(_membar_consumer) + dmb ishld + ret +END(_membar_producer) +ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer) +ATOMIC_OP_ALIAS(membar_read,_membar_consumer) +STRONG_ALIAS(_membar_read,_membar_consumer) + ENTRY_NP(_membar_sync) - dmb sy + dmb ish ret END(_membar_sync) ATOMIC_OP_ALIAS(membar_sync,_membar_sync) ATOMIC_OP_ALIAS(membar_enter,_membar_sync) ATOMIC_OP_ALIAS(membar_exit,_membar_sync) -ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) -ATOMIC_OP_ALIAS(membar_read,_membar_sync) STRONG_ALIAS(__sync_synchronize,_membar_sync) STRONG_ALIAS(_membar_enter,_membar_sync) STRONG_ALIAS(_membar_exit,_membar_sync) -STRONG_ALIAS(_membar_consumer,_membar_sync) -STRONG_ALIAS(_membar_read,_membar_sync)
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Tue Oct 13 21:17:35 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h Log Message: Remove memory barriers from the atomic ops macros in the same way as was done for the other atomic ops earlier. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 \ src/common/lib/libc/arch/aarch64/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/aarch64/atomic/atomic_op_asm.h diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.4 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.5 --- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.4 Wed Oct 7 07:34:29 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h Tue Oct 13 21:17:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_op_asm.h,v 1.4 2020/10/07 07:34:29 skrll Exp $ */ +/* $NetBSD: atomic_op_asm.h,v 1.5 2020/10/13 21:17:35 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -41,7 +41,6 @@ ENTRY_NP(_atomic_##OP##_8) ;\ INSN w2, w0, w1 /* calculate new value */ ;\ stxrb w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb st ;\ ret/* return old value */ ;\ END(_atomic_##OP##_8) @@ -52,7 +51,6 @@ ENTRY_NP(_atomic_##OP##_8_nv) ;\ INSN w0, w0, w1 /* calc new (return) value */ ;\ stxrb w3, w0, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb sy ;\ ret/* return new value */ ;\ END(_atomic_##OP##_8_nv) @@ -63,7 +61,6 @@ ENTRY_NP(_atomic_##OP##_16) ;\ INSN w2, w0, w1 /* calculate new value */ ;\ stxrh w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb st ;\ ret/* return old value */ ;\ END(_atomic_##OP##_16) @@ -74,7 +71,6 @@ ENTRY_NP(_atomic_##OP##_16_nv) ;\ INSN w0, w0, w1 /* calc new (return) value */ ;\ stxrh w3, w0, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb sy ;\ ret/* return new value */ ;\ END(_atomic_##OP##_16_nv) @@ -85,7 +81,6 @@ ENTRY_NP(_atomic_##OP##_32) ;\ INSN w2, w0, w1 /* calculate new value */ ;\ stxr w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb st ;\ ret/* return old value */ ;\ END(_atomic_##OP##_32) @@ -96,7 +91,6 @@ ENTRY_NP(_atomic_##OP##_32_nv) ;\ INSN w0, w0, w1 /* calc new (return) value */ ;\ stxr w3, w0, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again? */ ;\ - dmb sy ;\ ret/* return new value */ ;\ END(_atomic_##OP##_32_nv) @@ -107,7 +101,6 @@ ENTRY_NP(_atomic_##OP##_64) ;\ INSN x2, x0, x1 /* calculate new value */ ;\ stxr w3, x2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb st ;\ ret/* return old value */ ;\ END(_atomic_##OP##_64) @@ -118,7 +111,6 @@ ENTRY_NP(_atomic_##OP##_64_nv) ;\ INSN x0, x0, x1 /* calc new (return) value */ ;\ stxr w3, x0, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again? */ ;\ - dmb sy ;\ ret/* return new value */ ;\ END(_atomic_##OP##_64_nv)
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Wed Oct 7 07:34:30 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h Log Message: Comment nit To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/aarch64/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/aarch64/atomic/atomic_op_asm.h diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.4 --- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.3 Fri Feb 8 06:56:56 2019 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h Wed Oct 7 07:34:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_op_asm.h,v 1.3 2019/02/08 06:56:56 ryo Exp $ */ +/* $NetBSD: atomic_op_asm.h,v 1.4 2020/10/07 07:34:29 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ END(_atomic_##OP##_8) #define ATOMIC_OP8_NV(OP, INSN) \ ENTRY_NP(_atomic_##OP##_8_nv) ;\ - mov x4, x0 /* need r0 for return value */ ;\ + mov x4, x0 /* need x0 for return value */ ;\ 1: ldxrb w0, [x4] /* load old value */ ;\ INSN w0, w0, w1 /* calc new (return) value */ ;\ stxrb w3, w0, [x4] /* try to store */ ;\ @@ -69,7 +69,7 @@ END(_atomic_##OP##_16) #define ATOMIC_OP16_NV(OP, INSN) \ ENTRY_NP(_atomic_##OP##_16_nv) ;\ - mov x4, x0 /* need r0 for return value */ ;\ + mov x4, x0 /* need x0 for return value */ ;\ 1: ldxrh w0, [x4] /* load old value */ ;\ INSN w0, w0, w1 /* calc new (return) value */ ;\ stxrh w3, w0, [x4] /* try to store */ ;\ @@ -91,7 +91,7 @@ END(_atomic_##OP##_32) #define ATOMIC_OP32_NV(OP, INSN) \ ENTRY_NP(_atomic_##OP##_32_nv) ;\ - mov x4, x0 /* need r0 for return value */ ;\ + mov x4, x0 /* need x0 for return value */ ;\ 1: ldxr w0, [x4] /* load old value */ ;\ INSN w0, w0, w1 /* calc new (return) value */ ;\ stxr w3, w0, [x4] /* try to store */ ;\ @@ -113,7 +113,7 @@ END(_atomic_##OP##_64) #define ATOMIC_OP64_NV(OP, INSN) \ ENTRY_NP(_atomic_##OP##_64_nv) ;\ - mov x4, x0 /* need r0 for return value */ ;\ + mov x4, x0 /* need x0 for return value */ ;\ 1: ldxr x0, [x4] /* load old value */ ;\ INSN x0, x0, x1 /* calc new (return) value */ ;\ stxr w3, x0, [x4] /* try to store */ ;\
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Wed Oct 7 07:31:47 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_cas_16.S atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S Log Message: Comment nit To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S cvs rdiff -u -r1.4 -r1.5 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S 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/aarch64/atomic/atomic_cas_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S Wed Oct 7 07:31:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_cas_16.S,v 1.3 2020/10/07 07:31:47 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "atomic_op_asm.h" ENTRY_NP(_atomic_cas_16) - mov x4, x0 /* we need r0 for return value */ + mov x4, x0 /* we need x0 for return value */ 1: ldxrh w0, [x4] /* load old value */ cmp w0, w1 /* compare? */ b.ne 2f Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S Wed Oct 7 07:31:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_cas_32.S,v 1.3 2020/10/07 07:31:47 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "atomic_op_asm.h" ENTRY_NP(_atomic_cas_32) - mov x4, x0 /* we need r0 for return value */ + mov x4, x0 /* we need x0 for return value */ 1: ldxr w0, [x4] /* load old value */ cmp w0, w1 /* compare? */ b.ne 2f /* return if different */ Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.2 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S Wed Oct 7 07:31:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_8.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_cas_8.S,v 1.3 2020/10/07 07:31:47 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "atomic_op_asm.h" ENTRY_NP(_atomic_cas_8) - mov x4, x0 /* we need r0 for return value */ + mov x4, x0 /* we need x0 for return value */ 1: ldxrb w0, [x4] /* load old value */ cmp w0, w1 /* compare? */ b.ne 2f Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.4 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.5 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.4 Wed Aug 12 12:59:57 2020 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S Wed Oct 7 07:31:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_64.S,v 1.4 2020/08/12 12:59:57 skrll Exp $ */ +/* $NetBSD: atomic_cas_64.S,v 1.5 2020/10/07 07:31:47 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "atomic_op_asm.h" ENTRY_NP(_atomic_cas_64) - mov x4, x0 /* we need r0 for return value */ + mov x4, x0 /* we need x0 for return value */ 1: ldxr x0, [x4] /* load old value */ cmp x0, x1 /* compare? */ b.ne 2f /* return if different */
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: jakllsch Date: Wed Sep 9 14:49:27 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/string: strlen.S Log Message: Re-do previous aarch64eb strlen fix more simply and correctly. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/aarch64/string/strlen.S 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/aarch64/string/strlen.S diff -u src/common/lib/libc/arch/aarch64/string/strlen.S:1.4 src/common/lib/libc/arch/aarch64/string/strlen.S:1.5 --- src/common/lib/libc/arch/aarch64/string/strlen.S:1.4 Sat Sep 5 20:24:43 2020 +++ src/common/lib/libc/arch/aarch64/string/strlen.S Wed Sep 9 14:49:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: strlen.S,v 1.4 2020/09/05 20:24:43 jakllsch Exp $ */ +/* $NetBSD: strlen.S,v 1.5 2020/09/09 14:49:27 jakllsch Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: strlen.S,v 1.4 2020/09/05 20:24:43 jakllsch Exp $") +RCSID("$NetBSD: strlen.S,v 1.5 2020/09/09 14:49:27 jakllsch Exp $") #ifdef STRNLEN #define FUNCNAME strnlen @@ -66,12 +66,11 @@ ENTRY(FUNCNAME) */ add x4, x4, x0 /* make dword aligned */ ldr x7, [x4], #8 /* load dword */ - lsl x3, x3, #3 /* convert bytes to bits */ #ifdef __AARCH64EB__ - lsr x5, x11, x3 /* make mask for BE */ -#else - lsl x5, x11, x3 /* make mask for LE */ + rev x7, x7 /* convert to LE */ #endif + lsl x3, x3, #3 /* convert bytes to bits */ + lsl x5, x11, x3 /* make mask for LE */ eor x5, x5, x11 /* invert mask */ orr x7, x7, x5 /* prevent NULs */ b .Lstrlen_dword_loop_noload @@ -82,6 +81,9 @@ ENTRY(FUNCNAME) b.hs .Lstrlen_done #endif ldr x7, [x4], #8 /* load dword */ +#ifdef __AARCH64EB__ + rev x7, x7 /* convert to LE */ +#endif .Lstrlen_dword_loop_noload: /* * Use the formula (X - 1) & ~(X | 0x7f) to find NUL bytes. @@ -96,14 +98,6 @@ ENTRY(FUNCNAME) /* * We know there is a NUL in this dword. Use clz to find it. */ -#ifdef __AARCH64EB__ - /* avoid BE problem due to carry propagation if last non-NUL is \x01 */ - ldr x7, [x4, #-8] /* reload dword */ - rev x7, x7 /* byte swap */ - sub x6, x7, x11 /* a = X - 1 */ - orr x7, x7, #MASK8_0x7f /* b = X | 0x7f */ - bic x6, x6, x7 /* a & ~b */ -#endif rev x6, x6 /* convert to BE */ clz x6, x6 /* find null byte */ add x0, x0, x6, lsr #3 /* add offset to the length */
CVS commit: src/common/lib/libc/atomic
Module Name:src Committed By: mrg Date: Mon Sep 7 00:52:19 UTC 2020 Modified Files: src/common/lib/libc/atomic: atomic_c11_compare_exchange_cas_16.c atomic_c11_compare_exchange_cas_32.c atomic_c11_compare_exchange_cas_8.c atomic_load.c atomic_store.c Log Message: make some prototypes match the builtin properly. GCC 9 complains with the old version, GCC 8 is happy with this version. tested on sparc. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c \ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c \ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c \ src/common/lib/libc/atomic/atomic_load.c \ src/common/lib/libc/atomic/atomic_store.c 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/atomic/atomic_c11_compare_exchange_cas_16.c diff -u src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c:1.2 src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c:1.3 --- src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c:1.2 Tue Nov 4 19:56:44 2014 +++ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c Mon Sep 7 00:52:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.2 2014/11/04 19:56:44 joerg Exp $ */ +/* $NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -36,15 +36,15 @@ #endif #include -bool __atomic_compare_exchange_2(volatile uint16_t *, uint16_t *, uint16_t, +bool __atomic_compare_exchange_2(volatile void *, void *, uint16_t, bool, int, int); bool -__atomic_compare_exchange_2(volatile uint16_t *mem, -uint16_t *expected, uint16_t desired, +__atomic_compare_exchange_2(volatile void *mem, +void *expected, uint16_t desired, bool weak, int success, int failure) { - uint16_t old = *expected; + uint16_t old = *(uint16_t *)expected; /* * Ignore the details (weak, memory model on success and failure) Index: src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c diff -u src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c:1.2 src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c:1.3 --- src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c:1.2 Tue Nov 4 19:56:44 2014 +++ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c Mon Sep 7 00:52:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_c11_compare_exchange_cas_32.c,v 1.2 2014/11/04 19:56:44 joerg Exp $ */ +/* $NetBSD: atomic_c11_compare_exchange_cas_32.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -36,15 +36,15 @@ #endif #include -bool __atomic_compare_exchange_4(volatile uint32_t *, uint32_t *, uint32_t, +bool __atomic_compare_exchange_4(volatile void *, void *, uint32_t, bool, int, int); bool -__atomic_compare_exchange_4(volatile uint32_t *mem, -uint32_t *expected, uint32_t desired, +__atomic_compare_exchange_4(volatile void *mem, +void *expected, uint32_t desired, bool weak, int success, int failure) { - uint32_t old = *expected; + uint32_t old = *(uint32_t *)expected; /* * Ignore the details (weak, memory model on success and failure) Index: src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c diff -u src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c:1.2 src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c:1.3 --- src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c:1.2 Tue Nov 4 19:56:44 2014 +++ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c Mon Sep 7 00:52:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_c11_compare_exchange_cas_8.c,v 1.2 2014/11/04 19:56:44 joerg Exp $ */ +/* $NetBSD: atomic_c11_compare_exchange_cas_8.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -36,15 +36,15 @@ #endif #include -bool __atomic_compare_exchange_1(volatile uint8_t *, uint8_t *, uint8_t, +bool __atomic_compare_exchange_1(volatile void *, void *, uint8_t, bool, int, int); bool -__atomic_compare_exchange_1(volatile uint8_t *mem, -uint8_t *expected, uint8_t desired, +__atomic_compare_exchange_1(volatile void *mem, +void *expected, uint8_t desired, bool weak, int success, int failure) { - uint8_t old = *expected; + uint8_t old = *(uint8_t *)expected; /* * Ignore the details (weak, memory model on success and failure) Index: src/common/lib/libc/atomic/atomic_load.c diff -u src/common/lib/libc/atomic/atomic_load.c:1.2 src/common/lib/libc/atomic/atomic_load.c:1.3 --- src/common/lib/libc/atomic/atomic_load.c:1.2 Sun Jul 6 01:19:45 2014 +++ src/common/lib/libc/atomic/atomic_load.c Mon Sep 7 00:52:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD:
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: jakllsch Date: Sat Sep 5 20:24:43 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/string: strlen.S Log Message: Fix a broken corner case of strlen()/strnlen() on aarch64eb Previously a string such as "\x1\x1\x1\x1\x1\x1\x1" would count as 0 instead of 7 on BE. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/aarch64/string/strlen.S 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/aarch64/string/strlen.S diff -u src/common/lib/libc/arch/aarch64/string/strlen.S:1.3 src/common/lib/libc/arch/aarch64/string/strlen.S:1.4 --- src/common/lib/libc/arch/aarch64/string/strlen.S:1.3 Wed Aug 1 17:09:26 2018 +++ src/common/lib/libc/arch/aarch64/string/strlen.S Sat Sep 5 20:24:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: strlen.S,v 1.3 2018/08/01 17:09:26 ryo Exp $ */ +/* $NetBSD: strlen.S,v 1.4 2020/09/05 20:24:43 jakllsch Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: strlen.S,v 1.3 2018/08/01 17:09:26 ryo Exp $") +RCSID("$NetBSD: strlen.S,v 1.4 2020/09/05 20:24:43 jakllsch Exp $") #ifdef STRNLEN #define FUNCNAME strnlen @@ -96,9 +96,15 @@ ENTRY(FUNCNAME) /* * We know there is a NUL in this dword. Use clz to find it. */ -#ifdef __AARCH64EL__ - rev x6, x6 /* convert to BE */ +#ifdef __AARCH64EB__ + /* avoid BE problem due to carry propagation if last non-NUL is \x01 */ + ldr x7, [x4, #-8] /* reload dword */ + rev x7, x7 /* byte swap */ + sub x6, x7, x11 /* a = X - 1 */ + orr x7, x7, #MASK8_0x7f /* b = X | 0x7f */ + bic x6, x6, x7 /* a & ~b */ #endif + rev x6, x6 /* convert to BE */ clz x6, x6 /* find null byte */ add x0, x0, x6, lsr #3 /* add offset to the length */
CVS commit: src/common/lib/libc/arch/aarch64/gen
Module Name:src Committed By: jakllsch Date: Thu Sep 3 16:45:50 UTC 2020 Removed Files: src/common/lib/libc/arch/aarch64/gen: clzdi2.S ctzdi2.S ffsdi2.S Log Message: Remove unused assembly source files To generate a diff of this commit: cvs rdiff -u -r1.2 -r0 src/common/lib/libc/arch/aarch64/gen/clzdi2.S cvs rdiff -u -r1.1 -r0 src/common/lib/libc/arch/aarch64/gen/ctzdi2.S \ src/common/lib/libc/arch/aarch64/gen/ffsdi2.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/aarch64/gen
Module Name:src Committed By: jakllsch Date: Wed Sep 2 15:43:06 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/gen: clzdi2.S Log Message: Fix typo/pasteo in aarch64 clzdi2() END() To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/gen/clzdi2.S 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/aarch64/gen/clzdi2.S diff -u src/common/lib/libc/arch/aarch64/gen/clzdi2.S:1.1 src/common/lib/libc/arch/aarch64/gen/clzdi2.S:1.2 --- src/common/lib/libc/arch/aarch64/gen/clzdi2.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/gen/clzdi2.S Wed Sep 2 15:43:06 2020 @@ -1,10 +1,10 @@ -/* $NetBSD: clzdi2.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: clzdi2.S,v 1.2 2020/09/02 15:43:06 jakllsch Exp $ */ #include -RCSID("$NetBSD: clzdi2.S,v 1.1 2014/08/10 05:47:35 matt Exp $") +RCSID("$NetBSD: clzdi2.S,v 1.2 2020/09/02 15:43:06 jakllsch Exp $") ENTRY(clzdi2) clz x0, x0 ret -END(clsdi2) +END(clzdi2)
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: skrll Date: Wed Aug 12 12:59:57 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_cas_16.S atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S atomic_dec_32.S atomic_dec_64.S atomic_inc_32.S atomic_inc_64.S atomic_nand_16.S atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S atomic_swap_16.S atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S Log Message: Part I of ad@'s performance improvements for aarch64 - Remove memory barriers from the atomic ops. I don't understand why those are there. Is it some architectural thing, or for a CPU bug, or just over-caution maybe? They're not needed for correctness. - Have unlikely conditional branches go forwards to help the static branch predictor. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_dec_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_dec_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_inc_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_inc_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S cvs rdiff -u -r1.3 -r1.4 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S 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/aarch64/atomic/atomic_cas_16.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S Wed Aug 12 12:59:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_16.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: atomic_cas_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -37,9 +37,9 @@ ENTRY_NP(_atomic_cas_16) cmp w0, w1 /* compare? */ b.ne 2f stxrh w3, w2, [x4] /* store new value */ - cbnz w3, 1b /* succeed? nope, try again. */ - dmb st /* data memory barrier */ + cbnz w3, 3f /* succeed? nope, try again. */ 2: ret/* return. */ +3: b 1b END(_atomic_cas_16) ATOMIC_OP_ALIAS(atomic_cas_16,_atomic_cas_16) Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S Wed Aug 12 12:59:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_32.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: atomic_cas_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -37,9 +37,9 @@ ENTRY_NP(_atomic_cas_32) cmp w0, w1 /* compare? */ b.ne 2f /* return if different */ stxr w3, w2, [x4] /* store new value */ - cbnz w3, 1b /* succeed? nope, try again. */ - dmb st + cbnz w3, 3f /* succeed? nope, try again. */ 2: ret/* return. */ +3: b 1b END(_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S Wed Aug 12 12:59:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_8.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: atomic_cas_8.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -37,9 +37,9 @@ ENTRY_NP(_atomic_cas_8) cmp w0, w1 /* compare? */ b.ne 2f stxrb w3, w2, [x4] /* store new value */ - cbnz w3, 1b /* succeed? nope, try again. */ - dmb st /* data memory barrier */ + cbnz w3, 3f /* succeed? nope, try again. */ 2: ret/* return. */ +3: b 1b END(_atomic_cas_8) ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8) Index: src/common/lib/libc/arch/aarch64/atomic/atomic_dec_32.S diff -u
CVS commit: src/common/lib/libc/arch/mips/atomic
Module Name:src Committed By: skrll Date: Sat Aug 1 09:26:49 UTC 2020 Modified Files: src/common/lib/libc/arch/mips/atomic: atomic_add.S atomic_and.S atomic_cas.S atomic_cas_up.S atomic_dec.S atomic_inc.S atomic_op_asm.h atomic_or.S atomic_swap.S membar_ops.S Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/arch/mips/atomic/atomic_add.S \ src/common/lib/libc/arch/mips/atomic/atomic_dec.S \ src/common/lib/libc/arch/mips/atomic/atomic_inc.S \ src/common/lib/libc/arch/mips/atomic/atomic_swap.S cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/mips/atomic/atomic_and.S \ src/common/lib/libc/arch/mips/atomic/atomic_or.S cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/mips/atomic/atomic_cas.S cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/mips/atomic/atomic_cas_up.S cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/mips/atomic/atomic_op_asm.h cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/mips/atomic/membar_ops.S 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/mips/atomic/atomic_add.S diff -u src/common/lib/libc/arch/mips/atomic/atomic_add.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_add.S:1.6 --- src/common/lib/libc/arch/mips/atomic/atomic_add.S:1.5 Mon Jun 1 23:16:54 2015 +++ src/common/lib/libc/arch/mips/atomic/atomic_add.S Sat Aug 1 09:26:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ +/* $NetBSD: atomic_add.S,v 1.6 2020/08/01 09:26:49 skrll Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -12,7 +12,7 @@ * 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 @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_add.S,v 1.5 2015/06/01 23:16:54 matt Exp $") +RCSID("$NetBSD: atomic_add.S,v 1.6 2020/08/01 09:26:49 skrll Exp $") .text .set noreorder Index: src/common/lib/libc/arch/mips/atomic/atomic_dec.S diff -u src/common/lib/libc/arch/mips/atomic/atomic_dec.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_dec.S:1.6 --- src/common/lib/libc/arch/mips/atomic/atomic_dec.S:1.5 Mon Jun 1 23:16:54 2015 +++ src/common/lib/libc/arch/mips/atomic/atomic_dec.S Sat Aug 1 09:26:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_dec.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ +/* $NetBSD: atomic_dec.S,v 1.6 2020/08/01 09:26:49 skrll Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -12,7 +12,7 @@ * 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 @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_dec.S,v 1.5 2015/06/01 23:16:54 matt Exp $") +RCSID("$NetBSD: atomic_dec.S,v 1.6 2020/08/01 09:26:49 skrll Exp $") .text .set noreorder Index: src/common/lib/libc/arch/mips/atomic/atomic_inc.S diff -u src/common/lib/libc/arch/mips/atomic/atomic_inc.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_inc.S:1.6 --- src/common/lib/libc/arch/mips/atomic/atomic_inc.S:1.5 Mon Jun 1 23:16:54 2015 +++ src/common/lib/libc/arch/mips/atomic/atomic_inc.S Sat Aug 1 09:26:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_inc.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ +/* $NetBSD: atomic_inc.S,v 1.6 2020/08/01 09:26:49 skrll Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -12,7 +12,7 @@ * 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 @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_inc.S,v 1.5 2015/06/01 23:16:54 matt Exp $") +RCSID("$NetBSD: atomic_inc.S,v 1.6 2020/08/01 09:26:49 skrll Exp $") .text .set noreorder Index:
CVS commit: src/common/lib/libc/arch/m68k/gen
Module Name:src Committed By: rin Date: Sun May 31 12:37:07 UTC 2020 Modified Files: src/common/lib/libc/arch/m68k/gen: muldi3.S Log Message: Fix typo in comment. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/m68k/gen/muldi3.S 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/m68k/gen/muldi3.S diff -u src/common/lib/libc/arch/m68k/gen/muldi3.S:1.1 src/common/lib/libc/arch/m68k/gen/muldi3.S:1.2 --- src/common/lib/libc/arch/m68k/gen/muldi3.S:1.1 Sun May 31 11:43:37 2020 +++ src/common/lib/libc/arch/m68k/gen/muldi3.S Sun May 31 12:37:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: muldi3.S,v 1.1 2020/05/31 11:43:37 rin Exp $ */ +/* $NetBSD: muldi3.S,v 1.2 2020/05/31 12:37:07 rin Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: muldi3.S,v 1.1 2020/05/31 11:43:37 rin Exp $") +RCSID("$NetBSD: muldi3.S,v 1.2 2020/05/31 12:37:07 rin Exp $") | int64_t __muldi3(int64_t X, int64_t Y); | @@ -110,6 +110,6 @@ ENTRY(__muldi3) addl %d2, %d0 | E += C addl %d3, %d0 | %d0 = E + F - moveml (%sp)+, %d2-%d4 | pop %d2-%d6 + moveml (%sp)+, %d2-%d4 | pop %d2-%d4 rts END(__muldi3)
CVS commit: src/common/lib/libc/hash/sha3
Module Name:src Committed By: riastradh Date: Sat May 30 18:40:28 UTC 2020 Modified Files: src/common/lib/libc/hash/sha3: sha3.c Log Message: Merge updates from upstream to reduce stack usage of SHA3_Selftest. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/hash/sha3/sha3.c 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/hash/sha3/sha3.c diff -u src/common/lib/libc/hash/sha3/sha3.c:1.1 src/common/lib/libc/hash/sha3/sha3.c:1.2 --- src/common/lib/libc/hash/sha3/sha3.c:1.1 Thu Nov 30 05:47:24 2017 +++ src/common/lib/libc/hash/sha3/sha3.c Sat May 30 18:40:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sha3.c,v 1.1 2017/11/30 05:47:24 riastradh Exp $ */ +/* $NetBSD: sha3.c,v 1.2 2020/05/30 18:40:28 riastradh Exp $ */ /*- * Copyright (c) 2015 Taylor R. Campbell @@ -38,14 +38,14 @@ #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: sha3.c,v 1.1 2017/11/30 05:47:24 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sha3.c,v 1.2 2020/05/30 18:40:28 riastradh Exp $"); #include #define SHA3_ASSERT KASSERT #else -__RCSID("$NetBSD: sha3.c,v 1.1 2017/11/30 05:47:24 riastradh Exp $"); +__RCSID("$NetBSD: sha3.c,v 1.2 2020/05/30 18:40:28 riastradh Exp $"); #include "namespace.h" @@ -87,6 +87,7 @@ __weak_alias(SHAKE256_Final,_SHAKE256_Fi #endif /* kernel/standalone */ #define MIN(a,b) ((a) < (b) ? (a) : (b)) +#define arraycount(a) (sizeof(a)/sizeof((a)[0])) /* * Common body. All the SHA-3 functions share code structure. They @@ -428,19 +429,19 @@ sha3_selftest_prng(void *buf, size_t len int SHA3_Selftest(void) { - const uint8_t d224_0[] = { /* SHA3-224(0-bit) */ + static const uint8_t d224_0[] = { /* SHA3-224(0-bit) */ 0x6b,0x4e,0x03,0x42,0x36,0x67,0xdb,0xb7, 0x3b,0x6e,0x15,0x45,0x4f,0x0e,0xb1,0xab, 0xd4,0x59,0x7f,0x9a,0x1b,0x07,0x8e,0x3f, 0x5b,0x5a,0x6b,0xc7, }; - const uint8_t d256_0[] = { /* SHA3-256(0-bit) */ + static const uint8_t d256_0[] = { /* SHA3-256(0-bit) */ 0xa7,0xff,0xc6,0xf8,0xbf,0x1e,0xd7,0x66, 0x51,0xc1,0x47,0x56,0xa0,0x61,0xd6,0x62, 0xf5,0x80,0xff,0x4d,0xe4,0x3b,0x49,0xfa, 0x82,0xd8,0x0a,0x4b,0x80,0xf8,0x43,0x4a, }; - const uint8_t d384_0[] = { /* SHA3-384(0-bit) */ + static const uint8_t d384_0[] = { /* SHA3-384(0-bit) */ 0x0c,0x63,0xa7,0x5b,0x84,0x5e,0x4f,0x7d, 0x01,0x10,0x7d,0x85,0x2e,0x4c,0x24,0x85, 0xc5,0x1a,0x50,0xaa,0xaa,0x94,0xfc,0x61, @@ -448,7 +449,7 @@ SHA3_Selftest(void) 0xc3,0x71,0x38,0x31,0x26,0x4a,0xdb,0x47, 0xfb,0x6b,0xd1,0xe0,0x58,0xd5,0xf0,0x04, }; - const uint8_t d512_0[] = { /* SHA3-512(0-bit) */ + static const uint8_t d512_0[] = { /* SHA3-512(0-bit) */ 0xa6,0x9f,0x73,0xcc,0xa2,0x3a,0x9a,0xc5, 0xc8,0xb5,0x67,0xdc,0x18,0x5a,0x75,0x6e, 0x97,0xc9,0x82,0x16,0x4f,0xe2,0x58,0x59, @@ -458,14 +459,14 @@ SHA3_Selftest(void) 0xf5,0x00,0x19,0x9d,0x95,0xb6,0xd3,0xe3, 0x01,0x75,0x85,0x86,0x28,0x1d,0xcd,0x26, }; - const uint8_t shake128_0_41[] = { /* SHAKE128(0-bit, 41) */ + static const uint8_t shake128_0_41[] = { /* SHAKE128(0-bit, 41) */ 0x7f,0x9c,0x2b,0xa4,0xe8,0x8f,0x82,0x7d, 0x61,0x60,0x45,0x50,0x76,0x05,0x85,0x3e, 0xd7,0x3b,0x80,0x93,0xf6,0xef,0xbc,0x88, 0xeb,0x1a,0x6e,0xac,0xfa,0x66,0xef,0x26, 0x3c,0xb1,0xee,0xa9,0x88,0x00,0x4b,0x93,0x10, }; - const uint8_t shake256_0_73[] = { /* SHAKE256(0-bit, 73) */ + static const uint8_t shake256_0_73[] = { /* SHAKE256(0-bit, 73) */ 0x46,0xb9,0xdd,0x2b,0x0b,0xa8,0x8d,0x13, 0x23,0x3b,0x3f,0xeb,0x74,0x3e,0xeb,0x24, 0x3f,0xcd,0x52,0xea,0x62,0xb8,0x1b,0x82, @@ -476,19 +477,19 @@ SHA3_Selftest(void) 0x40,0x29,0x2e,0xac,0xb3,0xb7,0xc4,0xbe, 0x14,0x1e,0x96,0x61,0x6f,0xb1,0x39,0x57,0x69, }; - const uint8_t d224_1600[] = { /* SHA3-224(200 * 0xa3) */ + static const uint8_t d224_1600[] = { /* SHA3-224(200 * 0xa3) */ 0x93,0x76,0x81,0x6a,0xba,0x50,0x3f,0x72, 0xf9,0x6c,0xe7,0xeb,0x65,0xac,0x09,0x5d, 0xee,0xe3,0xbe,0x4b,0xf9,0xbb,0xc2,0xa1, 0xcb,0x7e,0x11,0xe0, }; - const uint8_t d256_1600[] = { /* SHA3-256(200 * 0xa3) */ + static const uint8_t d256_1600[] = { /* SHA3-256(200 * 0xa3) */ 0x79,0xf3,0x8a,0xde,0xc5,0xc2,0x03,0x07, 0xa9,0x8e,0xf7,0x6e,0x83,0x24,0xaf,0xbf, 0xd4,0x6c,0xfd,0x81,0xb2,0x2e,0x39,0x73, 0xc6,0x5f,0xa1,0xbd,0x9d,0xe3,0x17,0x87, }; - const uint8_t d384_1600[] = { /* SHA3-384(200 * 0xa3) */ + static const uint8_t d384_1600[] = { /* SHA3-384(200 * 0xa3) */ 0x18,0x81,0xde,0x2c,0xa7,0xe4,0x1e,0xf9, 0x5d,0xc4,0x73,0x2b,0x8f,0x5f,0x00,0x2b, 0x18,0x9c,0xc1,0xe4,0x2b,0x74,0x16,0x8e, @@ -496,7 +497,7 @@ SHA3_Selftest(void) 0x76,0x19,0x7a,0x31,0xfd,0x55,0xee,0x98, 0x9f,0x2d,0x70,0x50,0xdd,0x47,0x3e,0x8f, }; - const uint8_t d512_1600[] = { /* SHA3-512(200 * 0xa3) */ + static const uint8_t d512_1600[] = { /* SHA3-512(200 * 0xa3) */ 0xe7,0x6d,0xfa,0xd2,0x20,0x84,0xa8,0xb1,
CVS commit: src/common/lib/libc/atomic
Module Name:src Committed By: martin Date: Fri May 15 15:20:40 UTC 2020 Modified Files: src/common/lib/libc/atomic: atomic_init_testset.c Log Message: PR 55239: initialize all RAS sections for non-MP configurations To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/common/lib/libc/atomic/atomic_init_testset.c 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/atomic/atomic_init_testset.c diff -u src/common/lib/libc/atomic/atomic_init_testset.c:1.16 src/common/lib/libc/atomic/atomic_init_testset.c:1.17 --- src/common/lib/libc/atomic/atomic_init_testset.c:1.16 Mon Feb 18 11:22:56 2019 +++ src/common/lib/libc/atomic/atomic_init_testset.c Fri May 15 15:20:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_init_testset.c,v 1.16 2019/02/18 11:22:56 martin Exp $ */ +/* $NetBSD: atomic_init_testset.c,v 1.17 2020/05/15 15:20:40 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: atomic_init_testset.c,v 1.16 2019/02/18 11:22:56 martin Exp $"); +__RCSID("$NetBSD: atomic_init_testset.c,v 1.17 2020/05/15 15:20:40 martin Exp $"); #include "atomic_op_namespace.h" @@ -296,30 +296,28 @@ __libc_atomic_init(void) return; if (ncpu > 1) return; + if (rasctl(RAS_ADDR(_atomic_cas), RAS_SIZE(_atomic_cas), RAS_INSTALL) == 0) { _atomic_cas_fn = _atomic_cas_up; - return; } + #ifdef __HAVE_ATOMIC_CAS_64_UP if (rasctl(RAS_ADDR(_atomic_cas_64), RAS_SIZE(_atomic_cas_64), RAS_INSTALL) == 0) { _atomic_cas_64_fn = _atomic_cas_64_up; - return; } #endif if (rasctl(RAS_ADDR(_atomic_cas_16), RAS_SIZE(_atomic_cas_16), RAS_INSTALL) == 0) { _atomic_cas_16_fn = _atomic_cas_16_up; - return; } if (rasctl(RAS_ADDR(_atomic_cas_8), RAS_SIZE(_atomic_cas_8), RAS_INSTALL) == 0) { _atomic_cas_8_fn = _atomic_cas_8_up; - return; } }
CVS commit: src/common/lib/libc/arch
Module Name:src Committed By: maxv Date: Sun Apr 26 13:59:44 UTC 2020 Modified Files: src/common/lib/libc/arch/i386/atomic: atomic.S src/common/lib/libc/arch/x86_64/atomic: atomic.S Log Message: Remove unused argument in macro. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/common/lib/libc/arch/i386/atomic/atomic.S cvs rdiff -u -r1.20 -r1.21 src/common/lib/libc/arch/x86_64/atomic/atomic.S 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/i386/atomic/atomic.S diff -u src/common/lib/libc/arch/i386/atomic/atomic.S:1.26 src/common/lib/libc/arch/i386/atomic/atomic.S:1.27 --- src/common/lib/libc/arch/i386/atomic/atomic.S:1.26 Sun Apr 26 13:54:02 2020 +++ src/common/lib/libc/arch/i386/atomic/atomic.S Sun Apr 26 13:59:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.26 2020/04/26 13:54:02 maxv Exp $ */ +/* $NetBSD: atomic.S,v 1.27 2020/04/26 13:59:44 maxv Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -45,10 +45,10 @@ #ifdef _HARDKERNEL #include "opt_xen.h" #include -#define LOCK(n) HOTPATCH(HP_NAME_NOLOCK, 1); lock +#define LOCK HOTPATCH(HP_NAME_NOLOCK, 1); lock #define ENDLABEL(a) _ALIGN_TEXT; LABEL(a) #else -#define LOCK(n) lock +#define LOCK lock #define ENDLABEL(a) /* nothing */ #endif @@ -57,7 +57,7 @@ ENTRY(_atomic_add_32) movl 4(%esp), %edx movl 8(%esp), %eax - LOCK(1) + LOCK addl %eax, (%edx) ret END(_atomic_add_32) @@ -66,7 +66,7 @@ ENTRY(_atomic_add_32_nv) movl 4(%esp), %edx movl 8(%esp), %eax movl %eax, %ecx - LOCK(2) + LOCK xaddl %eax, (%edx) addl %ecx, %eax ret @@ -75,7 +75,7 @@ END(_atomic_add_32_nv) ENTRY(_atomic_and_32) movl 4(%esp), %edx movl 8(%esp), %eax - LOCK(3) + LOCK andl %eax, (%edx) ret END(_atomic_and_32) @@ -86,7 +86,7 @@ ENTRY(_atomic_and_32_nv) 0: movl %eax, %ecx andl 8(%esp), %ecx - LOCK(4) + LOCK cmpxchgl %ecx, (%edx) jnz 1f movl %ecx, %eax @@ -97,7 +97,7 @@ END(_atomic_and_32_nv) ENTRY(_atomic_dec_32) movl 4(%esp), %edx - LOCK(5) + LOCK decl (%edx) ret END(_atomic_dec_32) @@ -105,7 +105,7 @@ END(_atomic_dec_32) ENTRY(_atomic_dec_32_nv) movl 4(%esp), %edx movl $-1, %eax - LOCK(6) + LOCK xaddl %eax, (%edx) decl %eax ret @@ -113,7 +113,7 @@ END(_atomic_dec_32_nv) ENTRY(_atomic_inc_32) movl 4(%esp), %edx - LOCK(7) + LOCK incl (%edx) ret END(_atomic_inc_32) @@ -121,7 +121,7 @@ END(_atomic_inc_32) ENTRY(_atomic_inc_32_nv) movl 4(%esp), %edx movl $1, %eax - LOCK(8) + LOCK xaddl %eax, (%edx) incl %eax ret @@ -130,7 +130,7 @@ END(_atomic_inc_32_nv) ENTRY(_atomic_or_32) movl 4(%esp), %edx movl 8(%esp), %eax - LOCK(9) + LOCK orl %eax, (%edx) ret END(_atomic_or_32) @@ -141,7 +141,7 @@ ENTRY(_atomic_or_32_nv) 0: movl %eax, %ecx orl 8(%esp), %ecx - LOCK(10) + LOCK cmpxchgl %ecx, (%edx) jnz 1f movl %ecx, %eax @@ -161,7 +161,7 @@ ENTRY(_atomic_cas_32) movl 4(%esp), %edx movl 8(%esp), %eax movl 12(%esp), %ecx - LOCK(12) + LOCK cmpxchgl %ecx, (%edx) /* %eax now contains the old value */ ret @@ -177,7 +177,7 @@ ENTRY(_atomic_cas_32_ni) END(_atomic_cas_32_ni) ENTRY(_membar_consumer) - LOCK(13) + LOCK addl $0, -4(%esp) ret END(_membar_consumer) @@ -190,7 +190,7 @@ ENTRY(_membar_producer) END(_membar_producer) ENTRY(_membar_sync) - LOCK(14) + LOCK addl $0, -4(%esp) ret END(_membar_sync) @@ -241,7 +241,7 @@ ENTRY(_atomic_cas_cx8) movl 20(%esp), %edx movl 24(%esp), %ebx movl 28(%esp), %ecx - LOCK(15) + LOCK cmpxchg8b (%edi) popl %ebx popl %edi Index: src/common/lib/libc/arch/x86_64/atomic/atomic.S diff -u src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.20 src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.21 --- src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.20 Sun Apr 26 13:54:03 2020 +++ src/common/lib/libc/arch/x86_64/atomic/atomic.S Sun Apr 26 13:59:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.20 2020/04/26 13:54:03 maxv Exp $ */ +/* $NetBSD: atomic.S,v 1.21 2020/04/26 13:59:44 maxv Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -40,10 +40,10 @@ #ifdef _HARDKERNEL #include -#define LOCK(n) HOTPATCH(HP_NAME_NOLOCK, 1); lock +#define LOCK HOTPATCH(HP_NAME_NOLOCK, 1); lock #define ENDLABEL(a) _ALIGN_TEXT; LABEL(a) #else -#define LOCK(n) lock +#define LOCK lock #define ENDLABEL(a) /* nothing */ #endif @@ -52,21 +52,21 @@ /* 32-bit */ ENTRY(_atomic_add_32) - LOCK(1) + LOCK addl %esi, (%rdi) ret END(_atomic_add_32) ENTRY(_atomic_add_32_nv) movl %esi, %eax - LOCK(2) + LOCK xaddl %eax, (%rdi) addl %esi, %eax ret END(_atomic_add_32_nv) ENTRY(_atomic_and_32) - LOCK(3) + LOCK andl %esi, (%rdi) ret END(_atomic_and_32) @@ -76,7 +76,7 @@ ENTRY(_atomic_and_32_nv) 1: movl %eax, %ecx andl %esi, %ecx - LOCK(4) + LOCK cmpxchgl %ecx, (%rdi) jnz 1b movl %ecx, %eax @@ -84,35 +84,35 @@
CVS commit: src/common/lib/libc/arch
Module Name:src Committed By: maxv Date: Sun Apr 26 13:54:03 UTC 2020 Modified Files: src/common/lib/libc/arch/i386/atomic: atomic.S src/common/lib/libc/arch/x86_64/atomic: atomic.S Log Message: Remove unused. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/common/lib/libc/arch/i386/atomic/atomic.S cvs rdiff -u -r1.19 -r1.20 src/common/lib/libc/arch/x86_64/atomic/atomic.S 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/i386/atomic/atomic.S diff -u src/common/lib/libc/arch/i386/atomic/atomic.S:1.25 src/common/lib/libc/arch/i386/atomic/atomic.S:1.26 --- src/common/lib/libc/arch/i386/atomic/atomic.S:1.25 Sun Apr 26 13:37:14 2020 +++ src/common/lib/libc/arch/i386/atomic/atomic.S Sun Apr 26 13:54:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.25 2020/04/26 13:37:14 maxv Exp $ */ +/* $NetBSD: atomic.S,v 1.26 2020/04/26 13:54:02 maxv Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -188,7 +188,6 @@ ENTRY(_membar_producer) movl $0, -4(%esp) ret END(_membar_producer) -ENDLABEL(membar_producer_end) ENTRY(_membar_sync) LOCK(14) Index: src/common/lib/libc/arch/x86_64/atomic/atomic.S diff -u src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.19 src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.20 --- src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.19 Sun Apr 26 13:37:14 2020 +++ src/common/lib/libc/arch/x86_64/atomic/atomic.S Sun Apr 26 13:54:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.19 2020/04/26 13:37:14 maxv Exp $ */ +/* $NetBSD: atomic.S,v 1.20 2020/04/26 13:54:03 maxv Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -265,7 +265,6 @@ ENTRY(_membar_producer) movq $0, -8(%rsp) ret END(_membar_producer) -ENDLABEL(membar_producer_end) ENTRY(_membar_sync) LOCK(26)
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: ryo Date: Sat Apr 11 05:12:52 UTC 2020 Modified Files: src/common/lib/libc/arch/aarch64/string: bcopy.S memset.S Log Message: Fixed to not use the "br" instruction. Branch Target Identification (BTI) doesn't like "br". requested by maxv@ To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/string/bcopy.S cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/string/memset.S 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/aarch64/string/bcopy.S diff -u src/common/lib/libc/arch/aarch64/string/bcopy.S:1.1 src/common/lib/libc/arch/aarch64/string/bcopy.S:1.2 --- src/common/lib/libc/arch/aarch64/string/bcopy.S:1.1 Sun Feb 4 21:52:16 2018 +++ src/common/lib/libc/arch/aarch64/string/bcopy.S Sat Apr 11 05:12:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bcopy.S,v 1.1 2018/02/04 21:52:16 skrll Exp $ */ +/* $NetBSD: bcopy.S,v 1.2 2020/04/11 05:12:52 ryo Exp $ */ /* * Copyright (c) 2018 Ryo Shimizu @@ -29,7 +29,7 @@ #include #if defined(LIBC_SCCS) -RCSID("$NetBSD: bcopy.S,v 1.1 2018/02/04 21:52:16 skrll Exp $") +RCSID("$NetBSD: bcopy.S,v 1.2 2020/04/11 05:12:52 ryo Exp $") #endif #if defined(MEMCOPY) @@ -207,32 +207,60 @@ copy_backward: #endif /* (STP_ALIGN > 8) */ 9: +backward_copy1k: + /* while (len >= 1024) */ + /* { src -= 1024; dst -= 1024; copy1024(dst, src); len -= 1024; } */ cmp LEN, #1024 - bhs backward_copy1k -backward_less1k: - /* copy 16*n bytes */ - and TMP_D, LEN, #(1023-15) /* len &= 1023; len &= ~15; */ - adr TMP_X, 8f - sub LEN, LEN, TMP_D - sub TMP_X, TMP_X, TMP_D, lsr #1 /* jump to (8f - len/2) */ - br TMP_X -backward_copy1k: /* copy 16*64 bytes */ + blo 9f +1: sub LEN, LEN, #1024 .rept (1024 / 16) ldp DATA0, DATA1, [SRC0, #-16]! /* *--dst = *--src; */ stp DATA0, DATA1, [DST, #-16]! .endr -8: - cbz LEN, done cmp LEN, #1024 - bhs backward_copy1k - cmp LEN, #16 - bhs backward_less1k + bhs 1b +9: + /* if (len & 512) { src -= 512; dst -= 512; copy512(dst, src); } */ + tbz LEN, #9, 1f + .rept (512 / 16) + ldp DATA0, DATA1, [SRC0, #-16]! + stp DATA0, DATA1, [DST, #-16]! + .endr +1: + /* if (len & 256) { src -= 256; dst -= 256; copy256(dst, src); } */ + tbz LEN, #8, 1f + .rept (256 / 16) + ldp DATA0, DATA1, [SRC0, #-16]! + stp DATA0, DATA1, [DST, #-16]! + .endr +1: + /* if (len & 128) { src -= 128; dst -= 128; copy128(dst, src); } */ + tbz LEN, #7, 1f + .rept (128 / 16) + ldp DATA0, DATA1, [SRC0, #-16]! + stp DATA0, DATA1, [DST, #-16]! + .endr +1: + /* if (len & 64) { src -= 64; dst -= 64; copy64(dst, src); } */ + tbz LEN, #6, 1f + .rept (64 / 16) + ldp DATA0, DATA1, [SRC0, #-16]! + stp DATA0, DATA1, [DST, #-16]! + .endr +1: + /* if (len & 32) { src -= 32; dst -= 32; copy32(dst, src); } */ + tbz LEN, #5, 1f + .rept (32 / 16) + ldp DATA0, DATA1, [SRC0, #-16]! + stp DATA0, DATA1, [DST, #-16]! + .endr +1: /* if (len & 16) { *--(uint128_t *)dst = *--(uint128_t *)src; } */ tbz LEN, #4, 1f ldp DATA0, DATA1, [SRC0, #-16]! - ldp DATA0, DATA1, [DST, #-16]! + stp DATA0, DATA1, [DST, #-16]! 1: /* if (len & 8) { *--(uint64_t *)dst = *--(uint64_t *)src; } */ tbz LEN, #3, 1f @@ -271,14 +299,10 @@ backward_copy: bcs 9f backward_tiny: /* copy 1-10 bytes */ - adr TMP_X, 8f - sub TMP_X, TMP_X, LEN, lsl #3 /* jump to (8f - len*2) */ - br TMP_X - .rept 10 +1: sub LEN, LEN, #1 ldrb TMP_Xw, [SRC0, #-1]! strb TMP_Xw, [DST, #-1]! - .endr -8: + cbz LEN, 1b ret 9: /* length is small(<32), and src or dst may be unaligned */ @@ -548,14 +572,10 @@ ENTRY(FUNCTION) bcs 9f forward_tiny: /* copy 1-10 bytes */ - adr TMP_X, 8f - sub TMP_X, TMP_X, LEN, lsl #3 /* jump to (8f - len*2) */ - br TMP_X - .rept 10 +1: sub LEN, LEN, #1 ldrb TMP_Xw, [SRC0], #1 strb TMP_Xw, [DST], #1 - .endr -8: + cbz LEN, 1b ret 9: /* length is small(<32), and src or dst may be unaligned */ @@ -938,28 +958,56 @@ copy_forward: #endif /* (STP_ALIGN > 8) */ 9: +forward_copy1k: + /* while (len >= 1024) */ + /* { copy1024(dst, src); src += 1024; dst += 1024; len -= 1024; } */ cmp LEN, #1024 - bhs forward_copy1k -forward_less1k: - /* copy 16*n bytes */ - and TMP_D, LEN, #(1023-15) /* len &= 1023; len &= ~15; */ - adr TMP_X, 8f - sub LEN, LEN, TMP_D - sub TMP_X, TMP_X, TMP_D, lsr #1 /* jump to (8f - len/2) */ - br TMP_X -forward_copy1k: /* copy 16*64 bytes */ + blo 9f +1: sub LEN, LEN, #1024 .rept (1024 / 16) ldp DATA0, DATA1, [SRC0], #16 /* *dst++ = *src++; */ stp DATA0, DATA1, [DST], #16 .endr -8: - cbz LEN, done cmp LEN, #1024 - bhs forward_copy1k - cmp LEN, #16 - bhs forward_less1k + bhs 1b +9: + /* if (len & 512) { copy512(dst, src); src += 512; dst += 512; */ + tbz LEN, #9, 1f + .rept (512 / 16) + ldp DATA0, DATA1, [SRC0], #16 + stp DATA0, DATA1, [DST], #16 + .endr +1: + /* if (len & 256) { copy256(dst, src); src += 256; dst += 256; */ + tbz LEN, #8, 1f + .rept (256 /
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: ad Date: Sat Apr 11 01:46:47 UTC 2020 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: Match the naming convention in the file. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.25 src/common/lib/libc/gen/radixtree.c:1.26 --- src/common/lib/libc/gen/radixtree.c:1.25 Fri Apr 10 23:43:05 2020 +++ src/common/lib/libc/gen/radixtree.c Sat Apr 11 01:46:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.26 2020/04/11 01:46:47 ad Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.26 2020/04/11 01:46:47 ad Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.26 2020/04/11 01:46:47 ad Exp $"); #include #include #include @@ -356,14 +356,14 @@ radix_tree_await_memory(void) #endif /* defined(_KERNEL) */ /* - * radix_tree_node_sum: + * radix_tree_sum_node: * * return the logical sum of all entries in the given node. used to quickly * check for tag masks or empty nodes. */ static uintptr_t -radix_tree_node_sum(const struct radix_tree_node *n) +radix_tree_sum_node(const struct radix_tree_node *n) { #if RADIX_TREE_PTR_PER_NODE > 16 unsigned int i; @@ -437,7 +437,7 @@ radix_tree_alloc_node(void) radix_tree_node_init(n); } #endif /* defined(_KERNEL) */ - KASSERT(n == NULL || radix_tree_node_sum(n) == 0); + KASSERT(n == NULL || radix_tree_sum_node(n) == 0); return n; } @@ -445,7 +445,7 @@ static void radix_tree_free_node(struct radix_tree_node *n) { - KASSERT(radix_tree_node_sum(n) == 0); + KASSERT(radix_tree_sum_node(n) == 0); #if defined(_KERNEL) pool_cache_put(radix_tree_node_cache, n); #elif defined(_STANDALONE) @@ -627,7 +627,7 @@ radix_tree_undo_insert_node(struct radix KASSERT(pptr != NULL); n = entry_ptr(*pptr); KASSERT(n != NULL); - if (radix_tree_node_sum(n) != 0) { + if (radix_tree_sum_node(n) != 0) { break; } radix_tree_free_node(n); @@ -735,7 +735,7 @@ radix_tree_remove_node(struct radix_tree entry = *pptr; n = entry_ptr(entry); KASSERT(n != NULL); - if (radix_tree_node_sum(n) != 0) { + if (radix_tree_sum_node(n) != 0) { break; } radix_tree_free_node(n); @@ -762,8 +762,8 @@ radix_tree_remove_node(struct radix_tree entry = *pptr; n = entry_ptr(entry); KASSERT(n != NULL); - KASSERT(radix_tree_node_sum(n) != 0); - newmask = radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK; + KASSERT(radix_tree_sum_node(n) != 0); + newmask = radix_tree_sum_node(n) & RADIX_TREE_TAG_MASK; if (newmask == entry_tagmask(entry)) { break; } @@ -1139,7 +1139,7 @@ radix_tree_clear_tag(struct radix_tree * if (0 < i) { struct radix_tree_node *n = path_node(t, , i - 1); - if ((radix_tree_node_sum(n) & tagmask) != 0) { + if ((radix_tree_sum_node(n) & tagmask) != 0) { break; } } @@ -1172,7 +1172,7 @@ radix_tree_dump_node(const struct radix_ return; } n = entry_ptr(vp); - assert((radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK) == + assert((radix_tree_sum_node(n) & RADIX_TREE_TAG_MASK) == entry_tagmask(vp)); printf(" (%u children)\n", radix_tree_node_count_ptrs(n)); for (i = 0; i < __arraycount(n->n_ptrs); i++) {
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: ad Date: Fri Apr 10 23:43:05 UTC 2020 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: PR kern/54979 (radixtree might misbehave if ENOMEM) - radix_tree_insert_node(): if the insert failed due to ENOMEM, roll back any updates made to the tree. - radix_tree_grow(): either succeed or fail, never make partial adjustments to the tree. - radix_tree_await_memory(): allocate & free the maximum possible number of nodes required by any insertion. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.24 src/common/lib/libc/gen/radixtree.c:1.25 --- src/common/lib/libc/gen/radixtree.c:1.24 Fri Apr 10 21:56:41 2020 +++ src/common/lib/libc/gen/radixtree.c Fri Apr 10 23:43:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $"); #include #include #include @@ -335,16 +335,22 @@ radix_tree_init(void) * radix_tree_await_memory: * * after an insert has failed with ENOMEM, wait for memory to become - * available, so the caller can retry. + * available, so the caller can retry. this needs to ensure that the + * maximum possible required number of nodes is available. */ void radix_tree_await_memory(void) { - struct radix_tree_node *n; + struct radix_tree_node *nodes[RADIX_TREE_MAX_HEIGHT]; + int i; - n = pool_cache_get(radix_tree_node_cache, PR_WAITOK); - pool_cache_put(radix_tree_node_cache, n); + for (i = 0; i < __arraycount(nodes); i++) { + nodes[i] = pool_cache_get(radix_tree_node_cache, PR_WAITOK); + } + while (--i >= 0) { + pool_cache_put(radix_tree_node_cache, nodes[i]); + } } #endif /* defined(_KERNEL) */ @@ -360,8 +366,8 @@ static uintptr_t radix_tree_node_sum(const struct radix_tree_node *n) { #if RADIX_TREE_PTR_PER_NODE > 16 + unsigned int i; uintptr_t sum; - unsigned i; for (i = 0, sum = 0; i < RADIX_TREE_PTR_PER_NODE; i++) { sum |= (uintptr_t)n->n_ptrs[i]; @@ -449,31 +455,39 @@ radix_tree_free_node(struct radix_tree_n #endif } -static int +/* + * radix_tree_grow: + * + * increase the height of the tree. + */ + +static __noinline int radix_tree_grow(struct radix_tree *t, unsigned int newheight) { const unsigned int tagmask = entry_tagmask(t->t_root); + struct radix_tree_node *newnodes[RADIX_TREE_MAX_HEIGHT]; + void *root; + int h; - KASSERT(newheight <= 64 / RADIX_TREE_BITS_PER_HEIGHT); - if (t->t_root == NULL) { + KASSERT(newheight <= RADIX_TREE_MAX_HEIGHT); + if ((root = t->t_root) == NULL) { t->t_height = newheight; return 0; } - while (t->t_height < newheight) { - struct radix_tree_node *n; - - n = radix_tree_alloc_node(); - if (n == NULL) { - /* - * don't bother to revert our changes. - * the caller will likely retry. - */ + for (h = t->t_height; h < newheight; h++) { + newnodes[h] = radix_tree_alloc_node(); + if (__predict_false(newnodes[h] == NULL)) { + while (--h >= (int)t->t_height) { +newnodes[h]->n_ptrs[0] = NULL; +radix_tree_free_node(newnodes[h]); + } return ENOMEM; } - n->n_ptrs[0] = t->t_root; - t->t_root = entry_compose(n, tagmask); - t->t_height++; + newnodes[h]->n_ptrs[0] = root; + root = entry_compose(newnodes[h], tagmask); } + t->t_root = root; + t->t_height = h; return 0; } @@ -583,6 +597,52 @@ radix_tree_lookup_ptr(struct radix_tree } /* + * radix_tree_undo_insert_node: + * + * Undo the effects of a failed insert. The conditions that led to the + * insert may change and it may not be retried. If the insert is not + * retried, there will be no corresponding radix_tree_remove_node() for + * this index in the future. Therefore any adjustments made to the tree + * before memory was exhausted must be reverted. + */ + +static __noinline void +radix_tree_undo_insert_node(struct radix_tree *t, uint64_t idx) +{ + struct radix_tree_path path; + int i; + + (void)radix_tree_lookup_ptr(t, idx, , false, 0); + if (path.p_lastidx == RADIX_TREE_INVALID_HEIGHT) { + /* + * no nodes were inserted. + */ + return; + } + for (i = path.p_lastidx - 1;
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: ad Date: Fri Apr 10 21:56:41 UTC 2020 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: Rename radix_tree_node_clean_p() to radix_tree_node_sum() and have it return the computed sum. Use to replace any_children_tagmask(). Simpler & faster. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.23 src/common/lib/libc/gen/radixtree.c:1.24 --- src/common/lib/libc/gen/radixtree.c:1.23 Tue Jan 28 22:20:45 2020 +++ src/common/lib/libc/gen/radixtree.c Fri Apr 10 21:56:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $"); #include #include #include @@ -198,25 +198,6 @@ struct radix_tree_node { }; /* - * any_children_tagmask: - * - * return OR'ed tagmask of the given node's children. - */ - -static unsigned int -any_children_tagmask(const struct radix_tree_node *n) -{ - unsigned int mask; - int i; - - mask = 0; - for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) { - mask |= (unsigned int)(uintptr_t)n->n_ptrs[i]; - } - return mask & RADIX_TREE_TAG_MASK; -} - -/* * p_refs[0].pptr == >t_root * : * p_refs[n].pptr == &(*p_refs[n-1])->n_ptrs[x] @@ -368,18 +349,24 @@ radix_tree_await_memory(void) #endif /* defined(_KERNEL) */ -static bool __unused -radix_tree_node_clean_p(const struct radix_tree_node *n) +/* + * radix_tree_node_sum: + * + * return the logical sum of all entries in the given node. used to quickly + * check for tag masks or empty nodes. + */ + +static uintptr_t +radix_tree_node_sum(const struct radix_tree_node *n) { #if RADIX_TREE_PTR_PER_NODE > 16 - unsigned int i; + uintptr_t sum; + unsigned i; - for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) { - if (n->n_ptrs[i] != NULL) { - return false; - } + for (i = 0, sum = 0; i < RADIX_TREE_PTR_PER_NODE; i++) { + sum |= (uintptr_t)n->n_ptrs[i]; } - return true; + return sum; #else /* RADIX_TREE_PTR_PER_NODE > 16 */ uintptr_t sum; @@ -409,7 +396,7 @@ radix_tree_node_clean_p(const struct rad sum |= (uintptr_t)n->n_ptrs[14]; sum |= (uintptr_t)n->n_ptrs[15]; #endif - return sum == 0; + return sum; #endif /* RADIX_TREE_PTR_PER_NODE > 16 */ } @@ -444,7 +431,7 @@ radix_tree_alloc_node(void) radix_tree_node_init(n); } #endif /* defined(_KERNEL) */ - KASSERT(n == NULL || radix_tree_node_clean_p(n)); + KASSERT(n == NULL || radix_tree_node_sum(n) == 0); return n; } @@ -452,7 +439,7 @@ static void radix_tree_free_node(struct radix_tree_node *n) { - KASSERT(radix_tree_node_clean_p(n)); + KASSERT(radix_tree_node_sum(n) == 0); #if defined(_KERNEL) pool_cache_put(radix_tree_node_cache, n); #elif defined(_STANDALONE) @@ -687,7 +674,7 @@ radix_tree_remove_node(struct radix_tree entry = *pptr; n = entry_ptr(entry); KASSERT(n != NULL); - if (!radix_tree_node_clean_p(n)) { + if (radix_tree_node_sum(n) != 0) { break; } radix_tree_free_node(n); @@ -714,8 +701,8 @@ radix_tree_remove_node(struct radix_tree entry = *pptr; n = entry_ptr(entry); KASSERT(n != NULL); - KASSERT(!radix_tree_node_clean_p(n)); - newmask = any_children_tagmask(n); + KASSERT(radix_tree_node_sum(n) != 0); + newmask = radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK; if (newmask == entry_tagmask(entry)) { break; } @@ -1091,7 +1078,7 @@ radix_tree_clear_tag(struct radix_tree * if (0 < i) { struct radix_tree_node *n = path_node(t, , i - 1); - if ((any_children_tagmask(n) & tagmask) != 0) { + if ((radix_tree_node_sum(n) & tagmask) != 0) { break; } } @@ -1124,7 +,8 @@ radix_tree_dump_node(const struct radix_ return; } n = entry_ptr(vp); - assert(any_children_tagmask(n) == entry_tagmask(vp)); + assert((radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK) == + entry_tagmask(vp)); printf(" (%u children)\n", radix_tree_node_count_ptrs(n)); for (i = 0; i < __arraycount(n->n_ptrs); i++) { void *c;
CVS commit: src/common/lib/libc/arch/m68k/string
Module Name:src Committed By: rin Date: Tue Mar 10 08:15:44 UTC 2020 Modified Files: src/common/lib/libc/arch/m68k/string: ffs.S Log Message: For kernel, rename ffs to __ffssi2 rather than having a weak symbol. This enables us to load modules depended to __ffssi2. It is difficult to deal with weak symbols consistently in in-kernel linker. See explanation by pgoyette on tech-kern: http://mail-index.netbsd.org/tech-kern/2020/03/09/msg026148.html Also, we do not currently provide ffs(9) as a kernel routine. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/m68k/string/ffs.S 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/m68k/string/ffs.S diff -u src/common/lib/libc/arch/m68k/string/ffs.S:1.7 src/common/lib/libc/arch/m68k/string/ffs.S:1.8 --- src/common/lib/libc/arch/m68k/string/ffs.S:1.7 Mon Mar 9 13:36:10 2020 +++ src/common/lib/libc/arch/m68k/string/ffs.S Tue Mar 10 08:15:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs.S,v 1.7 2020/03/09 13:36:10 rin Exp $ */ +/* $NetBSD: ffs.S,v 1.8 2020/03/10 08:15:44 rin Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -39,13 +39,22 @@ #if 0 RCSID("from: @(#)ffs.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: ffs.S,v 1.7 2020/03/09 13:36:10 rin Exp $") + RCSID("$NetBSD: ffs.S,v 1.8 2020/03/10 08:15:44 rin Exp $") #endif #endif /* LIBC_SCCS and not lint */ /* bit = ffs(value) */ +#ifdef _LIBC WEAK_ALIAS(__ffssi2,ffs) +#else /* KERNEL */ +/* + * Our in-kernel linker does not understand weak references, which + * prevents modules depended on __ffssi2 from being loaded. Also, + * we do not provide ffs(9) as a kernel routine. Let's rename it! + */ +#define ffs __ffssi2 +#endif #if (!defined(__mc68010__) && !defined(__mcoldfire__)) || defined(__mcfisac__)
CVS commit: src/common/lib/libc/arch/m68k/string
Module Name:src Committed By: rin Date: Mon Mar 9 13:36:10 UTC 2020 Modified Files: src/common/lib/libc/arch/m68k/string: ffs.S Log Message: Add missing END() for coldfire. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/m68k/string/ffs.S 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/m68k/string/ffs.S diff -u src/common/lib/libc/arch/m68k/string/ffs.S:1.6 src/common/lib/libc/arch/m68k/string/ffs.S:1.7 --- src/common/lib/libc/arch/m68k/string/ffs.S:1.6 Sat Sep 7 19:06:29 2013 +++ src/common/lib/libc/arch/m68k/string/ffs.S Mon Mar 9 13:36:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs.S,v 1.6 2013/09/07 19:06:29 chs Exp $ */ +/* $NetBSD: ffs.S,v 1.7 2020/03/09 13:36:10 rin Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -39,7 +39,7 @@ #if 0 RCSID("from: @(#)ffs.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: ffs.S,v 1.6 2013/09/07 19:06:29 chs Exp $") + RCSID("$NetBSD: ffs.S,v 1.7 2020/03/09 13:36:10 rin Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -76,6 +76,7 @@ ENTRY(ffs) jcc .L1 | keep looping while carry is clear. .L2: rts +END(ffs) #else /* __mc68010__ */
CVS commit: src/common/lib/libc/arch/arm/atomic
Module Name:src Committed By: skrll Date: Mon Mar 9 11:21:54 UTC 2020 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_cas_up.S Log Message: Give the thumb atomic ops a chance of working To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S 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/atomic_cas_up.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S:1.7 src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S:1.8 --- src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S:1.7 Tue Mar 4 03:36:24 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S Mon Mar 9 11:21:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_up.S,v 1.7 2014/03/04 03:36:24 matt Exp $ */ +/* $NetBSD: atomic_cas_up.S,v 1.8 2020/03/09 11:21:54 skrll Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -41,6 +41,7 @@ RAS_START_ASM_HIDDEN(_atomic_cas) cmp r0, r1 #if defined(__thumb__) beq 1f + str r2, [r3] #else streq r2, [r3] #endif @@ -75,6 +76,7 @@ RAS_START_ASM_HIDDEN(_atomic_cas_16) cmp r0, r1 #if defined(__thumb__) beq 1f + strh r2, [r3] #else strheq r2, [r3] #endif @@ -91,6 +93,7 @@ RAS_START_ASM_HIDDEN(_atomic_cas_8) cmp r0, r1 #if defined(__thumb__) beq 1f + strb r2, [r3] #else strbeq r2, [r3] #endif
CVS commit: src/common/lib/libc/arch/m68k/gen
Module Name:src Committed By: rin Date: Mon Mar 9 08:29:12 UTC 2020 Modified Files: src/common/lib/libc/arch/m68k/gen: mulsi3.S Log Message: Remove wrong comment (copy-paste from somewhere); __mulsi3 does not depend on __udivsi3. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/m68k/gen/mulsi3.S 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/m68k/gen/mulsi3.S diff -u src/common/lib/libc/arch/m68k/gen/mulsi3.S:1.4 src/common/lib/libc/arch/m68k/gen/mulsi3.S:1.5 --- src/common/lib/libc/arch/m68k/gen/mulsi3.S:1.4 Tue Jul 16 23:24:18 2013 +++ src/common/lib/libc/arch/m68k/gen/mulsi3.S Mon Mar 9 08:29:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mulsi3.S,v 1.4 2013/07/16 23:24:18 matt Exp $ */ +/* $NetBSD: mulsi3.S,v 1.5 2020/03/09 08:29:11 rin Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -39,7 +39,7 @@ #if 0 RCSID("from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90") #else - RCSID("$NetBSD: mulsi3.S,v 1.4 2013/07/16 23:24:18 matt Exp $") + RCSID("$NetBSD: mulsi3.S,v 1.5 2020/03/09 08:29:11 rin Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -49,8 +49,6 @@ ENTRY(__mulsi3) movel 4(%sp),%d0 mulsl 8(%sp),%d0 #else -| NB: this requires that __udivsi3 preserve %a0 and return -| the modulus in %d1: movew 6(%sp), %d0 movel %d0, %a0 | save B muluw 8(%sp), %d0 | %d0 holds B * C
CVS commit: src/common/lib/libc/misc
Module Name:src Committed By: kamil Date: Sun Mar 8 21:35:03 UTC 2020 Modified Files: src/common/lib/libc/misc: ubsan.c Log Message: Add support for alignment_assumptions in uubsan Cherry-pick from FreeBSD: >From 7c1bc5ffc2fa68ddc76e5ea8a3a1a6fdfeee57f0 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 28 May 2019 09:12:15 + Subject: [PATCH] Teach the kernel KUBSAN runtime about alignment_assumption This checks the alignment of a given pointer is sufficient for the requested alignment asked for. This fixes the build with a recent llvm/clang. Sponsored by: DARPA, AFRL To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/misc/ubsan.c 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/misc/ubsan.c diff -u src/common/lib/libc/misc/ubsan.c:1.9 src/common/lib/libc/misc/ubsan.c:1.10 --- src/common/lib/libc/misc/ubsan.c:1.9 Fri Nov 1 14:54:07 2019 +++ src/common/lib/libc/misc/ubsan.c Sun Mar 8 21:35:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ubsan.c,v 1.9 2019/11/01 14:54:07 kamil Exp $ */ +/* $NetBSD: ubsan.c,v 1.10 2020/03/08 21:35:03 kamil Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,9 +38,9 @@ #include #if defined(_KERNEL) -__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.9 2019/11/01 14:54:07 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.10 2020/03/08 21:35:03 kamil Exp $"); #else -__RCSID("$NetBSD: ubsan.c,v 1.9 2019/11/01 14:54:07 kamil Exp $"); +__RCSID("$NetBSD: ubsan.c,v 1.10 2020/03/08 21:35:03 kamil Exp $"); #endif #if defined(_KERNEL) @@ -245,6 +245,12 @@ struct CImplicitConversionData { uint8_t mKind; }; +struct CAlignmentAssumptionData { + struct CSourceLocation mLocation; + struct CSourceLocation mAssumptionLocation; + struct CTypeDescriptor *mType; +}; + /* Local utility functions */ static void Report(bool isFatal, const char *pFormat, ...) __printflike(2, 3); static bool isAlreadyReported(struct CSourceLocation *pLocation); @@ -278,6 +284,8 @@ intptr_t __ubsan_vptr_type_cache[128]; /* Public symbols used in the instrumentation of the code generation part */ void __ubsan_handle_add_overflow(struct COverflowData *pData, unsigned long ulLHS, unsigned long ulRHS); void __ubsan_handle_add_overflow_abort(struct COverflowData *pData, unsigned long ulLHS, unsigned long ulRHS); +void __ubsan_handle_alignment_assumption(struct CAlignmentAssumptionData *pData, unsigned long ulPointer, unsigned long ulAlignment, unsigned long ulOffset); +void __ubsan_handle_alignment_assumption_abort(struct CAlignmentAssumptionData *pData, unsigned long ulPointer, unsigned long ulAlignment, unsigned long ulOffset); void __ubsan_handle_builtin_unreachable(struct CUnreachableData *pData); void __ubsan_handle_cfi_bad_type(struct CCFICheckFailData *pData, unsigned long ulVtable, bool bValidVtable, bool FromUnrecoverableHandler, unsigned long ProgramCounter, unsigned long FramePointer); void __ubsan_handle_cfi_check_fail(struct CCFICheckFailData *pData, unsigned long ulValue, unsigned long ulValidVtable); @@ -344,6 +352,7 @@ static void HandleMissingReturn(bool isF static void HandleNonnullArg(bool isFatal, struct CNonNullArgData *pData); static void HandleNonnullReturn(bool isFatal, struct CNonNullReturnData *pData, struct CSourceLocation *pLocationPointer); static void HandlePointerOverflow(bool isFatal, struct CPointerOverflowData *pData, unsigned long ulBase, unsigned long ulResult); +static void HandleAlignmentAssumption(bool isFatal, struct CAlignmentAssumptionData *pData, unsigned long ulPointer, unsigned long ulAlignment, unsigned long ulOffset); static void HandleOverflow(bool isFatal, struct COverflowData *pData, unsigned long ulLHS, unsigned long ulRHS, const char *szOperation) @@ -716,6 +725,34 @@ HandleImplicitConversion(bool isFatal, s szLocation, DeserializeImplicitConversionCheckKind(pData->mKind), szFrom, zDeserializeTypeWidth(pData->mFromType), ISSET(pData->mFromType->mTypeInfo, NUMBER_SIGNED_BIT) ? "signed" : "unsigned", pData->mFromType->mTypeName, pData->mToType->mTypeName, szTo, zDeserializeTypeWidth(pData->mToType), ISSET(pData->mToType->mTypeInfo, NUMBER_SIGNED_BIT) ? "signed" : "unsigned"); } +static void +HandleAlignmentAssumption(bool isFatal, struct CAlignmentAssumptionData *pData, unsigned long ulPointer, unsigned long ulAlignment, unsigned long ulOffset) +{ + char szLocation[LOCATION_MAXLEN]; + char szAssumptionLocation[LOCATION_MAXLEN]; + unsigned long ulRealPointer; + + ASSERT(pData); + + if (isAlreadyReported(>mLocation)) + return; + + DeserializeLocation(szLocation, LOCATION_MAXLEN, >mLocation); + + ulRealPointer = ulPointer - ulOffset; + + if (pData->mAssumptionLocation.mFilename != NULL) { + DeserializeLocation(szAssumptionLocation, LOCATION_MAXLEN, + >mAssumptionLocation); + Report(isFatal, "UBSan: Undefined Behavior in %s, alignment assumption
CVS commit: src/common/lib/libc/stdlib
Module Name:src Committed By: fox Date: Sat Feb 22 14:47:29 UTC 2020 Modified Files: src/common/lib/libc/stdlib: random.c Log Message: common/lib/libc/stdlib: Fix possible signed integer overflow. common/lib/libc/stdlib/random.c:482:6 can result in signed integer overflow. This bug was reported by UBSan runs. The change has been tested using the following program to generate random numbers in both the old and the new library and can be used to verify the correctness of the library after the change. #include #include #define COUNT 1000 * 1000 int main(void) { int i; FILE *fp = fopen("numbers.txt", "w"); srandom(0xdeadbeef); for(i = 0; i < COUNT; i++) { fprintf(fp, "%ld\n", random()); } fclose(fp); return 0; } Reviewed by: riastradh@ , kamil@ To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/stdlib/random.c 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/stdlib/random.c diff -u src/common/lib/libc/stdlib/random.c:1.5 src/common/lib/libc/stdlib/random.c:1.6 --- src/common/lib/libc/stdlib/random.c:1.5 Mon Feb 8 05:27:24 2016 +++ src/common/lib/libc/stdlib/random.c Sat Feb 22 14:47:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: random.c,v 1.5 2016/02/08 05:27:24 dholland Exp $ */ +/* $NetBSD: random.c,v 1.6 2020/02/22 14:47:29 fox Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,7 +35,7 @@ #if 0 static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95"; #else -__RCSID("$NetBSD: random.c,v 1.5 2016/02/08 05:27:24 dholland Exp $"); +__RCSID("$NetBSD: random.c,v 1.6 2020/02/22 14:47:29 fox Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -189,7 +189,7 @@ static const int seps[MAX_TYPES] = { SEP */ /* LINTED */ -static int randtbl[DEG_3 + 1] = { +static uint32_t randtbl[DEG_3 + 1] = { TYPE_3, #ifdef USE_BETTER_RANDOM 0x991539b1, 0x16a5bce3, 0x6774a4cd, @@ -232,8 +232,8 @@ static int randtbl[DEG_3 + 1] = { * in the initialization of randtbl) because the state table pointer is set * to point to randtbl[1] (as explained below). */ -static int *fptr = [SEP_3 + 1]; -static int *rptr = [1]; +static uint32_t *fptr = [SEP_3 + 1]; +static uint32_t *rptr = [1]; /* * The following things are the pointer to the state information table, the @@ -245,11 +245,11 @@ static int *rptr = [1]; * this is more efficient than indexing every time to find the address of * the last element to see if the front and rear pointers have wrapped. */ -static int *state = [1]; +static uint32_t *state = [1]; static int rand_type = TYPE_3; static int rand_deg = DEG_3; static int rand_sep = SEP_3; -static int *end_ptr = [DEG_3 + 1]; +static uint32_t *end_ptr = [DEG_3 + 1]; /* * srandom: @@ -340,17 +340,17 @@ initstate( size_t n) /* # bytes of state info */ { void *ostate = (void *)([-1]); - int *int_arg_state; + uint32_t *int_arg_state; _DIAGASSERT(arg_state != NULL); - int_arg_state = (int *)(void *)arg_state; + int_arg_state = (uint32_t *)(void *)arg_state; mutex_lock(_mutex); if (rand_type == TYPE_0) state[-1] = rand_type; else - state[-1] = MAX_TYPES * (int)(rptr - state) + rand_type; + state[-1] = MAX_TYPES * (uint32_t)(rptr - state) + rand_type; if (n < BREAK_0) { mutex_unlock(_mutex); return (NULL); @@ -375,13 +375,13 @@ initstate( rand_deg = DEG_4; rand_sep = SEP_4; } - state = (int *) (int_arg_state + 1); /* first location */ + state = (uint32_t *) (int_arg_state + 1); /* first location */ end_ptr = [rand_deg]; /* must set end_ptr before srandom */ srandom_unlocked(seed); if (rand_type == TYPE_0) int_arg_state[0] = rand_type; else - int_arg_state[0] = MAX_TYPES * (int)(rptr - state) + rand_type; + int_arg_state[0] = MAX_TYPES * (uint32_t)(rptr - state) + rand_type; mutex_unlock(_mutex); return((char *)ostate); } @@ -408,22 +408,22 @@ initstate( char * setstate(char *arg_state) /* pointer to state array */ { - int *new_state; - int type; - int rear; + uint32_t *new_state; + uint32_t type; + uint32_t rear; void *ostate = (void *)([-1]); _DIAGASSERT(arg_state != NULL); - new_state = (int *)(void *)arg_state; - type = (int)(new_state[0] % MAX_TYPES); - rear = (int)(new_state[0] / MAX_TYPES); + new_state = (uint32_t *)(void *)arg_state; + type = (uint32_t)(new_state[0] % MAX_TYPES); + rear = (uint32_t)(new_state[0] / MAX_TYPES); mutex_lock(_mutex); if (rand_type == TYPE_0) state[-1] = rand_type; else - state[-1] = MAX_TYPES * (int)(rptr - state) + rand_type; + state[-1] = MAX_TYPES * (uint32_t)(rptr - state) + rand_type; switch(type) { case TYPE_0: case TYPE_1: @@ -438,7 +438,7 @@ setstate(char *arg_state) /* pointer to mutex_unlock(_mutex); return (NULL); } - state = (int *) (new_state + 1); + state = (uint32_t *) (new_state + 1); if (rand_type !=
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: ad Date: Wed Jan 29 09:18:26 UTC 2020 Modified Files: src/common/lib/libc/string: bcmp.c memcmp.c Log Message: Some boot blocks too big now, only compare in big chunks if !_STANDALONE. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/string/bcmp.c cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/string/memcmp.c 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/string/bcmp.c diff -u src/common/lib/libc/string/bcmp.c:1.9 src/common/lib/libc/string/bcmp.c:1.10 --- src/common/lib/libc/string/bcmp.c:1.9 Mon Jan 27 22:22:03 2020 +++ src/common/lib/libc/string/bcmp.c Wed Jan 29 09:18:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bcmp.c,v 1.9 2020/01/27 22:22:03 ad Exp $ */ +/* $NetBSD: bcmp.c,v 1.10 2020/01/29 09:18:26 ad Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: bcmp.c,v 1.9 2020/01/27 22:22:03 ad Exp $"); +__RCSID("$NetBSD: bcmp.c,v 1.10 2020/01/29 09:18:26 ad Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -86,9 +86,11 @@ __RCSID("$NetBSD: bcmp.c,v 1.9 2020/01/2 int bcmp(const void *s1, const void *s2, size_t n) { - const uintptr_t *b1, *b2; const unsigned char *c1, *c2; +#ifndef _STANDALONE + const uintptr_t *b1, *b2; + b1 = s1; b2 = s2; @@ -105,6 +107,10 @@ bcmp(const void *s1, const void *s2, siz c1 = (const unsigned char *)b1; c2 = (const unsigned char *)b2; +#else + c1 = (const unsigned char *)s1; + c2 = (const unsigned char *)s2; +#endif if (n != 0) { do { Index: src/common/lib/libc/string/memcmp.c diff -u src/common/lib/libc/string/memcmp.c:1.7 src/common/lib/libc/string/memcmp.c:1.8 --- src/common/lib/libc/string/memcmp.c:1.7 Mon Jan 27 22:22:03 2020 +++ src/common/lib/libc/string/memcmp.c Wed Jan 29 09:18:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: memcmp.c,v 1.7 2020/01/27 22:22:03 ad Exp $ */ +/* $NetBSD: memcmp.c,v 1.8 2020/01/29 09:18:26 ad Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ #if 0 static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: memcmp.c,v 1.7 2020/01/27 22:22:03 ad Exp $"); +__RCSID("$NetBSD: memcmp.c,v 1.8 2020/01/29 09:18:26 ad Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -86,9 +86,11 @@ __RCSID("$NetBSD: memcmp.c,v 1.7 2020/01 int memcmp(const void *s1, const void *s2, size_t n) { - const uintptr_t *b1, *b2; const unsigned char *c1, *c2; +#ifndef _STANDALONE + const uintptr_t *b1, *b2; + b1 = s1; b2 = s2; @@ -107,6 +109,10 @@ memcmp(const void *s1, const void *s2, s c1 = (const unsigned char *)b1; c2 = (const unsigned char *)b2; +#else + c1 = (const unsigned char *)s1; + c2 = (const unsigned char *)s2; +#endif if (n != 0) { do {
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: ad Date: Tue Jan 28 22:20:45 UTC 2020 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: gang_lookup_scan(): if a dense scan and the first sibling doesn't match, the scan is finished. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.22 src/common/lib/libc/gen/radixtree.c:1.23 --- src/common/lib/libc/gen/radixtree.c:1.22 Tue Jan 28 16:33:34 2020 +++ src/common/lib/libc/gen/radixtree.c Tue Jan 28 22:20:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.22 2020/01/28 16:33:34 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.22 2020/01/28 16:33:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.22 2020/01/28 16:33:34 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $"); #include #include #include @@ -843,34 +843,16 @@ scan_siblings: break; } n = path_node(t, path, lastidx - 1); - /* - * we used to have an integer counter in the node, and this - * optimization made sense then, even though marginal. it - * no longer provides benefit with the structure cache line - * aligned and the counter replaced by an unrolled sequence - * testing the pointers in batch. - */ -#if 0 - if (*vpp != NULL && radix_tree_node_count_ptrs(n) == 1) { - /* - * optimization; if the node has only a single pointer - * and we've already visited it, there's no point to - * keep scanning in this node. - */ - goto no_siblings; - } -#endif /* 0 */ for (i = vpp - n->n_ptrs + step; i != guard; i += step) { KASSERT(i < RADIX_TREE_PTR_PER_NODE); if (entry_match_p(n->n_ptrs[i], tagmask)) { vpp = >n_ptrs[i]; break; + } else if (dense) { +return nfound; } } if (i == guard) { -#if 0 -no_siblings: -#endif /* 0 */ /* * not found. go to parent. */
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: ad Date: Mon Jan 27 22:22:03 UTC 2020 Modified Files: src/common/lib/libc/string: bcmp.c memcmp.c Log Message: Drop the alignment check if __NO_STRICT_ALIGNMENT (x86, m68k, vax). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/string/bcmp.c cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/string/memcmp.c 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/string/bcmp.c diff -u src/common/lib/libc/string/bcmp.c:1.8 src/common/lib/libc/string/bcmp.c:1.9 --- src/common/lib/libc/string/bcmp.c:1.8 Mon Jan 27 22:13:39 2020 +++ src/common/lib/libc/string/bcmp.c Mon Jan 27 22:22:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bcmp.c,v 1.8 2020/01/27 22:13:39 ad Exp $ */ +/* $NetBSD: bcmp.c,v 1.9 2020/01/27 22:22:03 ad Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: bcmp.c,v 1.8 2020/01/27 22:13:39 ad Exp $"); +__RCSID("$NetBSD: bcmp.c,v 1.9 2020/01/27 22:22:03 ad Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -92,7 +92,10 @@ bcmp(const void *s1, const void *s2, siz b1 = s1; b2 = s2; - if uintptr_t)b1 | (uintptr_t)b2) & (sizeof(uintptr_t) - 1)) == 0) { +#ifndef __NO_STRICT_ALIGNMENT + if uintptr_t)b1 | (uintptr_t)b2) & (sizeof(uintptr_t) - 1)) == 0) +#endif + { while (n >= sizeof(uintptr_t)) { if (*b1++ != *b2++) return 1; Index: src/common/lib/libc/string/memcmp.c diff -u src/common/lib/libc/string/memcmp.c:1.6 src/common/lib/libc/string/memcmp.c:1.7 --- src/common/lib/libc/string/memcmp.c:1.6 Mon Jan 27 22:13:39 2020 +++ src/common/lib/libc/string/memcmp.c Mon Jan 27 22:22:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: memcmp.c,v 1.6 2020/01/27 22:13:39 ad Exp $ */ +/* $NetBSD: memcmp.c,v 1.7 2020/01/27 22:22:03 ad Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ #if 0 static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: memcmp.c,v 1.6 2020/01/27 22:13:39 ad Exp $"); +__RCSID("$NetBSD: memcmp.c,v 1.7 2020/01/27 22:22:03 ad Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -92,7 +92,10 @@ memcmp(const void *s1, const void *s2, s b1 = s1; b2 = s2; - if uintptr_t)b1 | (uintptr_t)b2) & (sizeof(uintptr_t) - 1)) == 0) { +#ifndef __NO_STRICT_ALIGNMENT + if uintptr_t)b1 | (uintptr_t)b2) & (sizeof(uintptr_t) - 1)) == 0) +#endif + { while (n >= sizeof(uintptr_t)) { if (*b1 != *b2) break;
CVS commit: src/common/lib/libc/arch
Module Name:src Committed By: ad Date: Mon Jan 27 22:09:21 UTC 2020 Removed Files: src/common/lib/libc/arch/i386/string: memcmp.S src/common/lib/libc/arch/x86_64/string: bcmp.S memcmp.S Log Message: x86 uses the C versions of bcmp() and memcmp() now. To generate a diff of this commit: cvs rdiff -u -r1.3 -r0 src/common/lib/libc/arch/i386/string/memcmp.S cvs rdiff -u -r1.4 -r0 src/common/lib/libc/arch/x86_64/string/bcmp.S cvs rdiff -u -r1.5 -r0 src/common/lib/libc/arch/x86_64/string/memcmp.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: ad Date: Mon Jan 27 22:13:39 UTC 2020 Modified Files: src/common/lib/libc/string: bcmp.c memcmp.c Log Message: bcmp() / memcmp(): compare in uintptr_t sized chunks when it's easy to. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/string/bcmp.c cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/string/memcmp.c 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/string/bcmp.c diff -u src/common/lib/libc/string/bcmp.c:1.7 src/common/lib/libc/string/bcmp.c:1.8 --- src/common/lib/libc/string/bcmp.c:1.7 Fri Mar 9 15:41:16 2012 +++ src/common/lib/libc/string/bcmp.c Mon Jan 27 22:13:39 2020 @@ -1,4 +1,33 @@ -/* $NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $ */ +/* $NetBSD: bcmp.c,v 1.8 2020/01/27 22:13:39 ad Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. + */ /* * Copyright (c) 1987, 1993 @@ -34,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $"); +__RCSID("$NetBSD: bcmp.c,v 1.8 2020/01/27 22:13:39 ad Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -45,6 +74,8 @@ __RCSID("$NetBSD: bcmp.c,v 1.7 2012/03/0 #include #endif #else +#include + #include #include #endif @@ -53,18 +84,31 @@ __RCSID("$NetBSD: bcmp.c,v 1.7 2012/03/0 * bcmp -- vax cmpc3 instruction */ int -bcmp(const void *b1, const void *b2, size_t length) +bcmp(const void *s1, const void *s2, size_t n) { - const char *p1 = b1, *p2 = b2; + const uintptr_t *b1, *b2; + const unsigned char *c1, *c2; + + b1 = s1; + b2 = s2; - _DIAGASSERT(b1 != 0); - _DIAGASSERT(b2 != 0); + if uintptr_t)b1 | (uintptr_t)b2) & (sizeof(uintptr_t) - 1)) == 0) { + while (n >= sizeof(uintptr_t)) { + if (*b1++ != *b2++) +return 1; + n -= sizeof(uintptr_t); + } + } + + c1 = (const unsigned char *)b1; + c2 = (const unsigned char *)b2; + + if (n != 0) { + do { + if (*c1++ != *c2++) +return 1; + } while (--n != 0); + } - if (length == 0) - return(0); - do - if (*p1++ != *p2++) - break; - while (--length); - return length != 0; + return 0; } Index: src/common/lib/libc/string/memcmp.c diff -u src/common/lib/libc/string/memcmp.c:1.5 src/common/lib/libc/string/memcmp.c:1.6 --- src/common/lib/libc/string/memcmp.c:1.5 Sun Feb 4 20:22:17 2018 +++ src/common/lib/libc/string/memcmp.c Mon Jan 27 22:13:39 2020 @@ -1,4 +1,33 @@ -/* $NetBSD: memcmp.c,v 1.5 2018/02/04 20:22:17 mrg Exp $ */ +/* $NetBSD: memcmp.c,v 1.6 2020/01/27 22:13:39 ad Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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
CVS commit: src/common/lib/libc/arch/x86_64/string
Module Name:src Committed By: ad Date: Thu Jan 16 09:23:43 UTC 2020 Modified Files: src/common/lib/libc/arch/x86_64/string: memcmp.S Log Message: Back out previous, it's broken. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/x86_64/string/memcmp.S 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/x86_64/string/memcmp.S diff -u src/common/lib/libc/arch/x86_64/string/memcmp.S:1.4 src/common/lib/libc/arch/x86_64/string/memcmp.S:1.5 --- src/common/lib/libc/arch/x86_64/string/memcmp.S:1.4 Wed Jan 15 10:56:49 2020 +++ src/common/lib/libc/arch/x86_64/string/memcmp.S Thu Jan 16 09:23:43 2020 @@ -1,34 +1,3 @@ -/* $NetBSD: memcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $ */ - -/*- - * Copyright (c) 2020 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Doran. - * - * 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. - */ - /* * Written by J.T. Conklin . * Public domain. @@ -38,39 +7,34 @@ #include #if defined(LIBC_SCCS) - RCSID("$NetBSD: memcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $") + RCSID("$NetBSD: memcmp.S,v 1.5 2020/01/16 09:23:43 ad Exp $") #endif ENTRY(memcmp) - movq %rdx, %rcx /* compare by longs, equality only */ - shrq $3, %rcx - jz 2f -1: - movq (%rdi), %rax - cmpq %rax, (%rsi) - jne 6f - decq %rcx - leaq 8(%rdi), %rdi - leaq 8(%rsi), %rsi - jnz 1b -2: - andl $7, %edx - jz 5f -3: - movb (%rdi), %al /* compare by chars, find difference */ - subb (%rsi), %al - jne 4f - decl %edx - leaq 1(%rdi), %rdi - leaq 1(%rsi), %rsi - jnz 3b -4: - movsbl %al, %eax + movq %rdx,%rcx /* compare by longs */ + shrq $3,%rcx + repe + cmpsq + jne L5 /* do we match so far? */ + + movq %rdx,%rcx /* compare remainder by bytes */ + andq $7,%rcx + repe + cmpsb + jne L6 /* do we match? */ + + xorl %eax,%eax /* we match, return zero */ ret -5: - xorl %eax, %eax + +L5: movl $8,%ecx /* We know that one of the next */ + subq %rcx,%rdi /* eight pairs of bytes do not */ + subq %rcx,%rsi /* match. */ + repe + cmpsb +L6: xorl %eax,%eax /* Perform unsigned comparison */ + movb -1(%rdi),%al + xorl %edx,%edx + movb -1(%rsi),%dl + subl%edx,%eax ret -6: - movl $8, %edx - jmp 3b END(memcmp)
CVS commit: src/common/lib/libc/arch/x86_64/string
Module Name:src Committed By: ad Date: Wed Jan 15 10:56:49 UTC 2020 Modified Files: src/common/lib/libc/arch/x86_64/string: bcmp.S memcmp.S Log Message: Rewrite bcmp() & memcmp() to not use REP CMPS. Seems about 5-10x faster for small strings on modern hardware. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/x86_64/string/bcmp.S \ src/common/lib/libc/arch/x86_64/string/memcmp.S 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/x86_64/string/bcmp.S diff -u src/common/lib/libc/arch/x86_64/string/bcmp.S:1.3 src/common/lib/libc/arch/x86_64/string/bcmp.S:1.4 --- src/common/lib/libc/arch/x86_64/string/bcmp.S:1.3 Sat Mar 22 19:16:34 2014 +++ src/common/lib/libc/arch/x86_64/string/bcmp.S Wed Jan 15 10:56:49 2020 @@ -1,24 +1,67 @@ +/* $NetBSD: bcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 #if defined(LIBC_SCCS) - RCSID("$NetBSD: bcmp.S,v 1.3 2014/03/22 19:16:34 jakllsch Exp $") + RCSID("$NetBSD: bcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $") #endif ENTRY(bcmp) - xorl %eax,%eax /* clear return value */ - - movq %rdx,%rcx /* compare by words */ - shrq $3,%rcx - repe - cmpsq - jne L1 - - movq %rdx,%rcx /* compare remainder by bytes */ - andq $7,%rcx - repe - cmpsb - je L2 - -L1: incl %eax -L2: ret + movq %rdx, %rcx /* compare by longs, equality only */ + shrq $3, %rcx + jz 2f +1: + movq (%rdi), %rax + cmpq %rax, (%rsi) + jne 5f + decq %rcx + leaq 8(%rdi), %rdi + leaq 8(%rsi), %rsi + jnz 1b +2: + andl $7, %edx + jz 4f +3: + movb (%rdi), %al /* compare by chars, equality only */ + cmpb %al, (%rsi) + jne 5f + decl %edx + leaq 1(%rdi), %rdi + leaq 1(%rsi), %rsi + jnz 3b +4: + xorl %eax, %eax + ret +5: + movl $1, %eax + ret END(bcmp) Index: src/common/lib/libc/arch/x86_64/string/memcmp.S diff -u src/common/lib/libc/arch/x86_64/string/memcmp.S:1.3 src/common/lib/libc/arch/x86_64/string/memcmp.S:1.4 --- src/common/lib/libc/arch/x86_64/string/memcmp.S:1.3 Sat Mar 22 19:16:34 2014 +++ src/common/lib/libc/arch/x86_64/string/memcmp.S Wed Jan 15 10:56:49 2020 @@ -1,3 +1,34 @@ +/* $NetBSD: memcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: para Date: Sun Jan 12 20:00:41 UTC 2020 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: initialize radix_tree_node_cache with PR_LARGECACHE this increases the cache groups from 15 to 63 items in order to reduce traffic between pool cache layers this is the same as for other highly frequented pool caches as the pvpool and anonpool To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.20 src/common/lib/libc/gen/radixtree.c:1.21 --- src/common/lib/libc/gen/radixtree.c:1.20 Thu Dec 5 19:03:39 2019 +++ src/common/lib/libc/gen/radixtree.c Sun Jan 12 20:00:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.20 2019/12/05 19:03:39 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.21 2020/01/12 20:00:41 para Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.20 2019/12/05 19:03:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.21 2020/01/12 20:00:41 para Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.20 2019/12/05 19:03:39 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.21 2020/01/12 20:00:41 para Exp $"); #include #include #include @@ -345,7 +345,7 @@ radix_tree_init(void) { radix_tree_node_cache = pool_cache_init(sizeof(struct radix_tree_node), - coherency_unit, 0, 0, "radixnode", NULL, IPL_NONE, + coherency_unit, 0, PR_LARGECACHE, "radixnode", NULL, IPL_NONE, radix_tree_node_ctor, NULL, NULL); KASSERT(radix_tree_node_cache != NULL); }
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: ad Date: Thu Dec 5 19:03:39 UTC 2019 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: Fix warning that appears when compiling in kernel. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.19 src/common/lib/libc/gen/radixtree.c:1.20 --- src/common/lib/libc/gen/radixtree.c:1.19 Thu Dec 5 18:50:41 2019 +++ src/common/lib/libc/gen/radixtree.c Thu Dec 5 19:03:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.19 2019/12/05 18:50:41 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.20 2019/12/05 19:03:39 ad Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.19 2019/12/05 18:50:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.20 2019/12/05 19:03:39 ad Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.19 2019/12/05 18:50:41 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.20 2019/12/05 19:03:39 ad Exp $"); #include #include #include @@ -851,7 +851,9 @@ scan_siblings: } } if (i == guard) { +#if 0 no_siblings: +#endif /* 0 */ /* * not found. go to parent. */
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: ad Date: Thu Dec 5 18:50:41 UTC 2019 Modified Files: src/common/lib/libc/gen: radixtree.c Log Message: Delete the counter from "struct radix_tree_node", and in the one place we need a non-zero check, substitute with a deterministic bitwise OR of all values in the node. The structure then becomes cache line aligned. For each node we now need only touch 2 cache lines instead of 3, which makes all the operations faster (measured), amortises the cost of not having a counter, and will avoid intra-pool-page false sharing on MP. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/common/lib/libc/gen/radixtree.c 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/gen/radixtree.c diff -u src/common/lib/libc/gen/radixtree.c:1.18 src/common/lib/libc/gen/radixtree.c:1.19 --- src/common/lib/libc/gen/radixtree.c:1.18 Thu Dec 5 18:32:25 2019 +++ src/common/lib/libc/gen/radixtree.c Thu Dec 5 18:50:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: radixtree.c,v 1.18 2019/12/05 18:32:25 ad Exp $ */ +/* $NetBSD: radixtree.c,v 1.19 2019/12/05 18:50:41 ad Exp $ */ /*- * Copyright (c)2011,2012,2013 YAMAMOTO Takashi, @@ -112,7 +112,7 @@ #include #if defined(_KERNEL) || defined(_STANDALONE) -__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.18 2019/12/05 18:32:25 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.19 2019/12/05 18:50:41 ad Exp $"); #include #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c, #include #endif /* defined(_STANDALONE) */ #else /* defined(_KERNEL) || defined(_STANDALONE) */ -__RCSID("$NetBSD: radixtree.c,v 1.18 2019/12/05 18:32:25 ad Exp $"); +__RCSID("$NetBSD: radixtree.c,v 1.19 2019/12/05 18:50:41 ad Exp $"); #include #include #include @@ -185,11 +185,16 @@ entry_match_p(void *p, unsigned int tagm * radix_tree_node: an intermediate node * * we don't care the type of leaf nodes. they are just void *. + * + * we used to maintain a count of non-NULL nodes in this structure, but it + * prevented it from being aligned to a cache line boundary; the performance + * benefit from being cache friendly is greater than the benefit of having + * a dedicated count value, especially in multi-processor situations where + * we need to avoid intra-pool-page false sharing. */ struct radix_tree_node { void *n_ptrs[RADIX_TREE_PTR_PER_NODE]; - unsigned int n_nptrs; /* # of non-NULL pointers in n_ptrs */ }; /* @@ -340,8 +345,8 @@ radix_tree_init(void) { radix_tree_node_cache = pool_cache_init(sizeof(struct radix_tree_node), - 0, 0, 0, "radix_tree_node", NULL, IPL_NONE, radix_tree_node_ctor, - NULL, NULL); + coherency_unit, 0, 0, "radixnode", NULL, IPL_NONE, + radix_tree_node_ctor, NULL, NULL); KASSERT(radix_tree_node_cache != NULL); } #endif /* defined(_KERNEL) */ @@ -349,17 +354,57 @@ radix_tree_init(void) static bool __unused radix_tree_node_clean_p(const struct radix_tree_node *n) { +#if RADIX_TREE_PTR_PER_NODE > 16 unsigned int i; - if (n->n_nptrs != 0) { - return false; - } for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) { if (n->n_ptrs[i] != NULL) { return false; } } return true; +#else /* RADIX_TREE_PTR_PER_NODE > 16 */ + uintptr_t sum; + + /* + * Unrolling the above is much better than a tight loop with two + * test+branch pairs. On x86 with gcc 5.5.0 this compiles into 19 + * deterministic instructions including the "return" and prologue & + * epilogue. + */ + sum = (uintptr_t)n->n_ptrs[0]; + sum |= (uintptr_t)n->n_ptrs[1]; + sum |= (uintptr_t)n->n_ptrs[2]; + sum |= (uintptr_t)n->n_ptrs[3]; +#if RADIX_TREE_PTR_PER_NODE > 4 + sum |= (uintptr_t)n->n_ptrs[4]; + sum |= (uintptr_t)n->n_ptrs[5]; + sum |= (uintptr_t)n->n_ptrs[6]; + sum |= (uintptr_t)n->n_ptrs[7]; +#endif +#if RADIX_TREE_PTR_PER_NODE > 8 + sum |= (uintptr_t)n->n_ptrs[8]; + sum |= (uintptr_t)n->n_ptrs[9]; + sum |= (uintptr_t)n->n_ptrs[10]; + sum |= (uintptr_t)n->n_ptrs[11]; + sum |= (uintptr_t)n->n_ptrs[12]; + sum |= (uintptr_t)n->n_ptrs[13]; + sum |= (uintptr_t)n->n_ptrs[14]; + sum |= (uintptr_t)n->n_ptrs[15]; +#endif + return sum == 0; +#endif /* RADIX_TREE_PTR_PER_NODE > 16 */ +} + +static int __unused +radix_tree_node_count_ptrs(const struct radix_tree_node *n) +{ + unsigned int i, c; + + for (i = c = 0; i < RADIX_TREE_PTR_PER_NODE; i++) { + c += (n->n_ptrs[i] != NULL); + } + return c; } static struct radix_tree_node * @@ -421,7 +466,6 @@ radix_tree_grow(struct radix_tree *t, un */ return ENOMEM; } - n->n_nptrs = 1; n->n_ptrs[0] = t->t_root; t->t_root = entry_compose(n, tagmask); t->t_height++; @@ -516,10 +560,6 @@ radix_tree_lookup_ptr(struct radix_tree return NULL; } *vpp = c; - if (n != NULL) { -KASSERT(n->n_nptrs < RADIX_TREE_PTR_PER_NODE); -n->n_nptrs++; - } } n = c; vpp = >n_ptrs[i]; @@ -531,10
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: skrll Date: Thu May 9 10:56:24 UTC 2019 Modified Files: src/common/lib/libc/gen: rb.c Log Message: toolify PR/54182: Cross-building on Linux fails in rb.c To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/common/lib/libc/gen/rb.c 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/gen/rb.c diff -u src/common/lib/libc/gen/rb.c:1.14 src/common/lib/libc/gen/rb.c:1.15 --- src/common/lib/libc/gen/rb.c:1.14 Fri Mar 8 09:14:54 2019 +++ src/common/lib/libc/gen/rb.c Thu May 9 10:56:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rb.c,v 1.14 2019/03/08 09:14:54 roy Exp $ */ +/* $NetBSD: rb.c,v 1.15 2019/05/09 10:56:24 skrll Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -29,6 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #if !defined(_KERNEL) && !defined(_STANDALONE) #include #include @@ -41,10 +45,10 @@ #define KASSERT(s) do { } while (/*CONSTCOND*/ 0) #define __rbt_unused __unused #endif -__RCSID("$NetBSD: rb.c,v 1.14 2019/03/08 09:14:54 roy Exp $"); +__RCSID("$NetBSD: rb.c,v 1.15 2019/05/09 10:56:24 skrll Exp $"); #else #include -__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.14 2019/03/08 09:14:54 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.15 2019/05/09 10:56:24 skrll Exp $"); #ifndef DIAGNOSTIC #define __rbt_unused __unused #else
CVS commit: src/common/lib/libc/arch/riscv/atomic
Module Name:src Committed By: mrg Date: Wed Apr 17 07:40:35 UTC 2019 Modified Files: src/common/lib/libc/arch/riscv/atomic: Makefile.inc Log Message: add missing atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/riscv/atomic/Makefile.inc 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/riscv/atomic/Makefile.inc diff -u src/common/lib/libc/arch/riscv/atomic/Makefile.inc:1.2 src/common/lib/libc/arch/riscv/atomic/Makefile.inc:1.3 --- src/common/lib/libc/arch/riscv/atomic/Makefile.inc:1.2 Thu Oct 16 18:52:17 2014 +++ src/common/lib/libc/arch/riscv/atomic/Makefile.inc Wed Apr 17 07:40:34 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.2 2014/10/16 18:52:17 dennis Exp $ +# $NetBSD: Makefile.inc,v 1.3 2019/04/17 07:40:34 mrg Exp $ .for op in add and cas nand or sub swap xor sizes=32 @@ -27,4 +27,8 @@ SRCS.atomic+= atomic_init_cas.c \ .endif #LIB +.if ${LIB} == "c" +SRCS.atomic+= atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c +.endif + SRCS+= ${SRCS.atomic}
CVS commit: src/common/lib/libc/arch/riscv/atomic
Module Name:src Committed By: mrg Date: Wed Apr 17 07:35:38 UTC 2019 Modified Files: src/common/lib/libc/arch/riscv/atomic: atomic_cas_32.S Log Message: add missing aliases for _atomic_cas_32_ni and atomic_cas_uint_ni. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/riscv/atomic/atomic_cas_32.S 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/riscv/atomic/atomic_cas_32.S diff -u src/common/lib/libc/arch/riscv/atomic/atomic_cas_32.S:1.2 src/common/lib/libc/arch/riscv/atomic/atomic_cas_32.S:1.3 --- src/common/lib/libc/arch/riscv/atomic/atomic_cas_32.S:1.2 Fri Mar 27 06:42:37 2015 +++ src/common/lib/libc/arch/riscv/atomic/atomic_cas_32.S Wed Apr 17 07:35:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_32.S,v 1.2 2015/03/27 06:42:37 matt Exp $ */ +/* $NetBSD: atomic_cas_32.S,v 1.3 2019/04/17 07:35:38 mrg Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. * All rights reserved. @@ -43,6 +43,12 @@ END(_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) + +ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) +ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) + #ifndef _LP64 ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: jmcneill Date: Sat Mar 30 10:18:03 UTC 2019 Modified Files: src/common/lib/libc/string: memset.c Log Message: Fix typo: __aebi_memset -> __aeabi_memset To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/common/lib/libc/string/memset.c 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/string/memset.c diff -u src/common/lib/libc/string/memset.c:1.11 src/common/lib/libc/string/memset.c:1.12 --- src/common/lib/libc/string/memset.c:1.11 Tue Feb 6 09:28:48 2018 +++ src/common/lib/libc/string/memset.c Sat Mar 30 10:18:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: memset.c,v 1.11 2018/02/06 09:28:48 mrg Exp $ */ +/* $NetBSD: memset.c,v 1.12 2019/03/30 10:18:03 jmcneill Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: memset.c,v 1.11 2018/02/06 09:28:48 mrg Exp $"); +__RCSID("$NetBSD: memset.c,v 1.12 2019/03/30 10:18:03 jmcneill Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -80,8 +80,8 @@ bzero(void *dst0, size_t length) void __aeabi_memset(void *, size_t, int); void __aeabi_memclr(void *, size_t); -__strong_alias(__aeabi_memset4, __aebi_memset) -__strong_alias(__aeabi_memset8, __aebi_memset) +__strong_alias(__aeabi_memset4, __aeabi_memset) +__strong_alias(__aeabi_memset8, __aeabi_memset) void __aeabi_memset(void *dst0, size_t length, int c)
CVS commit: src/common/lib/libc/gen
Module Name:src Committed By: roy Date: Fri Mar 8 09:14:54 UTC 2019 Modified Files: src/common/lib/libc/gen: rb.c Log Message: rbtree: Add a define to mark function arguments as unused for non debug This allows rbtree to be used outside of NetBSD without any compile warnings and removes the need for the lint comment. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/common/lib/libc/gen/rb.c 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/gen/rb.c diff -u src/common/lib/libc/gen/rb.c:1.13 src/common/lib/libc/gen/rb.c:1.14 --- src/common/lib/libc/gen/rb.c:1.13 Fri Aug 22 17:19:48 2014 +++ src/common/lib/libc/gen/rb.c Fri Mar 8 09:14:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rb.c,v 1.13 2014/08/22 17:19:48 matt Exp $ */ +/* $NetBSD: rb.c,v 1.14 2019/03/08 09:14:54 roy Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -36,13 +36,20 @@ #include #ifdef RBDEBUG #define KASSERT(s) assert(s) +#define __rbt_unused #else #define KASSERT(s) do { } while (/*CONSTCOND*/ 0) +#define __rbt_unused __unused #endif -__RCSID("$NetBSD: rb.c,v 1.13 2014/08/22 17:19:48 matt Exp $"); +__RCSID("$NetBSD: rb.c,v 1.14 2019/03/08 09:14:54 roy Exp $"); #else #include -__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.13 2014/08/22 17:19:48 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.14 2019/03/08 09:14:54 roy Exp $"); +#ifndef DIAGNOSTIC +#define __rbt_unused __unused +#else +#define __rbt_unused +#endif #endif #ifdef _LIBC @@ -313,10 +320,9 @@ rb_tree_insert_node(struct rb_tree *rbt, * removal since rotation almost always involves the exchanging of colors * as a separate step. */ -/*ARGSUSED*/ static void -rb_tree_reparent_nodes(struct rb_tree *rbt, struct rb_node *old_father, - const unsigned int which) +rb_tree_reparent_nodes(__rbt_unused struct rb_tree *rbt, + struct rb_node *old_father, const unsigned int which) { const unsigned int other = which ^ RB_DIR_OTHER; struct rb_node * const grandpa = RB_FATHER(old_father);
CVS commit: src/common/lib/libc/atomic
Module Name:src Committed By: isaki Date: Fri Mar 1 09:57:32 UTC 2019 Modified Files: src/common/lib/libc/atomic: atomic_or_16_cas.c atomic_or_8_cas.c Log Message: Fix return value. or_and_fetch should return new value. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/atomic/atomic_or_16_cas.c \ src/common/lib/libc/atomic/atomic_or_8_cas.c 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/atomic/atomic_or_16_cas.c diff -u src/common/lib/libc/atomic/atomic_or_16_cas.c:1.3 src/common/lib/libc/atomic/atomic_or_16_cas.c:1.4 --- src/common/lib/libc/atomic/atomic_or_16_cas.c:1.3 Mon Jun 23 21:53:45 2014 +++ src/common/lib/libc/atomic/atomic_or_16_cas.c Fri Mar 1 09:57:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_16_cas.c,v 1.3 2014/06/23 21:53:45 joerg Exp $ */ +/* $NetBSD: atomic_or_16_cas.c,v 1.4 2019/03/01 09:57:32 isaki Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ or_and_fetch_2(volatile uint16_t *addr, old = *addr; new = old | val; } while (atomic_cas_16(addr, old, new) != old); - return old; + return new; } __strong_alias(__atomic_fetch_or_2,__sync_fetch_and_or_2) Index: src/common/lib/libc/atomic/atomic_or_8_cas.c diff -u src/common/lib/libc/atomic/atomic_or_8_cas.c:1.3 src/common/lib/libc/atomic/atomic_or_8_cas.c:1.4 --- src/common/lib/libc/atomic/atomic_or_8_cas.c:1.3 Mon Jun 23 21:53:45 2014 +++ src/common/lib/libc/atomic/atomic_or_8_cas.c Fri Mar 1 09:57:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_8_cas.c,v 1.3 2014/06/23 21:53:45 joerg Exp $ */ +/* $NetBSD: atomic_or_8_cas.c,v 1.4 2019/03/01 09:57:32 isaki Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ or_and_fetch_1(volatile uint8_t *addr, u old = *addr; new = old | val; } while (atomic_cas_8(addr, old, new) != old); - return old; + return new; } __strong_alias(__atomic_fetch_or_1,__sync_fetch_and_or_1)
CVS commit: src/common/lib/libc/atomic
Module Name:src Committed By: isaki Date: Fri Mar 1 06:14:52 UTC 2019 Modified Files: src/common/lib/libc/atomic: atomic_nand_16_cas.c atomic_nand_32_cas.c atomic_nand_8_cas.c Log Message: Add missing alias for __atomic_fetch_nand_N. XXX I'm not sure why does llvm/sparc call __atomic instead of __sync though. XXX atomic_*_cas.c should be more symmetric... To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/atomic/atomic_nand_16_cas.c \ src/common/lib/libc/atomic/atomic_nand_8_cas.c cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/atomic/atomic_nand_32_cas.c 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/atomic/atomic_nand_16_cas.c diff -u src/common/lib/libc/atomic/atomic_nand_16_cas.c:1.2 src/common/lib/libc/atomic/atomic_nand_16_cas.c:1.3 --- src/common/lib/libc/atomic/atomic_nand_16_cas.c:1.2 Fri Feb 21 16:06:48 2014 +++ src/common/lib/libc/atomic/atomic_nand_16_cas.c Fri Mar 1 06:14:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_16_cas.c,v 1.2 2014/02/21 16:06:48 martin Exp $ */ +/* $NetBSD: atomic_nand_16_cas.c,v 1.3 2019/03/01 06:14:52 isaki Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -61,3 +61,5 @@ nand_and_fetch_2(volatile uint16_t *addr } while (atomic_cas_16(addr, old, new) != old); return new; } + +__strong_alias(__atomic_fetch_nand_2,__sync_fetch_and_nand_2) Index: src/common/lib/libc/atomic/atomic_nand_8_cas.c diff -u src/common/lib/libc/atomic/atomic_nand_8_cas.c:1.2 src/common/lib/libc/atomic/atomic_nand_8_cas.c:1.3 --- src/common/lib/libc/atomic/atomic_nand_8_cas.c:1.2 Fri Feb 21 16:06:48 2014 +++ src/common/lib/libc/atomic/atomic_nand_8_cas.c Fri Mar 1 06:14:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_8_cas.c,v 1.2 2014/02/21 16:06:48 martin Exp $ */ +/* $NetBSD: atomic_nand_8_cas.c,v 1.3 2019/03/01 06:14:52 isaki Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -61,3 +61,5 @@ nand_and_fetch_1(volatile uint8_t *addr, } while (atomic_cas_8(addr, old, new) != old); return new; } + +__strong_alias(__atomic_fetch_nand_1,__sync_fetch_and_nand_1) Index: src/common/lib/libc/atomic/atomic_nand_32_cas.c diff -u src/common/lib/libc/atomic/atomic_nand_32_cas.c:1.1 src/common/lib/libc/atomic/atomic_nand_32_cas.c:1.2 --- src/common/lib/libc/atomic/atomic_nand_32_cas.c:1.1 Fri Feb 21 10:52:50 2014 +++ src/common/lib/libc/atomic/atomic_nand_32_cas.c Fri Mar 1 06:14:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_nand_32_cas.c,v 1.1 2014/02/21 10:52:50 martin Exp $ */ +/* $NetBSD: atomic_nand_32_cas.c,v 1.2 2019/03/01 06:14:52 isaki Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -59,3 +59,5 @@ nand_and_fetch_4(volatile uint32_t *addr } while (atomic_cas_32(addr, old, new) != old); return new; } + +__strong_alias(__atomic_fetch_nand_4,__sync_fetch_and_nand_4)
CVS commit: src/common/lib/libc/arch
Module Name:src Committed By: isaki Date: Thu Feb 28 02:35:38 UTC 2019 Modified Files: src/common/lib/libc/arch/hppa/atomic: Makefile.inc src/common/lib/libc/arch/m68k/atomic: Makefile.inc src/common/lib/libc/arch/mips/atomic: Makefile.inc src/common/lib/libc/arch/sh3/atomic: Makefile.inc src/common/lib/libc/arch/sparc/atomic: Makefile.inc src/common/lib/libc/arch/vax/atomic: Makefile.inc Log Message: Add missing atomic_and_{8,16}_nv_cas.c for __sync_and_and_fetch_{1,2}. XXX why is not only atomic_and_* symmetric unlike the others? (in common/lib/libc/atomic/) To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/common/lib/libc/arch/hppa/atomic/Makefile.inc cvs rdiff -u -r1.14 -r1.15 src/common/lib/libc/arch/m68k/atomic/Makefile.inc cvs rdiff -u -r1.13 -r1.14 src/common/lib/libc/arch/mips/atomic/Makefile.inc cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/sh3/atomic/Makefile.inc cvs rdiff -u -r1.22 -r1.23 src/common/lib/libc/arch/sparc/atomic/Makefile.inc cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/vax/atomic/Makefile.inc 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/hppa/atomic/Makefile.inc diff -u src/common/lib/libc/arch/hppa/atomic/Makefile.inc:1.13 src/common/lib/libc/arch/hppa/atomic/Makefile.inc:1.14 --- src/common/lib/libc/arch/hppa/atomic/Makefile.inc:1.13 Tue Oct 14 07:25:05 2014 +++ src/common/lib/libc/arch/hppa/atomic/Makefile.inc Thu Feb 28 02:35:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.13 2014/10/14 07:25:05 martin Exp $ +# $NetBSD: Makefile.inc,v 1.14 2019/02/28 02:35:37 isaki Exp $ .if defined(LIB) @@ -30,6 +30,7 @@ SRCS+= atomic_xor_32_cas.c atomic_xor_16 atomic_nand_32_cas.c atomic_nand_16_cas.c atomic_nand_8_cas.c \ atomic_or_16_cas.c atomic_or_8_cas.c\ atomic_and_16_cas.c atomic_and_8_cas.c\ + atomic_and_16_nv_cas.c atomic_and_8_nv_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 \ Index: src/common/lib/libc/arch/m68k/atomic/Makefile.inc diff -u src/common/lib/libc/arch/m68k/atomic/Makefile.inc:1.14 src/common/lib/libc/arch/m68k/atomic/Makefile.inc:1.15 --- src/common/lib/libc/arch/m68k/atomic/Makefile.inc:1.14 Thu Nov 20 07:07:13 2014 +++ src/common/lib/libc/arch/m68k/atomic/Makefile.inc Thu Feb 28 02:35:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.14 2014/11/20 07:07:13 matt Exp $ +# $NetBSD: Makefile.inc,v 1.15 2019/02/28 02:35:37 isaki Exp $ # # Note: The atomic operations here in these assembly files are atomic @@ -30,6 +30,7 @@ SRCS+= atomic_add_16_cas.c atomic_add_8 atomic_nand_32_cas.c atomic_nand_16_cas.c atomic_nand_8_cas.c \ atomic_xor_32_cas.c atomic_xor_16_cas.c atomic_xor_8_cas.c \ atomic_and_32_cas.c atomic_and_16_cas.c atomic_and_8_cas.c \ + atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c \ atomic_or_32_cas.c atomic_or_16_cas.c atomic_or_8_cas.c \ atomic_cas_32_cas.c atomic_cas_16_cas.c atomic_cas_8_cas.c \ atomic_swap_32_cas.c atomic_swap_16_cas.c atomic_swap_8_cas.c Index: src/common/lib/libc/arch/mips/atomic/Makefile.inc diff -u src/common/lib/libc/arch/mips/atomic/Makefile.inc:1.13 src/common/lib/libc/arch/mips/atomic/Makefile.inc:1.14 --- src/common/lib/libc/arch/mips/atomic/Makefile.inc:1.13 Mon Oct 13 13:00:55 2014 +++ src/common/lib/libc/arch/mips/atomic/Makefile.inc Thu Feb 28 02:35:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.13 2014/10/13 13:00:55 martin Exp $ +# $NetBSD: Makefile.inc,v 1.14 2019/02/28 02:35:37 isaki Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ || ${LIB} == "rump") @@ -44,6 +44,7 @@ SRCS+= atomic_xor_32_cas.c atomic_xor_16 atomic_nand_32_cas.c atomic_nand_16_cas.c atomic_nand_8_cas.c \ atomic_or_16_cas.c atomic_or_8_cas.c\ atomic_and_16_cas.c atomic_and_8_cas.c\ + atomic_and_16_nv_cas.c atomic_and_8_nv_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 \ Index: src/common/lib/libc/arch/sh3/atomic/Makefile.inc diff -u src/common/lib/libc/arch/sh3/atomic/Makefile.inc:1.7 src/common/lib/libc/arch/sh3/atomic/Makefile.inc:1.8 --- src/common/lib/libc/arch/sh3/atomic/Makefile.inc:1.7 Mon Oct 13 13:00:55 2014 +++ src/common/lib/libc/arch/sh3/atomic/Makefile.inc Thu Feb 28 02:35:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.7 2014/10/13 13:00:55 martin Exp $ +# $NetBSD: Makefile.inc,v 1.8 2019/02/28 02:35:37 isaki Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ || ${LIB} == "rump") @@ -12,6 +12,7 @@ SRCS+= atomic_add_32_cas.c atomic_add_32 SRCS+= atomic_add_16_cas.c atomic_add_8_cas.c \ atomic_sub_32_cas.c atomic_sub_16_cas.c atomic_sub_8_cas.c \
CVS commit: src/common/lib/libc/arch/mips/atomic
Module Name:src Committed By: rin Date: Wed Feb 20 05:25:12 UTC 2019 Modified Files: src/common/lib/libc/arch/mips/atomic: atomic_cas.S Log Message: Export atomic_cas_32_ni in a similar manner to its 64-bit counterpart. Compile test only, but seems trivial enough for me. Fix build error due to test/lib/libc/atomic/t_atomic_cas. Note that mips32 does not use atomic_cas.S. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/arch/mips/atomic/atomic_cas.S 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/mips/atomic/atomic_cas.S diff -u src/common/lib/libc/arch/mips/atomic/atomic_cas.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_cas.S:1.6 --- src/common/lib/libc/arch/mips/atomic/atomic_cas.S:1.5 Tue Feb 19 18:17:45 2019 +++ src/common/lib/libc/arch/mips/atomic/atomic_cas.S Wed Feb 20 05:25:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas.S,v 1.5 2019/02/19 18:17:45 martin Exp $ */ +/* $NetBSD: atomic_cas.S,v 1.6 2019/02/20 05:25:12 rin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_cas.S,v 1.5 2019/02/19 18:17:45 martin Exp $") +RCSID("$NetBSD: atomic_cas.S,v 1.6 2019/02/20 05:25:12 rin Exp $") .text .set noat @@ -54,6 +54,7 @@ LEAF(_atomic_cas_32) nop END(_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_32, _atomic_cas_32) +ATOMIC_OP_ALIAS(atomic_cas_32_ni, _atomic_cas_32) #if !defined(__mips_o32) LEAF(_atomic_cas_64)
CVS commit: src/common/lib/libc/arch/mips/atomic
Module Name:src Committed By: martin Date: Tue Feb 19 18:17:46 UTC 2019 Modified Files: src/common/lib/libc/arch/mips/atomic: atomic_cas.S Log Message: Add atomic_cas_64_ni alias To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/mips/atomic/atomic_cas.S 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/mips/atomic/atomic_cas.S diff -u src/common/lib/libc/arch/mips/atomic/atomic_cas.S:1.4 src/common/lib/libc/arch/mips/atomic/atomic_cas.S:1.5 --- src/common/lib/libc/arch/mips/atomic/atomic_cas.S:1.4 Mon Jun 1 23:16:54 2015 +++ src/common/lib/libc/arch/mips/atomic/atomic_cas.S Tue Feb 19 18:17:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas.S,v 1.4 2015/06/01 23:16:54 matt Exp $ */ +/* $NetBSD: atomic_cas.S,v 1.5 2019/02/19 18:17:45 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_cas.S,v 1.4 2015/06/01 23:16:54 matt Exp $") +RCSID("$NetBSD: atomic_cas.S,v 1.5 2019/02/19 18:17:45 martin Exp $") .text .set noat @@ -74,6 +74,7 @@ LEAF(_atomic_cas_64) nop END(_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_64, _atomic_cas_64) +ATOMIC_OP_ALIAS(atomic_cas_64_ni, _atomic_cas_64) #endif #ifdef _LP64
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: rin Date: Tue Feb 19 12:51:44 UTC 2019 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_cas_64.S Log Message: Sort STRONG_ALIAS's in the same manner as ATOMIC_OP_ALIAS's. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S 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/aarch64/atomic/atomic_cas_64.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.2 Tue Feb 19 12:47:36 2019 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S Tue Feb 19 12:51:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_64.S,v 1.2 2019/02/19 12:47:36 rin Exp $ */ +/* $NetBSD: atomic_cas_64.S,v 1.3 2019/02/19 12:51:44 rin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_ato ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64) STRONG_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64) STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) +STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64) -STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64) STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64) -STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) +STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: rin Date: Tue Feb 19 12:47:36 UTC 2019 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_cas_64.S Log Message: Export _atomic_cas_64 as atomic_cas_64_ni. Note that _atomic_cas_64 is already exported as atomic_cas_{ulong,prt}_ni. Fix build error of test/lib/atomic/t_atomic_cas, which is successfully passed on RPI3B+ now. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S 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/aarch64/atomic/atomic_cas_64.S diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.2 --- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S Tue Feb 19 12:47:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_64.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: atomic_cas_64.S,v 1.2 2019/02/19 12:47:36 rin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -45,6 +45,7 @@ END(_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64) +ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64) STRONG_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64)
CVS commit: src/common/lib/libc
Module Name:src Committed By: martin Date: Mon Feb 18 11:22:56 UTC 2019 Modified Files: src/common/lib/libc/arch/arm/atomic: atomic_cas_64.S src/common/lib/libc/atomic: atomic_init_testset.c Log Message: Add some atomic_cas_64_ni aliases To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 \ src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S cvs rdiff -u -r1.15 -r1.16 src/common/lib/libc/atomic/atomic_init_testset.c 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/atomic_cas_64.S diff -u src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S:1.10 src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S:1.11 --- src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S:1.10 Wed Mar 5 17:20:48 2014 +++ src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S Mon Feb 18 11:22:56 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas_64.S,v 1.10 2014/03/05 17:20:48 matt Exp $ */ +/* $NetBSD: atomic_cas_64.S,v 1.11 2019/02/18 11:22:56 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -70,6 +70,8 @@ ENTRY_NP(_atomic_cas_64) END(_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) +ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64) +STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64) CRT_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64) #endif /* _ARM_ARCH_6 */ Index: src/common/lib/libc/atomic/atomic_init_testset.c diff -u src/common/lib/libc/atomic/atomic_init_testset.c:1.15 src/common/lib/libc/atomic/atomic_init_testset.c:1.16 --- src/common/lib/libc/atomic/atomic_init_testset.c:1.15 Thu Feb 27 09:39:00 2014 +++ src/common/lib/libc/atomic/atomic_init_testset.c Mon Feb 18 11:22:56 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_init_testset.c,v 1.15 2014/02/27 09:39:00 matt Exp $ */ +/* $NetBSD: atomic_init_testset.c,v 1.16 2019/02/18 11:22:56 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: atomic_init_testset.c,v 1.15 2014/02/27 09:39:00 matt Exp $"); +__RCSID("$NetBSD: atomic_init_testset.c,v 1.16 2019/02/18 11:22:56 martin Exp $"); #include "atomic_op_namespace.h" @@ -354,7 +354,8 @@ __strong_alias(_atomic_cas_ptr_ni,_atomi //atomic_op_alias(atomic_cas_8,_atomic_cas_8) //atomic_op_alias(atomic_cas_8_ni,_atomic_cas_8) #ifdef __HAVE_ATOMIC_CAS_64_UP -//atomic_op_alias(atomic_cas_64_ni,_atomic_cas_64) +atomic_op_alias(atomic_cas_64_ni,_atomic_cas_64) +__strong_alias(_atomic_cas_64_ni,_atomic_cas_64) crt_alias(__sync_val_compare_and_swap_8,_atomic_cas_64) #endif crt_alias(__sync_val_compare_and_swap_4,_atomic_cas_32)
CVS commit: src/common/lib/libc/arch/x86_64/atomic
Module Name:src Committed By: isaki Date: Sun Feb 17 07:34:44 UTC 2019 Modified Files: src/common/lib/libc/arch/x86_64/atomic: atomic.S Log Message: Add missing export of atomic_or_64 (since rev1.1). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/common/lib/libc/arch/x86_64/atomic/atomic.S 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/x86_64/atomic/atomic.S diff -u src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.17 src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.18 --- src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.17 Thu May 22 15:23:11 2014 +++ src/common/lib/libc/arch/x86_64/atomic/atomic.S Sun Feb 17 07:34:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.17 2014/05/22 15:23:11 uebayasi Exp $ */ +/* $NetBSD: atomic.S,v 1.18 2019/02/17 07:34:44 isaki Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -345,6 +345,7 @@ ALIAS(atomic_inc_ulong_nv,_atomic_inc_64 ALIAS(atomic_inc_ptr_nv,_atomic_inc_64_nv) ALIAS(atomic_or_32,_atomic_or_32) +ALIAS(atomic_or_64,_atomic_or_64) ALIAS(atomic_or_uint,_atomic_or_32) ALIAS(atomic_or_ulong,_atomic_or_64) ALIAS(atomic_or_ptr,_atomic_or_64)
CVS commit: src/common/lib/libc/misc
Module Name:src Committed By: kamil Date: Wed Feb 13 17:17:02 UTC 2019 Modified Files: src/common/lib/libc/misc: ubsan.c Log Message: Fix kUBSan build with GCC7 Add missing __unreachable() and FALLTHROUGH keywords. Reported by To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/misc/ubsan.c 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/misc/ubsan.c diff -u src/common/lib/libc/misc/ubsan.c:1.4 src/common/lib/libc/misc/ubsan.c:1.5 --- src/common/lib/libc/misc/ubsan.c:1.4 Mon Feb 4 22:07:41 2019 +++ src/common/lib/libc/misc/ubsan.c Wed Feb 13 17:17:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $ */ +/* $NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,9 +38,9 @@ #include #if defined(_KERNEL) -__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $"); #else -__RCSID("$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $"); +__RCSID("$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $"); #endif #if defined(_KERNEL) @@ -110,7 +110,7 @@ __RCSID("$NetBSD: ubsan.c,v 1.4 2019/02/ #define NUMBER_SIGNED_BIT 1U -#if __SIZEOF_INT128__ +#ifdef __SIZEOF_INT128__ typedef __int128 longest; typedef unsigned __int128 ulongest; #else @@ -1192,6 +1192,7 @@ Report(bool isFatal, const char *pFormat } if (isFatal || ISSET(ubsan_flags, UBSAN_ABORT)) { abort(); + __unreachable(); /* NOTREACHED */ } #endif @@ -1291,6 +1292,7 @@ DeserializeNumberSigned(char *pBuffer, s switch (zDeserializeTypeWidth(pType)) { default: ASSERT(0 && "Invalid codepath"); + __unreachable(); /* NOTREACHED */ #ifdef __SIZEOF_INT128__ case WIDTH_128: @@ -1298,8 +1300,11 @@ DeserializeNumberSigned(char *pBuffer, s break; #endif case WIDTH_64: + /* FALLTHROUGH */ case WIDTH_32: + /* FALLTHROUGH */ case WIDTH_16: + /* FALLTHROUGH */ case WIDTH_8: snprintf(pBuffer, zBUfferLength, "%" PRId64, STATIC_CAST(int64_t, L)); break; @@ -1318,6 +1323,7 @@ DeserializeNumberUnsigned(char *pBuffer, switch (zDeserializeTypeWidth(pType)) { default: ASSERT(0 && "Invalid codepath"); + __unreachable(); /* NOTREACHED */ #ifdef __SIZEOF_INT128__ case WIDTH_128: @@ -1325,8 +1331,11 @@ DeserializeNumberUnsigned(char *pBuffer, break; #endif case WIDTH_64: + /* FALLTHROUGH */ case WIDTH_32: + /* FALLTHROUGH */ case WIDTH_16: + /* FALLTHROUGH */ case WIDTH_8: snprintf(pBuffer, zBUfferLength, "%" PRIu64, STATIC_CAST(uint64_t, L)); break; @@ -1358,7 +1367,9 @@ DeserializeFloatOverPointer(char *pBuffe switch (zDeserializeTypeWidth(pType)) { #ifdef __HAVE_LONG_DOUBLE case WIDTH_128: + /* FALLTHROUGH */ case WIDTH_96: + /* FALLTHROUGH */ case WIDTH_80: memcpy(, pNumber, sizeof(long double)); snprintf(pBuffer, zBUfferLength, "%Lg", LD); @@ -1512,7 +1523,9 @@ DeserializeNumberFloat(char *szLocation, /* NOTREACHED */ #ifdef __HAVE_LONG_DOUBLE case WIDTH_128: + /* FALLTHROUGH */ case WIDTH_96: + /* FALLTHROUGH */ case WIDTH_80: DeserializeFloatOverPointer(pBuffer, zBUfferLength, pType, REINTERPRET_CAST(unsigned long *, ulNumber)); break; @@ -1524,6 +1537,7 @@ DeserializeNumberFloat(char *szLocation, } /* FALLTHROUGH */ case WIDTH_32: + /* FALLTHROUGH */ case WIDTH_16: DeserializeFloatInlined(pBuffer, zBUfferLength, pType, ulNumber); break;
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: ryo Date: Fri Feb 8 06:56:56 UTC 2019 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h Log Message: - atomic_*_{8,16}_nv() must return a new value, not an old value. - use "dmb sy" for atomic_*{8,16}_nv() in the same way as atomic_*{32,64}_nv(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/common/lib/libc/arch/aarch64/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/aarch64/atomic/atomic_op_asm.h diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.3 --- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.2 Wed Feb 6 05:33:14 2019 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h Fri Feb 8 06:56:56 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_op_asm.h,v 1.2 2019/02/06 05:33:14 ryo Exp $ */ +/* $NetBSD: atomic_op_asm.h,v 1.3 2019/02/08 06:56:56 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -49,10 +49,10 @@ END(_atomic_##OP##_8) ENTRY_NP(_atomic_##OP##_8_nv) ;\ mov x4, x0 /* need r0 for return value */ ;\ 1: ldxrb w0, [x4] /* load old value */ ;\ - INSN w2, w0, w1 /* calc new (return) value */ ;\ - stxrb w3, w2, [x4] /* try to store */ ;\ + INSN w0, w0, w1 /* calc new (return) value */ ;\ + stxrb w3, w0, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb st ;\ + dmb sy ;\ ret/* return new value */ ;\ END(_atomic_##OP##_8_nv) @@ -71,10 +71,10 @@ END(_atomic_##OP##_16) ENTRY_NP(_atomic_##OP##_16_nv) ;\ mov x4, x0 /* need r0 for return value */ ;\ 1: ldxrh w0, [x4] /* load old value */ ;\ - INSN w2, w0, w1 /* calc new (return) value */ ;\ - stxrh w3, w2, [x4] /* try to store */ ;\ + INSN w0, w0, w1 /* calc new (return) value */ ;\ + stxrh w3, w0, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ - dmb st ;\ + dmb sy ;\ ret/* return new value */ ;\ END(_atomic_##OP##_16_nv)
CVS commit: src/common/lib/libc/arch/aarch64/atomic
Module Name:src Committed By: ryo Date: Wed Feb 6 05:33:14 UTC 2019 Modified Files: src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h Log Message: fix atomic_sub_*(). it was (delta - *ptr), should be (*ptr - delta). changing shared macro doesn't effect other atomic_ops because (*ptr [+|^] delta) and (delta [+|^] *ptr) have same result. atomic_sub_*() haven't used because non standard API? To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/common/lib/libc/arch/aarch64/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/aarch64/atomic/atomic_op_asm.h diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.2 --- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h Wed Feb 6 05:33:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_op_asm.h,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: atomic_op_asm.h,v 1.2 2019/02/06 05:33:14 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ ENTRY_NP(_atomic_##OP##_8) ;\ mov x4, x0 ;\ 1: ldxrb w0, [x4] /* load old value */ ;\ - INSN w2, w1, w0 /* calculate new value */ ;\ + INSN w2, w0, w1 /* calculate new value */ ;\ stxrb w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ dmb st ;\ @@ -49,7 +49,7 @@ END(_atomic_##OP##_8) ENTRY_NP(_atomic_##OP##_8_nv) ;\ mov x4, x0 /* need r0 for return value */ ;\ 1: ldxrb w0, [x4] /* load old value */ ;\ - INSN w2, w1, w0 /* calc new (return) value */ ;\ + INSN w2, w0, w1 /* calc new (return) value */ ;\ stxrb w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ dmb st ;\ @@ -60,7 +60,7 @@ END(_atomic_##OP##_8_nv) ENTRY_NP(_atomic_##OP##_16) ;\ mov x4, x0 ;\ 1: ldxrh w0, [x4] /* load old value */ ;\ - INSN w2, w1, w0 /* calculate new value */ ;\ + INSN w2, w0, w1 /* calculate new value */ ;\ stxrh w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ dmb st ;\ @@ -71,7 +71,7 @@ END(_atomic_##OP##_16) ENTRY_NP(_atomic_##OP##_16_nv) ;\ mov x4, x0 /* need r0 for return value */ ;\ 1: ldxrh w0, [x4] /* load old value */ ;\ - INSN w2, w1, w0 /* calc new (return) value */ ;\ + INSN w2, w0, w1 /* calc new (return) value */ ;\ stxrh w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ dmb st ;\ @@ -82,7 +82,7 @@ END(_atomic_##OP##_16_nv) ENTRY_NP(_atomic_##OP##_32) ;\ mov x4, x0 ;\ 1: ldxr w0, [x4] /* load old value */ ;\ - INSN w2, w1, w0 /* calculate new value */ ;\ + INSN w2, w0, w1 /* calculate new value */ ;\ stxr w3, w2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ dmb st ;\ @@ -104,7 +104,7 @@ END(_atomic_##OP##_32_nv) ENTRY_NP(_atomic_##OP##_64) ;\ mov x4, x0 ;\ 1: ldxr x0, [x4] /* load old value */ ;\ - INSN x2, x1, x0 /* calculate new value */ ;\ + INSN x2, x0, x1 /* calculate new value */ ;\ stxr w3, x2, [x4] /* try to store */ ;\ cbnz w3, 1b /* succeed? no, try again */ ;\ dmb st ;\
CVS commit: src/common/lib/libc/misc
Module Name:src Committed By: mrg Date: Mon Feb 4 22:07:41 UTC 2019 Modified Files: src/common/lib/libc/misc: ubsan.c Log Message: - use __unreachable() and move 'break's around to increase consistency and correctness ok kamil@ To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/misc/ubsan.c 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/misc/ubsan.c diff -u src/common/lib/libc/misc/ubsan.c:1.3 src/common/lib/libc/misc/ubsan.c:1.4 --- src/common/lib/libc/misc/ubsan.c:1.3 Fri Aug 3 16:31:04 2018 +++ src/common/lib/libc/misc/ubsan.c Mon Feb 4 22:07:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $ */ +/* $NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,9 +38,9 @@ #include #if defined(_KERNEL) -__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $"); #else -__RCSID("$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $"); +__RCSID("$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $"); #endif #if defined(_KERNEL) @@ -1236,6 +1236,7 @@ zDeserializeTypeWidth(struct CTypeDescri break; default: Report(true, "UBSan: Unknown variable type %#04" PRIx16 "\n", pType->mTypeKind); + __unreachable(); /* NOTREACHED */ } @@ -1418,15 +1419,17 @@ llliGetNumber(char *szLocation, struct C switch (zNumberWidth) { default: Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation); + __unreachable(); /* NOTREACHED */ case WIDTH_128: #ifdef __SIZEOF_INT128__ memcpy(, REINTERPRET_CAST(longest *, ulNumber), sizeof(longest)); + break; #else Report(true, "UBSan: Unexpected 128-Bit Type in %s\n", szLocation); + __unreachable(); /* NOTREACHED */ #endif - break; case WIDTH_64: if (sizeof(ulNumber) * CHAR_BIT < WIDTH_64) { L = *REINTERPRET_CAST(int64_t *, ulNumber); @@ -1460,6 +1463,7 @@ llluGetNumber(char *szLocation, struct C switch (zNumberWidth) { default: Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation); + __unreachable(); /* NOTREACHED */ case WIDTH_128: #ifdef __SIZEOF_INT128__ @@ -1467,6 +1471,7 @@ llluGetNumber(char *szLocation, struct C break; #else Report(true, "UBSan: Unexpected 128-Bit Type in %s\n", szLocation); + __unreachable(); /* NOTREACHED */ #endif case WIDTH_64: @@ -1503,6 +1508,7 @@ DeserializeNumberFloat(char *szLocation, switch (zNumberWidth) { default: Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation); + __unreachable(); /* NOTREACHED */ #ifdef __HAVE_LONG_DOUBLE case WIDTH_128: @@ -1516,6 +1522,7 @@ DeserializeNumberFloat(char *szLocation, DeserializeFloatOverPointer(pBuffer, zBUfferLength, pType, REINTERPRET_CAST(unsigned long *, ulNumber)); break; } + /* FALLTHROUGH */ case WIDTH_32: case WIDTH_16: DeserializeFloatInlined(pBuffer, zBUfferLength, pType, ulNumber); @@ -1546,15 +1553,16 @@ DeserializeNumber(char *szLocation, char case KIND_FLOAT: #ifdef _KERNEL Report(true, "UBSan: Unexpected Float Type in %s\n", szLocation); + __unreachable(); /* NOTREACHED */ #else DeserializeNumberFloat(szLocation, pBuffer, zBUfferLength, pType, ulNumber); -#endif break; +#endif case KIND_UNKNOWN: Report(true, "UBSan: Unknown Type in %s\n", szLocation); + __unreachable(); /* NOTREACHED */ - break; } }
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: christos Date: Mon Oct 15 19:32:48 UTC 2018 Modified Files: src/common/lib/libc/string: memmem.c Log Message: use postincrement, like the patch XXX: pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/string/memmem.c 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/string/memmem.c diff -u src/common/lib/libc/string/memmem.c:1.2 src/common/lib/libc/string/memmem.c:1.3 --- src/common/lib/libc/string/memmem.c:1.2 Mon Oct 15 14:37:19 2018 +++ src/common/lib/libc/string/memmem.c Mon Oct 15 15:32:48 2018 @@ -25,7 +25,7 @@ #if 0 __FBSDID("$FreeBSD: head/lib/libc/string/memmem.c 315468 2017-03-18 00:53:24Z emaste $"); #else -__RCSID("$NetBSD: memmem.c,v 1.2 2018/10/15 18:37:19 christos Exp $"); +__RCSID("$NetBSD: memmem.c,v 1.3 2018/10/15 19:32:48 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -40,7 +40,7 @@ static char *twobyte_memmem(const unsign const unsigned char *n) { uint16_t nw = n[0] << 8 | n[1], hw = h[0] << 8 | h[1]; - for (h += 2, k -= 2; k; k--, hw = hw << 8 | *++h) + for (h += 2, k -= 2; k; k--, hw = hw << 8 | *h++) if (hw == nw) return __UNCONST(h - 2); return hw == nw ? __UNCONST(h - 2) : 0; } @@ -50,7 +50,7 @@ static char *threebyte_memmem(const unsi { uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; - for (h += 3, k -= 3; k; k--, hw = (hw|*++h) << 8) + for (h += 3, k -= 3; k; k--, hw = (hw|*h++) << 8) if (hw == nw) return __UNCONST(h - 3); return hw == nw ? __UNCONST(h - 3) : 0; } @@ -60,7 +60,7 @@ static char *fourbyte_memmem(const unsig { uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; - for (h += 4, k -= 4; k; k--, hw = hw << 8 | *++h) + for (h += 4, k -= 4; k; k--, hw = hw << 8 | *h++) if (hw == nw) return __UNCONST(h - 4); return hw == nw ? __UNCONST(h - 4) : 0; return 0;
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: christos Date: Mon Oct 15 18:37:19 UTC 2018 Modified Files: src/common/lib/libc/string: memmem.c Log Message: Avoid out-of-bounds reads https://www.openwall.com/lists/musl/2017/06/29/6 XXX: pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/string/memmem.c 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/string/memmem.c diff -u src/common/lib/libc/string/memmem.c:1.1 src/common/lib/libc/string/memmem.c:1.2 --- src/common/lib/libc/string/memmem.c:1.1 Sun Jul 8 13:53:12 2018 +++ src/common/lib/libc/string/memmem.c Mon Oct 15 14:37:19 2018 @@ -25,7 +25,7 @@ #if 0 __FBSDID("$FreeBSD: head/lib/libc/string/memmem.c 315468 2017-03-18 00:53:24Z emaste $"); #else -__RCSID("$NetBSD: memmem.c,v 1.1 2018/07/08 17:53:12 christos Exp $"); +__RCSID("$NetBSD: memmem.c,v 1.2 2018/10/15 18:37:19 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -36,29 +36,33 @@ __RCSID("$NetBSD: memmem.c,v 1.1 2018/07 #include #endif -static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +static char *twobyte_memmem(const unsigned char *h, size_t k, +const unsigned char *n) { - uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h++, k--; k; k--, hw = hw<<8 | *++h) - if (hw == nw) return __UNCONST(h-1); - return 0; + uint16_t nw = n[0] << 8 | n[1], hw = h[0] << 8 | h[1]; + for (h += 2, k -= 2; k; k--, hw = hw << 8 | *++h) + if (hw == nw) return __UNCONST(h - 2); + return hw == nw ? __UNCONST(h - 2) : 0; } -static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +static char *threebyte_memmem(const unsigned char *h, size_t k, +const unsigned char *n) { - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=2, k-=2; k; k--, hw = (hw|*++h)<<8) - if (hw == nw) return __UNCONST(h-2); - return 0; + uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; + uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; + for (h += 3, k -= 3; k; k--, hw = (hw|*++h) << 8) + if (hw == nw) return __UNCONST(h - 3); + return hw == nw ? __UNCONST(h - 3) : 0; } -static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +static char *fourbyte_memmem(const unsigned char *h, size_t k, +const unsigned char *n) { - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=3, k-=3; k; k--, hw = hw<<8 | *++h) - if (hw == nw) return __UNCONST(h-3); + uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; + uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; + for (h += 4, k -= 4; k; k--, hw = hw << 8 | *++h) + if (hw == nw) return __UNCONST(h - 4); + return hw == nw ? __UNCONST(h - 4) : 0; return 0; }
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: christos Date: Thu Aug 16 12:03:10 UTC 2018 Modified Files: src/common/lib/libc/string: strncasecmp.c Log Message: toolify. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/string/strncasecmp.c 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/string/strncasecmp.c diff -u src/common/lib/libc/string/strncasecmp.c:1.2 src/common/lib/libc/string/strncasecmp.c:1.3 --- src/common/lib/libc/string/strncasecmp.c:1.2 Mon Jun 4 14:19:27 2007 +++ src/common/lib/libc/string/strncasecmp.c Thu Aug 16 08:03:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ +/* $NetBSD: strncasecmp.c,v 1.3 2018/08/16 12:03:10 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -29,12 +29,16 @@ * SUCH DAMAGE. */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); +__RCSID("$NetBSD: strncasecmp.c,v 1.3 2018/08/16 12:03:10 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: christos Date: Sat Aug 11 16:25:32 UTC 2018 Modified Files: src/common/lib/libc/string: strcasecmp.c Log Message: Add nbotool stuff. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/string/strcasecmp.c 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/string/strcasecmp.c diff -u src/common/lib/libc/string/strcasecmp.c:1.2 src/common/lib/libc/string/strcasecmp.c:1.3 --- src/common/lib/libc/string/strcasecmp.c:1.2 Mon Jun 4 14:19:27 2007 +++ src/common/lib/libc/string/strcasecmp.c Sat Aug 11 12:25:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strcasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ +/* $NetBSD: strcasecmp.c,v 1.3 2018/08/11 16:25:32 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -29,12 +29,16 @@ * SUCH DAMAGE. */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strcasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); +__RCSID("$NetBSD: strcasecmp.c,v 1.3 2018/08/11 16:25:32 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */
CVS commit: src/common/lib/libc/misc
Module Name:src Committed By: kamil Date: Fri Aug 3 16:31:04 UTC 2018 Modified Files: src/common/lib/libc/misc: ubsan.c Log Message: Try to fix the evbppc-powerpc64 build Avoid "comparison between signed and unsigned integer expressions" on Big-Endian hosts. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/misc/ubsan.c 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/misc/ubsan.c diff -u src/common/lib/libc/misc/ubsan.c:1.2 src/common/lib/libc/misc/ubsan.c:1.3 --- src/common/lib/libc/misc/ubsan.c:1.2 Fri Aug 3 03:12:32 2018 +++ src/common/lib/libc/misc/ubsan.c Fri Aug 3 16:31:04 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $ */ +/* $NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,9 +38,9 @@ #include #if defined(_KERNEL) -__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $"); #else -__RCSID("$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $"); +__RCSID("$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $"); #endif #if defined(_KERNEL) @@ -1269,7 +1269,7 @@ DeserializeUINT128(char *pBuffer, size_t #if BYTE_ORDER == LITTLE_ENDIAN for (zI = sizeof(ulongest) - 1; zI >= 0; zI--) { #else - for (zI = 0; zI < sizeof(ulongest); zI++) { + for (zI = 0; zI < (ssize_t)sizeof(ulongest); zI++) { #endif snprintf(szBuf, sizeof(szBuf), "%02" PRIx8, rgNumber[zI]); strlcat(pBuffer, szBuf, zBUfferLength);
CVS commit: src/common/lib/libc
Module Name:src Committed By: kamil Date: Fri Aug 3 03:35:17 UTC 2018 Modified Files: src/common/lib/libc: Makefile.inc Log Message: Register a new directory in common/lib/libc/misc Registe misc/ with ubsan.c. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/common/lib/libc/Makefile.inc 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/Makefile.inc diff -u src/common/lib/libc/Makefile.inc:1.17 src/common/lib/libc/Makefile.inc:1.18 --- src/common/lib/libc/Makefile.inc:1.17 Thu Nov 30 05:47:24 2017 +++ src/common/lib/libc/Makefile.inc Fri Aug 3 03:35:17 2018 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile.inc,v 1.17 2017/11/30 05:47:24 riastradh Exp $ +# $NetBSD: Makefile.inc,v 1.18 2018/08/03 03:35:17 kamil Exp $ .include COMMON_DIR:=${.PARSEDIR} -COMMON_CODEDIRS=atomic gen gmon inet md net stdlib string sys +COMMON_CODEDIRS=atomic gen gmon inet md misc net stdlib string sys COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/sha3 hash/rmd160 hash/murmurhash .if defined(COMMON_MACHINE_ARCH) && !empty(COMMON_MACHINE_ARCH) && \
CVS commit: src/common/lib/libc/misc
Module Name:src Committed By: kamil Date: Fri Aug 3 03:12:32 UTC 2018 Modified Files: src/common/lib/libc/misc: ubsan.c Log Message: Tidy up the comment in ubsan.c As noted, style has no impact on the comparison of a similar code. This version is a reimplementation from scratch with no code and no algirithm (whenever possible) reuse. Public symbols and struct layout must be kept in sync with the code generation part. It casues violation of the style like with long filenames. My previous comment was 'too perfect' and could trigger some unnecessary attention. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/misc/ubsan.c 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/misc/ubsan.c diff -u src/common/lib/libc/misc/ubsan.c:1.1 src/common/lib/libc/misc/ubsan.c:1.2 --- src/common/lib/libc/misc/ubsan.c:1.1 Fri Aug 3 02:05:43 2018 +++ src/common/lib/libc/misc/ubsan.c Fri Aug 3 03:12:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ubsan.c,v 1.1 2018/08/03 02:05:43 kamil Exp $ */ +/* $NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,17 +32,15 @@ * The uBSSan versions is suitable for inclusion into libc or used standalone * with ATF tests. * - * This file due to long symbol names and licensing reasons does not fully - * follow the KNF style with 80-column limit. Hungarian style variables - * and function names are on the same purpose (Pascal and Snake style names, - * are used in different implementations). + * This file due to long symbol names generated by a compiler during the + * instrumentation process does not follow the KNF style with 80-column limit. */ #include #if defined(_KERNEL) -__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.1 2018/08/03 02:05:43 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $"); #else -__RCSID("$NetBSD: ubsan.c,v 1.1 2018/08/03 02:05:43 kamil Exp $"); +__RCSID("$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $"); #endif #if defined(_KERNEL)
CVS commit: src/common/lib/libc/misc
Module Name:src Committed By: kamil Date: Fri Aug 3 02:05:43 UTC 2018 Added Files: src/common/lib/libc/misc: ubsan.c Log Message: Import micro-UBSan (ubsan.c) This is a reimplementation of the Undefined Behavior Sanitizer with the following properties: - pure C implementation, - no -fsanitize=vpts support, as it requires RTTI support and C++ low-level routies to validate whether C++ objects are compatible - designed to be used inside libc and known as uUBSan or user-UBSan - designed to be shared with kernel and known as kUBSan or kernel-UBSan - designed to be usable with ATF tests as a standalone runtime, reachable without any MK* switches - designed to be safer for hardening as it does not have side effects on executables like writing to a selected location on demand - controllable with environment variable LIBC_UBSAN with options: * a - abort on report * A - do not abort on a report (unless a failure is unrecoverable) * e - output report to stderr * E - do not output report on stderr * l - output report on syslog (LOG_DEBUG | LOG_USER) * L - do not output report on syslog * o - output report on stdout * O - do not output report on stdout The default options are: "AeLO". - compatible with Clang (3.8, 7.x) and GCC (6.x) code generation - all handlers (except =vptr) from Clang/LLVM up to 7svn are supported This file does not follow the regular KNF style, due to potential licensing concerns. Tested with Clang amd64+i386 and GCC amd64+i386. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/common/lib/libc/misc/ubsan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/common/lib/libc/misc/ubsan.c diff -u /dev/null src/common/lib/libc/misc/ubsan.c:1.1 --- /dev/null Fri Aug 3 02:05:43 2018 +++ src/common/lib/libc/misc/ubsan.c Fri Aug 3 02:05:43 2018 @@ -0,0 +1,1640 @@ +/* $NetBSD: ubsan.c,v 1.1 2018/08/03 02:05:43 kamil Exp $ */ + +/*- + * Copyright (c) 2018 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. + */ + + +/* + * The micro UBSan implementation for the userland (uUBSan) and kernel (kUBSan). + * The uBSSan versions is suitable for inclusion into libc or used standalone + * with ATF tests. + * + * This file due to long symbol names and licensing reasons does not fully + * follow the KNF style with 80-column limit. Hungarian style variables + * and function names are on the same purpose (Pascal and Snake style names, + * are used in different implementations). + */ + +#include +#if defined(_KERNEL) +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.1 2018/08/03 02:05:43 kamil Exp $"); +#else +__RCSID("$NetBSD: ubsan.c,v 1.1 2018/08/03 02:05:43 kamil Exp $"); +#endif + +#if defined(_KERNEL) +#include +#include +#include +#define ASSERT(x) KASSERT(x) +#else +#if defined(_LIBC) +#include "namespace.h" +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(_LIBC) +#include "extern.h" +#define ubsan_vsyslog vsyslog_ss +#define ASSERT(x) _DIAGASSERT(x) +#else +#define ubsan_vsyslog vsyslog_r +#define ASSERT(x) assert(x) +#endif +/* These macros are available in _KERNEL only */ +#define SET(t, f) ((t) |= (f)) +#define ISSET(t, f) ((t) & (f)) +#define CLR(t, f) ((t) &= ~(f)) +#endif + +#define REINTERPRET_CAST(__dt, __st) ((__dt)(__st)) +#define STATIC_CAST(__dt, __st) ((__dt)(__st)) + +#define ACK_REPORTED __BIT(31) + +#define MUL_STRING "*" +#define PLUS_STRING "+" +#define MINUS_STRING "-" +#define DIVREM_STRING "divrem" +
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: ryo Date: Wed Aug 1 17:09:26 UTC 2018 Modified Files: src/common/lib/libc/arch/aarch64/string: strlen.S Log Message: strnlen(s, (size_t)-1) returned -1. it must return the length of s. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/string/strlen.S 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/aarch64/string/strlen.S diff -u src/common/lib/libc/arch/aarch64/string/strlen.S:1.2 src/common/lib/libc/arch/aarch64/string/strlen.S:1.3 --- src/common/lib/libc/arch/aarch64/string/strlen.S:1.2 Tue Aug 22 06:45:07 2017 +++ src/common/lib/libc/arch/aarch64/string/strlen.S Wed Aug 1 17:09:26 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strlen.S,v 1.2 2017/08/22 06:45:07 ryo Exp $ */ +/* $NetBSD: strlen.S,v 1.3 2018/08/01 17:09:26 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: strlen.S,v 1.2 2017/08/22 06:45:07 ryo Exp $") +RCSID("$NetBSD: strlen.S,v 1.3 2018/08/01 17:09:26 ryo Exp $") #ifdef STRNLEN #define FUNCNAME strnlen @@ -49,7 +49,10 @@ ENTRY(FUNCNAME) add x9, x0, #8 /* start + dword */ bic x9, x9, #7 /* and aligned */ #ifdef STRNLEN - add x10, x0, x1 /* don't go past here */ + adds x10, x0, x1 /* x10 = s + maxlen */ + b.cc 1f /* if go past, */ + mvn x10, xzr /* set limit 0x */ +1: #endif mov x11, #MASK8_0x01 /* test mask */ @@ -76,7 +79,7 @@ ENTRY(FUNCNAME) .Lstrlen_dword_loop: #ifdef STRNLEN cmp x4, x10 - b.ge .Lstrlen_done + b.hs .Lstrlen_done #endif ldr x7, [x4], #8 /* load dword */ .Lstrlen_dword_loop_noload: @@ -103,7 +106,7 @@ ENTRY(FUNCNAME) sub x0, x0, x9 /* subtract start from the length */ #ifdef STRNLEN cmp x0, x1 /* did we go too far? */ - csel x0, x0, x1, lt /* yes, return max length */ + csel x0, x0, x1, lo /* yes, return max length */ #endif ret #ifdef STRNLEN
CVS commit: src/common/lib/libc/inet
Module Name:src Committed By: kamil Date: Thu Jul 26 00:20:41 UTC 2018 Modified Files: src/common/lib/libc/inet: inet_addr.c Log Message: Avoid undefined behavior in an inet_addr.c Do not change the signedness bit with a left shift operation. Cast to unsigned integer to prevent this. inet_addr.c:218:20, left shift of 131 by 24 places cannot be represented in type 'int' Detected with micro-UBSan in the user mode. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/inet/inet_addr.c 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/inet/inet_addr.c diff -u src/common/lib/libc/inet/inet_addr.c:1.3 src/common/lib/libc/inet/inet_addr.c:1.4 --- src/common/lib/libc/inet/inet_addr.c:1.3 Fri Mar 9 15:41:16 2012 +++ src/common/lib/libc/inet/inet_addr.c Thu Jul 26 00:20:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $ */ +/* $NetBSD: inet_addr.c,v 1.4 2018/07/26 00:20:41 kamil Exp $ */ /* * Copyright (c) 1983, 1990, 1993 @@ -77,7 +77,7 @@ static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp"; #else -__RCSID("$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $"); +__RCSID("$NetBSD: inet_addr.c,v 1.4 2018/07/26 00:20:41 kamil Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -203,19 +203,20 @@ inet_aton(const char *cp, struct in_addr case 2:/* a.b -- 8.24 bits */ if (val > 0xffU) return (0); - val |= parts[0] << 24; + val |= (uint32_t)parts[0] << 24; break; case 3:/* a.b.c -- 8.8.16 bits */ if (val > 0xU) return (0); - val |= (parts[0] << 24) | (parts[1] << 16); + val |= ((uint32_t)parts[0] << 24) | (parts[1] << 16); break; case 4:/* a.b.c.d -- 8.8.8.8 bits */ if (val > 0xffU) return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + val |= ((uint32_t)parts[0] << 24) | (parts[1] << 16) | + (parts[2] << 8); break; } if (addr != NULL)
CVS commit: src/common/lib/libc/sys
Module Name:src Committed By: kamil Date: Thu Jul 26 00:13:19 UTC 2018 Modified Files: src/common/lib/libc/sys: cpuset.c Log Message: Avoid undefined behavior in an cpuset.c Do not change the signedness bit with a left shift operation. Switch to unsigned integer to prevent this. cpuset.c:112:18, left shift of 1 by 31 places cannot be represented in type 'int' Detected with micro-UBSan in the user mode. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/common/lib/libc/sys/cpuset.c 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/sys/cpuset.c diff -u src/common/lib/libc/sys/cpuset.c:1.19 src/common/lib/libc/sys/cpuset.c:1.20 --- src/common/lib/libc/sys/cpuset.c:1.19 Thu Jan 4 20:57:28 2018 +++ src/common/lib/libc/sys/cpuset.c Thu Jul 26 00:13:19 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuset.c,v 1.19 2018/01/04 20:57:28 kamil Exp $ */ +/* $NetBSD: cpuset.c,v 1.20 2018/07/26 00:13:19 kamil Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #ifndef _STANDALONE #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: cpuset.c,v 1.19 2018/01/04 20:57:28 kamil Exp $"); +__RCSID("$NetBSD: cpuset.c,v 1.20 2018/07/26 00:13:19 kamil Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef _LIBC @@ -97,7 +97,7 @@ _cpuset_isset(cpuid_t i, const cpuset_t errno = EINVAL; return -1; } - return ((1 << (unsigned int)(i & CPUSET_MASK)) & c->bits[j]) != 0; + return ((1U << (unsigned int)(i & CPUSET_MASK)) & c->bits[j]) != 0; } int @@ -109,7 +109,7 @@ _cpuset_set(cpuid_t i, cpuset_t *c) errno = EINVAL; return -1; } - c->bits[j] |= 1 << (unsigned int)(i & CPUSET_MASK); + c->bits[j] |= 1U << (unsigned int)(i & CPUSET_MASK); return 0; } @@ -122,7 +122,7 @@ _cpuset_clr(cpuid_t i, cpuset_t *c) errno = EINVAL; return -1; } - c->bits[j] &= ~(1 << (unsigned int)(i & CPUSET_MASK)); + c->bits[j] &= ~(1U << (unsigned int)(i & CPUSET_MASK)); return 0; }
CVS commit: src/common/lib/libc/arch/i386/atomic
Module Name:src Committed By: bouyer Date: Wed Jul 18 13:39:36 UTC 2018 Modified Files: src/common/lib/libc/arch/i386/atomic: atomic.S Log Message: On Xen, always alias _atomic_cas_64 to _atomic_cas_cx8. AFAIK Xen doesn't support CPUs that don't support cx8. i386 XENPAE_DOMU boots again. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/common/lib/libc/arch/i386/atomic/atomic.S 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/i386/atomic/atomic.S diff -u src/common/lib/libc/arch/i386/atomic/atomic.S:1.22 src/common/lib/libc/arch/i386/atomic/atomic.S:1.23 --- src/common/lib/libc/arch/i386/atomic/atomic.S:1.22 Fri May 23 03:17:31 2014 +++ src/common/lib/libc/arch/i386/atomic/atomic.S Wed Jul 18 13:39:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.S,v 1.22 2014/05/23 03:17:31 uebayasi Exp $ */ +/* $NetBSD: atomic.S,v 1.23 2018/07/18 13:39:36 bouyer Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -43,6 +43,7 @@ #endif #ifdef _HARDKERNEL +#include "opt_xen.h" #define LOCK(n) .Lpatch ## n: lock #define ENDLABEL(a) _ALIGN_TEXT; LABEL(a) #else @@ -196,6 +197,9 @@ END(_membar_sync) ENDLABEL(membar_sync_end) #if defined(__HAVE_ATOMIC64_OPS) || defined(_KERNEL) +#ifdef XEN +STRONG_ALIAS(_atomic_cas_64,_atomic_cas_cx8) +#else ENTRY(_atomic_cas_64) #ifdef _HARDKERNEL pushf @@ -227,6 +231,7 @@ ENTRY(_atomic_cas_64) jmp 1b END(_atomic_cas_64) ENDLABEL(_atomic_cas_64_end) +#endif /* !XEN */ ENTRY(_atomic_cas_cx8) pushl %edi
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: ryo Date: Mon Jul 9 06:07:06 UTC 2018 Modified Files: src/common/lib/libc/arch/aarch64/string: memcmp.S Log Message: avoid reading from out of range that may cause access fault. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/string/memcmp.S 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/aarch64/string/memcmp.S diff -u src/common/lib/libc/arch/aarch64/string/memcmp.S:1.2 src/common/lib/libc/arch/aarch64/string/memcmp.S:1.3 --- src/common/lib/libc/arch/aarch64/string/memcmp.S:1.2 Sun Feb 4 21:52:16 2018 +++ src/common/lib/libc/arch/aarch64/string/memcmp.S Mon Jul 9 06:07:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memcmp.S,v 1.2 2018/02/04 21:52:16 skrll Exp $ */ +/* $NetBSD: memcmp.S,v 1.3 2018/07/09 06:07:06 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: memcmp.S,v 1.2 2018/02/04 21:52:16 skrll Exp $") +RCSID("$NetBSD: memcmp.S,v 1.3 2018/07/09 06:07:06 ryo Exp $") ENTRY(memcmp) mov x9, x0 @@ -55,17 +55,19 @@ ENTRY(memcmp) sub x2, x2, #8 /* now subtract a dword */ sub x9, x9, x3 /* dword align src1 */ - sub x10, x10, x3 /* adjust src2 */ + ldr x6, [x10], #8 /* load dword from src2 */ + sub x10, x10, x3 /* src2 -= x3 */ lsl x3, x3, #3 /* convert bytes to bits */ ldr x4, [x9], #8 /* load dword from src1 */ - ldr x6, [x10], #8 /* load dword from src2 */ #ifdef __AARCH64EB__ lsl x4, x4, x3 /* discard leading bytes from data1 */ - lsl x6, x6, x3 /* discard leading bytes from data2 */ + lsr x6, x6, x3 /* discard leading bytes from data2 */ + lsl x6, x6, x3 /* get back bit position */ #else lsr x4, x4, x3 /* discard leading bytes from data1 */ - lsr x6, x6, x3 /* discard leading bytes from data2 */ + lsl x6, x6, x3 /* discard leading bytes from data2 */ + lsr x6, x6, x3 /* get back bit position */ #endif subs x0, x4, x6 /* compare data */ b.ne .Lmemcmp_last_compare /* difference. find it */
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: christos Date: Sun Jul 8 17:53:13 UTC 2018 Added Files: src/common/lib/libc/string: memmem.c Log Message: switch to FreeBSD's memmem (faster) To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/common/lib/libc/string/memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/common/lib/libc/string/memmem.c diff -u /dev/null src/common/lib/libc/string/memmem.c:1.1 --- /dev/null Sun Jul 8 13:53:13 2018 +++ src/common/lib/libc/string/memmem.c Sun Jul 8 13:53:12 2018 @@ -0,0 +1,191 @@ +/*- + * Copyright (c) 2005-2014 Rich Felker, et al. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +__FBSDID("$FreeBSD: head/lib/libc/string/memmem.c 315468 2017-03-18 00:53:24Z emaste $"); +#else +__RCSID("$NetBSD: memmem.c,v 1.1 2018/07/08 17:53:12 christos Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#include +#else +#include +#endif + +static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +{ + uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; + for (h++, k--; k; k--, hw = hw<<8 | *++h) + if (hw == nw) return __UNCONST(h-1); + return 0; +} + +static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +{ + uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; + uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; + for (h+=2, k-=2; k; k--, hw = (hw|*++h)<<8) + if (hw == nw) return __UNCONST(h-2); + return 0; +} + +static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +{ + uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; + uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; + for (h+=3, k-=3; k; k--, hw = hw<<8 | *++h) + if (hw == nw) return __UNCONST(h-3); + return 0; +} + +#define MAX(a,b) ((a)>(b)?(a):(b)) +#define MIN(a,b) ((a)<(b)?(a):(b)) + +#define BITOP(a,b,op) \ + ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a + +/* + * Two Way string search algorithm, with a bad shift table applied to the last + * byte of the window. A bit array marks which entries in the shift table are + * initialized to avoid fully initializing a 1kb/2kb table. + * + * Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching, + * Journal of the ACM 38(3):651-675 + */ +static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l) +{ + size_t i, ip, jp, k, p, ms, p0, mem, mem0; + size_t byteset[32 / sizeof(size_t)] = { 0 }; + size_t shift[256]; + + /* Computing length of needle and fill shift table */ + for (i=0; i n[jp+k]) { + jp += k; + k = 1; + p = jp - ip; + } else { + ip = jp++; + k = p = 1; + } + } + ms = ip; + p0 = p; + + /* And with the opposite comparison */ + ip = (size_t)-1; jp = 0; k = p = 1; + while (jp+k ms+1) ms = ip; + else p = p0; + + /* Periodic needle? */ + if (memcmp(n, n+p, ms+1)) { + mem0 = 0; + p = MAX(ms, l-ms-1) + 1; + } else mem0 = l-p; + mem = 0; + + /* Search loop */ + for (;;) { + /* If remainder of haystack is shorter than needle, done */ + if ((size_t)(z-h) < l) return 0; + + /* Check last byte first; advance by shift on mismatch */ + if (BITOP(byteset, h[l-1], &)) { + k = l-shift[h[l-1]]; + if (k) { +if (mem0 && mem && k < p) k = l-p; +h += k; +mem = 0; +continue; + } + } else { + h += l; + mem = 0; + continue; + } + + /* Compare right half */ + for (k=MAX(ms+1,mem); kmem && n[k-1] == h[k-1]; k--); + if (k <= mem) return __UNCONST(h); + h += p; + mem = mem0; + } +} + +void *memmem(const void *h0, size_t k, const void *n0, size_t l) +{ + const unsigned char *h = h0, *n = n0; + + /* Return immediately on empty needle */ + if (!l) return __UNCONST(h); + + /* Return immediately
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: martin Date: Mon Feb 12 11:14:15 UTC 2018 Modified Files: src/common/lib/libc/string: bcopy.c Log Message: Complete previous by complteley removing the _DIAGASSERT from memmove - the accidental left over from previous fired on all legitimate calls and caused PR bin/52986 and PR lib/52987. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/common/lib/libc/string/bcopy.c 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/string/bcopy.c diff -u src/common/lib/libc/string/bcopy.c:1.12 src/common/lib/libc/string/bcopy.c:1.13 --- src/common/lib/libc/string/bcopy.c:1.12 Sun Feb 4 20:22:17 2018 +++ src/common/lib/libc/string/bcopy.c Mon Feb 12 11:14:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bcopy.c,v 1.12 2018/02/04 20:22:17 mrg Exp $ */ +/* $NetBSD: bcopy.c,v 1.13 2018/02/12 11:14:15 martin Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: bcopy.c,v 1.12 2018/02/04 20:22:17 mrg Exp $"); +__RCSID("$NetBSD: bcopy.c,v 1.13 2018/02/12 11:14:15 martin Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -88,10 +88,6 @@ bcopy(const void *src0, void *dst0, size size_t t; unsigned long u; -#if !defined(_KERNEL) - _DIAGASSERT(length == 0); -#endif - if (length == 0 || dst == src) /* nothing to do */ goto done;
CVS commit: src/common/lib/libc/string
Module Name:src Committed By: mrg Date: Tue Feb 6 09:28:48 UTC 2018 Modified Files: src/common/lib/libc/string: memset.c strlen.c Log Message: - remove two more _DIAGASSERT() checks against not NULL for functions with arguments with nonnull attributes. in two cases, leave code behind that should set defaults to "(null)". To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/string/memset.c cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/string/strlen.c 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/string/memset.c diff -u src/common/lib/libc/string/memset.c:1.10 src/common/lib/libc/string/memset.c:1.11 --- src/common/lib/libc/string/memset.c:1.10 Mon Dec 2 21:21:33 2013 +++ src/common/lib/libc/string/memset.c Tue Feb 6 09:28:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memset.c,v 1.10 2013/12/02 21:21:33 joerg Exp $ */ +/* $NetBSD: memset.c,v 1.11 2018/02/06 09:28:48 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: memset.c,v 1.10 2013/12/02 21:21:33 joerg Exp $"); +__RCSID("$NetBSD: memset.c,v 1.11 2018/02/06 09:28:48 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -106,8 +106,6 @@ memset(void *dst0, int c0, size_t length #endif u_char *dst; - _DIAGASSERT(dst0 != 0); - dst = dst0; /* * If not enough words, just fill bytes. A length >= 2 words Index: src/common/lib/libc/string/strlen.c diff -u src/common/lib/libc/string/strlen.c:1.2 src/common/lib/libc/string/strlen.c:1.3 --- src/common/lib/libc/string/strlen.c:1.2 Mon Jun 4 18:19:27 2007 +++ src/common/lib/libc/string/strlen.c Tue Feb 6 09:28:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strlen.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ +/* $NetBSD: strlen.c,v 1.3 2018/02/06 09:28:48 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)strlen.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strlen.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); +__RCSID("$NetBSD: strlen.c,v 1.3 2018/02/06 09:28:48 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -50,8 +50,6 @@ strlen(const char *str) { const char *s; - _DIAGASSERT(str != NULL); - for (s = str; *s; ++s) continue; return(s - str);
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: skrll Date: Sun Feb 4 21:52:17 UTC 2018 Modified Files: src/common/lib/libc/arch/aarch64/string: memcmp.S memcpy.S Added Files: src/common/lib/libc/arch/aarch64/string: bcopy.S memmove.S Log Message: Working / new versions from Ryo Shimizu To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/common/lib/libc/arch/aarch64/string/bcopy.S \ src/common/lib/libc/arch/aarch64/string/memmove.S cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/string/memcmp.S \ src/common/lib/libc/arch/aarch64/string/memcpy.S 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/aarch64/string/memcmp.S diff -u src/common/lib/libc/arch/aarch64/string/memcmp.S:1.1 src/common/lib/libc/arch/aarch64/string/memcmp.S:1.2 --- src/common/lib/libc/arch/aarch64/string/memcmp.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/string/memcmp.S Sun Feb 4 21:52:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memcmp.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: memcmp.S,v 1.2 2018/02/04 21:52:16 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: memcmp.S,v 1.1 2014/08/10 05:47:35 matt Exp $") +RCSID("$NetBSD: memcmp.S,v 1.2 2018/02/04 21:52:16 skrll Exp $") ENTRY(memcmp) mov x9, x0 @@ -42,14 +42,14 @@ ENTRY(memcmp) cmp x2, #6 b.eq .Lmemcmp_6bytes #endif - cmp x2, #7 + cmp x2, #8 b.ls .Lmemcmp_lessthan8 ands x3, x9, #7 b.eq .Lmemcmp_dword_loop /* - * The two addresses have identical alignment but are not yet dword aligned. + * The src1 address is not dword aligned. */ add x2, x2, x3 /* add unalignment to length */ sub x2, x2, #8 /* now subtract a dword */ @@ -68,14 +68,7 @@ ENTRY(memcmp) lsr x6, x6, x3 /* discard leading bytes from data2 */ #endif subs x0, x4, x6 /* compare data */ -#ifdef __AARCH64EL__ b.ne .Lmemcmp_last_compare /* difference. find it */ -#else - b.eq .Lmemcmp_dword_loop /* no difference. go to loop */ - rev x4, x4 /* byte swap data1 */ - rev x6, x6 /* byte swap data2 */ - b .Lmemcmp_last_compare /* go find the difference. */ -#endif .Lmemcmp_dword_loop: subs x2, x2, #8 @@ -84,10 +77,6 @@ ENTRY(memcmp) ldr x6, [x10], #8 subs x0, x4, x6 b.eq .Lmemcmp_dword_loop /* no difference. go to loop */ -#ifdef __AARCH64EB__ - rev x4, x4 /* byte swap data1 */ - rev x6, x6 /* byte swap data2 */ -#endif b .Lmemcmp_last_compare /* go find the difference. */ .Lmemcmp_finish_dword: @@ -96,6 +85,8 @@ ENTRY(memcmp) */ tst x2, #7 b.eq .Lmemcmp_ret + mov x4, xzr + mov x6, xzr /* * */ @@ -120,16 +111,18 @@ ENTRY(memcmp) #endif .Lmemcmp_finish_hword: -#ifdef __AARCH64EB__ - rev x4, x4 /* byte swap data1 */ - rev x6, x6 /* byte swap data1 */ -#endif - tbz x2, #0, .Lmemcmp_last_compare + tbz x2, #0, .Lmemcmp_last_compare0 + ldrb w5, [x9] ldrb w7, [x10] +#ifdef __AARCH64EB__ + orr x4, x4, x5, lsl #8 + orr x6, x6, x7, lsl #8 +#else orr x4, x4, x5, lsl #48 orr x6, x6, x7, lsl #48 - b .Lmemcmp_last_compare /* go find the difference. */ +#endif + b .Lmemcmp_last_compare0 /* go find the difference. */ /* * D @@ -167,7 +160,7 @@ ENTRY(memcmp) #endif /* _KERNEL */ /* - * We have loaded the final bytes in x4 and x6 in LE format. Now we have + * We have loaded the final bytes in x4 and x6 in host-endian. Now we have * to figure what the difference is (if any). First we subtract. Any bytes * that are the same will be 0. So to find the first non-zero byte we byterev * and then use clz to find that byte. @@ -175,13 +168,25 @@ ENTRY(memcmp) * data dwords left to remove the equal part. Then we shift right to discard * the trailing bytes. Then we subtract and return. */ +.Lmemcmp_last_compare0: subs x0, x4, x6 b.eq .Lmemcmp_ret .Lmemcmp_last_compare: - rev x1, x0 /* byte reverse */ +#if __AARCH64EB__ + clz x1, x0 /* find first non-zero byte */ + rev x0, x0 +#else + rev x1, x0 clz x1, x1 /* find first non-zero byte */ - bfi x1, xzr, #0, #3 /* make it byte aligned */ - lsr x0, x0, x1 /* shift to LSB */ - sxtb w0, w0 /* sign extend */ +#endif + bfi x1, xzr, #0, #3 /* make it byte aligned */ + lsr x1, x0, x1 /* shift to LSB */ +#if __AARCH64EL__ + rev x4, x4 /* byte reverse */ + rev x6, x6 /* byte reverse */ +#endif + subs x0, x4, x6 + csetm x0, cc /* set mask bits as sign */ + bfm x0, x1, #0, #7 /* extend with sign bit */ ret END(memcmp) Index: src/common/lib/libc/arch/aarch64/string/memcpy.S diff -u src/common/lib/libc/arch/aarch64/string/memcpy.S:1.1 src/common/lib/libc/arch/aarch64/string/memcpy.S:1.2 --- src/common/lib/libc/arch/aarch64/string/memcpy.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/string/memcpy.S Sun Feb 4 21:52:16 2018 @@ -1,126 +1,4 @@ -/* $NetBSD: memcpy.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD:
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: ryo Date: Tue Aug 29 15:00:23 UTC 2017 Modified Files: src/common/lib/libc/arch/aarch64/string: memset.S Log Message: * aarch64/memset.S didn't work! fixed some bugs. * maximum size of DCZID_EL0:BS (2048) supported. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/string/memset.S 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/aarch64/string/memset.S diff -u src/common/lib/libc/arch/aarch64/string/memset.S:1.1 src/common/lib/libc/arch/aarch64/string/memset.S:1.2 --- src/common/lib/libc/arch/aarch64/string/memset.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/string/memset.S Tue Aug 29 15:00:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: memset.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: memset.S,v 1.2 2017/08/29 15:00:23 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ ENTRY(memset) add x13, x15, x2 /* get ending address */ asr x13, x13, x9 /* "ending" block numebr */ cmp x13, x12 /* how many blocks? */ - b.eq .Lfilled /* none, do it 16 bytes at a time */ + b.ls .Lfilled /* none, do it 16 bytes at a time */ /* * Now we have one or more blocks to deal with. First now we need @@ -144,7 +144,7 @@ ENTRY(memset) sub x7, x10, x7 /* subtract offset from block length */ sub x2, x2, x7 /* subtract that from length */ - asr x7, x7, #2 /* qword -> word */ + asr x7, x7, #4 /* length -> N*16 */ tbz x15, #0, .Lzero_hword_aligned strb wzr, [x15], #1 @@ -158,28 +158,18 @@ ENTRY(memset) tbz x15, #3, .Lzero_qword_aligned str xzr, [x15], #8 .Lzero_qword_aligned: - cbz x7, .Lblock_aligned /* no qwords? just branch */ - adr x6, .Lblock_aligned - sub x6, x6, x7 /* backup to write the last N qwords */ - br x6 /* and do it */ + cbz x7, .Lblock_aligned /* less than 16 bytes? just branch */ + adr x6, .Lunrolled_end + sub x6, x6, x7, lsl #2 /* backup to write the last N insn */ + br x6 /* and do it */ + /* - * This is valid for cache lines <= 256 bytes. + * The maximum size of DCZID_EL0:BS supported is 2048 bytes. */ + .rept (2048 / 16) - 1 stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 - stp xzr, xzr, [x15], #16 + .endr +.Lunrolled_end: /* * Now we are block aligned. @@ -193,7 +183,7 @@ ENTRY(memset) ret .Lblock_done: - and x2, x2, x12 /* make positive again */ + and x2, x2, x11 /* make positive again */ mov x6, xzr /* fill 2nd xword */ b .Lqword_loop /* and finish filling */
CVS commit: src/common/lib/libc/arch/aarch64/string
Module Name:src Committed By: ryo Date: Tue Aug 22 06:45:08 UTC 2017 Modified Files: src/common/lib/libc/arch/aarch64/string: strlen.S Log Message: aarch64/strlen.S didn't work. fixed some bugs. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/string/strlen.S 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/aarch64/string/strlen.S diff -u src/common/lib/libc/arch/aarch64/string/strlen.S:1.1 src/common/lib/libc/arch/aarch64/string/strlen.S:1.2 --- src/common/lib/libc/arch/aarch64/string/strlen.S:1.1 Sun Aug 10 05:47:35 2014 +++ src/common/lib/libc/arch/aarch64/string/strlen.S Tue Aug 22 06:45:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: strlen.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */ +/* $NetBSD: strlen.S,v 1.2 2017/08/22 06:45:07 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -RCSID("$NetBSD: strlen.S,v 1.1 2014/08/10 05:47:35 matt Exp $") +RCSID("$NetBSD: strlen.S,v 1.2 2017/08/22 06:45:07 ryo Exp $") #ifdef STRNLEN #define FUNCNAME strnlen @@ -47,6 +47,7 @@ RCSID("$NetBSD: strlen.S,v 1.1 2014/08/1 ENTRY(FUNCNAME) mov x4, x0 /* need x0 for return */ add x9, x0, #8 /* start + dword */ + bic x9, x9, #7 /* and aligned */ #ifdef STRNLEN add x10, x0, x1 /* don't go past here */ #endif @@ -93,16 +94,16 @@ ENTRY(FUNCNAME) * We know there is a NUL in this dword. Use clz to find it. */ #ifdef __AARCH64EL__ - rev x7, x7 /* convert to BE */ + rev x6, x6 /* convert to BE */ #endif - clz x7, x7 /* find null byte */ - add x0, x0, x7, lsr #3 /* add offset to the length */ + clz x6, x6 /* find null byte */ + add x0, x0, x6, lsr #3 /* add offset to the length */ add x0, x0, x4 /* add end to the length */ sub x0, x0, x9 /* subtract start from the length */ #ifdef STRNLEN cmp x0, x1 /* did we go too far? */ -cselx0, x0, x1, lt /* yes, return max length */ + csel x0, x0, x1, lt /* yes, return max length */ #endif ret #ifdef STRNLEN