Re: CVS commit: src/tests/lib/libm

2024-05-01 Thread Robert Elz
And yes, I know, it should have been 2^50 not 10^50...

kre


CVS commit: src/tests/lib/libm

2024-05-01 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu May  2 03:30:07 UTC 2024

Modified Files:
src/tests/lib/libm: t_fe_round.c

Log Message:
Use intmax_t instead of long int when trying to represent very large
integers (10^50 or so), so we don't exceed the capacity of systems where
long int is only 32 bits.

Hopefully will unbreak the i386 build, perhaps others.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fe_round.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/lib/libm/t_fe_round.c
diff -u src/tests/lib/libm/t_fe_round.c:1.11 src/tests/lib/libm/t_fe_round.c:1.12
--- src/tests/lib/libm/t_fe_round.c:1.11	Thu May  2 00:01:48 2024
+++ src/tests/lib/libm/t_fe_round.c	Thu May  2 03:30:07 2024
@@ -9,6 +9,7 @@
 #include 
 #ifdef __HAVE_FENV
 #include 
+#include 
 #include 
 #include 
 
@@ -145,24 +146,28 @@ ATF_TC_BODY(fe_nearbyint, tc)
 
 #ifdef __HAVE_LONG_DOUBLE
 
+#define IM intmax_t
+
 /*
  * Use one bit more than fits in IEEE 754 binary64.
  */
 static const struct {
 	int round_mode;
 	long double input;
-	long int expected;
+	IM expected;
 } valuesl[] = {
-	{ FE_TOWARDZERO,	0x2.08p+52L, 0x20 },
-	{ FE_DOWNWARD,		0x2.08p+52L, 0x20 },
-	{ FE_UPWARD,		0x2.08p+52L, 0x21 },
-	{ FE_TONEAREST,		0x2.08p+52L, 0x20 },
-	{ FE_TOWARDZERO,	0x2.18p+52L, 0x21 },
-	{ FE_DOWNWARD,		0x2.18p+52L, 0x21 },
-	{ FE_UPWARD,		0x2.18p+52L, 0x22 },
-	{ FE_TONEAREST,		0x2.18p+52L, 0x22 },
+	{ FE_TOWARDZERO,	0x2.08p+52L, (IM)0x20 },
+	{ FE_DOWNWARD,		0x2.08p+52L, (IM)0x20 },
+	{ FE_UPWARD,		0x2.08p+52L, (IM)0x21 },
+	{ FE_TONEAREST,		0x2.08p+52L, (IM)0x20 },
+	{ FE_TOWARDZERO,	0x2.18p+52L, (IM)0x21 },
+	{ FE_DOWNWARD,		0x2.18p+52L, (IM)0x21 },
+	{ FE_UPWARD,		0x2.18p+52L, (IM)0x22 },
+	{ FE_TONEAREST,		0x2.18p+52L, (IM)0x22 },
 };
 
+#undef IM
+
 ATF_TC(fe_nearbyintl);
 ATF_TC_HEAD(fe_nearbyintl, tc)
 {
@@ -183,7 +188,7 @@ ATF_TC_BODY(fe_nearbyintl, tc)
 		"%s nearbyintl(%Lf) has fractional part %Lf",
 		rmname(values[i].round_mode), valuesl[i].input, fpart);
 		ATF_CHECK_MSG((long int)received == valuesl[i].expected,
-		"%s [%u] nearbyint(%Lf): got %Lf, expected %ld",
+		"%s [%u] nearbyint(%Lf): got %Lf, expected %jd",
 		rmname(values[i].round_mode), i,
 		valuesl[i].input, received, valuesl[i].expected);
 



CVS commit: src/tests/lib/libm

2024-05-01 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu May  2 03:30:07 UTC 2024

Modified Files:
src/tests/lib/libm: t_fe_round.c

Log Message:
Use intmax_t instead of long int when trying to represent very large
integers (10^50 or so), so we don't exceed the capacity of systems where
long int is only 32 bits.

Hopefully will unbreak the i386 build, perhaps others.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fe_round.c

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



CVS commit: src/tests/lib/libm

2024-05-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  2 00:01:48 UTC 2024

Modified Files:
src/tests/lib/libm: t_fe_round.c

Log Message:
tests/lib/libm/t_fe_round: Test nearbyintl.

This uses inputs that can't be distinguished with only 53 bits of
precision, so it should work in essentially all long double formats
to detect when nearbyintl is incorrectly implemented in terms of
nearbyint.

PR lib/58054


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_fe_round.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/lib/libm/t_fe_round.c
diff -u src/tests/lib/libm/t_fe_round.c:1.10 src/tests/lib/libm/t_fe_round.c:1.11
--- src/tests/lib/libm/t_fe_round.c:1.10	Thu May  2 00:00:47 2024
+++ src/tests/lib/libm/t_fe_round.c	Thu May  2 00:01:48 2024
@@ -143,6 +143,61 @@ ATF_TC_BODY(fe_nearbyint, tc)
 	}
 }
 
+#ifdef __HAVE_LONG_DOUBLE
+
+/*
+ * Use one bit more than fits in IEEE 754 binary64.
+ */
+static const struct {
+	int round_mode;
+	long double input;
+	long int expected;
+} valuesl[] = {
+	{ FE_TOWARDZERO,	0x2.08p+52L, 0x20 },
+	{ FE_DOWNWARD,		0x2.08p+52L, 0x20 },
+	{ FE_UPWARD,		0x2.08p+52L, 0x21 },
+	{ FE_TONEAREST,		0x2.08p+52L, 0x20 },
+	{ FE_TOWARDZERO,	0x2.18p+52L, 0x21 },
+	{ FE_DOWNWARD,		0x2.18p+52L, 0x21 },
+	{ FE_UPWARD,		0x2.18p+52L, 0x22 },
+	{ FE_TONEAREST,		0x2.18p+52L, 0x22 },
+};
+
+ATF_TC(fe_nearbyintl);
+ATF_TC_HEAD(fe_nearbyintl, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Checking IEEE 754 rounding modes using nearbyintl");
+}
+
+ATF_TC_BODY(fe_nearbyintl, tc)
+{
+	long double received, ipart, fpart;
+
+	for (unsigned int i = 0; i < __arraycount(valuesl); i++) {
+		fesetround(valuesl[i].round_mode);
+
+		received = nearbyintl(valuesl[i].input);
+		fpart = modfl(received, );
+		ATF_CHECK_MSG(fpart == 0,
+		"%s nearbyintl(%Lf) has fractional part %Lf",
+		rmname(values[i].round_mode), valuesl[i].input, fpart);
+		ATF_CHECK_MSG((long int)received == valuesl[i].expected,
+		"%s [%u] nearbyint(%Lf): got %Lf, expected %ld",
+		rmname(values[i].round_mode), i,
+		valuesl[i].input, received, valuesl[i].expected);
+
+		/* Do we get the same rounding mode out? */
+		ATF_CHECK_MSG(fegetround() == valuesl[i].round_mode,
+		"[%u] set %d (%s), got %d (%s)",
+		i,
+		valuesl[i].round_mode, rmname(valuesl[i].round_mode),
+		fegetround(), rmname(fegetround()));
+	}
+}
+
+#endif
+
 static const struct {
 	double input;
 	double toward;
@@ -209,6 +264,9 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, fe_round);
 	ATF_TP_ADD_TC(tp, fe_nearbyint);
+#ifdef __HAVE_LONG_DOUBLE
+	ATF_TP_ADD_TC(tp, fe_nearbyintl);
+#endif
 	ATF_TP_ADD_TC(tp, fe_nextafter);
 	ATF_TP_ADD_TC(tp, fe_nexttoward);
 



CVS commit: src/tests/lib/libm

2024-05-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  2 00:01:48 UTC 2024

Modified Files:
src/tests/lib/libm: t_fe_round.c

Log Message:
tests/lib/libm/t_fe_round: Test nearbyintl.

This uses inputs that can't be distinguished with only 53 bits of
precision, so it should work in essentially all long double formats
to detect when nearbyintl is incorrectly implemented in terms of
nearbyint.

PR lib/58054


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_fe_round.c

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



CVS commit: src/tests/lib/libm

2024-05-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  2 00:00:47 UTC 2024

Modified Files:
src/tests/lib/libm: t_fe_round.c

Log Message:
tests/lib/libm/t_fe_round: Tidy up nearbyint test.

Prompted by PR lib/58054.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_fe_round.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/lib/libm/t_fe_round.c
diff -u src/tests/lib/libm/t_fe_round.c:1.9 src/tests/lib/libm/t_fe_round.c:1.10
--- src/tests/lib/libm/t_fe_round.c:1.9	Mon Aug 21 17:11:18 2017
+++ src/tests/lib/libm/t_fe_round.c	Thu May  2 00:00:47 2024
@@ -18,6 +18,23 @@
 
 #define EPSILON 0.001
 
