CVS commit: src/external/gpl3/gcc

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 05:15:04 UTC 2021

Added Files:
src/external/gpl3/gcc: README.warnings

Log Message:
document various gcc warnings that occur frequently enough to
inspire the GCC_NO_* series of variables, and explain some
about what the issues may be for each, hopefully providing some
direction on how to fix new warnings in this space.

christos asked me for this last year, and it's finally complete
enough to commit.  :-)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/gpl3/gcc/README.warnings

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/gpl3/gcc/README.warnings
diff -u /dev/null src/external/gpl3/gcc/README.warnings:1.1
--- /dev/null	Thu Apr 15 05:15:04 2021
+++ src/external/gpl3/gcc/README.warnings	Thu Apr 15 05:15:04 2021
@@ -0,0 +1,132 @@
+$NetBSD: README.warnings,v 1.1 2021/04/15 05:15:04 mrg Exp $
+
+What to do about GCC warnings and NetBSD.
+
+
+New GCC releases always come with a host of new warnings and
+each new warning can find real bugs, find odd code, or simply
+be a pain of new useless warnings, or all three and more.
+
+As each warning has its own set of issues they each have their
+own section and it is expected that this document will be
+modified for updates to warnings and new warnings.
+
+
+ provides several variables for use in Makefiles:
+   COPTS.foo.c += ${GCC_NO_FORMAT_TRUNCATION}
+   COPTS.foo.c += ${GCC_NO_FORMAT_OVERFLOW}
+   COPTS.foo.c += ${GCC_NO_STRINGOP_OVERFLOW}
+   COPTS.foo.c += ${GCC_NO_STRINGOP_TRUNCATION}
+   COPTS.foo.c += ${GCC_NO_CAST_FUNCTION_TYPE}
+   COPTS.foo.c += ${GCC_NO_IMPLICIT_FALLTHRU}
+   COPTS.foo.c += ${GCC_NO_ADDR_OF_PACKED_MEMBER}
+   COPTS.foo.c += ${GCC_NO_MAYBE_UNINITIALIZED}
+   COPTS.foo.c += ${GCC_NO_RETURN_LOCAL_ADDR}
+
+
+new GCC 10 warnings:
+
+  GCC 10 switched the default from "-fcommon" to "-fno-common",
+  which can cause multiply defined symbol issues.  Ideally we
+  fix all of these, but "-fcommon" can be used otherwise.
+
+  -Wno-maybe-uninitialized
+
+  This warning was introduced in an ancient GCC but was
+  significantly enhanced in GCC 10, unfortunately, many of
+  the new instances are incorrect.
+
+  bsd.own.mk variable: ${GCC_NO_MAYBE_UNINITIALIZED}
+
+  -Wno-return-local-addr
+
+  This warning was introduced in GCC 5 and was enhanced in GCC
+  10.  Unfortunately, the new instances are failing to correctly
+  analyze code flow and miss that most of the are handled.
+
+  bsd.own.mk variable: ${GCC_NO_RETURN_LOCAL_ADDR}
+
+
+new GCC 9 warnings:
+
+  -Wno-address-of-packed-member
+
+  This warning was introduced in GCC 8.
+  This warning is similar to -Wformat-truncation, but for the
+  general family of string functions (str*(), etc.), and has
+  similar issues of false positives.
+
+  bsd.own.mk variable: ${GCC_NO_ADDR_OF_PACKED_MEMBER}
+
+
+new GCC 8 warnings:
+
+  -Wstringop-truncation
+
+  This warning was introduced in GCC 8.
+  This warning is similar to -Wformat-truncation, but for the
+  general family of string functions (str*(), etc.), and has
+  similar issues of false positives.
+
+  bsd.own.mk variable: ${GCC_NO_STRINGOP_TRUNCATION}
+
+
+  -Wcast-function-type
+
+  This warning was introduced in GCC 8.
+  This warning can find real problems.  Most instances are
+  false positives, and hopefully this warning will become
+  more useful in the future.  See __FPTRCAST().
+
+  bsd.own.mk variable: ${GCC_NO_CAST_FUNCTION_TYPE}
+
+
+new GCC 7 warnings:
+
+  -Wstringop-overflow
+
+  This warning was introduced in GCC 7.
+  This warning can find issues where source length is
+  passed as destination length (eg, strncpy() where the
+  length is strlen(src)) that are potential buffer overflow
+  cases and should always be inspected, but false positives
+  are also seen.
+
+  bsd.own.mk variable: ${GCC_NO_STRINGOP_OVERFLOW}
+
+
+  -Wformat-truncation
+
+This warning was introduced in GCC 7.
+This warning has many false positives where truncation is
+either expected or unavoidable, but also finds several real
+code bugs.
+
+Code should always be manually inspected for this warning
+as it does pick up real issues.
+
+bsd.own.mk variable: ${GCC_NO_FORMAT_TRUNCATION}
+
+
+  -Wformat-overflow
+
+This warning was introduced in GCC 7.
+This warning typically identifies a real problem, but it may
+fail to notice the code handles this case.
+
+Code should always be manually inspected for this warning
+as it does pick up real issues.
+
+bsd.own.mk variable: ${GCC_NO_FORMAT_OVERFLOW}
+
+
+  -Wimplicit-fallthrough
+
+This warning was introduced in GCC 7.
+This warning has many false positives in GCC 7, and many are
+fixed in newer GCC 10.  Old uses should be checked 

CVS commit: src/external/gpl3/gcc

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 05:12:57 UTC 2021

Modified Files:
src/external/gpl3/gcc: README.gcc10

Log Message:
feedback from rin@: alpha and m68k work well, powerpc not so much
but fixes are known.

thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/gpl3/gcc/README.gcc10

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/README.gcc10
diff -u src/external/gpl3/gcc/README.gcc10:1.8 src/external/gpl3/gcc/README.gcc10:1.9
--- src/external/gpl3/gcc/README.gcc10:1.8	Thu Apr 15 01:59:51 2021
+++ src/external/gpl3/gcc/README.gcc10	Thu Apr 15 05:12:57 2021
@@ -1,4 +1,4 @@
-$NetBSD: README.gcc10,v 1.8 2021/04/15 01:59:51 mrg Exp $
+$NetBSD: README.gcc10,v 1.9 2021/04/15 05:12:57 mrg Exp $
 
 
 new stuff:
@@ -34,7 +34,7 @@ architecture	tools	kernels	libgcc	native
 	-	---	--	--			---	
 aarch64		y	n[3]	n[3]	y		n		?	?	?
 aarch64be	y	n[3]	n[3]	y		n		?	?	?
-alpha		y	b	y	y		y		?	?	?
+alpha		y	y	y	y		y		y	y	n
 earmv4		y	y	y	y		y		y	?	n
 earmv4eb	y	b	y	y		y		?	?	?
 earmv5		y	b	y	y		y		?	?	?
@@ -53,12 +53,12 @@ hppa		y	b	y	y		y		?	?	?
 i386		y	y	y	y		y		y	n[8]	?
 ia64		y	y	y	y		y		?	N/A	n
 m68000		y	b	y	y		n[1]		?	?	?
-m68k		y	y	y	y		y[9]		?	?	?
+m68k		y	y	y	y		y[9]		y	?	?
 mipseb		y	y	y	y		y		y	?	?
 mipsel		y	y	y	y		y		y	?	?
 mips64eb	y	y	y	y		y		n[4]	?	?
 mips64el	y	b	y	y		y		y	?	?
-powerpc		y	b	y	y		y		?	?	?
+powerpc		y	b	y	y		y		n[2]	?	?
 powerpc64	y	b	y	y		y		N/A	N/A	?
 sh3eb		y	b	y	y		y		?	?	?
 sh3el		y	y	y	y		y		y	y[7]	?
@@ -74,6 +74,7 @@ coldfire	?	N/A	?	?		?		N/A	N/A
 architecture	tools	kernels	libgcc	native-gcc	make release	runs	atf
 
 [1] - ramdisk.fs is too large, needs fixing.
+[2] - powerpc ports have regressions; fixes incoming from rin@
 [3] - missing __aarch64_swp1_acq in kernels.  missing lse.S in libgcc.
 [4] - edgerouter lite3 crashes early in boot:
   [   1.000] u-boot bootmem desc @ 0x24108 version 3.0



CVS commit: src/external/gpl3/gcc

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 01:59:51 UTC 2021

Modified Files:
src/external/gpl3/gcc: README.gcc10

Log Message:
i've test-built all platforms.  everything except arm64, x68k and sun2
builds.  many of them work as well.  most mips are (minimally) tested.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gcc/README.gcc10

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/README.gcc10
diff -u src/external/gpl3/gcc/README.gcc10:1.7 src/external/gpl3/gcc/README.gcc10:1.8
--- src/external/gpl3/gcc/README.gcc10:1.7	Wed Apr 14 01:19:13 2021
+++ src/external/gpl3/gcc/README.gcc10	Thu Apr 15 01:59:51 2021
@@ -1,4 +1,4 @@
-$NetBSD: README.gcc10,v 1.7 2021/04/14 01:19:13 mrg Exp $
+$NetBSD: README.gcc10,v 1.8 2021/04/15 01:59:51 mrg Exp $
 
 
 new stuff:
@@ -32,36 +32,36 @@ switched:	has port switched?  y (yes), n
 
 architecture	tools	kernels	libgcc	native-gcc	make release	runs	atf	switched
 	-	---	--	--			---	
-aarch64		y	n[3]	y	y		n		?	?	?
-aarch64be	y	n	n	y		n		?	?	?
+aarch64		y	n[3]	n[3]	y		n		?	?	?
+aarch64be	y	n[3]	n[3]	y		n		?	?	?
 alpha		y	b	y	y		y		?	?	?
 earmv4		y	y	y	y		y		y	?	n
-earmv4eb	y	b	y	y		n		?	?	?
-earmv5		y	b	y	y		n		?	?	?
-earmv5eb	y	b	y	y		n		?	?	?
-earmv5hf	y	b	y	y		n		?	?	?
-earmv5hfeb	y	b	y	y		n		?	?	?
-earmv6		y	b	y	y		n		?	?	?
-earmv6eb	y	b	y	y		n		?	?	?
-earmv6hf	y	b	y	y		n		?	?	?
-earmv6hfeb	y	b	y	y		n		?	?	?
-earmv7		y	b	y	y		n		?	?	?
-earmv7eb	y	b	y	y		n		?	?	?
+earmv4eb	y	b	y	y		y		?	?	?
+earmv5		y	b	y	y		y		?	?	?
+earmv5eb	y	b	y	y		y		?	?	?
+earmv5hf	y	b	y	y		y		?	?	?
+earmv5hfeb	y	b	y	y		y		?	?	?
+earmv6		y	b	y	y		y		?	?	?
+earmv6eb	y	b	y	y		y		?	?	?
+earmv6hf	y	b	y	y		y		?	?	?
+earmv6hfeb	y	b	y	y		y		?	?	?
+earmv7		y	b	y	y		y		?	?	?
+earmv7eb	y	b	y	y		y		?	?	?
 earmv7hf	y	y	y	y		y		y	y	n
 earmv7hfeb	y	b	y	y		y		?	?	?
 hppa		y	b	y	y		y		?	?	?
 i386		y	y	y	y		y		y	n[8]	?
-ia64		y	y	y	y		n[2]		?	N/A	n
+ia64		y	y	y	y		y		?	N/A	n
 m68000		y	b	y	y		n[1]		?	?	?
-m68k		y	y	y	y		y		?	?	?
-mipseb		y	b	y	y		y		?	?	?
-mipsel		y	b	y	y		y		?	?	?
-mips64eb	y	y	y	y		y		n[4,5]	?	?
-mips64el	y	b	y	y		y		?	?	?
+m68k		y	y	y	y		y[9]		?	?	?
+mipseb		y	y	y	y		y		y	?	?
+mipsel		y	y	y	y		y		y	?	?
+mips64eb	y	y	y	y		y		n[4]	?	?
+mips64el	y	b	y	y		y		y	?	?
 powerpc		y	b	y	y		y		?	?	?
 powerpc64	y	b	y	y		y		N/A	N/A	?
 sh3eb		y	b	y	y		y		?	?	?
-sh3el		y	y	y	y		y		y	?	?
+sh3el		y	y	y	y		y		y	y[7]	?
 sparc		y	y	y	y		y		y	y	n
 sparc64		y	y	y	y		y		y	y	n
 vax		y	y	y	y		y		y	n[6]	n
@@ -74,12 +74,7 @@ coldfire	?	N/A	?	?		?		N/A	N/A
 architecture	tools	kernels	libgcc	native-gcc	make release	runs	atf
 
 [1] - ramdisk.fs is too large, needs fixing.
-[2] - rescue fails to build:
-  /tmp//ccnNTCsS.s: Assembler messages:
-  /tmp//ccnNTCsS.s:610: Warning: .label_state outside of body region
-  /tmp//ccnNTCsS.s:611: Warning: .restore outside of body region
-  /tmp//ccnNTCsS.s: Error: 2 warnings, treating warnings as errors
-[3] - missing __aarch64_swp1_acq in kernels.
+[3] - missing __aarch64_swp1_acq in kernels.  missing lse.S in libgcc.
 [4] - edgerouter lite3 crashes early in boot:
   [   1.000] u-boot bootmem desc @ 0x24108 version 3.0
   [   1.000] phys segment: 0xfc000 @ 0x102000
@@ -98,13 +93,16 @@ architecture	tools	kernels	libgcc	native
   0x98165cf0: 0x802563+0xd8 (0x8000,0,0,0xc800) ra 0x803edd18 sz 0
   0x98165cf0: 0x803edc+0x84 (0x8000,0,0,0xc800) ra 0 sz 0
 - OCTEON kernel seems OK, something in my private configuration?
-[5] - userland is broken.  some dynamic apps run on old install (ie, old
-  ld.elf_so & shlibs) but nothing in chroot runs (static or dynamic).
-  memset.c compiles wrongly, wants -ffreestanding.  oddness.
-[6] - vax vs c++ exceptions issue
+[6] - vax vs c++ exceptions issue, same as it ever was
+[7] - fails just as poorly in gxemul/landisk as GCC 9
 [8] - i386 seems to have a signal delivery issue.  GCC 9 or 10 kernels are
   unable to reboot properly, and GCC 10 atf runs hang in signal delivery.