+static const char *
+rmname(int rm)
+{
+	switch (rm) {
+	case FE_TOWARDZERO:
+		return "FE_TOWARDZERO";
+	case FE_DOWNWARD:
+		return "FE_DOWNWARD";
+	case FE_UPWARD:
+		return "FE_UPWARD";
+	case FE_TONEAREST:
+		return "FE_TONEAREST";
+	default:
+		return "unknown";
+	}
+}
+
 static const struct {
 	int round_mode;
 	double input;
@@ -96,29 +113,33 @@ ATF_TC_BODY(fe_round, tc)
 ATF_TC(fe_nearbyint);
 ATF_TC_HEAD(fe_nearbyint, tc)
 {
-	atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using nearbyint");
+	atf_tc_set_md_var(tc, "descr",
+	"Checking IEEE 754 rounding modes using nearbyint");
 }
 
 ATF_TC_BODY(fe_nearbyint, tc)
 {
-	double received;
+	double received, ipart, fpart;
 
 	for (unsigned int i = 0; i < __arraycount(values); i++) {
 		fesetround(values[i].round_mode);
 
 		received = nearbyint(values[i].input);
-		ATF_CHECK_MSG(
-		(fabs(received - values[i].expected) < EPSILON),
-		"nearbyint rounding wrong, difference too large\n"
-		"input: %f (index %d): got %f, expected %ld\n",
-		values[i].input, i, received, values[i].expected);
+		fpart = modf(received, );
+		ATF_CHECK_MSG(fpart == 0,
+		"%s nearbyint(%f) has fractional part %f",
+		rmname(values[i].round_mode), values[i].input, fpart);
+		ATF_CHECK_MSG((long int)received == values[i].expected,
+		"%s [%u] nearbyint(%f) got %f, expected %ld\n",
+		rmname(values[i].round_mode),
+		i, values[i].input, received, values[i].expected);
 
 		/* Do we get the same rounding mode out? */
-		ATF_CHECK_MSG(
-		(fegetround() == values[i].round_mode),
-		"Didn't get the same rounding mode out!\n"
-		"(index %d) fed in %d rounding mode, got %d out\n",
-		i, values[i].round_mode, fegetround());
+		ATF_CHECK_MSG(fegetround() == values[i].round_mode,
+		"[%u] set %d (%s), got %d (%s)",
+		i,
+		values[i].round_mode, rmname(values[i].round_mode),
+		fegetround(), rmname(fegetround()));
 	}
 }
 



CVS commit: src/tests/lib/libm

2024-05-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  2 00:00:47 UTC 2024

Modified Files:
src/tests/lib/libm: t_fe_round.c

Log Message:
tests/lib/libm/t_fe_round: Tidy up nearbyint test.

Prompted by PR lib/58054.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_fe_round.c

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



Re: CVS commit: src/lib/libutil

2024-05-01 Thread Robert Elz
Date:Wed, 1 May 2024 22:27:02 +0200
From:Roland Illig 
Message-ID:  <754bd755-be0a-4eff-aa7b-d53fce9b4...@gmx.de>

  | > Log Message:
  | > next should increement by 1 not 2.
  |
  | Are you sure?

I agree, that change should be reverted.

"next" is even documented to be two ...

 6  Despite what is stated above, ?next? is actually 2.  The input ?next
January?, instead of producing a timestamp for January of the
following year, produces one for January 2nd, of the current year.
Use caution with ?next? it rarely does what humans expect.  For
example, on a Sunday ?next sunday? means the following Sunday (7 days
hence) whereas ?next monday? means the monday that follows that (8
days hence) rather than ?tomorrow? or just ?Mon? (without the ?next?)
which is the nearest subsequent Monday.

and is actually more useful that way.   It is peculiar, but that's how it
has worked ~forever.

There are limits to how sane a half hearted (but still useful) attempt
to understand English idiom can possibly work, we really don't want to
attempt to turn parsedate into an AI machine.

kre




CVS commit: src/external/mit/xorg/lib/gallium

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 21:34:48 UTC 2024

Modified Files:
src/external/mit/xorg/lib/gallium: Makefile

Log Message:
Allow c99 array designators


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/external/mit/xorg/lib/gallium/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/mit/xorg/lib/gallium/Makefile
diff -u src/external/mit/xorg/lib/gallium/Makefile:1.54 src/external/mit/xorg/lib/gallium/Makefile:1.55
--- src/external/mit/xorg/lib/gallium/Makefile:1.54	Fri Apr 26 12:34:17 2024
+++ src/external/mit/xorg/lib/gallium/Makefile	Wed May  1 17:34:48 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.54 2024/04/26 16:34:17 rillig Exp $
+# $NetBSD: Makefile,v 1.55 2024/05/01 21:34:48 christos Exp $
 
 # Link the gallium mega driver.
 
@@ -19,7 +19,7 @@ DRIDEBUGDIR=	${DEBUGDIR}${X11USRLIBDIR}/
 
 LLVM_INCLUDE_OBJDIR!=	cd ${NETBSDSRCDIR}/external/apache2/llvm/include && ${PRINTOBJDIR}
 
-CWARNFLAGS.clang += -Wno-atomic-alignment -Wno-unknown-warning-option -Wno-implicit-int-float-conversion
+CWARNFLAGS.clang += -Wno-atomic-alignment -Wno-unknown-warning-option -Wno-implicit-int-float-conversion -Wno-c99-designator
 
 CXXFLAGS+=	-std=c++14
 CFLAGS+=	-std=gnu11



CVS commit: src/external/mit/xorg/lib/gallium

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 21:34:48 UTC 2024

Modified Files:
src/external/mit/xorg/lib/gallium: Makefile

Log Message:
Allow c99 array designators


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/external/mit/xorg/lib/gallium/Makefile

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



Re: CVS commit: src/lib/libutil

2024-05-01 Thread Roland Illig
Am 01.05.2024 um 21:59 schrieb Christos Zoulas:
> Module Name:  src
> Committed By: christos
> Date: Wed May  1 19:59:08 UTC 2024
>
> Modified Files:
>   src/lib/libutil: parsedate.y
>
> Log Message:
> next should increement by 1 not 2.

Are you sure? I get these test results:

> t_parsedate (2/5): 7 test cases
> atsecs: [0.006548s] Passed.
> dates: [0.007241s] Passed.
> dsttimes: [0.007517s] Passed.
> gibberish: [0.007637s] Passed.
> relative: [0.287375s] Failed: 2258 checks failed; see output for more 
> details
> times: [0.008402s] Passed.
> zones: [0.007586s] Passed.

After your change, "next sunday" goes backward in time, for example:

> From 28110552 (Sun Nov 22 08:29:12 1970) using "next sunday",
> obtained 2808 (Sun Nov 22 00:00:00 1970);
> expected 28684800 (Sun Nov 29 00:00:00 1970)



CVS commit: src/lib/libutil

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 19:59:08 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
next should increement by 1 not 2.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libutil/parsedate.y

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

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.38 src/lib/libutil/parsedate.y:1.39
--- src/lib/libutil/parsedate.y:1.38	Thu Feb 29 15:55:35 2024
+++ src/lib/libutil/parsedate.y	Wed May  1 15:59:07 2024
@@ -12,7 +12,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.38 2024/02/29 20:55:35 rillig Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.39 2024/05/01 19:59:07 christos Exp $");
 #endif
 
 #include 
@@ -546,7 +546,7 @@ static const TABLE OtherTable[] = {
 { "now",		tMINUTE_UNIT,	0 },
 { "last",		tUNUMBER,	-1 },
 { "this",		tMINUTE_UNIT,	0 },
-{ "next",		tUNUMBER,	2 },
+{ "next",		tUNUMBER,	1 },
 { "first",		tUNUMBER,	1 },
 { "one",		tUNUMBER,	1 },
 /*  { "second",		tUNUMBER,	2 }, */



CVS commit: src/lib/libutil

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 19:59:08 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
next should increement by 1 not 2.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libutil/parsedate.y

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



CVS commit: src/distrib/notes/hp300

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:40:56 UTC 2024

Modified Files:
src/distrib/notes/hp300: hardware

Log Message:
Add 98542 and 98543 framebuffers to supported "Graphics Devices" section.

I hope someone will sync a list of supported devices in port wiki pages
with one in this installation notes.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/distrib/notes/hp300/hardware

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

Modified files:

Index: src/distrib/notes/hp300/hardware
diff -u src/distrib/notes/hp300/hardware:1.27 src/distrib/notes/hp300/hardware:1.28
--- src/distrib/notes/hp300/hardware:1.27	Sun Jan 14 12:05:33 2024
+++ src/distrib/notes/hp300/hardware	Wed May  1 19:40:56 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: hardware,v 1.27 2024/01/14 12:05:33 tsutsui Exp $
+.\"	$NetBSD: hardware,v 1.28 2024/05/01 19:40:56 tsutsui Exp $
 .
 .Nx*M
 \*V will run on most HP 9000/300- and 400-series machines.
@@ -155,6 +155,10 @@ Network interfaces
 .It
 Graphics Devices
 .(bullet -compact
+98542 monochrome Topcat (512x400, 1 bit, DIO-II)
+.It
+98543 color Topcat (512x400, 4 bits, DIO-II)
+.It
 98544 monochrome Topcat (1024x768, 1 bit, DIO-II)
 .It
 98545A color Topcat (1024x768, 4 bits, DIO-II)



CVS commit: src/distrib/notes/hp300

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:40:56 UTC 2024

Modified Files:
src/distrib/notes/hp300: hardware

Log Message:
Add 98542 and 98543 framebuffers to supported "Graphics Devices" section.

I hope someone will sync a list of supported devices in port wiki pages
with one in this installation notes.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/distrib/notes/hp300/hardware

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



CVS commit: src/share/man/man4/man4.hp300

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:34:19 UTC 2024

Modified Files:
src/share/man/man4/man4.hp300: topcat.4

Log Message:
Note that 98542 and 98543 variants are also supported by topcat(4).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/man4.hp300/topcat.4

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/man4/man4.hp300/topcat.4
diff -u src/share/man/man4/man4.hp300/topcat.4:1.7 src/share/man/man4/man4.hp300/topcat.4:1.8
--- src/share/man/man4/man4.hp300/topcat.4:1.7	Wed Feb  9 14:37:56 2011
+++ src/share/man/man4/man4.hp300/topcat.4	Wed May  1 19:34:19 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: topcat.4,v 1.7 2011/02/09 14:37:56 wiz Exp $
+.\"	$NetBSD: topcat.4,v 1.8 2024/05/01 19:34:19 tsutsui Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\" from: @(#)tc.4	8.1 (Berkeley) 6/9/93
 .\"
-.Dd February 9, 2011
+.Dd May 1, 2024
 .Dt TOPCAT 4 hp300
 .Os
 .Sh NAME
@@ -52,7 +52,7 @@ device interface
 .Sh DESCRIPTION
 This driver is for the
 .Tn HP98544 ,
-98545 and 98547
+98545, 98542, 98543, and 98547
 .Dq Topcat
 and
 .Tn HP98548 ,



CVS commit: src/share/man/man4/man4.hp300

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:34:19 UTC 2024

Modified Files:
src/share/man/man4/man4.hp300: topcat.4

Log Message:
Note that 98542 and 98543 variants are also supported by topcat(4).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/man4.hp300/topcat.4

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



CVS commit: src/sys/arch/hp300/dev

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:28:33 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c diofbvar.h topcat.c

Log Message:
Fix topcat(4) problems on some models that cause garbages on screen.

- Make sure that windowmove (hardware BITBLT) ops complete by checking
  tc_busywait() before calling putchar functions by MI rasops(9).
  It looks CPU accesses against VRAM during windowmove (copy, erase,
  and cursor) ops causes unexpected garbages at least on 98543 on HP360,
  98547 on HP370, and also on 98543 on 040 HP380 (but not on 98549).

- Handle 'sparse VRAM' on 98543 (and probably 98542) properly:
 - Prepare and use own topcat_putchar1_4() function for sparse VRAM.
 - Pass proper 'VRAM width' rather than actuall font width to all
   windowmove (copycols, erasecols, copyrows, eraserows, and do_cursor)
   operation functions.

Now all topcat(4) consoles on 98543 on HP360/HP380 and 98547 on HP370
work fine, and no visible regression on 98549 on HP380 and 98544 on HP360.

Worth to pullup netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hp300/dev/diofbvar.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hp300/dev/topcat.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/hp300/dev/diofb.c
diff -u src/sys/arch/hp300/dev/diofb.c:1.9 src/sys/arch/hp300/dev/diofb.c:1.10
--- src/sys/arch/hp300/dev/diofb.c:1.9	Mon Apr 29 17:25:11 2024
+++ src/sys/arch/hp300/dev/diofb.c	Wed May  1 19:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofb.c,v 1.9 2024/04/29 17:25:11 tsutsui Exp $	*/
+/*	$NetBSD: diofb.c,v 1.10 2024/05/01 19:28:33 tsutsui Exp $	*/
 /*	$OpenBSD: diofb.c,v 1.18 2010/12/26 15:40:59 miod Exp $	*/
 
 /*
@@ -361,10 +361,11 @@ diofb_copycols(void *cookie, int row, in
 {
 	struct rasops_info *ri = cookie;
 	struct diofb *fb = ri->ri_hw;
+	int fontwidth = fb->wsd.fontwidth;
 
-	n *= ri->ri_font->fontwidth;
-	src *= ri->ri_font->fontwidth;
-	dst *= ri->ri_font->fontwidth;
+	n *= fontwidth;
+	src *= fontwidth;
+	dst *= fontwidth;
 	row *= ri->ri_font->fontheight;
 
 	(*fb->bmv)(fb, ri->ri_xorigin + src, ri->ri_yorigin + row,
@@ -394,11 +395,12 @@ diofb_erasecols(void *cookie, int row, i
 	struct diofb *fb = ri->ri_hw;
 	int fg, bg;
 	int snum, scol, srow;
+	int fontwidth = fb->wsd.fontwidth;
 
 	rasops_unpack_attr(attr, , , NULL);
 
-	snum = num * ri->ri_font->fontwidth;
-	scol = col * ri->ri_font->fontwidth + ri->ri_xorigin;
+	snum = num * fontwidth;
+	scol = col * fontwidth + ri->ri_xorigin;
 	srow = row * ri->ri_font->fontheight + ri->ri_yorigin;
 
 	/*
@@ -423,7 +425,7 @@ diofb_eraserows(void *cookie, int row, i
 	bg ^= 0xff;
 
 	if (num == ri->ri_rows && (ri->ri_flg & RI_FULLCLEAR)) {
-		rc = (*fb->bmv)(fb, 0, 0, 0, 0, ri->ri_width, ri->ri_height,
+		rc = (*fb->bmv)(fb, 0, 0, 0, 0, fb->fbwidth, ri->ri_height,
 		RR_CLEAR, bg);
 	} else {
 		srow = row * ri->ri_font->fontheight + ri->ri_yorigin;
@@ -440,10 +442,11 @@ diofb_do_cursor(struct rasops_info *ri)
 {
 	struct diofb *fb = ri->ri_hw;
 	int x, y;
+	int fontwidth = fb->wsd.fontwidth;
 
-	x = ri->ri_ccol * ri->ri_font->fontwidth + ri->ri_xorigin;
+	x = ri->ri_ccol * fontwidth + ri->ri_xorigin;
 	y = ri->ri_crow * ri->ri_font->fontheight + ri->ri_yorigin;
-	(*fb->bmv)(fb, x, y, x, y, ri->ri_font->fontwidth,
+	(*fb->bmv)(fb, x, y, x, y, fontwidth,
 	ri->ri_font->fontheight, RR_INVERT, 0xff);
 }
 

Index: src/sys/arch/hp300/dev/diofbvar.h
diff -u src/sys/arch/hp300/dev/diofbvar.h:1.4 src/sys/arch/hp300/dev/diofbvar.h:1.5
--- src/sys/arch/hp300/dev/diofbvar.h:1.4	Sun Jan 15 06:19:45 2023
+++ src/sys/arch/hp300/dev/diofbvar.h	Wed May  1 19:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofbvar.h,v 1.4 2023/01/15 06:19:45 tsutsui Exp $	*/
+/*	$NetBSD: diofbvar.h,v 1.5 2024/05/01 19:28:33 tsutsui Exp $	*/
 /*	$OpenBSD: diofbvar.h,v 1.10 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -105,6 +105,9 @@ struct diofb {
 	/* blockmove routine */
 	int	(*bmv)(struct diofb *, uint16_t, uint16_t, uint16_t,
 		uint16_t, uint16_t, uint16_t, int16_t, int16_t);
+
+	/* putchar routine to handle rasops; MD busywait might be required */
+	void	(*wsputchar)(void *, int, int, u_int, long);
 };
 
 /* Replacement Rules (rops) */

Index: src/sys/arch/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.10 src/sys/arch/hp300/dev/topcat.c:1.11
--- src/sys/arch/hp300/dev/topcat.c:1.10	Wed May  1 08:58:34 2024
+++ src/sys/arch/hp300/dev/topcat.c	Wed May  1 19:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.10 2024/05/01 08:58:34 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.11 2024/05/01 19:28:33 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -149,6 +149,8 @@ static int	topcat_windowmove(struct diof
 		uint16_t, uint16_t, uint16_t, int16_t, int16_t);
 
 static int	topcat_ioctl(void *, void *, 

CVS commit: src/sys/arch/hp300/dev

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:28:33 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c diofbvar.h topcat.c

Log Message:
Fix topcat(4) problems on some models that cause garbages on screen.

- Make sure that windowmove (hardware BITBLT) ops complete by checking
  tc_busywait() before calling putchar functions by MI rasops(9).
  It looks CPU accesses against VRAM during windowmove (copy, erase,
  and cursor) ops causes unexpected garbages at least on 98543 on HP360,
  98547 on HP370, and also on 98543 on 040 HP380 (but not on 98549).

- Handle 'sparse VRAM' on 98543 (and probably 98542) properly:
 - Prepare and use own topcat_putchar1_4() function for sparse VRAM.
 - Pass proper 'VRAM width' rather than actuall font width to all
   windowmove (copycols, erasecols, copyrows, eraserows, and do_cursor)
   operation functions.

Now all topcat(4) consoles on 98543 on HP360/HP380 and 98547 on HP370
work fine, and no visible regression on 98549 on HP380 and 98544 on HP360.

Worth to pullup netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hp300/dev/diofbvar.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hp300/dev/topcat.c

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



CVS commit: src/sys/arch/zaurus/dev

2024-05-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  1 19:11:46 UTC 2024

Modified Files:
src/sys/arch/zaurus/dev: wm8750_zaudio.c

Log Message:
s/Diffrential/Differential/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/zaurus/dev/wm8750_zaudio.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/zaurus/dev/wm8750_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.3 src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.4
--- src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.3	Wed May  8 13:40:17 2019
+++ src/sys/arch/zaurus/dev/wm8750_zaudio.c	Wed May  1 19:11:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: wm8750_zaudio.c,v 1.3 2019/05/08 13:40:17 isaki Exp $	*/
+/*	$NetBSD: wm8750_zaudio.c,v 1.4 2024/05/01 19:11:45 andvar Exp $	*/
 /*	$OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $	*/
 
 /*
@@ -51,7 +51,7 @@
 #include "opt_zaudio.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.3 2019/05/08 13:40:17 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.4 2024/05/01 19:11:45 andvar Exp $");
 
 #include 
 #include 
@@ -192,7 +192,7 @@ static const uint16_t record_regs[][2] =
 	{ ADCTL1_REG, ADCTL1_TSDEN | ADCTL1_SET_VSEL(3)
 	  | ADCTL1_SET_DATSEL(1) },
 
-	/* Diffrential input select: LINPUT1-RINPUT1, stereo */
+	/* Differential input select: LINPUT1-RINPUT1, stereo */
 	{ ADCINPMODE_REG, 0x000 },
 
 	/* L-R differential, micboost 20dB */



CVS commit: src/sys/arch/zaurus/dev

2024-05-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  1 19:11:46 UTC 2024

Modified Files:
src/sys/arch/zaurus/dev: wm8750_zaudio.c

Log Message:
s/Diffrential/Differential/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/zaurus/dev/wm8750_zaudio.c

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



CVS commit: src/lib/libc/compiler_rt

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 18:38:15 UTC 2024

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

Log Message:
fix clang lint build.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/lib/libc/compiler_rt/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/compiler_rt/Makefile.inc
diff -u src/lib/libc/compiler_rt/Makefile.inc:1.47 src/lib/libc/compiler_rt/Makefile.inc:1.48
--- src/lib/libc/compiler_rt/Makefile.inc:1.47	Sun Mar 10 14:00:13 2024
+++ src/lib/libc/compiler_rt/Makefile.inc	Wed May  1 14:38:15 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.47 2024/03/10 18:00:13 rillig Exp $
+# $NetBSD: Makefile.inc,v 1.48 2024/05/01 18:38:15 christos Exp $
 
 COMPILER_RT_DIR=	${NETBSDSRCDIR}/sys/external/bsd/compiler_rt
 COMPILER_RT_SRCDIR=	${COMPILER_RT_DIR}/dist
@@ -380,6 +380,7 @@ LINTFLAGS.floatuntidf.c += -X 122,141,26
 LINTFLAGS.floatuntisf.c += -X 351
 LINTFLAGS.floatuntixf.c += -X 122,351
 LINTFLAGS.floatuntixf.c += -X 141 # alpha
+LINTFLAGS.gcc_personality_v0.c += -X 132,231
 LINTFLAGS.int_util.c += -X 231
 LINTFLAGS.lshrti3.c += -X 351
 LINTFLAGS.moddi3.c += -X 117 # vax



CVS commit: src/lib/libc/compiler_rt

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 18:38:15 UTC 2024

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

Log Message:
fix clang lint build.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/lib/libc/compiler_rt/Makefile.inc

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



CVS commit: src

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 17:42:58 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: decl.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: make 'offsetof(t, array-member)' a constant expression

The macro 'offsetof(t, m)' already expanded to a constant expression for
scalar members but not for arrays.  This was because the macro expanded
to '(size_t)(((t *)0)->m)', which lint internally represents as
'addr(indir(ptr(0) + offset(m)))', and build_address simplifies
'addr(indir(x))' to 'x' if the types match.  The types only match for
scalar types though, but not for arrays.

When build_address happens, the type information is incomplete,
therefore 'offsetof(t, array)' has to be simplified at a later point.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.638 -r1.639 src/usr.bin/xlint/lint1/tree.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/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.29 src/tests/usr.bin/xlint/lint1/decl.c:1.30
--- src/tests/usr.bin/xlint/lint1/decl.c:1.29	Wed May  1 12:36:56 2024
+++ src/tests/usr.bin/xlint/lint1/decl.c	Wed May  1 17:42:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl.c,v 1.29 2024/05/01 12:36:56 rillig Exp $	*/
+/*	$NetBSD: decl.c,v 1.30 2024/05/01 17:42:57 rillig Exp $	*/
 # 3 "decl.c"
 
 /*
@@ -243,22 +243,29 @@ get_x(struct point3d { struct point3d_nu
 }
 
 // Expressions of the form '(size_t)_ptr->member' are used by several
-// C implementations to implement the offsetof macro.  Dereferencing a null
-// pointer invokes undefined behavior, though, even in this form.
+// C implementations to implement the offsetof macro.
 void
 offsetof_on_array_member(void)
 {
-	struct s1 {
+	typedef struct {
 		int padding, plain, arr[2];
-	};
+	} s1;
 
+	// Bit-fields must have a constant number of bits.
 	struct s2 {
-		unsigned int off_plain:(unsigned long)&((struct s1 *)0)->plain;
-		// FIXME: offsetof must work for array members as well.
-		/* expect+1: error: integral constant expression expected [55] */
-		unsigned int off_arr:(unsigned long)&((struct s1 *)0)->arr;
-		// FIXME: offsetof must work for array members as well.
-		/* expect+1: error: integral constant expression expected [55] */
-		unsigned int off_arr_element:(unsigned long)&((struct s1 *)0)->arr[0];
+		unsigned int off_plain:(unsigned long)&((s1 *)0)->plain;
+		unsigned int off_arr:(unsigned long)&((s1 *)0)->arr;
+		unsigned int off_arr_0:(unsigned long)&((s1 *)0)->arr[0];
+		unsigned int off_arr_3:(unsigned long)&((s1 *)0)->arr[3];
 	};
+
+	// Arrays may be variable-width, but the diagnostic reveals the size.
+	/* expect+1: error: negative array dimension (-4) [20] */
+	typedef int off_plain[-(int)(unsigned long)&((s1 *)0)->plain];
+	/* expect+1: error: negative array dimension (-8) [20] */
+	typedef int off_arr[-(int)(unsigned long)&((s1 *)0)->arr];
+	/* expect+1: error: negative array dimension (-8) [20] */
+	typedef int off_arr_0[-(int)(unsigned long)&((s1 *)0)->arr[0]];
+	/* expect+1: error: negative array dimension (-20) [20] */
+	typedef int off_arr_3[-(int)(unsigned long)&((s1 *)0)->arr[3]];
 }

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.638 src/usr.bin/xlint/lint1/tree.c:1.639
--- src/usr.bin/xlint/lint1/tree.c:1.638	Wed May  1 05:49:33 2024
+++ src/usr.bin/xlint/lint1/tree.c	Wed May  1 17:42:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.638 2024/05/01 05:49:33 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.639 2024/05/01 17:42:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.638 2024/05/01 05:49:33 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.639 2024/05/01 17:42:57 rillig Exp $");
 #endif
 
 #include 
@@ -4112,6 +4112,28 @@ cast_to_union(tnode_t *otn, bool sys, ty
 	return NULL;
 }
 
+// In GCC mode, allow 'nullptr + offset' as a constant expression.
+static tnode_t *
+null_pointer_offset(tnode_t *tn)
+{
+	uint64_t off = 0;
+	const tnode_t *n = tn;
+	while ((n->tn_op == PLUS || n->tn_op == MINUS)
+	&& is_integer(n->u.ops.right->tn_type->t_tspec)) {
+		off += (uint64_t)n->u.ops.right->u.value.u.integer;
+		n = n->u.ops.left;
+	}
+	if (n->tn_type->t_tspec == PTR
+	&& n->tn_op == ADDR
+	&& n->u.ops.left->tn_op == INDIR
+	&& n->u.ops.left->u.ops.left->tn_op == CON
+	&& n->u.ops.left->u.ops.left->tn_type->t_tspec == PTR) {
+		off += (uint64_t)n->u.ops.left->u.ops.left->u.value.u.integer;
+		return build_integer_constant(SIZEOF_TSPEC, (int64_t)off);
+	}
+	return tn;
+}
+
 tnode_t *
 cast(tnode_t *tn, bool sys, type_t *tp)
 {
@@ -4144,7 +4166,7 @@ cast(tnode_t *tn, bool sys, type_t *tp)
 		error(148);
 		return NULL;
 	} else if (is_integer(nt) && is_scalar(ot)) {
-		/* ok */
+		tn = 

CVS commit: src

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 17:42:58 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: decl.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: make 'offsetof(t, array-member)' a constant expression

The macro 'offsetof(t, m)' already expanded to a constant expression for
scalar members but not for arrays.  This was because the macro expanded
to '(size_t)(((t *)0)->m)', which lint internally represents as
'addr(indir(ptr(0) + offset(m)))', and build_address simplifies
'addr(indir(x))' to 'x' if the types match.  The types only match for
scalar types though, but not for arrays.

When build_address happens, the type information is incomplete,
therefore 'offsetof(t, array)' has to be simplified at a later point.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.638 -r1.639 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/sys/arch/i386/eisa

2024-05-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  1 16:28:33 UTC 2024

Modified Files:
src/sys/arch/i386/eisa: eisa_machdep.c

Log Message:
Make eisa_machdep build without NIOAPIC > 0 by extracting irq definition.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/eisa/eisa_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/i386/eisa/eisa_machdep.c
diff -u src/sys/arch/i386/eisa/eisa_machdep.c:1.41 src/sys/arch/i386/eisa/eisa_machdep.c:1.42
--- src/sys/arch/i386/eisa/eisa_machdep.c:1.41	Sat Jun 18 22:11:00 2022
+++ src/sys/arch/i386/eisa/eisa_machdep.c	Wed May  1 16:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: eisa_machdep.c,v 1.41 2022/06/18 22:11:00 andvar Exp $	*/
+/*	$NetBSD: eisa_machdep.c,v 1.42 2024/05/01 16:28:33 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.41 2022/06/18 22:11:00 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.42 2024/05/01 16:28:33 andvar Exp $");
 
 #include "ioapic.h"
 
@@ -160,7 +160,15 @@ const char *
 eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih, char *buf,
 size_t len)
 {
-	if (ih == 0 || APIC_IRQ_LEGACY_IRQ(ih) >= NUM_LEGACY_IRQS || ih == 2)
+	int irq; 
+	
+#if NIOAPIC > 0
+	irq = APIC_IRQ_LEGACY_IRQ(ih);
+#else
+	irq = (int) ih;
+#endif
+
+	if (ih == 0 || irq >= NUM_LEGACY_IRQS || ih == 2)
 		panic("eisa_intr_string: bogus handle 0x%" PRIx64, ih);
 
 #if NIOAPIC > 0
@@ -168,11 +176,11 @@ eisa_intr_string(eisa_chipset_tag_t ec, 
 		snprintf(buf, len, "apic %d int %d (irq %d)",
 		APIC_IRQ_APIC(ih),
 		APIC_IRQ_PIN(ih),
-		APIC_IRQ_LEGACY_IRQ(ih));
+		irq);
 	else
-		snprintf(buf, len, "irq %d",  APIC_IRQ_LEGACY_IRQ(ih));
+		snprintf(buf, len, "irq %d",  irq);
 #else
-	snprintf(buf, len, "irq %d", APIC_IRQ_LEGACY_IRQ(ih));
+	snprintf(buf, len, "irq %d", irq);
 #endif
 	return buf;
 }



CVS commit: src/sys/arch/i386/eisa

2024-05-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  1 16:28:33 UTC 2024

Modified Files:
src/sys/arch/i386/eisa: eisa_machdep.c

Log Message:
Make eisa_machdep build without NIOAPIC > 0 by extracting irq definition.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/eisa/eisa_machdep.c

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



CVS commit: src/sys/conf

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 14:52:01 UTC 2024

Modified Files:
src/sys/conf: newvers.mk newvers.sh

Log Message:
PR/58220: Kouichi Hashikawa: use ${TOOL_AWK}


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/conf/newvers.mk
cvs rdiff -u -r1.63 -r1.64 src/sys/conf/newvers.sh

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

Modified files:

Index: src/sys/conf/newvers.mk
diff -u src/sys/conf/newvers.mk:1.3 src/sys/conf/newvers.mk:1.4
--- src/sys/conf/newvers.mk:1.3	Fri Apr  5 18:27:25 2024
+++ src/sys/conf/newvers.mk	Wed May  1 10:52:01 2024
@@ -1,4 +1,4 @@
-# $NetBSD: newvers.mk,v 1.3 2024/04/05 22:27:25 christos Exp $
+# $NetBSD: newvers.mk,v 1.4 2024/05/01 14:52:01 christos Exp $
 
 MKREPRO?=no
 
@@ -17,7 +17,8 @@ newvers: vers.o
 vers.o: ${SYSTEM_OBJ:O} Makefile $S/conf/newvers.sh \
 		$S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
 	${_MKMSG_CREATE} vers.c
-	TOOL_DATE=${TOOL_DATE} ${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
+	TOOL_AWK=${TOOL_AWK} TOOL_DATE=${TOOL_DATE} \
+	${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
 	${_MKTARGET_COMPILE}
 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
 	${COMPILE_CTFCONVERT}

Index: src/sys/conf/newvers.sh
diff -u src/sys/conf/newvers.sh:1.63 src/sys/conf/newvers.sh:1.64
--- src/sys/conf/newvers.sh:1.63	Fri Apr  5 18:27:25 2024
+++ src/sys/conf/newvers.sh	Wed May  1 10:52:01 2024
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: newvers.sh,v 1.63 2024/04/05 22:27:25 christos Exp $
+#	$NetBSD: newvers.sh,v 1.64 2024/05/01 14:52:01 christos Exp $
 #
 # Copyright (c) 1984, 1986, 1990, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -134,7 +134,7 @@ source_lines()
 	else
 		cat
 	fi \
-	| awk '{
+	| "${AWK}" '{
 		# awk does not care about whether or not the last line
 		# of input ends with a newline.
 		# Convert  to .
@@ -154,6 +154,7 @@ if [ ! -e version ]; then
 fi
 
 DATE=${TOOL_DATE:-date}
+AWK=${TOOL_AWK:-awk}
 Rflag=false
 nflag=false
 timestamp=



CVS commit: src/sys/conf

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 14:52:01 UTC 2024

Modified Files:
src/sys/conf: newvers.mk newvers.sh

Log Message:
PR/58220: Kouichi Hashikawa: use ${TOOL_AWK}


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/conf/newvers.mk
cvs rdiff -u -r1.63 -r1.64 src/sys/conf/newvers.sh

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



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

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 12:36:56 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: decl.c decl_enum.c

Log Message:
tests/lint: test large enum constants and offsetof with array members


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/decl_enum.c

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



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

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 12:36:56 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: decl.c decl_enum.c

Log Message:
tests/lint: test large enum constants and offsetof with array members


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/decl_enum.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/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.28 src/tests/usr.bin/xlint/lint1/decl.c:1.29
--- src/tests/usr.bin/xlint/lint1/decl.c:1.28	Sun Jan 28 08:17:27 2024
+++ src/tests/usr.bin/xlint/lint1/decl.c	Wed May  1 12:36:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl.c,v 1.28 2024/01/28 08:17:27 rillig Exp $	*/
+/*	$NetBSD: decl.c,v 1.29 2024/05/01 12:36:56 rillig Exp $	*/
 # 3 "decl.c"
 
 /*
@@ -241,3 +241,24 @@ get_x(struct point3d { struct point3d_nu
 	static struct point3d_number z;
 	return arg.x.v + local.x.v + z.v;
 }
+
+// Expressions of the form '(size_t)_ptr->member' are used by several
+// C implementations to implement the offsetof macro.  Dereferencing a null
+// pointer invokes undefined behavior, though, even in this form.
+void
+offsetof_on_array_member(void)
+{
+	struct s1 {
+		int padding, plain, arr[2];
+	};
+
+	struct s2 {
+		unsigned int off_plain:(unsigned long)&((struct s1 *)0)->plain;
+		// FIXME: offsetof must work for array members as well.
+		/* expect+1: error: integral constant expression expected [55] */
+		unsigned int off_arr:(unsigned long)&((struct s1 *)0)->arr;
+		// FIXME: offsetof must work for array members as well.
+		/* expect+1: error: integral constant expression expected [55] */
+		unsigned int off_arr_element:(unsigned long)&((struct s1 *)0)->arr[0];
+	};
+}

Index: src/tests/usr.bin/xlint/lint1/decl_enum.c
diff -u src/tests/usr.bin/xlint/lint1/decl_enum.c:1.4 src/tests/usr.bin/xlint/lint1/decl_enum.c:1.5
--- src/tests/usr.bin/xlint/lint1/decl_enum.c:1.4	Fri Jun 30 21:39:54 2023
+++ src/tests/usr.bin/xlint/lint1/decl_enum.c	Wed May  1 12:36:56 2024
@@ -1,10 +1,22 @@
-/*	$NetBSD: decl_enum.c,v 1.4 2023/06/30 21:39:54 rillig Exp $	*/
+/*	$NetBSD: decl_enum.c,v 1.5 2024/05/01 12:36:56 rillig Exp $	*/
 # 3 "decl_enum.c"
 
 /*
  * Tests for enum declarations.
  */
 
+
+// Initializing an enum from a 64-bit value cuts off the upper bits.
+// TIME_MIN thus gets truncated from 0x8000___ to 0.
+// TIME_MAX thus gets truncated from 0x7fff___ to -1.
+enum {
+	/* expect+1: warning: integral constant too large [56] */
+	TIME_MIN = (long long)(1ULL << 63),
+	/* expect+1: warning: integral constant too large [56] */
+	TIME_MAX = (long long)~(1ULL << 63),
+};
+
+
 /* cover 'enumerator_list: error' */
 enum {
 	/* expect+1: error: syntax error 'goto' [249] */



CVS commit: src/tests/lib/libc/stdio

2024-05-01 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Wed May  1 11:40:25 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_intr.sh

Log Message:
Increase the estimate of disk space required for the test, as the old
estimate recently proved too optimistic on the amd64 testbed on b4.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/stdio/t_intr.sh

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

Modified files:

Index: src/tests/lib/libc/stdio/t_intr.sh
diff -u src/tests/lib/libc/stdio/t_intr.sh:1.6 src/tests/lib/libc/stdio/t_intr.sh:1.7
--- src/tests/lib/libc/stdio/t_intr.sh:1.6	Sun Oct 31 11:36:26 2021
+++ src/tests/lib/libc/stdio/t_intr.sh	Wed May  1 11:40:25 2024
@@ -1,4 +1,4 @@
-# $NetBSD: t_intr.sh,v 1.6 2021/10/31 11:36:26 gson Exp $
+# $NetBSD: t_intr.sh,v 1.7 2024/05/01 11:40:25 gson Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,7 +37,10 @@ TMOUT=20
 
 h_test() {
 	local avail=$( df -m . | awk '{if (int($4) > 0) print $4}' )
-	local need=$(( 2 * $MAX * 8 / 100 ))
+	# The test data are stored in triplicate: numbers.in, numbers.out,
+	# and a temporary "stdout" file created by ATF.  Each line consists
+	# of up to 7 digits and a newline for a total of 8 bytes.
+	local need=$(( 3 * $MAX * 8 / 100 ))
 	if [ $avail -lt $need ]; then
 		atf_skip "not enough free space in working directory"
 	fi



CVS commit: src/tests/lib/libc/stdio

2024-05-01 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Wed May  1 11:40:25 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_intr.sh

Log Message:
Increase the estimate of disk space required for the test, as the old
estimate recently proved too optimistic on the amd64 testbed on b4.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/stdio/t_intr.sh

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



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 11:32:29 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_16.c

Log Message:
Enable compat sigreturn system call.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/netbsd32/netbsd32_compat_16.c

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



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 11:32:29 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_16.c

Log Message:
Enable compat sigreturn system call.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/netbsd32/netbsd32_compat_16.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/compat/netbsd32/netbsd32_compat_16.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_16.c:1.4 src/sys/compat/netbsd32/netbsd32_compat_16.c:1.5
--- src/sys/compat/netbsd32/netbsd32_compat_16.c:1.4	Fri Nov 26 08:06:11 2021
+++ src/sys/compat/netbsd32/netbsd32_compat_16.c	Wed May  1 11:32:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_16.c,v 1.4 2021/11/26 08:06:11 ryo Exp $	*/
+/*	$NetBSD: netbsd32_compat_16.c,v 1.5 2024/05/01 11:32:29 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,13 +29,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_16.c,v 1.4 2021/11/26 08:06:11 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_16.c,v 1.5 2024/05/01 11:32:29 mlelstv Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -47,40 +48,87 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_com
 
 struct uvm_object *emul_netbsd32_object;
 
-MODULE(MODULE_CLASS_EXEC, compat_netbsd32_16, "compat_netbsd32_20,compat_16");
+static const struct syscall_package netbsd32_kern_sig_16_syscalls[] = {
+/* compat_16_netbs32___sigreturn14 is in MD code! */
+{ NETBSD32_SYS_compat_16_netbsd32___sigreturn14, 0,
+(sy_call_t *)compat_16_netbsd32___sigreturn14 },
+{ 0, 0, NULL }
+};
 
 static int
-compat_netbsd32_16_modcmd(modcmd_t cmd, void *arg)
+compat_netbsd32_16_init(void)
+{
+	int error;
+
+	error = syscall_establish(_netbsd32, netbsd32_kern_sig_16_syscalls);
+	if (error)
+		return error;
+
+	rw_enter(_lock, RW_WRITER);
+	emul_netbsd32.e_sigcode = netbsd32_sigcode;
+	emul_netbsd32.e_esigcode = netbsd32_esigcode;
+	emul_netbsd32.e_sigobject = _netbsd32_object;
+	error = exec_sigcode_alloc(_netbsd);
+	if (error) {
+		emul_netbsd32.e_sigcode = NULL;
+		emul_netbsd32.e_esigcode = NULL;
+		emul_netbsd32.e_sigobject = NULL;
+	}
+	rw_exit(_lock);
+	if (error)
+		return error;
+	netbsd32_machdep_md_16_init();
+	return 0;
+}
+
+static int
+compat_netbsd32_16_fini(void)
 {
+	proc_t *p;
 	int error;
 
+	error = syscall_disestablish(_netbsd32, netbsd32_kern_sig_16_syscalls);
+if (error)
+return error;
+/*
+ * Ensure sendsig_sigcontext() is not being used.
+ * module_lock prevents the flag being set on any
+ * further processes while we are here.  See
+ * sigaction1() for the opposing half.
+ */
+mutex_enter(_lock);
+PROCLIST_FOREACH(p, ) {
+if ((p->p_lflag & PL_SIGCOMPAT) != 0) {
+break;
+}
+}
+mutex_exit(_lock);
+if (p != NULL) {
+syscall_establish(_netbsd32, netbsd32_kern_sig_16_syscalls);
+return EBUSY;
+}
+
+	rw_enter(_lock, RW_WRITER);
+	exec_sigcode_free(_netbsd);
+	emul_netbsd32.e_sigcode = NULL;
+   	emul_netbsd32.e_esigcode = NULL;
+   	emul_netbsd32.e_sigobject = NULL;
+	rw_exit(_lock);
+	netbsd32_machdep_md_16_fini();
+	return 0;
+}
+
+MODULE(MODULE_CLASS_EXEC, compat_netbsd32_16, "compat_netbsd32_20,compat_16");
+
+static int
+compat_netbsd32_16_modcmd(modcmd_t cmd, void *arg)
+{
 	switch (cmd) {
 	case MODULE_CMD_INIT:
-		rw_enter(_lock, RW_WRITER);
-		emul_netbsd32.e_sigcode = netbsd32_sigcode;
-	emul_netbsd32.e_esigcode = netbsd32_esigcode;
-	emul_netbsd32.e_sigobject = _netbsd32_object;
-		error = exec_sigcode_alloc(_netbsd);
-		if (error) {
-			emul_netbsd32.e_sigcode = NULL;
-			emul_netbsd32.e_esigcode = NULL;
-			emul_netbsd32.e_sigobject = NULL;
-		}
-		rw_exit(_lock);
-		if (error)
-			return error;
-		netbsd32_machdep_md_16_init();
-		return 0;
+		return compat_netbsd32_16_init();
 
 	case MODULE_CMD_FINI:
-		rw_enter(_lock, RW_WRITER);
-		exec_sigcode_free(_netbsd);
-		emul_netbsd32.e_sigcode = NULL;
-	emul_netbsd32.e_esigcode = NULL;
-	emul_netbsd32.e_sigobject = NULL;
-		rw_exit(_lock);
-		netbsd32_machdep_md_16_fini();
-		return 0;
+		return compat_netbsd32_16_fini();
 
 	default:
 		return ENOTTY;



CVS commit: src/share/man/man4

2024-05-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  1 11:22:06 UTC 2024

Modified Files:
src/share/man/man4: wm.4

Log Message:
Fix typos (nerwork->network, exepense->expense).


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/share/man/man4/wm.4

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/man4/wm.4
diff -u src/share/man/man4/wm.4:1.43 src/share/man/man4/wm.4:1.44
--- src/share/man/man4/wm.4:1.43	Sat May 28 00:53:41 2022
+++ src/share/man/man4/wm.4	Wed May  1 11:22:06 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wm.4,v 1.43 2022/05/28 00:53:41 manu Exp $
+.\"	$NetBSD: wm.4,v 1.44 2024/05/01 11:22:06 andvar Exp $
 .\"
 .\" Copyright 2002, 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -186,12 +186,12 @@ utility configures the adapter to receiv
 .Sh OPTIONS
 The driver default behavior is to handle packets in interrupt context,
 which reduces the CPU time available to user processes when under 
-heavy nerwork load. The 
+heavy network load. The 
 .Em hw.wmX.txrx_workqueue
 .Xr sysctl 8
 alters this behavior so that packets are handled by a kernel thread, 
 which executes at a lower priority. This gives user processes more
-opportunity to be executed, at the exepense of network throughput.
+opportunity to be executed, at the expense of network throughput.
 .Pp
 The following options can be set at build time:
 .Bl -tag -width WM_RX_INTR_PROCESS_LIMIT_DEFAULT -offset 3n



CVS commit: src/share/man/man4

2024-05-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  1 11:22:06 UTC 2024

Modified Files:
src/share/man/man4: wm.4

Log Message:
Fix typos (nerwork->network, exepense->expense).


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/share/man/man4/wm.4

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



CVS commit: src

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 10:30:56 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_attribute_aligned.c
src/usr.bin/xlint/lint1: decl.c

Log Message:
lint: fix size of struct with large alignment

Lint now successfully passes all compile-time assertions in the amd64
kernel that deal with struct sizes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c
cvs rdiff -u -r1.399 -r1.400 src/usr.bin/xlint/lint1/decl.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/gcc_attribute_aligned.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.7 src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.8
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.7	Wed May  1 07:40:11 2024
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c	Wed May  1 10:30:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_aligned.c,v 1.7 2024/05/01 07:40:11 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_aligned.c,v 1.8 2024/05/01 10:30:56 rillig Exp $	*/
 # 3 "gcc_attribute_aligned.c"
 
 /*
@@ -72,3 +72,13 @@ aligned_struct_member(void)
 	/* expect+1: error: negative array dimension (-32) [20] */
 	typedef int ctassert[-(int)sizeof(struct aligned)];
 }
+
+void
+alignment_larger_than_size(void)
+{
+	struct s {
+		unsigned u32 __attribute__((__aligned__(32)));
+	} _Alignas(4096);
+	/* expect+1: error: negative array dimension (-4096) [20] */
+	typedef int size[-(int)sizeof(struct s)];
+}

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.399 src/usr.bin/xlint/lint1/decl.c:1.400
--- src/usr.bin/xlint/lint1/decl.c:1.399	Wed May  1 07:40:11 2024
+++ src/usr.bin/xlint/lint1/decl.c	Wed May  1 10:30:56 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.399 2024/05/01 07:40:11 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.400 2024/05/01 10:30:56 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.399 2024/05/01 07:40:11 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.400 2024/05/01 10:30:56 rillig Exp $");
 #endif
 
 #include 
@@ -463,6 +463,9 @@ void
 dcs_add_alignas(tnode_t *tn)
 {
 	dcs->d_mem_align_in_bits = to_int_constant(tn, true) * CHAR_SIZE;
+	if (dcs->d_type != NULL && is_struct_or_union(dcs->d_type->t_tspec))
+		dcs->d_type->u.sou->sou_align_in_bits =
+		dcs->d_mem_align_in_bits;
 }
 
 void
@@ -606,6 +609,7 @@ dcs_begin_type(void)
 	dcs->d_redeclared_symbol = NULL;
 	// keep d_sou_size_in_bits
 	// keep d_sou_align_in_bits
+	dcs->d_mem_align_in_bits = 0;
 	dcs->d_qual = (type_qualifiers) { .tq_const = false };
 	dcs->d_inline = false;
 	dcs->d_multiple_storage_classes = false;
@@ -707,6 +711,8 @@ dcs_merge_declaration_specifiers(void)
 	debug_dcs();
 }
 
+static void dcs_align(unsigned int, unsigned int);
+
 /* Create a type in 'dcs->d_type' from the information gathered in 'dcs'. */
 void
 dcs_end_type(void)
@@ -741,6 +747,14 @@ dcs_end_type(void)
 		dcs->d_type->t_const |= dcs->d_qual.tq_const;
 		dcs->d_type->t_volatile |= dcs->d_qual.tq_volatile;
 	}