-
+  bisection so far has reduced bug introduction between 2020-05-08 and
+  2020-05-15.  possibly pthread or condvar changes in this period.
+[9] - x68k/stand fails with:
+  link  loadbsd/loadbsd.x
+  loadbsd1: program header #1 is not loadable
+  may be due to it pulling in libc sources that get TLS marked?
 
 
 
@@ -114,33 +112,33 @@ values:		y (yes), k (kernels only), n (f
 CPU		platform list
 ---		 
 		acorn32		cats	epoc32	evbarm-eb	evbarm-el	hpcarm		iyonix		netwinder	shark 		zaurus
-earmv4:		k		k	k	k		k		k		 		k		y		 
-earm:		 		 	 	k		k		 		k		 		 		k
-earmhf:		 		 	 	k		k		 		 		 		 		 
-earmv6:		 		 	 	k		k
-earmv6hf:	 		 	 	k		k
-earmv7:		 		 	 	k		y
-earmv7hf:	 		 	 	y		k

CVS commit: src/sys/dev/mvme

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 01:57:11 UTC 2021

Modified Files:
src/sys/dev/mvme: mvmebus.c

Log Message:
convert 'extern phys_ram_seg_t mem_clusters[0];' to the '[]' form
so that when this code accesses mem_clustes[0] and mem_clusters[1]
it does't reach out of bounds.

XXX: should be in a header, but it's ugly to fix and i stopped
 when bus_dma.c wouldn't build.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/mvme/mvmebus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/mvme/mvmebus.c
diff -u src/sys/dev/mvme/mvmebus.c:1.21 src/sys/dev/mvme/mvmebus.c:1.22
--- src/sys/dev/mvme/mvmebus.c:1.21	Sun Nov 10 21:16:36 2019
+++ src/sys/dev/mvme/mvmebus.c	Thu Apr 15 01:57:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvmebus.c,v 1.21 2019/11/10 21:16:36 chs Exp $	*/
+/*	$NetBSD: mvmebus.c,v 1.22 2021/04/15 01:57:11 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mvmebus.c,v 1.21 2019/11/10 21:16:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvmebus.c,v 1.22 2021/04/15 01:57:11 mrg Exp $");
 
 #include 
 #include 
@@ -80,7 +80,7 @@ const char *mvmebus_irq_name[] = {
 	"vmeirq4", "vmeirq5", "vmeirq6", "vmeirq7"
 };
 
-extern phys_ram_seg_t mem_clusters[0];
+extern phys_ram_seg_t mem_clusters[];
 extern int mem_cluster_cnt;
 
 



CVS commit: src/sbin/fsdb

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 01:56:00 UTC 2021

Modified Files:
src/sbin/fsdb: Makefile

Log Message:
vax vs gcc:  fsdb.c loses.  also build this with -O0.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sbin/fsdb/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/fsdb/Makefile
diff -u src/sbin/fsdb/Makefile:1.40 src/sbin/fsdb/Makefile:1.41
--- src/sbin/fsdb/Makefile:1.40	Sun Sep  6 07:20:27 2020
+++ src/sbin/fsdb/Makefile	Thu Apr 15 01:56:00 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.40 2020/09/06 07:20:27 mrg Exp $
+#	$NetBSD: Makefile,v 1.41 2021/04/15 01:56:00 mrg Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include 
@@ -42,6 +42,7 @@ COPTS.pass1.c+=	-fno-tree-fre -fno-tree-
 .if ${MACHINE_ARCH} == "vax"
 COPTS.pass1.c+=	-O0
 COPTS.inode.c+=	-O0
+COPTS.fsdb.c+=	-O0
 .endif
 
 CWARNFLAGS.gcc+=	${GCC_NO_ADDR_OF_PACKED_MEMBER}



CVS commit: src/games/hunt/huntd

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 01:55:21 UTC 2021

Modified Files:
src/games/hunt/huntd: Makefile

Log Message:
one port complains about string overflow here that i can't see.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/games/hunt/huntd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/hunt/huntd/Makefile
diff -u src/games/hunt/huntd/Makefile:1.9 src/games/hunt/huntd/Makefile:1.10
--- src/games/hunt/huntd/Makefile:1.9	Mon Apr 12 02:54:08 2021
+++ src/games/hunt/huntd/Makefile	Thu Apr 15 01:55:21 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.9 2021/04/12 02:54:08 mrg Exp $
+#	$NetBSD: Makefile,v 1.10 2021/04/15 01:55:21 mrg Exp $
 
 PROG=	huntd
 SRCS=	answer.c draw.c driver.c execute.c expl.c \
@@ -12,5 +12,6 @@ CPPFLAGS+=-I${.CURDIR}/../include
 # Appears wrong - should not exceed bounds of array.
 COPTS.answer.c+=	${GCC_NO_STRINGOP_OVERFLOW}
 COPTS.shots.c+=		${GCC_NO_STRINGOP_OVERFLOW}
+COPTS.driver.c+=	${GCC_NO_STRINGOP_OVERFLOW}
 
 .include 



CVS commit: src/sys/arch

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 15 01:54:39 UTC 2021

Modified Files:
src/sys/arch/hp300/stand: Makefile.inc
src/sys/arch/mvme68k/stand: Makefile.booters
src/sys/arch/sgimips/stand: Makefile.inc
src/sys/arch/x68k/stand: Makefile.inc

Log Message:
more -fcommon for boot programs.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hp300/stand/Makefile.inc
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mvme68k/stand/Makefile.booters
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sgimips/stand/Makefile.inc
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x68k/stand/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/sys/arch/hp300/stand/Makefile.inc
diff -u src/sys/arch/hp300/stand/Makefile.inc:1.16 src/sys/arch/hp300/stand/Makefile.inc:1.17
--- src/sys/arch/hp300/stand/Makefile.inc:1.16	Sun Mar 15 06:10:03 2009
+++ src/sys/arch/hp300/stand/Makefile.inc	Thu Apr 15 01:54:38 2021
@@ -1,7 +1,9 @@
-#	$NetBSD: Makefile.inc,v 1.16 2009/03/15 06:10:03 tsutsui Exp $
+#	$NetBSD: Makefile.inc,v 1.17 2021/04/15 01:54:38 mrg Exp $
 
 BINDIR=			/usr/mdec
 
 release:
 
 S?=		${.CURDIR}/../../../..
+
+COPTS+=		-fcommon

Index: src/sys/arch/mvme68k/stand/Makefile.booters
diff -u src/sys/arch/mvme68k/stand/Makefile.booters:1.26 src/sys/arch/mvme68k/stand/Makefile.booters:1.27
--- src/sys/arch/mvme68k/stand/Makefile.booters:1.26	Sat Apr  8 19:53:21 2017
+++ src/sys/arch/mvme68k/stand/Makefile.booters	Thu Apr 15 01:54:39 2021
@@ -1,10 +1,11 @@
-#	$NetBSD: Makefile.booters,v 1.26 2017/04/08 19:53:21 christos Exp $
+#	$NetBSD: Makefile.booters,v 1.27 2021/04/15 01:54:39 mrg Exp $
 
 S?=		${.CURDIR}/../../../..
 MDEC_DIR?=	/usr/mdec
 RELOC?=		0x3F
 COPTS?=		-Os -Wall -Wno-main -Wmissing-prototypes -Wstrict-prototypes \
-		-ffreestanding -fomit-frame-pointer -fno-unwind-tables
+		-ffreestanding -fomit-frame-pointer -fno-unwind-tables \
+		-fcommon
 DEFS?= 
 STRIPFLAG?=
 

Index: src/sys/arch/sgimips/stand/Makefile.inc
diff -u src/sys/arch/sgimips/stand/Makefile.inc:1.3 src/sys/arch/sgimips/stand/Makefile.inc:1.4
--- src/sys/arch/sgimips/stand/Makefile.inc:1.3	Wed Jan  2 03:04:26 2019
+++ src/sys/arch/sgimips/stand/Makefile.inc	Thu Apr 15 01:54:39 2021
@@ -1,9 +1,11 @@
-# $NetBSD: Makefile.inc,v 1.3 2019/01/02 03:04:26 tsutsui Exp $
+# $NetBSD: Makefile.inc,v 1.4 2021/04/15 01:54:39 mrg Exp $
 
 NOPIE=	# defined
 
 BINDIR?=	/usr/mdec
 
+COPTS+=		-fcommon
+
 # XXX SHOULD NOT NEED TO DEFINE THESE!
 LIBCRT0=
 LIBCRTI=

Index: src/sys/arch/x68k/stand/Makefile.inc
diff -u src/sys/arch/x68k/stand/Makefile.inc:1.3 src/sys/arch/x68k/stand/Makefile.inc:1.4
--- src/sys/arch/x68k/stand/Makefile.inc:1.3	Mon Aug 10 07:00:49 2020
+++ src/sys/arch/x68k/stand/Makefile.inc	Thu Apr 15 01:54:39 2021
@@ -1,3 +1,3 @@
-#	$NetBSD: Makefile.inc,v 1.3 2020/08/10 07:00:49 rin Exp $
+#	$NetBSD: Makefile.inc,v 1.4 2021/04/15 01:54:39 mrg Exp $
 
-DBG=-Os -fno-unwind-tables -Wno-attributes
+DBG=-Os -fno-unwind-tables -Wno-attributes -fcommon



CVS commit: src/sys/kern

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 15 00:37:31 UTC 2021

Modified Files:
src/sys/kern: subr_evcnt.c

Log Message:
intrcnt[] is changed from long to u_int. Use sizeof(var) instead of
sizeof(type) to catch up with this change.

No binary changes as all ports with __HAVE_LEGACY_INTRCNT are ILP32, IIUC.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_evcnt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_evcnt.c
diff -u src/sys/kern/subr_evcnt.c:1.15 src/sys/kern/subr_evcnt.c:1.16
--- src/sys/kern/subr_evcnt.c:1.15	Fri Apr  2 10:39:22 2021
+++ src/sys/kern/subr_evcnt.c	Thu Apr 15 00:37:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_evcnt.c,v 1.15 2021/04/02 10:39:22 simonb Exp $ */
+/* $NetBSD: subr_evcnt.c,v 1.16 2021/04/15 00:37:31 rin Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.15 2021/04/02 10:39:22 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.16 2021/04/15 00:37:31 rin Exp $");
 
 #include 
 #include 
@@ -393,7 +393,7 @@ evcnt_attach_legacy_intrcnt(void)
 	size_t i;
 	const char *cp;
 
-	nintr = ((intptr_t)eintrcnt - (intptr_t)intrcnt) / sizeof(long);
+	nintr = ((intptr_t)eintrcnt - (intptr_t)intrcnt) / sizeof(intrcnt[0]);
 	intr_evcnts = kmem_alloc(sizeof(struct evcnt) * nintr, KM_SLEEP);
 	for (cp = intrnames, i = 0; i < nintr; i++) {
 		evcnt_attach_dynamic(_evcnts[i], EVCNT_TYPE_INTR,



CVS commit: src/sys/dev

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 15 00:32:50 UTC 2021

Modified Files:
src/sys/dev: dksubr.c

Log Message:
dk_start(): retry device-dependent start() routine later, also when it
returns ENOMEM in addition to EAGAIN.

Device-dependent start() routine may allocate buffer directly, or via
bus_dma(9) API (some implementations for bus_dma(9) like alpha allocate
memory internally).

If these attempts fail with ENOMEM, this is not a disk error, therefore
we must retry later, as already done for EAGAIN.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/dksubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/dksubr.c
diff -u src/sys/dev/dksubr.c:1.112 src/sys/dev/dksubr.c:1.113
--- src/sys/dev/dksubr.c:1.112	Sun Mar  1 03:21:54 2020
+++ src/sys/dev/dksubr.c	Thu Apr 15 00:32:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.112 2020/03/01 03:21:54 riastradh Exp $ */
+/* $NetBSD: dksubr.c,v 1.113 2021/04/15 00:32:50 rin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.112 2020/03/01 03:21:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.113 2021/04/15 00:32:50 rin Exp $");
 
 #include 
 #include 
@@ -428,7 +428,10 @@ dk_start(struct dk_softc *dksc, struct b
 			mutex_exit(>sc_iolock);
 			error = dkd->d_diskstart(dksc->sc_dev, bp);
 			mutex_enter(>sc_iolock);
-			if (error == EAGAIN) {
+			if (error == EAGAIN || error == ENOMEM) {
+/*
+ * Not a disk error. Retry later.
+ */
 KASSERT(dksc->sc_deferred == NULL);
 dksc->sc_deferred = bp;
 disk_unbusy(>sc_dkdev, 0, (bp->b_flags & B_READ));



CVS commit: src/sys/arch/alpha/alpha

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 15 00:19:52 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: interrupt.c

Log Message:
Contrary to comment here, nowadays hardclock() and statclock() should be
called with cpu_intr_p() is turning on, if used from the interrupt context.

Otherwise, entropy_enter() is used instead of entropy_enter_intr(), which
results in KASSERT() failure.

Therefore, bump ci_intrdepth for clock interrupt. Remove stale comment also.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/alpha/alpha/interrupt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/alpha/interrupt.c
diff -u src/sys/arch/alpha/alpha/interrupt.c:1.92 src/sys/arch/alpha/alpha/interrupt.c:1.93
--- src/sys/arch/alpha/alpha/interrupt.c:1.92	Sat Oct 10 03:05:04 2020
+++ src/sys/arch/alpha/alpha/interrupt.c	Thu Apr 15 00:19:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: interrupt.c,v 1.92 2020/10/10 03:05:04 thorpej Exp $ */
+/* $NetBSD: interrupt.c,v 1.93 2021/04/15 00:19:52 rin Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.92 2020/10/10 03:05:04 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.93 2021/04/15 00:19:52 rin Exp $");
 
 #include 
 #include 
@@ -212,12 +212,7 @@ interrupt(unsigned long a0, unsigned lon
 		break;
 		
 	case ALPHA_INTR_CLOCK:	/* clock interrupt */
-		/*
-		 * We don't increment the interrupt depth for the
-		 * clock interrupt, since it is *sampled* from
-		 * the clock interrupt, so if we did, all system
-		 * time would be counted as interrupt time.
-		 */
+		atomic_inc_ulong(>ci_intrdepth);
 		sc->sc_evcnt_clock.ev_count++;
 		ci->ci_data.cpu_nintr++;
 		if (platform.clockintr) {
@@ -242,6 +237,7 @@ interrupt(unsigned long a0, unsigned lon
 			schedhz != 0)
 schedclock(ci->ci_curlwp);
 		}
+		atomic_dec_ulong(>ci_intrdepth);
 		break;
 
 	case ALPHA_INTR_ERROR:	/* Machine Check or Correctable Error */



CVS commit: src/sys/arch/alpha/common

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 15 00:11:10 UTC 2021

Modified Files:
src/sys/arch/alpha/common: sgmap_typedep.c

Log Message:
Fix inverted logic!!

vmem_xalloc(9) should be used with VM_NOSLEEP for BUS_DMA_NOWAIT.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/alpha/common/sgmap_typedep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/common/sgmap_typedep.c
diff -u src/sys/arch/alpha/common/sgmap_typedep.c:1.40 src/sys/arch/alpha/common/sgmap_typedep.c:1.41
--- src/sys/arch/alpha/common/sgmap_typedep.c:1.40	Sun Oct 11 00:33:30 2020
+++ src/sys/arch/alpha/common/sgmap_typedep.c	Thu Apr 15 00:11:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.40 2020/10/11 00:33:30 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.41 2021/04/15 00:11:09 rin Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.40 2020/10/11 00:33:30 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.41 2021/04/15 00:11:09 rin Exp $");
 
 #include "opt_ddb.h"
 
@@ -138,7 +138,7 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag
 #endif
 
 	const vm_flag_t vmflags = VM_INSTANTFIT |
-	((flags & BUS_DMA_NOWAIT) ? VM_SLEEP : VM_NOSLEEP);
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
 
 	error = vmem_xalloc(sgmap->aps_arena, sgvalen,
 			alignment,		/* alignment */



CVS commit: src/sys/arch

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 15 00:04:07 UTC 2021

Modified Files:
src/sys/arch/powerpc/powerpc: powerpc_machdep.c
src/sys/arch/sandpoint/include: types.h

Log Message:
sandpoint has its own module_init_md(). So, do not compile in
that function in powerpc_machdep.c.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/powerpc/powerpc/powerpc_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/include/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/powerpc/powerpc_machdep.c
diff -u src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.82 src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.83
--- src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.82	Sat Mar  6 08:32:17 2021
+++ src/sys/arch/powerpc/powerpc/powerpc_machdep.c	Thu Apr 15 00:04:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: powerpc_machdep.c,v 1.82 2021/03/06 08:32:17 rin Exp $	*/
+/*	$NetBSD: powerpc_machdep.c,v 1.83 2021/04/15 00:04:07 rin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.82 2021/03/06 08:32:17 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.83 2021/04/15 00:04:07 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -820,7 +820,7 @@ emulate_mxmsr(struct lwp *l, struct trap
 	return 0;
 }
 
-#ifdef MODULAR
+#if defined(MODULAR) && !defined(__PPC_HAVE_MODULE_INIT_MD)
 /*
  * Push any modules loaded by the boot loader.
  */
@@ -828,7 +828,7 @@ void
 module_init_md(void)
 {
 }
-#endif /* MODULAR */
+#endif
 
 bool
 mm_md_direct_mapped_phys(paddr_t pa, vaddr_t *vap)

Index: src/sys/arch/sandpoint/include/types.h
diff -u src/sys/arch/sandpoint/include/types.h:1.9 src/sys/arch/sandpoint/include/types.h:1.10
--- src/sys/arch/sandpoint/include/types.h:1.9	Thu Apr  1 04:35:47 2021
+++ src/sys/arch/sandpoint/include/types.h	Thu Apr 15 00:04:07 2021
@@ -1,6 +1,7 @@
-/*	$NetBSD: types.h,v 1.9 2021/04/01 04:35:47 simonb Exp $	*/
+/*	$NetBSD: types.h,v 1.10 2021/04/15 00:04:07 rin Exp $	*/
 
 #define	__HAVE_NEW_STYLE_BUS_H
+#define	__PPC_HAVE_MODULE_INIT_MD
 
 #include 
 



CVS commit: src/sys/arch/powerpc/ibm4xx

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 15 00:00:46 UTC 2021

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Use uvm_km_alloc(9) with UVM_KMF_NOWAIT flag in pte_enter(), in order not to
sleep in pmap_enter(9) and pmap_kenter_pa(9), which can result in dead lock.

In most cases, pmap_enter(9) is used with PMAP_CANFAIL flag. In this case,
if pte_enter() fails due to uvm_km_alloc(9), we can safely return ENOMEM.
UVM layer will take care of it.

uvm_km_alloc(9) fails for pmap_enter(9) without PMAP_CANFAIL or for
pmap_kenter_pa(9), we have no choice but to panic there.

However, my testbeds for 403 and 405 survive more than a week at least
without hitting this panic.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/powerpc/ibm4xx/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.97 src/sys/arch/powerpc/ibm4xx/pmap.c:1.98
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.97	Wed Apr 14 23:45:11 2021
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Apr 15 00:00:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.97 2021/04/14 23:45:11 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.98 2021/04/15 00:00:46 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.97 2021/04/14 23:45:11 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.98 2021/04/15 00:00:46 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -236,11 +236,15 @@ pte_enter(struct pmap *pm, vaddr_t va, u
 	if (!pm->pm_ptbl[seg]) {
 		/* Don't allocate a page to clear a non-existent mapping. */
 		if (!pte)
+			return 1;
+
+		vaddr_t km = uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
+		UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
+
+		if (__predict_false(km == 0))
 			return 0;
-		/* Allocate a page  this will sleep! */
-		pm->pm_ptbl[seg] =
-		(uint *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
-		UVM_KMF_WIRED | UVM_KMF_ZERO);
+
+		pm->pm_ptbl[seg] = (u_int *)km;
 	}
 	oldpte = pm->pm_ptbl[seg][ptn];
 	pm->pm_ptbl[seg][ptn] = pte;
@@ -862,7 +866,7 @@ pmap_enter(struct pmap *pm, vaddr_t va, 
 
 		if (!pmap_enter_pv(pm, va, pa, flags)) {
 			/* Could not enter pv on a managed page */
-			return 1;
+			return ENOMEM;
 		}
 
 		/* Now set attributes. */
@@ -880,7 +884,12 @@ pmap_enter(struct pmap *pm, vaddr_t va, 
 	s = splvm();
 
 	/* Insert page into page table. */
-	pte_enter(pm, va, tte);
+	if (__predict_false(!pte_enter(pm, va, tte))) {
+		if (__predict_false((flags & PMAP_CANFAIL) == 0))
+			panic("%s: pte_enter", __func__);
+		splx(s);
+		return ENOMEM;
+	}
 
 	/* If this is a real fault, enter it in the tlb */
 	if (tte && ((flags & PMAP_WIRED) == 0)) {
@@ -969,7 +978,8 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v
 	s = splvm();
 
 	/* Insert page into page table. */
-	pte_enter(pm, va, tte);
+	if (__predict_false(!pte_enter(pm, va, tte)))
+		panic("%s: pte_enter", __func__);
 	splx(s);
 }
 
@@ -978,7 +988,7 @@ pmap_kremove(vaddr_t va, vsize_t len)
 {
 
 	while (len > 0) {
-		pte_enter(pmap_kernel(), va, 0);
+		(void)pte_enter(pmap_kernel(), va, 0);	/* never fail */
 		va += PAGE_SIZE;
 		len -= PAGE_SIZE;
 	}



CVS commit: src/sys/arch/powerpc/ibm4xx

2021-04-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 14 23:45:11 UTC 2021

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Style fixes:

- Add "static inline" to pte_enter(), to match with its declaration.
- Remove parentheses from return.
- Use NULL instead of 0 for pointer initialization.

No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/powerpc/ibm4xx/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.96 src/sys/arch/powerpc/ibm4xx/pmap.c:1.97
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.96	Tue Mar 30 03:15:53 2021
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Wed Apr 14 23:45:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.96 2021/03/30 03:15:53 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.97 2021/04/14 23:45:11 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.96 2021/03/30 03:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.97 2021/04/14 23:45:11 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -226,7 +226,7 @@ pa_to_attr(paddr_t pa)
 /*
  * Insert PTE into page table.
  */
-int
+static inline int
 pte_enter(struct pmap *pm, vaddr_t va, u_int pte)
 {
 	int seg = STIDX(va);
@@ -236,7 +236,7 @@ pte_enter(struct pmap *pm, vaddr_t va, u
 	if (!pm->pm_ptbl[seg]) {
 		/* Don't allocate a page to clear a non-existent mapping. */
 		if (!pte)
-			return (0);
+			return 0;
 		/* Allocate a page  this will sleep! */
 		pm->pm_ptbl[seg] =
 		(uint *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
@@ -253,7 +253,7 @@ pte_enter(struct pmap *pm, vaddr_t va, u
 		else
 			pm->pm_stats.resident_count++;
 	}
-	return (1);
+	return 1;
 }
 
 /*
@@ -266,9 +266,9 @@ pte_find(struct pmap *pm, vaddr_t va)
 	int ptn = PTIDX(va);
 
 	if (pm->pm_ptbl[seg])
-		return (>pm_ptbl[seg][ptn]);
+		return >pm_ptbl[seg][ptn];
 
-	return (NULL);
+	return NULL;
 }
 
 /*
@@ -293,7 +293,7 @@ pmap_bootstrap(u_int kernelstart, u_int 
 	 * Initialize kernel page table.
 	 */
 	for (i = 0; i < STSZ; i++) {
-		pmap_kernel()->pm_ptbl[i] = 0;
+		pmap_kernel()->pm_ptbl[i] = NULL;
 	}
 	ctxbusy[0] = ctxbusy[1] = pmap_kernel();
 
@@ -565,7 +565,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		pm->pm_ptbl[seg] = (u_int *)pg;
 	}
 	splx(s);
-	return (kbreak);
+	return kbreak;
 }
 
 /*
@@ -758,7 +758,7 @@ pmap_enter_pv(struct pmap *pm, vaddr_t v
 		pm->pm_stats.wired_count++;
 	}
 	splx(s);
-	return (1);
+	return 1;
 }
 
 static void
@@ -1026,7 +1026,7 @@ pmap_extract(struct pmap *pm, vaddr_t va
 		*pap = TTE_PA(pa) | (va & PGOFSET);
 	}
 	splx(s);
-	return (pa != 0);
+	return pa != 0;
 }
 
 /*
@@ -1338,7 +1338,7 @@ ppc4xx_tlb_find_victim(void)
 tlb_info[tlbnext].ti_flags = flags;
 			} else {
 /* Found it! */
-return (tlbnext);
+return tlbnext;
 			}
 		} else {
 			tlb_info[tlbnext].ti_flags = (flags & ~TLBF_REF);
@@ -1428,9 +1428,9 @@ ppc4xx_tlb_size_mask(size_t size, int *m
 		if (size <= tlbsize[i]) {
 			*mask = (i << TLB_SIZE_SHFT);
 			*rsiz = tlbsize[i];
-			return (0);
+			return 0;
 		}
-	return (EINVAL);
+	return EINVAL;
 }
 
 /*
@@ -1470,10 +1470,10 @@ ppc4xx_tlb_mapiodev(paddr_t base, psize_
 			continue;
 
 		va = (hi & TLB_EPN_MASK) + (base & (sz - 1)); 	/* sz = 2^n */
-		return (void *)(va);
+		return (void *)va;
 	}
 
-	return (NULL);
+	return NULL;
 }
 
 /*
@@ -1579,7 +1579,7 @@ ctx_flush(int cnum)
 Debugger();
 #endif
 #endif
-return (1);
+return 1;
 			}
 #ifdef DIAGNOSTIC
 			if (i < tlb_nreserved)
@@ -1592,7 +1592,7 @@ ctx_flush(int cnum)
 			tlb_invalidate_entry(i);
 		}
 	}
-	return (0);
+	return 0;
 }
 
 /*
@@ -1610,7 +1610,7 @@ ctx_alloc(struct pmap *pm)
 #ifdef DIAGNOSTIC
 		printf("ctx_alloc: kernel pmap!\n");
 #endif
-		return (0);
+		return 0;
 	}
 	s = splvm();
 



CVS commit: src/usr.bin/xlint/lint1

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 22:08:28 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: remove stray semicolon from grammar, make empty rule visible

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.217 src/usr.bin/xlint/lint1/cgram.y:1.218
--- src/usr.bin/xlint/lint1/cgram.y:1.217	Wed Apr 14 21:20:21 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Apr 14 22:08:28 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.217 2021/04/14 21:20:21 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.218 2021/04/14 22:08:28 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.217 2021/04/14 21:20:21 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.218 2021/04/14 22:08:28 rillig Exp $");
 #endif
 
 #include 
@@ -1133,7 +1133,8 @@ param_decl:
 	;
 
 opt_type_qualifier_list:
-	| type_qualifier_list;
+	  /* empty */
+	| type_qualifier_list
 	;
 
 array_size:



CVS commit: src/tests/usr.bin/xlint/lint1

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 22:06:38 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_343.c msg_343.exp

Log Message:
tests/lint: adjust test for C11 to the change in grammar and options


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_343.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_343.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_343.c
diff -u src/tests/usr.bin/xlint/lint1/msg_343.c:1.3 src/tests/usr.bin/xlint/lint1/msg_343.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_343.c:1.3	Wed Apr 14 20:06:40 2021
+++ src/tests/usr.bin/xlint/lint1/msg_343.c	Wed Apr 14 22:06:38 2021
@@ -1,14 +1,14 @@
-/*	$NetBSD: msg_343.c,v 1.3 2021/04/14 20:06:40 rillig Exp $	*/
+/*	$NetBSD: msg_343.c,v 1.4 2021/04/14 22:06:38 rillig Exp $	*/
 # 3 "msg_343.c"
 
 /* Test for message: static array size is a C11 extension [343] */
 
-/* lint1-flags: -gSw */
+/* lint1-flags: -Sw */
 
 void takes_int_pointer(int []);
 void takes_int_pointer_with_ignored_size(int [3]);
 void takes_int_array(int[static 3]);	/* expect: 343 */
-/* expect+1: syntax error 'volatile' */
+/* expect+1: syntax error '3' */
 void takes_volatile_int_array(int[volatile 3]);
 
 int
@@ -30,7 +30,7 @@ returns_int_array(int a[static 3])	/* ex
 }
 
 int
-/* expect+1: syntax error 'volatile' */
+/* expect+1: syntax error '3' */
 returns_volatile_int_array(int a[volatile 3])
 {
 	/* expect+2: cannot dereference non-pointer type */

Index: src/tests/usr.bin/xlint/lint1/msg_343.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_343.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_343.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_343.exp:1.2	Wed Apr 14 18:35:40 2021
+++ src/tests/usr.bin/xlint/lint1/msg_343.exp	Wed Apr 14 22:06:38 2021
@@ -1,6 +1,6 @@
 msg_343.c(10): error: static array size is a C11 extension [343]
-msg_343.c(12): error: syntax error 'volatile' [249]
+msg_343.c(12): error: syntax error '3' [249]
 msg_343.c(27): error: static array size is a C11 extension [343]
-msg_343.c(34): error: syntax error 'volatile' [249]
+msg_343.c(34): error: syntax error '3' [249]
 msg_343.c(38): error: cannot dereference non-pointer type [96]
 msg_343.c(38): warning: function returns_volatile_int_array expects to return value [214]



CVS commit: src/sys/crypto/adiantum

2021-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 14 21:29:57 UTC 2021

Modified Files:
src/sys/crypto/adiantum: adiantum.c

Log Message:
use an enum instead of constant variables so that they work in CTASSERT.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/crypto/adiantum/adiantum.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/crypto/adiantum/adiantum.c
diff -u src/sys/crypto/adiantum/adiantum.c:1.5 src/sys/crypto/adiantum/adiantum.c:1.6
--- src/sys/crypto/adiantum/adiantum.c:1.5	Sun Jul 26 00:05:20 2020
+++ src/sys/crypto/adiantum/adiantum.c	Wed Apr 14 17:29:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: adiantum.c,v 1.5 2020/07/26 04:05:20 riastradh Exp $	*/
+/*	$NetBSD: adiantum.c,v 1.6 2021/04/14 21:29:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: adiantum.c,v 1.5 2020/07/26 04:05:20 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: adiantum.c,v 1.6 2021/04/14 21:29:57 christos Exp $");
 
 #include 
 #include 
@@ -390,10 +390,12 @@ static void
 nh(uint8_t h[static 32], const uint8_t *m, size_t mlen,
 const uint32_t k[static 268 /* u/w + 2s(r - 1) */])
 {
-	const unsigned w = 32;	 /* word size */
-	const unsigned s = 2;	 /* stride */
-	const unsigned r = 4;	 /* rounds */
-	const unsigned u = 8192; /* unit count (bits per msg unit) */
+	enum {
+	s = 2,	 /* stride */
+	r = 4,	 /* rounds */
+	w = 32,	 /* word size */
+	u = 8192	 /* unit count (bits per msg unit) */
+	};
 	uint64_t h0 = 0, h1 = 0, h2 = 0, h3 = 0;
 	unsigned i;
 



CVS commit: src/usr.bin/xlint/lint1

2021-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 14 21:20:21 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
there is also an optional type qualifier list in the array size


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.216 src/usr.bin/xlint/lint1/cgram.y:1.217
--- src/usr.bin/xlint/lint1/cgram.y:1.216	Wed Apr 14 14:35:40 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Apr 14 17:20:21 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.216 2021/04/14 18:35:40 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.217 2021/04/14 21:20:21 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.216 2021/04/14 18:35:40 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.217 2021/04/14 21:20:21 christos Exp $");
 #endif
 
 #include 
@@ -1132,14 +1132,18 @@ param_decl:
 	  }
 	;
 
+opt_type_qualifier_list:
+	| type_qualifier_list;
+	;
+
 array_size:
-	  T_SCLASS constant_expr {
+	  opt_type_qualifier_list T_SCLASS constant_expr {
 		/* C11 6.7.6.3p7 */
-		if ($1 != STATIC)
+		if ($2 != STATIC)
 			yyerror("Bad attribute");
 		/* static array size is a C11 extension */
 		c11ism(343);
-		$$ = $2;
+		$$ = $3;
 	  }
 	| constant_expr {
 		$$ = $1;



CVS commit: src/usr.bin/xlint/lint1

2021-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 14 21:20:02 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: err.c

Log Message:
gnu enables c11 extensions


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/xlint/lint1/err.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.110 src/usr.bin/xlint/lint1/err.c:1.111
--- src/usr.bin/xlint/lint1/err.c:1.110	Wed Apr 14 16:06:40 2021
+++ src/usr.bin/xlint/lint1/err.c	Wed Apr 14 17:20:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.110 2021/04/14 20:06:40 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.111 2021/04/14 21:20:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.110 2021/04/14 20:06:40 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.111 2021/04/14 21:20:02 christos Exp $");
 #endif
 
 #include 
@@ -617,7 +617,7 @@ void
 {
 	va_list	ap;
 
-	if (c11flag)
+	if (c11flag || gflag)
 		return;
 	va_start(ap, n);
 	verror(n, ap);



CVS commit: src/usr.bin/xlint/xlint

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 20:35:31 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: un-abbreviate code for passing options to cpp, lint1 and lint2

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/xlint/xlint.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.60 src/usr.bin/xlint/xlint/xlint.c:1.61
--- src/usr.bin/xlint/xlint/xlint.c:1.60	Wed Apr 14 20:06:40 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Wed Apr 14 20:35:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.60 2021/04/14 20:06:40 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.61 2021/04/14 20:35:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.60 2021/04/14 20:06:40 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.61 2021/04/14 20:35:31 rillig Exp $");
 #endif
 
 #include 
@@ -204,6 +204,27 @@ freelst(char ***lstp)
 	}
 }
 
+static void
+pass_to_lint1(const char *opt)
+{
+
+	appcstrg(, opt);
+}
+
+static void
+pass_to_lint2(const char *opt)
+{
+
+	appcstrg(, opt);
+}
+
+static void
+pass_to_cpp(const char *opt)
+{
+
+	appcstrg(, opt);
+}
+
 static char *
 concat2(const char *s1, const char *s2)
 {
@@ -345,25 +366,25 @@ main(int argc, char *argv[])
 	libs = xcalloc(1, sizeof(*libs));
 	libsrchpath = xcalloc(1, sizeof(*libsrchpath));
 
-	appcstrg(, "-E");
-	appcstrg(, "-x");
-	appcstrg(, "c");
+	pass_to_cpp("-E");
+	pass_to_cpp("-x");
+	pass_to_cpp("c");
 #if 0
-	appcstrg(, "-D__attribute__(x)=");
-	appcstrg(, "-D__extension__(x)=/*NOSTRICT*/0");
+	pass_to_cpp("-D__attribute__(x)=");
+	pass_to_cpp("-D__extension__(x)=/*NOSTRICT*/0");
 #else
-	appcstrg(, "-U__GNUC__");
-	appcstrg(, "-U__PCC__");
-	appcstrg(, "-U__SSE__");
-	appcstrg(, "-U__SSE4_1__");
+	pass_to_cpp("-U__GNUC__");
+	pass_to_cpp("-U__PCC__");
+	pass_to_cpp("-U__SSE__");
+	pass_to_cpp("-U__SSE4_1__");
 #endif
 #if 0
-	appcstrg(, "-Wp,-$");
+	pass_to_cpp("-Wp,-$");
 #endif
-	appcstrg(, "-Wp,-CC");
-	appcstrg(, "-Wcomment");
-	appcstrg(, "-D__LINT__");
-	appcstrg(, "-Dlint");		/* XXX don't def. with -s */
+	pass_to_cpp("-Wp,-CC");
+	pass_to_cpp("-Wcomment");
+	pass_to_cpp("-D__LINT__");
+	pass_to_cpp("-Dlint");		/* XXX don't def. with -s */
 
 	appdef(, "lint");
 
@@ -388,12 +409,12 @@ main(int argc, char *argv[])
 		case 'w':
 		case 'z':
 			(void)sprintf(flgbuf, "-%c", c);
-			appcstrg(, flgbuf);
+			pass_to_lint1(flgbuf);
 			break;
 
 		case 'A':
-			appcstrg(, "-A");
-			appcstrg(, optarg);
+			pass_to_lint1("-A");
+			pass_to_lint1(optarg);
 			break;
 
 		case 'F':
@@ -402,14 +423,14 @@ main(int argc, char *argv[])
 		case 'u':
 		case 'h':
 			(void)sprintf(flgbuf, "-%c", c);
-			appcstrg(, flgbuf);
-			appcstrg(, flgbuf);
+			pass_to_lint1(flgbuf);
+			pass_to_lint2(flgbuf);
 			break;
 
 		case 'X':
 			(void)sprintf(flgbuf, "-%c", c);
-			appcstrg(, flgbuf);
-			appcstrg(, optarg);
+			pass_to_lint1(flgbuf);
+			pass_to_lint1(optarg);
 			break;
 
 		case 'i':
@@ -423,8 +444,8 @@ main(int argc, char *argv[])
 			break;
 
 		case 'p':
-			appcstrg(, "-p");
-			appcstrg(, "-p");
+			pass_to_lint1("-p");
+			pass_to_lint2("-p");
 			if (*deflibs != NULL) {
 freelst();
 appcstrg(, "c");
@@ -432,11 +453,11 @@ main(int argc, char *argv[])
 			break;
 
 		case 'P':
-			appcstrg(, "-P");
+			pass_to_lint1("-P");
 			break;
 
 		case 'R':
-			appcstrg(, concat2("-R", optarg));
+			pass_to_lint1(concat2("-R", optarg));
 			break;
 
 		case 's':
@@ -447,23 +468,23 @@ main(int argc, char *argv[])
 			appcstrg(, "-Wtrigraphs");
 			appcstrg(, "-pedantic");
 			appcstrg(, "-D__STRICT_ANSI__");
-			appcstrg(, "-s");
-			appcstrg(, "-s");
+			pass_to_lint1("-s");
+			pass_to_lint2("-s");
 			sflag = true;
 			break;
 
 		case 'S':
 			if (tflag)
 usage();
-			appcstrg(, "-S");
+			pass_to_lint1("-S");
 			Sflag = true;
 			break;
 
 		case 'T':
 			(void)sprintf(flgbuf, "-%c", c);
-			appcstrg(, "-I" PATH_STRICT_BOOL_INCLUDE);
-			appcstrg(, flgbuf);
-			appcstrg(, flgbuf);
+			pass_to_cpp("-I" PATH_STRICT_BOOL_INCLUDE);
+			pass_to_lint1(flgbuf);
+			pass_to_lint2(flgbuf);
 			break;
 
 #if ! HAVE_NBTOOL_CONFIG_H
@@ -475,14 +496,14 @@ main(int argc, char *argv[])
 			appcstrg(, "-Wtraditional");
 			appstrg(, concat2("-D", MACHINE));
 			appstrg(, concat2("-D", MACHINE_ARCH));
-			appcstrg(, "-t");
-			appcstrg(, "-t");
+			pass_to_lint1("-t");
+			pass_to_lint2("-t");
 			tflag = true;
 			break;
 #endif
 
 		case 'x':
-			appcstrg(, "-x");
+			pass_to_lint2("-x");
 			break;
 
 		case 'C':
@@ -499,9 +520,9 @@ main(int argc, char *argv[])
 			if (dflag)
 usage();
 			dflag = true;
-			appcstrg(, "-nostdinc");
-			appcstrg(, "-isystem");
-			

CVS commit: src

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 20:06:40 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_343.c
src/usr.bin/xlint/lint1: err.c externs1.h main1.c
src/usr.bin/xlint/xlint: lint.1 xlint.c

Log Message:
lint: add option to accept C11 features

The list of available letters for the command line options gets shorter
and shorter.  Most of the interesting letters are already used for some
warning categories.  Curiously, -A, -W and -E were all still available.

The option -A nicely matches the intention of the option, which is to
allow a certain set of language features.  To keep the option available
for further extensions, define -Ac11 as the currently only valid option
of that kind.  This allows straight-forward extension for C17 and future
language standards, as well as independent feature-sets.  The options -W
and -E may someday complement the -A option, using the allow/warn/error
categories.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_343.c
cvs rdiff -u -r1.109 -r1.110 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/xlint/lint.1
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/xlint/xlint.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_343.c
diff -u src/tests/usr.bin/xlint/lint1/msg_343.c:1.2 src/tests/usr.bin/xlint/lint1/msg_343.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_343.c:1.2	Wed Apr 14 18:35:40 2021
+++ src/tests/usr.bin/xlint/lint1/msg_343.c	Wed Apr 14 20:06:40 2021
@@ -1,9 +1,9 @@
-/*	$NetBSD: msg_343.c,v 1.2 2021/04/14 18:35:40 rillig Exp $	*/
+/*	$NetBSD: msg_343.c,v 1.3 2021/04/14 20:06:40 rillig Exp $	*/
 # 3 "msg_343.c"
 
 /* Test for message: static array size is a C11 extension [343] */
 
-/* lint1-flags: -sw */
+/* lint1-flags: -gSw */
 
 void takes_int_pointer(int []);
 void takes_int_pointer_with_ignored_size(int [3]);

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.109 src/usr.bin/xlint/lint1/err.c:1.110
--- src/usr.bin/xlint/lint1/err.c:1.109	Wed Apr 14 18:38:06 2021
+++ src/usr.bin/xlint/lint1/err.c	Wed Apr 14 20:06:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.109 2021/04/14 18:38:06 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.110 2021/04/14 20:06:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.109 2021/04/14 18:38:06 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.110 2021/04/14 20:06:40 rillig Exp $");
 #endif
 
 #include 
@@ -612,19 +612,15 @@ void
 	va_end(ap);
 }
 
-/* TODO: add a command line option for allowing C99 but not C11. */
 void
 (c11ism)(int n, ...)
 {
 	va_list	ap;
-	bool extensions_ok = Sflag || gflag;
 
+	if (c11flag)
+		return;
 	va_start(ap, n);
-	if (sflag && !extensions_ok) {
-		verror(n, ap);
-	} else if (sflag || !extensions_ok) {
-		vwarning(n, ap);
-	}
+	verror(n, ap);
 	va_end(ap);
 }
 

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.104 src/usr.bin/xlint/lint1/externs1.h:1.105
--- src/usr.bin/xlint/lint1/externs1.h:1.104	Wed Apr 14 18:35:40 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Wed Apr 14 20:06:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.104 2021/04/14 18:35:40 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.105 2021/04/14 20:06:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,6 +37,7 @@
 extern	int	aflag;
 extern	bool	bflag;
 extern	bool	cflag;
+extern	bool	c11flag;
 extern	bool	dflag;
 extern	bool	eflag;
 extern	bool	Fflag;

Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.42 src/usr.bin/xlint/lint1/main1.c:1.43
--- src/usr.bin/xlint/lint1/main1.c:1.42	Fri Apr  2 12:16:50 2021
+++ src/usr.bin/xlint/lint1/main1.c	Wed Apr 14 20:06:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.42 2021/04/02 12:16:50 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.43 2021/04/14 20:06:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.42 2021/04/02 12:16:50 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.43 2021/04/14 20:06:40 rillig Exp $");
 #endif
 
 #include 
@@ -68,6 +68,9 @@ bool	bflag;
 /* Print warnings for pointer casts. */
 bool	cflag;
 
+/* Allow features from C11, C99 and C90. */
+bool	c11flag;
+
 /* Print various debug information. */
 bool	dflag;
 
@@ -178,7 +181,7 @@ main(int argc, char *argv[])
 	setprogname(argv[0]);
 
 	ERR_ZERO();
-	while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFPR:STX:")) != -1) {
+	while ((c = getopt(argc, argv, "abcdeghmprstuvwyzA:FPR:STX:")) != -1) {
 		switch (c) {
 		case 'a':	aflag++;	

CVS commit: src/usr.bin/xlint/xlint

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 19:25:48 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: arrange options in the usage messages

* lowercase the word 'usage'
* group the preprocessor flags on a line of their own
* add missing closing ']' for '-X'
* properly indent the lines


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/xlint/xlint.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.58 src/usr.bin/xlint/xlint/xlint.c:1.59
--- src/usr.bin/xlint/xlint/xlint.c:1.58	Fri Apr  2 12:16:50 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Wed Apr 14 19:25:48 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.58 2021/04/02 12:16:50 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.59 2021/04/14 19:25:48 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.58 2021/04/02 12:16:50 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.59 2021/04/14 19:25:48 rillig Exp $");
 #endif
 
 #include 
@@ -288,18 +288,22 @@ appdef(char ***lstp, const char *def)
 static void
 usage(void)
 {
+	const char *name;
+	int indent;
 
+	name = getprogname();
+	indent = (int)(strlen("usage: ") + strlen(name));
 	(void)fprintf(stderr,
-	"Usage: %s [-abceghprvwxzHFST] [-s|-t] [-i|-nu] [-Dname[=def]]"
-	" [-Uname] [-X [,]... [-Z ]\n", getprogname());
+	"usage: %s [-abceghprvwxzHFST] [-s|-t] [-i|-nu]\n"
+	"%*s [-Dname[=def]] [-Uname] [-Idirectory] [-Z ]\n"
+	"%*s [-Ldirectory] [-llibrary] [-ooutputfile]\n"
+	"%*s [-X [,]...] file...\n",
+	name, indent, "", indent, "", indent, "");
 	(void)fprintf(stderr,
-	"\t[-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile]"
-	" file...\n");
-	(void)fprintf(stderr,
-	"   %s [-abceghprvwzHFST] [|-s|-t] -Clibrary [-Dname[=def]]\n"
-	" [-X [,]... [-Z ]\n", getprogname());
-	(void)fprintf(stderr, "\t[-Idirectory] [-Uname] [-Bpath] [-R old=new]"
-	" file ...\n");
+	"   %s [-abceghprvwzHFST] [-s|-t] -Clibrary\n"
+	"%*s [-Dname[=def]] [-Uname] [-Idirectory] [-Z ]\n"
+	"%*s [-Bpath] [-X [,]...] [-R old=new] file ...\n",
+	name, indent, "", indent, "");
 	terminate(-1);
 }
 



CVS commit: src/usr.bin/xlint/lint1

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 18:38:06 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: err.c

Log Message:
lint: remove redundant condition in update_location


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/xlint/lint1/err.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.108 src/usr.bin/xlint/lint1/err.c:1.109
--- src/usr.bin/xlint/lint1/err.c:1.108	Wed Apr 14 18:35:40 2021
+++ src/usr.bin/xlint/lint1/err.c	Wed Apr 14 18:38:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.108 2021/04/14 18:35:40 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.109 2021/04/14 18:38:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.108 2021/04/14 18:35:40 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.109 2021/04/14 18:38:06 rillig Exp $");
 #endif
 
 #include 
@@ -423,7 +423,7 @@ update_location(const char *filename, in
 		top->by = includes;
 		includes = top;
 	} else {
-		if (is_end && top != NULL) {
+		if (is_end) {
 			includes = top->by;
 			free(top);
 			top = includes;



CVS commit: src

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 18:35:40 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_343.c msg_343.exp
src/usr.bin/xlint/lint1: cgram.y check-msgs.lua err.c externs1.h
lint1.h

Log Message:
lint: add support for C11-isms such as int[static 3]


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_343.c \
src/tests/usr.bin/xlint/lint1/msg_343.exp
cvs rdiff -u -r1.215 -r1.216 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/check-msgs.lua
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/xlint/lint1/lint1.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_343.c
diff -u src/tests/usr.bin/xlint/lint1/msg_343.c:1.1 src/tests/usr.bin/xlint/lint1/msg_343.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_343.c:1.1	Wed Apr 14 18:27:11 2021
+++ src/tests/usr.bin/xlint/lint1/msg_343.c	Wed Apr 14 18:35:40 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_343.c,v 1.1 2021/04/14 18:27:11 rillig Exp $	*/
+/*	$NetBSD: msg_343.c,v 1.2 2021/04/14 18:35:40 rillig Exp $	*/
 # 3 "msg_343.c"
 
-/* Test for message: static array size is a C99 extension [343] */
+/* Test for message: static array size is a C11 extension [343] */
 
 /* lint1-flags: -sw */
 
Index: src/tests/usr.bin/xlint/lint1/msg_343.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_343.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_343.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_343.exp:1.1	Wed Apr 14 18:27:11 2021
+++ src/tests/usr.bin/xlint/lint1/msg_343.exp	Wed Apr 14 18:35:40 2021
@@ -1,6 +1,6 @@
-msg_343.c(10): error: static array size is a C99 extension [343]
+msg_343.c(10): error: static array size is a C11 extension [343]
 msg_343.c(12): error: syntax error 'volatile' [249]
-msg_343.c(27): error: static array size is a C99 extension [343]
+msg_343.c(27): error: static array size is a C11 extension [343]
 msg_343.c(34): error: syntax error 'volatile' [249]
 msg_343.c(38): error: cannot dereference non-pointer type [96]
 msg_343.c(38): warning: function returns_volatile_int_array expects to return value [214]

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.215 src/usr.bin/xlint/lint1/cgram.y:1.216
--- src/usr.bin/xlint/lint1/cgram.y:1.215	Wed Apr 14 18:27:11 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Apr 14 18:35:40 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.215 2021/04/14 18:27:11 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.216 2021/04/14 18:35:40 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.215 2021/04/14 18:27:11 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.216 2021/04/14 18:35:40 rillig Exp $");
 #endif
 
 #include 
@@ -1134,11 +1134,11 @@ param_decl:
 
 array_size:
 	  T_SCLASS constant_expr {
-		/* C99 6.7.6.3 */
+		/* C11 6.7.6.3p7 */
 		if ($1 != STATIC)
 			yyerror("Bad attribute");
-		/* static array size is a C99 extension */
-		c99ism(343);
+		/* static array size is a C11 extension */
+		c11ism(343);
 		$$ = $2;
 	  }
 	| constant_expr {

Index: src/usr.bin/xlint/lint1/check-msgs.lua
diff -u src/usr.bin/xlint/lint1/check-msgs.lua:1.9 src/usr.bin/xlint/lint1/check-msgs.lua:1.10
--- src/usr.bin/xlint/lint1/check-msgs.lua:1.9	Sun Feb 28 12:45:47 2021
+++ src/usr.bin/xlint/lint1/check-msgs.lua	Wed Apr 14 18:35:40 2021
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: check-msgs.lua,v 1.9 2021/02/28 12:45:47 rillig Exp $
+-- $NetBSD: check-msgs.lua,v 1.10 2021/04/14 18:35:40 rillig Exp $
 
 --[[
 
@@ -83,7 +83,8 @@ local function collect_errors(fname, msg
 
 local func, id = line:match("^%s+(%w+)%((%d+)[),]")
 id = tonumber(id)
-if func == "error" or func == "warning" or func == "c99ism" or
+if func == "error" or func == "warning" or
+   func == "c99ism" or func == "c11ism" or
func == "gnuism" or func == "message" then
   local comment = prev:match("^%s+/%* (.+) %*/$")
   if comment ~= nil then

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.107 src/usr.bin/xlint/lint1/err.c:1.108
--- src/usr.bin/xlint/lint1/err.c:1.107	Wed Apr 14 13:34:08 2021
+++ src/usr.bin/xlint/lint1/err.c	Wed Apr 14 18:35:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.107 2021/04/14 13:34:08 christos Exp $	*/
+/*	$NetBSD: err.c,v 1.108 2021/04/14 18:35:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.107 2021/04/14 13:34:08 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.108 2021/04/14 18:35:40 rillig Exp $");
 #endif
 
 #include 
@@ -397,7 +397,7 

CVS commit: src

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 18:27:11 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile t_integration.sh
src/usr.bin/xlint/lint1: cgram.y
Added Files:
src/tests/usr.bin/xlint/lint1: msg_343.c msg_343.exp

Log Message:
lint: add test for newly added message about static array size


To generate a diff of this commit:
cvs rdiff -u -r1.1039 -r1.1040 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.41 -r1.42 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_343.c \
src/tests/usr.bin/xlint/lint1/msg_343.exp
cvs rdiff -u -r1.40 -r1.41 src/tests/usr.bin/xlint/lint1/t_integration.sh
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1039 src/distrib/sets/lists/tests/mi:1.1040
--- src/distrib/sets/lists/tests/mi:1.1039	Fri Apr  9 21:07:39 2021
+++ src/distrib/sets/lists/tests/mi	Wed Apr 14 18:27:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1039 2021/04/09 21:07:39 rillig Exp $
+# $NetBSD: mi,v 1.1040 2021/04/14 18:27:11 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6870,6 +6870,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_341.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_342.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_342.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_343.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_343.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/t_integration			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.41 src/tests/usr.bin/xlint/lint1/Makefile:1.42
--- src/tests/usr.bin/xlint/lint1/Makefile:1.41	Fri Apr  9 21:07:39 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Wed Apr 14 18:27:11 2021
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.41 2021/04/09 21:07:39 rillig Exp $
+# $NetBSD: Makefile,v 1.42 2021/04/14 18:27:11 rillig Exp $
 
 NOMAN=		# defined
-MAX_MESSAGE=	342		# see lint1/err.c
+MAX_MESSAGE=	343		# see lint1/err.c
 
 .include 
 

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.40 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.41
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.40	Thu Apr  8 22:18:27 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Wed Apr 14 18:27:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.40 2021/04/08 22:18:27 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.41 2021/04/14 18:27:11 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -177,7 +177,7 @@ all_messages_body()
 
 	failed=""
 
-	for msg in $(seq 0 342); do
+	for msg in $(seq 0 343); do
 		name="$(printf 'msg_%03d.c' "${msg}")"
 		check_lint1 "${name}" \
 		|| failed="$failed${failed:+ }$name"

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.214 src/usr.bin/xlint/lint1/cgram.y:1.215
--- src/usr.bin/xlint/lint1/cgram.y:1.214	Wed Apr 14 13:34:08 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Apr 14 18:27:11 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.214 2021/04/14 13:34:08 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.215 2021/04/14 18:27:11 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.214 2021/04/14 13:34:08 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.215 2021/04/14 18:27:11 rillig Exp $");
 #endif
 
 #include 
@@ -1137,9 +1137,10 @@ array_size:
 		/* C99 6.7.6.3 */
 		if ($1 != STATIC)
 			yyerror("Bad attribute");
+		/* static array size is a C99 extension */
 		c99ism(343);
 		$$ = $2;
-	  } 
+	  }
 	| constant_expr {
 		$$ = $1;
 	}

Added files:

Index: src/tests/usr.bin/xlint/lint1/msg_343.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_343.c:1.1
--- /dev/null	Wed Apr 14 18:27:11 2021
+++ src/tests/usr.bin/xlint/lint1/msg_343.c	Wed Apr 14 18:27:11 2021
@@ -0,0 +1,39 @@
+/*	$NetBSD: msg_343.c,v 1.1 2021/04/14 18:27:11 rillig Exp $	*/
+# 3 "msg_343.c"
+
+/* Test for message: static array size is a C99 extension [343] */
+
+/* lint1-flags: -sw */
+
+void takes_int_pointer(int []);
+void takes_int_pointer_with_ignored_size(int [3]);
+void takes_int_array(int[static 3]);	/* expect: 343 */
+/* expect+1: syntax error 'volatile' */

CVS commit: src/usr.bin/make

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 17:39:11 UTC 2021

Modified Files:
src/usr.bin/make: make.h str.h

Log Message:
make: let the compiler decide whether to inline string functions

On x86_64, this reduces the binary size by 2 kB.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/make.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/str.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.261 src/usr.bin/make/make.h:1.262
--- src/usr.bin/make/make.h:1.261	Sun Apr 11 12:06:53 2021
+++ src/usr.bin/make/make.h	Wed Apr 14 17:39:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.261 2021/04/11 12:06:53 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.262 2021/04/14 17:39:11 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,6 +131,7 @@
 #endif
 
 #define MAKE_INLINE static inline MAKE_ATTR_UNUSED
+#define MAKE_STATIC static MAKE_ATTR_UNUSED
 
 #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN)
 #include 

Index: src/usr.bin/make/str.h
diff -u src/usr.bin/make/str.h:1.7 src/usr.bin/make/str.h:1.8
--- src/usr.bin/make/str.h:1.7	Wed Apr 14 16:59:34 2021
+++ src/usr.bin/make/str.h	Wed Apr 14 17:39:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.h,v 1.7 2021/04/14 16:59:34 rillig Exp $	*/
+/*	$NetBSD: str.h,v 1.8 2021/04/14 17:39:11 rillig Exp $	*/
 
 /*
  Copyright (c) 2021 Roland Illig 
@@ -146,7 +146,7 @@ MFStr_Done(MFStr *mfstr)
 }
 
 
-MAKE_INLINE Substring
+MAKE_STATIC Substring
 Substring_Init(const char *start, const char *end)
 {
 	Substring sub;
@@ -162,13 +162,13 @@ Substring_InitStr(const char *str)
 	return Substring_Init(str, str + strlen(str));
 }
 
-MAKE_INLINE size_t
+MAKE_STATIC size_t
 Substring_Length(Substring sub)
 {
 	return (size_t)(sub.end - sub.start);
 }
 
-MAKE_INLINE bool
+MAKE_STATIC bool
 Substring_IsEmpty(Substring sub)
 {
 	return sub.start == sub.end;
@@ -182,7 +182,7 @@ Substring_Equals(Substring sub, const ch
 	   memcmp(sub.start, str, len) == 0;
 }
 
-MAKE_INLINE Substring
+MAKE_STATIC Substring
 Substring_Sub(Substring sub, size_t start, size_t end)
 {
 	assert(start <= Substring_Length(sub));
@@ -190,14 +190,14 @@ Substring_Sub(Substring sub, size_t star
 	return Substring_Init(sub.start + start, sub.start + end);
 }
 
-MAKE_INLINE bool
+MAKE_STATIC bool
 Substring_HasPrefix(Substring sub, Substring prefix)
 {
 	return Substring_Length(sub) >= Substring_Length(prefix) &&
 	   memcmp(sub.start, prefix.start, Substring_Length(prefix)) == 0;
 }
 
-MAKE_INLINE bool
+MAKE_STATIC bool
 Substring_HasSuffix(Substring sub, Substring suffix)
 {
 	size_t suffixLen = Substring_Length(suffix);
@@ -206,7 +206,7 @@ Substring_HasSuffix(Substring sub, Subst
 }
 
 /* Returns an independent, null-terminated copy of the substring. */
-MAKE_INLINE FStr
+MAKE_STATIC FStr
 Substring_Str(Substring sub)
 {
 	if (Substring_IsEmpty(sub))
@@ -214,7 +214,7 @@ Substring_Str(Substring sub)
 	return FStr_InitOwn(bmake_strsedup(sub.start, sub.end));
 }
 
-MAKE_INLINE const char *
+MAKE_STATIC const char *
 Substring_SkipFirst(Substring sub, char ch)
 {
 	const char *p;
@@ -225,7 +225,7 @@ Substring_SkipFirst(Substring sub, char 
 	return sub.start;
 }
 
-MAKE_INLINE const char *
+MAKE_STATIC const char *
 Substring_LastIndex(Substring sub, char ch)
 {
 	const char *p;
@@ -236,7 +236,7 @@ Substring_LastIndex(Substring sub, char 
 	return NULL;
 }
 
-MAKE_INLINE Substring
+MAKE_STATIC Substring
 Substring_Dirname(Substring pathname)
 {
 	const char *p;
@@ -247,7 +247,7 @@ Substring_Dirname(Substring pathname)
 	return Substring_InitStr(".");
 }
 
-MAKE_INLINE Substring
+MAKE_STATIC Substring
 Substring_Basename(Substring pathname)
 {
 	const char *p;
@@ -259,7 +259,7 @@ Substring_Basename(Substring pathname)
 }
 
 
-MAKE_INLINE void
+MAKE_STATIC void
 LazyBuf_Init(LazyBuf *buf, const char *expected)
 {
 	buf->data = NULL;
@@ -275,7 +275,7 @@ LazyBuf_Done(LazyBuf *buf)
 	free(buf->freeIt);
 }
 
-MAKE_INLINE void
+MAKE_STATIC void
 LazyBuf_Add(LazyBuf *buf, char ch)
 {
 
@@ -298,7 +298,7 @@ LazyBuf_Add(LazyBuf *buf, char ch)
 	}
 }
 
-MAKE_INLINE void
+MAKE_STATIC void
 LazyBuf_AddStr(LazyBuf *buf, const char *str)
 {
 	const char *p;
@@ -307,7 +307,7 @@ LazyBuf_AddStr(LazyBuf *buf, const char 
 		LazyBuf_Add(buf, *p);
 }
 
-MAKE_INLINE void
+MAKE_STATIC void
 LazyBuf_AddBytesBetween(LazyBuf *buf, const char *start, const char *end)
 {
 	const char *p;
@@ -322,14 +322,14 @@ LazyBuf_AddSubstring(LazyBuf *buf, Subst
 	LazyBuf_AddBytesBetween(buf, sub.start, sub.end);
 }
 
-MAKE_INLINE Substring
+MAKE_STATIC Substring
 LazyBuf_Get(const LazyBuf *buf)
 {
 	const char *start = buf->data != NULL ? buf->data : buf->expected;
 	return Substring_Init(start, start + buf->len);
 }
 
-MAKE_INLINE FStr
+MAKE_STATIC FStr
 LazyBuf_DoneGet(LazyBuf *buf)
 {
 	if (buf->data != NULL) {


CVS commit: src/usr.bin/make

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 17:24:48 UTC 2021

Modified Files:
src/usr.bin/make: main.c

Log Message:
make: turn run-time string concatenation into compile-time

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.537 -r1.538 src/usr.bin/make/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.537 src/usr.bin/make/main.c:1.538
--- src/usr.bin/make/main.c:1.537	Wed Apr 14 17:20:48 2021
+++ src/usr.bin/make/main.c	Wed Apr 14 17:24:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.537 2021/04/14 17:20:48 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.538 2021/04/14 17:24:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.537 2021/04/14 17:20:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.538 2021/04/14 17:24:48 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -869,9 +869,8 @@ PrintVar(const char *varname, bool expan
  * is false, otherwise true.
  */
 static bool
-GetBooleanVar(const char *varname, bool fallback)
+GetBooleanExpr(const char *expr, bool fallback)
 {
-	char *expr = str_concat3("${", varname, "}");
 	char *value;
 	bool res;
 
@@ -879,7 +878,6 @@ GetBooleanVar(const char *varname, bool 
 	/* TODO: handle errors */
 	res = ParseBoolean(value, fallback);
 	free(value);
-	free(expr);
 	return res;
 }
 
@@ -894,7 +892,8 @@ doPrintVars(void)
 	else if (opts.debugVflag)
 		expandVars = false;
 	else
-		expandVars = GetBooleanVar(".MAKE.EXPAND_VARIABLES", false);
+		expandVars = GetBooleanExpr("${.MAKE.EXPAND_VARIABLES}",
+		false);
 
 	for (ln = opts.variables.first; ln != NULL; ln = ln->next) {
 		const char *varname = ln->datum;
@@ -1086,7 +1085,7 @@ InitObjdir(const char *machine, const ch
 	bool writable;
 
 	Dir_InitCur(curdir);
-	writable = GetBooleanVar("MAKE_OBJDIR_CHECK_WRITABLE", true);
+	writable = GetBooleanExpr("${MAKE_OBJDIR_CHECK_WRITABLE}", true);
 	(void)Main_SetObjdir(false, "%s", curdir);
 
 	if (!SetVarObjdir(writable, "MAKEOBJDIRPREFIX", curdir) &&
@@ -2086,7 +2085,8 @@ shouldDieQuietly(GNode *gn, int bf)
 	static int quietly = -1;
 
 	if (quietly < 0) {
-		if (DEBUG(JOB) || !GetBooleanVar(".MAKE.DIE_QUIETLY", true))
+		if (DEBUG(JOB) ||
+		!GetBooleanExpr("${.MAKE.DIE_QUIETLY}", true))
 			quietly = 0;
 		else if (bf >= 0)
 			quietly = bf;



CVS commit: src/usr.bin/make

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 17:20:48 UTC 2021

Modified Files:
src/usr.bin/make: main.c
src/usr.bin/make/unit-tests: varname-empty.exp

Log Message:
make: remove unnecessary modifier ':U' for certain fixed expressions

No functional change, since the expression is evaluated using
VARE_WANTRES, not using VARE_UNDEFERR.


To generate a diff of this commit:
cvs rdiff -u -r1.536 -r1.537 src/usr.bin/make/main.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varname-empty.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.536 src/usr.bin/make/main.c:1.537
--- src/usr.bin/make/main.c:1.536	Sun Apr  4 10:13:09 2021
+++ src/usr.bin/make/main.c	Wed Apr 14 17:20:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.536 2021/04/04 10:13:09 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.537 2021/04/14 17:20:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.536 2021/04/04 10:13:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.537 2021/04/14 17:20:48 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -871,7 +871,7 @@ PrintVar(const char *varname, bool expan
 static bool
 GetBooleanVar(const char *varname, bool fallback)
 {
-	char *expr = str_concat3("${", varname, ":U}");
+	char *expr = str_concat3("${", varname, "}");
 	char *value;
 	bool res;
 

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.15 src/usr.bin/make/unit-tests/varname-empty.exp:1.16
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.15	Sat Apr 10 22:35:02 2021
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Wed Apr 14 17:20:48 2021
@@ -1,9 +1,7 @@
 Var_SetExpand: variable name "${:U}" expands to empty string, with value "cmdline-u" - ignored
 Var_SetExpand: variable name "" expands to empty string, with value "cmdline-plain" - ignored
 Global: .CURDIR = 
-Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE:U} (eval)
-Evaluating modifier ${MAKE_OBJDIR_CHECK_WRITABLE:U} on value "" (eval, undefined)
-Result of ${MAKE_OBJDIR_CHECK_WRITABLE:U} is "" (eval, defined)
+Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE} (eval)
 Global: .OBJDIR = 
 Global:delete .PATH (not found)
 Global: .PATH = .



CVS commit: src/usr.bin/make

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 16:59:34 UTC 2021

Modified Files:
src/usr.bin/make: str.h var.c

Log Message:
make: reduce memory allocations in the modifiers ':D' and ':U'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/str.h
cvs rdiff -u -r1.928 -r1.929 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/str.h
diff -u src/usr.bin/make/str.h:1.6 src/usr.bin/make/str.h:1.7
--- src/usr.bin/make/str.h:1.6	Mon Apr 12 18:48:00 2021
+++ src/usr.bin/make/str.h	Wed Apr 14 16:59:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.h,v 1.6 2021/04/12 18:48:00 rillig Exp $	*/
+/*	$NetBSD: str.h,v 1.7 2021/04/14 16:59:34 rillig Exp $	*/
 
 /*
  Copyright (c) 2021 Roland Illig 
@@ -205,9 +205,12 @@ Substring_HasSuffix(Substring sub, Subst
 	   memcmp(sub.end - suffixLen, suffix.start, suffixLen) == 0;
 }
 
+/* Returns an independent, null-terminated copy of the substring. */
 MAKE_INLINE FStr
 Substring_Str(Substring sub)
 {
+	if (Substring_IsEmpty(sub))
+		return FStr_InitRefer("");
 	return FStr_InitOwn(bmake_strsedup(sub.start, sub.end));
 }
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.928 src/usr.bin/make/var.c:1.929
--- src/usr.bin/make/var.c:1.928	Wed Apr 14 16:12:26 2021
+++ src/usr.bin/make/var.c	Wed Apr 14 16:59:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.928 2021/04/14 16:12:26 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.929 2021/04/14 16:59:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.928 2021/04/14 16:12:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.929 2021/04/14 16:59:34 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -2484,7 +2484,7 @@ static ApplyModifierResult
 ApplyModifier_Defined(const char **pp, ModChain *ch)
 {
 	Expr *expr = ch->expr;
-	Buffer buf;
+	LazyBuf buf;
 	const char *p;
 
 	VarEvalMode emode = VARE_PARSE_ONLY;
@@ -2492,8 +2492,8 @@ ApplyModifier_Defined(const char **pp, M
 		if ((**pp == 'D') == (expr->defined == DEF_REGULAR))
 			emode = expr->emode;
 
-	Buf_Init();
 	p = *pp + 1;
+	LazyBuf_Init(, p);
 	while (!IsDelimiter(*p, ch) && *p != '\0') {
 
 		/* XXX: This code is similar to the one in Var_Parse.
@@ -2505,7 +2505,7 @@ ApplyModifier_Defined(const char **pp, M
 		if (*p == '\\') {
 			char c = p[1];
 			if (IsDelimiter(c, ch) || c == '$' || c == '\\') {
-Buf_AddByte(, c);
+LazyBuf_Add(, c);
 p += 2;
 continue;
 			}
@@ -2518,13 +2518,13 @@ ApplyModifier_Defined(const char **pp, M
 			(void)Var_Parse(, expr->scope, emode, _val);
 			/* TODO: handle errors */
 			if (Expr_ShouldEval(expr))
-Buf_AddStr(, nested_val.str);
+LazyBuf_AddStr(, nested_val.str);
 			FStr_Done(_val);
 			continue;
 		}
 
 		/* Ordinary text */
-		Buf_AddByte(, *p);
+		LazyBuf_Add(, *p);
 		p++;
 	}
 	*pp = p;
@@ -2532,9 +2532,9 @@ ApplyModifier_Defined(const char **pp, M
 	Expr_Define(expr);
 
 	if (VarEvalMode_ShouldEval(emode))
-		Expr_SetValueOwn(expr, Buf_DoneData());
+		Expr_SetValue(expr, Substring_Str(LazyBuf_Get()));
 	else
-		Buf_Done();
+		LazyBuf_Done();
 
 	return AMR_OK;
 }



CVS commit: src/sys/compat/netbsd32

2021-04-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Apr 14 16:26:23 UTC 2021

Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.c netbsd32_ioctl.h

Log Message:
Add DIOCGDISKINFO compat.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/compat/netbsd32/netbsd32_ioctl.c
cvs rdiff -u -r1.77 -r1.78 src/sys/compat/netbsd32/netbsd32_ioctl.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.118 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.119
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.118	Sun Jan 17 10:50:01 2021
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Wed Apr 14 16:26:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.118 2021/01/17 10:50:01 simonb Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.119 2021/04/14 16:26:23 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.118 2021/01/17 10:50:01 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.119 2021/04/14 16:26:23 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -1693,6 +1693,8 @@ netbsd32_ioctl(struct lwp *l,
 		IOCTL_STRUCT_CONV_TO(DIOCGSTRATEGY, disk_strategy);
 	case DIOCSSTRATEGY32:
 		IOCTL_STRUCT_CONV_TO(DIOCSSTRATEGY, disk_strategy);
+	case DIOCGDISKINFO32:
+		IOCTL_STRUCT_CONV_TO(DIOCGDISKINFO, plistref);
 	case DIOCLWEDGES32:
 		IOCTL_STRUCT_CONV_TO(DIOCLWEDGES, dkwedge_list);
 

Index: src/sys/compat/netbsd32/netbsd32_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.77 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.78
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.77	Sun Jan 17 10:50:01 2021
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h	Wed Apr 14 16:26:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.h,v 1.77 2021/01/17 10:50:01 simonb Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.h,v 1.78 2021/04/14 16:26:23 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -672,6 +672,7 @@ struct netbsd32_disk_strategy {
 
 #define DIOCGSTRATEGY32		_IOR('d', 125, struct netbsd32_disk_strategy)
 #define DIOCSSTRATEGY32		_IOW('d', 126, struct netbsd32_disk_strategy)
+#define DIOCGDISKINFO32		_IOR('d', 127, struct netbsd32_plistref)
 
 /* from  */
 struct netbsd32_lsenable {



CVS commit: src/usr.bin/make

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 16:12:26 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: rename members of ModifyWord_LoopArgs

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.927 -r1.928 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.927 src/usr.bin/make/var.c:1.928
--- src/usr.bin/make/var.c:1.927	Wed Apr 14 15:41:08 2021
+++ src/usr.bin/make/var.c	Wed Apr 14 16:12:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.927 2021/04/14 15:41:08 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.928 2021/04/14 16:12:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.927 2021/04/14 15:41:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.928 2021/04/14 16:12:26 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1688,8 +1688,8 @@ tryagain:
 
 struct ModifyWord_LoopArgs {
 	GNode *scope;
-	const char *tvar;	/* name of temporary variable */
-	const char *str;	/* string to expand */
+	const char *var;	/* name of the temporary variable */
+	const char *body;	/* string to expand */
 	VarEvalMode emode;
 };
 
@@ -1705,15 +1705,15 @@ ModifyWord_Loop(Substring word, SepBuf *
 
 	args = data;
 	assert(word.end[0] == '\0');	/* assume null-terminated word */
-	Var_SetWithFlags(args->scope, args->tvar, word.start,
+	Var_SetWithFlags(args->scope, args->var, word.start,
 	VAR_SET_NO_EXPORT);
-	(void)Var_Subst(args->str, args->scope, args->emode, );
+	(void)Var_Subst(args->body, args->scope, args->emode, );
 	/* TODO: handle errors */
 
 	assert(word.end[0] == '\0');	/* assume null-terminated word */
 	DEBUG4(VAR, "ModifyWord_Loop: "
 		"in \"%s\", replace \"%s\" with \"%s\" to \"%s\"\n",
-	word.start, args->tvar, args->str, s);
+	word.start, args->var, args->body, s);
 
 	if (s[0] == '\n' || Buf_EndsWith(>buf, '\n'))
 		buf->needSep = false;
@@ -2447,12 +2447,12 @@ ApplyModifier_Loop(const char **pp, ModC
 	if (res != VPR_OK)
 		return AMR_CLEANUP;
 	tvar = LazyBuf_DoneGet();
-	args.tvar = tvar.str;
-	if (strchr(args.tvar, '$') != NULL) {
+	args.var = tvar.str;
+	if (strchr(args.var, '$') != NULL) {
 		Parse_Error(PARSE_FATAL,
 		"In the :@ modifier of \"%s\", the variable name \"%s\" "
 		"must not contain a dollar.",
-		expr->name, args.tvar);
+		expr->name, args.var);
 		return AMR_CLEANUP;
 	}
 
@@ -2460,7 +2460,7 @@ ApplyModifier_Loop(const char **pp, ModC
 	if (res != VPR_OK)
 		return AMR_CLEANUP;
 	str = LazyBuf_DoneGet();
-	args.str = str.str;
+	args.body = str.str;
 
 	if (!Expr_ShouldEval(expr))
 		goto done;
@@ -2470,8 +2470,8 @@ ApplyModifier_Loop(const char **pp, ModC
 	ch->sep = ' ';		/* XXX: should be ch->sep for consistency */
 	ModifyWords(ch, ModifyWord_Loop, , ch->oneBigWord);
 	ch->sep = prev_sep;
-	/* XXX: Consider restoring the previous variable instead of deleting. */
-	Var_Delete(expr->scope, args.tvar);
+	/* XXX: Consider restoring the previous value instead of deleting. */
+	Var_Delete(expr->scope, args.var);
 
 done:
 	FStr_Done();



CVS commit: src/usr.bin/make

2021-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Apr 14 15:41:08 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: clean up pattern flags for the modifiers ':S' and ':C'

No special handling is necessary for C90 since none of the struct
members is a const_member.

The prefix 'Var' is not necessary since this type does not apply to a
variable but only to a modifier.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.926 -r1.927 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.926 src/usr.bin/make/var.c:1.927
--- src/usr.bin/make/var.c:1.926	Mon Apr 12 18:53:51 2021
+++ src/usr.bin/make/var.c	Wed Apr 14 15:41:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.926 2021/04/12 18:53:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.927 2021/04/14 15:41:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.926 2021/04/12 18:53:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.927 2021/04/14 15:41:08 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -241,12 +241,12 @@ typedef enum UnexportWhat {
 } UnexportWhat;
 
 /* Flags for pattern matching in the :S and :C modifiers */
-typedef struct VarPatternFlags {
+typedef struct PatternFlags {
 	bool subGlobal: 1;	/* 'g': replace as often as possible */
 	bool subOnce: 1;	/* '1': replace only once */
 	bool anchorStart: 1;	/* '^': match only at start of word */
 	bool anchorEnd: 1;	/* '$': match only at end of word */
-} VarPatternFlags;
+} PatternFlags;
 
 /* SepBuf builds a string from words interleaved with separators. */
 typedef struct SepBuf {
@@ -1495,7 +1495,7 @@ no_match:
 struct ModifyWord_SubstArgs {
 	Substring lhs;
 	Substring rhs;
-	VarPatternFlags pflags;
+	PatternFlags pflags;
 	bool matched;
 };
 
@@ -1589,7 +1589,7 @@ struct ModifyWord_SubstRegexArgs {
 	regex_t re;
 	size_t nsub;
 	const char *replace;
-	VarPatternFlags pflags;
+	PatternFlags pflags;
 	bool matched;
 };
 
@@ -2161,7 +2161,7 @@ ParseModifierPartSubst(
 LazyBuf *part,
 /* For the first part of the :S modifier, sets the VARP_ANCHOR_END flag
  * if the last character of the pattern is a $. */
-VarPatternFlags *out_pflags,
+PatternFlags *out_pflags,
 /* For the second part of the :S modifier, allow ampersands to be
  * escaped and replace unescaped ampersands with subst->lhs. */
 struct ModifyWord_SubstArgs *subst
@@ -2858,7 +2858,7 @@ ApplyModifier_Match(const char **pp, Mod
 }
 
 static void
-ParsePatternFlags(const char **pp, VarPatternFlags *pflags, bool *oneBigWord)
+ParsePatternFlags(const char **pp, PatternFlags *pflags, bool *oneBigWord)
 {
 	for (;; (*pp)++) {
 		if (**pp == 'g')
@@ -2872,16 +2872,12 @@ ParsePatternFlags(const char **pp, VarPa
 	}
 }
 
-#if __STDC_VERSION__ >= 199901L
-#define VarPatternFlags_Literal() (VarPatternFlags) { false, false, false, false }
-#else
-MAKE_INLINE VarPatternFlags
-VarPatternFlags_Literal(void)
+MAKE_INLINE PatternFlags
+PatternFlags_None(void)
 {
-	VarPatternFlags pflags = { false, false, false, false };
+	PatternFlags pflags = { false, false, false, false };
 	return pflags;
 }
-#endif
 
 /* :S,from,to, */
 static ApplyModifierResult
@@ -2901,7 +2897,7 @@ ApplyModifier_Subst(const char **pp, Mod
 
 	*pp += 2;
 
-	args.pflags = VarPatternFlags_Literal();
+	args.pflags = PatternFlags_None();
 	args.matched = false;
 
 	if (**pp == '^') {
@@ -2968,7 +2964,7 @@ ApplyModifier_Regex(const char **pp, Mod
 	replace = LazyBuf_DoneGet();
 	args.replace = replace.str;
 
-	args.pflags = VarPatternFlags_Literal();
+	args.pflags = PatternFlags_None();
 	args.matched = false;
 	oneBigWord = ch->oneBigWord;
 	ParsePatternFlags(pp, , );



CVS commit: src/usr.bin/xlint/lint1

2021-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 14 13:34:08 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y err.c

Log Message:
support parsing c99's static class for array size expressions.


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/xlint/lint1/err.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.213 src/usr.bin/xlint/lint1/cgram.y:1.214
--- src/usr.bin/xlint/lint1/cgram.y:1.213	Tue Apr 13 18:22:02 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Apr 14 09:34:08 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.213 2021/04/13 22:22:02 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.214 2021/04/14 13:34:08 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.213 2021/04/13 22:22:02 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.214 2021/04/14 13:34:08 christos Exp $");
 #endif
 
 #include 
@@ -296,6 +296,7 @@ anonymize(sym_t *s)
 %type			notype_member_decl
 %type			type_member_decl
 %type		constant_expr
+%type		array_size
 %type			enum_declaration
 %type			enums_with_opt_comma
 %type			enums
@@ -1071,7 +1072,7 @@ notype_direct_decl:
 	| notype_direct_decl T_LBRACK T_RBRACK {
 		$$ = add_array($1, false, 0);
 	  }
-	| notype_direct_decl T_LBRACK constant_expr T_RBRACK {
+	| notype_direct_decl T_LBRACK array_size T_RBRACK {
 		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| notype_direct_decl param_list opt_asm_or_symbolrename {
@@ -1104,7 +1105,7 @@ type_direct_decl:
 	| type_direct_decl T_LBRACK T_RBRACK {
 		$$ = add_array($1, false, 0);
 	  }
-	| type_direct_decl T_LBRACK constant_expr T_RBRACK {
+	| type_direct_decl T_LBRACK array_size T_RBRACK {
 		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| type_direct_decl param_list opt_asm_or_symbolrename {
@@ -1131,6 +1132,19 @@ param_decl:
 	  }
 	;
 
+array_size:
+	  T_SCLASS constant_expr {
+		/* C99 6.7.6.3 */
+		if ($1 != STATIC)
+			yyerror("Bad attribute");
+		c99ism(343);
+		$$ = $2;
+	  } 
+	| constant_expr {
+		$$ = $1;
+	}
+	;
+
 direct_param_decl:
 	  identifier type_attribute_list {
 		$$ = declarator_name(getsym($1));
@@ -1144,7 +1158,7 @@ direct_param_decl:
 	| direct_param_decl T_LBRACK T_RBRACK {
 		$$ = add_array($1, false, 0);
 	  }
-	| direct_param_decl T_LBRACK constant_expr T_RBRACK {
+	| direct_param_decl T_LBRACK array_size T_RBRACK {
 		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| direct_param_decl param_list opt_asm_or_symbolrename {
@@ -1173,7 +1187,7 @@ direct_notype_param_decl:
 	| direct_notype_param_decl T_LBRACK T_RBRACK {
 		$$ = add_array($1, false, 0);
 	  }
-	| direct_notype_param_decl T_LBRACK constant_expr T_RBRACK {
+	| direct_notype_param_decl T_LBRACK array_size T_RBRACK {
 		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| direct_notype_param_decl param_list opt_asm_or_symbolrename {
@@ -1468,7 +1482,7 @@ direct_abstract_decl:
 	| T_LBRACK T_RBRACK {
 		$$ = add_array(abstract_name(), false, 0);
 	  }
-	| T_LBRACK constant_expr T_RBRACK {
+	| T_LBRACK array_size T_RBRACK {
 		$$ = add_array(abstract_name(), true, to_int_constant($2, false));
 	  }
 	| type_attribute direct_abstract_decl {
@@ -1477,7 +1491,7 @@ direct_abstract_decl:
 	| direct_abstract_decl T_LBRACK T_RBRACK {
 		$$ = add_array($1, false, 0);
 	  }
-	| direct_abstract_decl T_LBRACK constant_expr T_RBRACK {
+	| direct_abstract_decl T_LBRACK array_size T_RBRACK {
 		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| abstract_decl_param_list opt_asm_or_symbolrename {

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.106 src/usr.bin/xlint/lint1/err.c:1.107
--- src/usr.bin/xlint/lint1/err.c:1.106	Fri Apr  9 16:12:00 2021
+++ src/usr.bin/xlint/lint1/err.c	Wed Apr 14 09:34:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.106 2021/04/09 20:12:00 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.107 2021/04/14 13:34:08 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.106 2021/04/09 20:12:00 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.107 2021/04/14 13:34:08 christos Exp $");
 #endif
 
 #include 
@@ -397,6 +397,7 @@ const	char *msgs[] = {
 	"initialization with '[a...b]' is a GNU extension",	  /* 340 */
 	"argument to '%s' must be 'unsigned char' or EOF, not '%s'",  /* 341 */
 	"argument to '%s' must be cast to 'unsigned char', not to '%s'", /* 342 */
+	"static array size is a C99 extension",			  /* 343 */
 };
 
 static struct include_level {



CVS commit: src/external/gpl3/gcc/usr.bin/lto1

2021-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 14 12:20:59 UTC 2021

Modified Files:
src/external/gpl3/gcc/usr.bin/lto1: Makefile

Log Message:
lto-common.c needs the stack protector treatment


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/gcc/usr.bin/lto1/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/usr.bin/lto1/Makefile
diff -u src/external/gpl3/gcc/usr.bin/lto1/Makefile:1.6 src/external/gpl3/gcc/usr.bin/lto1/Makefile:1.7
--- src/external/gpl3/gcc/usr.bin/lto1/Makefile:1.6	Sun Apr 11 20:05:56 2021
+++ src/external/gpl3/gcc/usr.bin/lto1/Makefile	Wed Apr 14 08:20:59 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2021/04/12 00:05:56 mrg Exp $
+#	$NetBSD: Makefile,v 1.7 2021/04/14 12:20:59 christos Exp $
 
 PROG=		lto1
 SRCS=		attribs.c \
@@ -14,6 +14,7 @@ CPPFLAGS+=	-DPREFIX=\"/usr\"
 
 COPTS.lto.c+=		-Wno-stack-protector
 COPTS.lto-lang.c+=	-Wno-stack-protector
+COPTS.lto-common.c+=	-Wno-stack-protector
 
 .include "../Makefile.backend"
 .include "../Makefile.backtrace"



CVS commit: src/sys/arch

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr 14 09:29:40 UTC 2021

Modified Files:
src/sys/arch/bebox/stand: Makefile.inc
src/sys/arch/ofppc/stand: Makefile.inc

Log Message:
more -fcommon.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/bebox/stand/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ofppc/stand/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/sys/arch/bebox/stand/Makefile.inc
diff -u src/sys/arch/bebox/stand/Makefile.inc:1.2 src/sys/arch/bebox/stand/Makefile.inc:1.3
--- src/sys/arch/bebox/stand/Makefile.inc:1.2	Sun Dec 11 12:17:04 2005
+++ src/sys/arch/bebox/stand/Makefile.inc	Wed Apr 14 09:29:40 2021
@@ -1,5 +1,7 @@
-# $NetBSD: Makefile.inc,v 1.2 2005/12/11 12:17:04 christos Exp $
+# $NetBSD: Makefile.inc,v 1.3 2021/04/14 09:29:40 mrg Exp $
 
 .include 
 
 BINDIR?=	/usr/mdec
+
+COPTS+=		-fcommon

Index: src/sys/arch/ofppc/stand/Makefile.inc
diff -u src/sys/arch/ofppc/stand/Makefile.inc:1.4 src/sys/arch/ofppc/stand/Makefile.inc:1.5
--- src/sys/arch/ofppc/stand/Makefile.inc:1.4	Sun Aug 10 17:44:26 2014
+++ src/sys/arch/ofppc/stand/Makefile.inc	Wed Apr 14 09:29:40 2021
@@ -1,7 +1,8 @@
-#	$NetBSD: Makefile.inc,v 1.4 2014/08/10 17:44:26 joerg Exp $
+#	$NetBSD: Makefile.inc,v 1.5 2021/04/14 09:29:40 mrg Exp $
 
 BINDIR=		/usr/mdec
 
 CPPFLAGS+=	-D_STANDALONE
+COPTS+=		-fcommon
 
 CFLAGS+=	${${ACTIVE_CC} == "gcc":? -msoft-float :}



CVS commit: src/sbin/dump_lfs

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr 14 08:31:25 UTC 2021

Modified Files:
src/sbin/dump_lfs: Makefile

Log Message:
build lfs_node.c with -O3 on ia64 to avoid assembler overflow issues.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/dump_lfs/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/dump_lfs/Makefile
diff -u src/sbin/dump_lfs/Makefile:1.19 src/sbin/dump_lfs/Makefile:1.20
--- src/sbin/dump_lfs/Makefile:1.19	Mon Sep  7 03:09:53 2020
+++ src/sbin/dump_lfs/Makefile	Wed Apr 14 08:31:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.19 2020/09/07 03:09:53 mrg Exp $
+#	$NetBSD: Makefile,v 1.20 2021/04/14 08:31:24 mrg Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 #	lfs_inode.c		LFS filestore-specific routines
@@ -27,6 +27,10 @@ LDADD+= -lutil
 COPTS.lfs_inode.c+=	-fno-tree-ter
 .endif
 
+.if ${MACHINE_ARCH} == "ia64"
+COPTS.lfs_inode.c+=	-O3
+.endif
+
 .PATH:  ${NETBSDSRCDIR}/sbin/dump ${NETBSDSRCDIR}/sys/ufs/lfs \
 ${NETBSDSRCDIR}/sys/ufs/ffs
 



CVS commit: src/lib/libc/string

2021-04-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr 14 08:07:49 UTC 2021

Modified Files:
src/lib/libc/string: Makefile.inc

Log Message:
for GCC, built memset.c with -fno-builtin.  this avoids GCC 10 compiling
memset() and emitting calls to memset() where it seems code that looks
like what memset() does, which ends up recursing and blowing the stack.

this makes mips userland with GCC 10 work.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/lib/libc/string/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/lib/libc/string/Makefile.inc
diff -u src/lib/libc/string/Makefile.inc:1.84 src/lib/libc/string/Makefile.inc:1.85
--- src/lib/libc/string/Makefile.inc:1.84	Wed Mar 25 18:45:42 2020
+++ src/lib/libc/string/Makefile.inc	Wed Apr 14 08:07:49 2021
@@ -1,5 +1,5 @@
 #	from: @(#)Makefile.inc	8.1 (Berkeley) 6/4/93
-#	$NetBSD: Makefile.inc,v 1.84 2020/03/25 18:45:42 kre Exp $
+#	$NetBSD: Makefile.inc,v 1.85 2021/04/14 08:07:49 mrg Exp $
 
 # string sources
 .PATH: ${ARCHDIR}/string ${.CURDIR}/string
@@ -34,6 +34,12 @@ CPPFLAGS.wcscmp.c+=	-I${LIBCDIR}/locale
 CPPFLAGS.wcsncmp.c+=	-I${LIBCDIR}/locale
 CPPFLAGS.wmemcmp.c+=	-I${LIBCDIR}/locale
 
+# Avoid memset() compilation generating calls to memset() via code
+# that appears to implement memset()-like semantics (similar to how
+# printf("foo") may be converted to puts("foo")), since that tends
+# to recurse and blow the stack.
+COPTS.memset.c+=	${${ACTIVE_CC} == "gcc":? -fno-builtin :}
+
 .include "${ARCHDIR}/string/Makefile.inc"
 
 MAN+=	bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 consttime_memequal.3 \



CVS commit: src/share/man/man3

2021-04-14 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Apr 14 07:56:23 UTC 2021

Modified Files:
src/share/man/man3: intro.3

Log Message:
OpenSSL man pages have moved


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/share/man/man3/intro.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man3/intro.3
diff -u src/share/man/man3/intro.3:1.35 src/share/man/man3/intro.3:1.36
--- src/share/man/man3/intro.3:1.35	Wed Apr 14 07:52:53 2021
+++ src/share/man/man3/intro.3	Wed Apr 14 07:56:23 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: intro.3,v 1.35 2021/04/14 07:52:53 nia Exp $
+.\"	$NetBSD: intro.3,v 1.36 2021/04/14 07:56:23 nia Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -123,7 +123,7 @@ See
 .It Em libcrypto Pq Fl l Ns Ar crypto
 The OpenSSL cryptographic library.
 See
-.Xr crypto 3 .
+.Xr crypto 7 .
 .It Em libcurses Pq Fl l Ns Ar curses Fl l Ns Ar terminfo
 Terminal independent screen management routines
 for two dimensional non-bitmap display terminals.
@@ -281,7 +281,7 @@ See
 .It Em libssl Pq Fl l Ns Ar ssl
 The secure sockets layer (SSL) library.
 See
-.Xr ssl 3 .
+.Xr ssl 7 .
 .It Em libtelnet Pq Fl l Ns Ar telnet
 The telnet library.
 .It Em libterminfo Pq Fl l Ns Ar terminfo



CVS commit: src/share/man/man3

2021-04-14 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Apr 14 07:52:53 UTC 2021

Modified Files:
src/share/man/man3: intro.3

Log Message:
intro.3: add a few


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/share/man/man3/intro.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man3/intro.3
diff -u src/share/man/man3/intro.3:1.34 src/share/man/man3/intro.3:1.35
--- src/share/man/man3/intro.3:1.34	Fri May 11 12:54:56 2018
+++ src/share/man/man3/intro.3	Wed Apr 14 07:52:53 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: intro.3,v 1.34 2018/05/11 12:54:56 sevan Exp $
+.\"	$NetBSD: intro.3,v 1.35 2021/04/14 07:52:53 nia Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)intro.3	8.1 (Berkeley) 6/5/93
 .\"
-.Dd May 11, 2018
+.Dd April 14, 2021
 .Dt INTRO 3
 .Os
 .Sh NAME
@@ -228,6 +228,15 @@ See
 The curses menu library.
 See
 .Xr menus 3 .
+.It Em libnvmm Pq Fl l Ns Ar nvmm
+.Nx
+Virtualization API.
+See
+.Xr libnvmm 3 .
+.It Em libossaudio Pq Fl l Ns Ar ossaudio
+Open Sound System compatibility library.
+See
+.Xr ossaudio 3 .
 .It Em libpanel Pq Fl l Ns Ar panel
 The curses panel library.
 See



CVS commit: src/sys/arch/riscv

2021-04-14 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Apr 14 06:32:20 UTC 2021

Modified Files:
src/sys/arch/riscv/include: db_machdep.h insn.h
src/sys/arch/riscv/riscv: db_disasm.c db_machdep.c

Log Message:
Add a ddb disassembler for riscv.

builds, but not really tested yet.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/include/db_machdep.h \
src/sys/arch/riscv/include/insn.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/riscv/db_disasm.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/riscv/riscv/db_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/riscv/include/db_machdep.h
diff -u src/sys/arch/riscv/include/db_machdep.h:1.2 src/sys/arch/riscv/include/db_machdep.h:1.3
--- src/sys/arch/riscv/include/db_machdep.h:1.2	Mon Nov  6 03:47:48 2017
+++ src/sys/arch/riscv/include/db_machdep.h	Wed Apr 14 06:32:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.2 2017/11/06 03:47:48 christos Exp $ */
+/* $NetBSD: db_machdep.h,v 1.3 2021/04/14 06:32:20 dholland Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -62,6 +62,17 @@ extern const uint32_t __cpu_Debugger_ins
 #define	BKPT_SIZE	(sizeof(uint32_t))	/* size of breakpoint inst */
 #define	BKPT_SET(inst, addr)	(BKPT_INST)
 
+/*
+ * XXX with the C extension there's also a 16-bit-wide breakpoint
+ * instruction, the idea being that you use it when inserting a
+ * breakpoint into a stream of 16-bit instructions, but it looks like
+ * MI ddb can't cope with having two sizes :-(
+ */
+#if 0
+#define BKPT_INST_2	0x9002
+#define BKPT_SIZE_2	(sizeof(uint16_t))
+#endif
+
 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == CAUSE_BREAKPOINT)
 #define IS_WATCHPOINT_TRAP(type, code)	(0)
 
Index: src/sys/arch/riscv/include/insn.h
diff -u src/sys/arch/riscv/include/insn.h:1.2 src/sys/arch/riscv/include/insn.h:1.3
--- src/sys/arch/riscv/include/insn.h:1.2	Wed Nov  4 07:09:45 2020
+++ src/sys/arch/riscv/include/insn.h	Wed Apr 14 06:32:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: insn.h,v 1.2 2020/11/04 07:09:45 skrll Exp $ */
+/* $NetBSD: insn.h,v 1.3 2021/04/14 06:32:20 dholland Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,8 +32,14 @@
 #ifndef _RISCV_INSN_H_
 #define _RISCV_INSN_H_
 
+/*
+ * I have corrected and updated this, but it's the wrong way to do it.
+ * It's still used by ddb_machdep.c but that code should be fixed to
+ * use the newer stuff below. - dholland
+ */
 union riscv_insn {
 	uint32_t val;
+	/* register ops */
 	struct {
 		unsigned int r_opcode : 7;
 		unsigned int r_rd : 5;
@@ -42,14 +48,26 @@ union riscv_insn {
 		unsigned int r_rs2 : 5;
 		unsigned int r_funct7 : 7;
 	} type_r;
+	/* 32-bit shifts */
+	struct {
+		unsigned int rs32_opcode : 7;
+		unsigned int rs32_rd : 5;
+		unsigned int rs32_funct3 : 3;
+		unsigned int rs32_rs1 : 5;
+		unsigned int rs32_shamt : 5;
+		unsigned int rs32_funct7 : 7;
+	} type_rs32;
+	/* 64-bit shifts */
 	struct {
-		unsigned int rs_opcode : 7;
-		unsigned int rs_rd : 5;
-		unsigned int rs_funct3 : 3;
-		unsigned int rs_rs1 : 5;
-		unsigned int rs_shmat : 6;
-		unsigned int rs_funct6 : 6;
-	} type_rs;
+		unsigned int rs64_opcode : 7;
+		unsigned int rs64_rd : 5;
+		unsigned int rs64_funct3 : 3;
+		unsigned int rs64_rs1 : 5;
+		unsigned int rs64_shamt : 6;
+		unsigned int rs64_zero : 1;
+		unsigned int rs64_funct5 : 5;
+	} type_rs64;
+	/* atomics */
 	struct {
 		unsigned int ra_opcode : 7;
 		unsigned int ra_rd : 5;
@@ -58,17 +76,29 @@ union riscv_insn {
 		unsigned int ra_rs2 : 5;
 		unsigned int ra_rl : 1;
 		unsigned int ra_aq : 1;
-		unsigned int ra_funct5 : 6;
+		unsigned int ra_funct5 : 5;
 	} type_ra;
+	/* certain fpu ops */
 	struct {
 		unsigned int rf_opcode : 7;
 		unsigned int rf_rd : 5;
 		unsigned int rf_rm : 3;
 		unsigned int rf_rs1 : 5;
 		unsigned int rf_rs2 : 5;
-		unsigned int rf_funct2 : 2;
-		unsigned int rf_rs3 : 5;
+		unsigned int rf_size : 2;
+		unsigned int rf_funct5 : 5;
 	} type_rf;
+	/* other fpu ops */
+	struct {
+		unsigned int rf4_opcode : 7;
+		unsigned int rf4_rd : 5;
+		unsigned int rf4_rm : 3;
+		unsigned int rf4_rs1 : 5;
+		unsigned int rf4_rs2 : 5;
+		unsigned int rf4_size : 2;
+		unsigned int rf4_rs3 : 5;
+	} type_rf4;
+	/* immediates */
 	struct {
 		unsigned int i_opcode : 7;
 		unsigned int i_rd : 5;
@@ -76,6 +106,7 @@ union riscv_insn {
 		unsigned int i_rs1 : 5;
 		signed int i_imm11to0 : 12;
 	} type_i;
+	/* stores */
 	struct {
 		unsigned int s_opcode : 7;
 		unsigned int s_imm4_to_0 : 5;
@@ -84,33 +115,241 @@ union riscv_insn {
 		unsigned int s_rs2 : 5;
 		signed int s_imm11_to_5 : 7;
 	} type_s;
+	/* branches */
 	struct {
-		unsigned int sb_opcode : 7;
-		unsigned int sb_imm11 : 1;
-		unsigned int sb_imm4to1 : 4;
-		unsigned int sb_funct3 : 3;
-		unsigned int sb_rs1 : 5;
-		unsigned int sb_rs2 : 5;
-		unsigned int sb_imm10to5 : 6;
-		signed int sb_imm12 : 1;
-	} type_sb;