+	unsigned align = dcs->d_mem_align_in_bits;
+	if (align > 0 && dcs->d_type->t_tspec == STRUCT) {
+		dcs_align(align, 0);
+		dcs->d_type->u.sou->sou_align_in_bits = align;
+		dcs->d_type->u.sou->sou_size_in_bits =
+		(dcs->d_type->u.sou->sou_size_in_bits + align - 1)
+		& -align;
+	}
 
 	debug_dcs();
 	debug_leave();
@@ -814,7 +828,6 @@ alignment_in_bits(const type_t *tp)
 			a = worst_align_in_bits;
 	}
 	lint_assert(a >= CHAR_SIZE);
-	lint_assert(a <= worst_align_in_bits);
 	return a;
 }
 



CVS commit: src

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 10:30:56 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_attribute_aligned.c
src/usr.bin/xlint/lint1: decl.c

Log Message:
lint: fix size of struct with large alignment

Lint now successfully passes all compile-time assertions in the amd64
kernel that deal with struct sizes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c
cvs rdiff -u -r1.399 -r1.400 src/usr.bin/xlint/lint1/decl.c

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



CVS commit: src/sys/arch/hp300/dev

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 08:58:34 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Add DELAY(9) to make palette register settings stable on 98543 in HP360.

Note 98547 (6 bpp variant) on HP370 (68030 33MHz) doesn't need these
DELAYs so maybe only some old variants (98543 and 98545?) on 020/030
have such restriction (actually only one nop seems enough.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/topcat.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/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.9 src/sys/arch/hp300/dev/topcat.c:1.10
--- src/sys/arch/hp300/dev/topcat.c:1.9	Mon Apr 29 17:47:27 2024
+++ src/sys/arch/hp300/dev/topcat.c	Wed May  1 08:58:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.9 2024/04/29 17:47:27 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.10 2024/05/01 08:58:34 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -474,7 +474,9 @@ topcat_setcolor(struct diofb *fb, u_int 
 		tc->rdata  = fb->cmap.r[index];
 		tc->gdata  = fb->cmap.g[index];
 		tc->bdata  = fb->cmap.b[index];
+		DELAY(1);	/* necessary for at least old HP98543 */
 		tc->cindex = ~index;
+		DELAY(1);	/* necessary for at least old HP98543 */
 		tc->strobe = 0xff;
 		/* XXX delay required on 68020/30 to avoid bus error */
 		DELAY(100);



CVS commit: src/sys/arch/hp300/dev

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 08:58:34 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Add DELAY(9) to make palette register settings stable on 98543 in HP360.

Note 98547 (6 bpp variant) on HP370 (68030 33MHz) doesn't need these
DELAYs so maybe only some old variants (98543 and 98545?) on 020/030
have such restriction (actually only one nop seems enough.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/topcat.c

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



CVS commit: src/sys/sys

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 07:43:42 UTC 2024

Modified Files:
src/sys/sys: cdefs.h

Log Message:
sys/cdefs.h: pass __aligned to lint

Lint could parse _Alignas and __attribute__((__aligned__(4))) previously
but simply ignored them. Since today, they affect the layout of struct
and union.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/sys/cdefs.h

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



CVS commit: src/sys/sys

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 07:43:42 UTC 2024

Modified Files:
src/sys/sys: cdefs.h

Log Message:
sys/cdefs.h: pass __aligned to lint

Lint could parse _Alignas and __attribute__((__aligned__(4))) previously
but simply ignored them. Since today, they affect the layout of struct
and union.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/sys/cdefs.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/sys/cdefs.h
diff -u src/sys/sys/cdefs.h:1.160 src/sys/sys/cdefs.h:1.161
--- src/sys/sys/cdefs.h:1.160	Sun Apr 30 08:45:48 2023
+++ src/sys/sys/cdefs.h	Wed May  1 07:43:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdefs.h,v 1.160 2023/04/30 08:45:48 riastradh Exp $	*/
+/*	$NetBSD: cdefs.h,v 1.161 2024/05/01 07:43:41 rillig Exp $	*/
 
 /* * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -451,7 +451,7 @@
 #if defined(__lint__)
 #define __thread	/* delete */
 #define	__packed	__packed
-#define	__aligned(x)	/* delete */
+#define	__aligned(x)	_Alignas((x))
 #define	__section(x)	/* delete */
 #elif __GNUC_PREREQ__(2, 7) || defined(__PCC__) || defined(__lint__)
 #define	__packed	__attribute__((__packed__))



CVS commit: src

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 07:40:11 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_precedence.c
gcc_attribute_aligned.c
src/usr.bin/xlint/lint1: cgram.y debug.c decl.c externs1.h lint1.h

Log Message:
lint: support _Alignas and __attribute__((__aligned(4)))


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/expr_precedence.c
cvs rdiff -u -r1.6 -r1.7 \
src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c
cvs rdiff -u -r1.493 -r1.494 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.398 -r1.399 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/xlint/lint1/externs1.h \
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/expr_precedence.c
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.11 src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.12
--- src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.11	Tue Mar 28 14:44:34 2023
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.c	Wed May  1 07:40:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_precedence.c,v 1.11 2023/03/28 14:44:34 rillig Exp $	*/
+/*	$NetBSD: expr_precedence.c,v 1.12 2024/05/01 07:40:11 rillig Exp $	*/
 # 3 "expr_precedence.c"
 
 /*
@@ -20,8 +20,9 @@ int init_error = 3, 4;
 int init_syntactically_ok = var = 1 ? 2 : 3;
 
 /*
- * The arguments of __attribute__ must be constant-expression, as assignments
- * don't make sense at that point.
+ * The arguments of __attribute__ must be constant-expression, but for
+ * simplicity of implementation, they are parsed just like function arguments,
+ * even though this allows assignment-expression.
  */
 void __attribute__((format(printf,
 /*
@@ -32,7 +33,6 @@ void __attribute__((format(printf,
  *
  * See lex.c, function 'search', keyword 'in_gcc_attribute'.
  */
-/* expect+1: error: syntax error '=' [249] */
 var = 1,
 /* Syntactically ok, must be a constant expression though. */
 var > 0 ? 2 : 1)))

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.6 src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.7
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.6	Fri Jul  7 19:45:22 2023
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c	Wed May  1 07:40:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_aligned.c,v 1.6 2023/07/07 19:45:22 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_aligned.c,v 1.7 2024/05/01 07:40:11 rillig Exp $	*/
 # 3 "gcc_attribute_aligned.c"
 
 /*
@@ -47,8 +47,8 @@ struct save87 {
 	struct fpacc87 s87_ac[8];
 };
 
-/* FIXME: @4 2 + @4 2 + @4 2 + @4 8 + @4 8 + @2 (8 * 10) == 108 */
-/* expect+1: error: negative array dimension (-104) [20] */
+/* @4 2 + @4 2 + @4 2 + @4 8 + @4 8 + @2 (8 * 10) == 108 */
+/* expect+1: error: negative array dimension (-108) [20] */
 typedef int sizeof_save87[-(int)sizeof(struct save87)];
 
 
@@ -69,7 +69,6 @@ aligned_struct_member(void)
 	 *
 	 * https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
 	 */
-	/* TODO: should be -32 instead of -8. */
-	/* expect+1: error: negative array dimension (-8) [20] */
+	/* expect+1: error: negative array dimension (-32) [20] */
 	typedef int ctassert[-(int)sizeof(struct aligned)];
 }

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.493 src/usr.bin/xlint/lint1/cgram.y:1.494
--- src/usr.bin/xlint/lint1/cgram.y:1.493	Fri Mar 29 08:35:32 2024
+++ src/usr.bin/xlint/lint1/cgram.y	Wed May  1 07:40:11 2024
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.493 2024/03/29 08:35:32 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.494 2024/05/01 07:40:11 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.493 2024/03/29 08:35:32 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.494 2024/05/01 07:40:11 rillig Exp $");
 #endif
 
 #include 
@@ -423,7 +423,6 @@ is_either(const char *s, const char *a, 
 /* No type for gcc_attribute_specifier. */
 /* No type for gcc_attribute_list. */
 /* No type for gcc_attribute. */
-/* No type for gcc_attribute_parameters. */
 %type	 sys
 
 %%
@@ -937,8 +936,12 @@ type_attribute_opt:
 
 type_attribute:			/* See C11 6.7 declaration-specifiers */
 	gcc_attribute_specifier
-|	T_ALIGNAS T_LPAREN type_specifier T_RPAREN	/* C11 6.7.5 */
-|	T_ALIGNAS T_LPAREN constant_expression T_RPAREN	/* C11 6.7.5 */
+|	T_ALIGNAS T_LPAREN type_specifier T_RPAREN {		/* C11 6.7.5 */
+		dcs_add_alignas(build_sizeof($3));
+	}
+|	T_ALIGNAS T_LPAREN constant_expression T_RPAREN {	/* C11 6.7.5 */
+		dcs_add_alignas($3);
+	}
 |	T_PACKED {
 		dcs_add_packed();
 	}
@@ -2197,18 +2200,18 @@ gcc_attribute:
 	

CVS commit: src

2024-05-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed May  1 07:40:11 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_precedence.c
gcc_attribute_aligned.c
src/usr.bin/xlint/lint1: cgram.y debug.c decl.c externs1.h lint1.h

Log Message:
lint: support _Alignas and __attribute__((__aligned(4)))


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/expr_precedence.c
cvs rdiff -u -r1.6 -r1.7 \
src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c
cvs rdiff -u -r1.493 -r1.494 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.398 -r1.399 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/xlint/lint1/externs1.h \
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.



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:22:43 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_sysent.c

Log Message:
Revert previous, the syscall needs to be enabled at runtime.

The compat_16 module just enables it for the "netbsd" emulation, but
nothing enables it yet for "netbsd32".


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/compat/netbsd32/netbsd32_sysent.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/compat/netbsd32/netbsd32_sysent.c
diff -u src/sys/compat/netbsd32/netbsd32_sysent.c:1.159 src/sys/compat/netbsd32/netbsd32_sysent.c:1.160
--- src/sys/compat/netbsd32/netbsd32_sysent.c:1.159	Tue Apr 30 17:10:22 2024
+++ src/sys/compat/netbsd32/netbsd32_sysent.c	Wed May  1 07:22:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_sysent.c,v 1.159 2024/04/30 17:10:22 mlelstv Exp $ */
+/* $NetBSD: netbsd32_sysent.c,v 1.160 2024/05/01 07:22:43 mlelstv Exp $ */
 
 /*
  * System call switch table.
@@ -8,7 +8,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.159 2024/04/30 17:10:22 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.160 2024/05/01 07:22:43 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1280,7 +1280,7 @@ struct sysent netbsd32_sysent[] = {
 	},		/* 294 = netbsd32___sigsuspend14 */
 	{
 		ns(struct compat_16_netbsd32___sigreturn14_args),
-		.sy_call = (sy_call_t *)compat_16_netbsd32___sigreturn14
+		.sy_call = (sy_call_t *)sys_nomodule
 	},		/* 295 = compat_16_netbsd32___sigreturn14 */
 	{
 		ns(struct netbsd32___getcwd_args),



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:22:43 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_sysent.c

Log Message:
Revert previous, the syscall needs to be enabled at runtime.

The compat_16 module just enables it for the "netbsd" emulation, but
nothing enables it yet for "netbsd32".


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/compat/netbsd32/netbsd32_sysent.c

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