CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 23:12:40 UTC 2022

Modified Files:
src/games/gomoku: gomoku.h pickmove.c

Log Message:
gomoku: remove unused function 'list_eq'


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.37 -r1.38 src/games/gomoku/pickmove.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 23:12:40 UTC 2022

Modified Files:
src/games/gomoku: gomoku.h pickmove.c

Log Message:
gomoku: remove unused function 'list_eq'


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.37 -r1.38 src/games/gomoku/pickmove.c

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

Modified files:

Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.29 src/games/gomoku/gomoku.h:1.30
--- src/games/gomoku/gomoku.h:1.29	Thu May 19 18:58:59 2022
+++ src/games/gomoku/gomoku.h	Thu May 19 23:12:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gomoku.h,v 1.29 2022/05/19 18:58:59 rillig Exp $	*/
+/*	$NetBSD: gomoku.h,v 1.30 2022/05/19 23:12:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -244,7 +244,6 @@ void	whatsup(int);
 const char   *stoc(int);
 int	ctos(const char *);
 int	makemove(int, int);
-int	list_eq(struct combostr **, struct combostr **, int);
 void	clearcombo(struct combostr *, int);
 void	markcombo(struct combostr *);
 int	pickmove(int);

Index: src/games/gomoku/pickmove.c
diff -u src/games/gomoku/pickmove.c:1.37 src/games/gomoku/pickmove.c:1.38
--- src/games/gomoku/pickmove.c:1.37	Thu May 19 22:29:36 2022
+++ src/games/gomoku/pickmove.c	Thu May 19 23:12:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pickmove.c,v 1.37 2022/05/19 22:29:36 rillig Exp $	*/
+/*	$NetBSD: pickmove.c,v 1.38 2022/05/19 23:12:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)pickmove.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: pickmove.c,v 1.37 2022/05/19 22:29:36 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.38 2022/05/19 23:12:40 rillig Exp $");
 
 #include 
 #include 
@@ -1470,19 +1470,4 @@ clearcombo(struct combostr *cbp, int ope
 	for (; --n >= 0; sp += d)
 		sp->s_flags &= mask;
 }
-
-int
-list_eq(struct combostr **scbpp, struct combostr **cbpp, int n)
-{
-	struct combostr **spp, **cpp;
-
-	spp = scbpp + n;
-	cpp = cbpp + n;
-	do {
-		if (*--spp != *--cpp)
-			return 0;
-	} while (cpp != cbpp);
-	/* we found a match */
-	return 1;
-}
 #endif /* DEBUG */



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:49:05 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c main.c

Log Message:
gomoku: use combined curses functions

To save some screen space in the source code and some bytes in the
generated binary.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.41 -r1.42 src/games/gomoku/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/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.35 src/games/gomoku/bdisp.c:1.36
--- src/games/gomoku/bdisp.c:1.35	Thu May 19 22:24:54 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 22:49:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.35 2022/05/19 22:24:54 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.36 2022/05/19 22:49:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdisp.c,v 1.35 2022/05/19 22:24:54 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.36 2022/05/19 22:49:05 rillig Exp $");
 
 #include 
 #include 
@@ -97,26 +97,20 @@ void
 bdisp_init(void)
 {
 
-	/* top border */
+	/* top and bottom borders */
 	for (int i = 1; i < BSZ + 1; i++) {
-		move(scr_y(BSZ + 1), scr_x(i));
-		addch(letters[i]);
+		mvaddch(scr_y(BSZ + 1), scr_x(i), letters[i]);
+		mvaddch(scr_y(0), scr_x(i), letters[i]);
 	}
+
 	/* left and right edges */
 	for (int j = BSZ + 1; --j > 0; ) {
-		move(scr_y(j), 0);
-		printw("%2d ", j);
-		move(scr_y(j), scr_x(BSZ) + 2);
-		printw("%d ", j);
-	}
-	/* bottom border */
-	for (int i = 1; i < BSZ + 1; i++) {
-		move(scr_y(0), scr_x(i));
-		addch(letters[i]);
+		mvprintw(scr_y(j), 0, "%2d ", j);
+		mvprintw(scr_y(j), scr_x(BSZ) + 2, "%d ", j);
 	}
+
 	bdwho(false);
-	move(0, TRANSCRIPT_COL + 1);
-	addstr("#  black  white");
+	mvaddstr(0, TRANSCRIPT_COL + 1, "#  black  white");
 	lastline = 0;
 	bdisp();
 }
@@ -133,12 +127,11 @@ bdwho(bool update)
 	int fixed = (int)sizeof("BLACK/ (*) vs. WHITE/ (O)") - 1;
 	int total = fixed + bw + ww;
 
-	move(BSZ + 2, 0);
-	hline(' ', available);
+	mvhline(BSZ + 2, 0, ' ', available);
 
 	if (total <= available) {
-		move(BSZ + 2, (available - total) / 2);
-		printw("BLACK/%s (*) vs. WHITE/%s (O)",
+		mvprintw(BSZ + 2, (available - total) / 2,
+		"BLACK/%s (*) vs. WHITE/%s (O)",
 		plyr[BLACK], plyr[WHITE]);
 	} else {
 		int remaining = available - fixed;
@@ -151,8 +144,7 @@ bdwho(bool update)
 		else
 			bw = half, ww = remaining - half;
 
-		move(BSZ + 2, 0);
-		printw("BLACK/%.*s (*) vs. WHITE/%.*s (O)",
+		mvprintw(BSZ + 2, 0, "BLACK/%.*s (*) vs. WHITE/%.*s (O)",
 		bw, plyr[BLACK], ww, plyr[WHITE]);
 	}
 	if (update)
@@ -170,7 +162,6 @@ bdisp(void)
 
 	for (int j = BSZ + 1; --j > 0; ) {
 		for (int i = 1; i < BSZ + 1; i++) {
-			move(scr_y(j), scr_x(i));
 			sp = [i + j * (BSZ + 1)];
 			if (debug > 1 && sp->s_occ == EMPTY) {
 if ((sp->s_flags & IFLAGALL) != 0)
@@ -181,6 +172,8 @@ bdisp(void)
 	c = '.';
 			} else
 c = pcolor[sp->s_occ];
+
+			move(scr_y(j), scr_x(i));
 			if (movenum > 1 && movelog[movenum - 2] == PT(i, j)) {
 attron(A_BOLD);
 addch(c);
@@ -242,8 +235,7 @@ dislog(const char *str)
 		/* move 'em up */
 		lastline = 1;
 	}
-	move(lastline, TRANSCRIPT_COL);
-	addnstr(str, SCRNW - TRANSCRIPT_COL - 1);
+	mvaddnstr(lastline, TRANSCRIPT_COL, str, SCRNW - TRANSCRIPT_COL - 1);
 	clrtoeol();
 	move(lastline + 1, TRANSCRIPT_COL);
 	clrtoeol();
@@ -258,8 +250,7 @@ ask(const char *str)
 {
 	int len = (int)strlen(str);
 
-	move(BSZ + 4, 0);
-	addstr(str);
+	mvaddstr(BSZ + 4, 0, str);
 	clrtoeol();
 	move(BSZ + 4, len);
 	refresh();

Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.41 src/games/gomoku/main.c:1.42
--- src/games/gomoku/main.c:1.41	Thu May 19 22:19:18 2022
+++ src/games/gomoku/main.c	Thu May 19 22:49:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.41 2022/05/19 22:19:18 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.42 2022/05/19 22:49:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -36,7 +36,7 @@
 __COPYRIGHT("@(#) Copyright (c) 1994\
  The Regents of the University of California.  All rights reserved.");
 /*	@(#)main.c	8.4 (Berkeley) 5/4/95	*/
-__RCSID("$NetBSD: main.c,v 1.41 2022/05/19 22:19:18 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.42 2022/05/19 22:49:05 rillig Exp $");
 
 #include 
 #include 
@@ -157,8 +157,7 @@ again:
 #endif
 
 		if (inputfp == NULL && test == 0) {
-			move(BSZ + 3, 0);
-			printw("Black moves first. ");
+			mvprintw(BSZ + 3, 0, "Black moves first. ");
 			ask("(B)lack or (W)hite? ");
 			for (;;) {
 ch = get_key(NULL);



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:49:05 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c main.c

Log Message:
gomoku: use combined curses functions

To save some screen space in the source code and some bytes in the
generated binary.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.41 -r1.42 src/games/gomoku/main.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:29:36 UTC 2022

Modified Files:
src/games/gomoku: bdinit.c pickmove.c

Log Message:
gomoku: use NULL instead of more verbose null pointer

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.36 -r1.37 src/games/gomoku/pickmove.c

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

Modified files:

Index: src/games/gomoku/bdinit.c
diff -u src/games/gomoku/bdinit.c:1.18 src/games/gomoku/bdinit.c:1.19
--- src/games/gomoku/bdinit.c:1.18	Thu May 19 22:19:18 2022
+++ src/games/gomoku/bdinit.c	Thu May 19 22:29:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdinit.c,v 1.18 2022/05/19 22:19:18 rillig Exp $	*/
+/*	$NetBSD: bdinit.c,v 1.19 2022/05/19 22:29:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	from: @(#)bdinit.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdinit.c,v 1.18 2022/05/19 22:19:18 rillig Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.19 2022/05/19 22:29:36 rillig Exp $");
 
 #include 
 #include "gomoku.h"
@@ -144,8 +144,8 @@ bdinit(struct spotstr *bp)
 		sp->s_flags = BFLAGALL;
 	}
 
-	sortframes[BLACK] = (struct combostr *)0;
-	sortframes[WHITE] = (struct combostr *)0;
+	sortframes[BLACK] = NULL;
+	sortframes[WHITE] = NULL;
 	init_overlap();
 }
 

Index: src/games/gomoku/pickmove.c
diff -u src/games/gomoku/pickmove.c:1.36 src/games/gomoku/pickmove.c:1.37
--- src/games/gomoku/pickmove.c:1.36	Thu May 19 22:19:18 2022
+++ src/games/gomoku/pickmove.c	Thu May 19 22:29:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pickmove.c,v 1.36 2022/05/19 22:19:18 rillig Exp $	*/
+/*	$NetBSD: pickmove.c,v 1.37 2022/05/19 22:29:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)pickmove.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: pickmove.c,v 1.36 2022/05/19 22:19:18 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.37 2022/05/19 22:29:36 rillig Exp $");
 
 #include 
 #include 
@@ -239,7 +239,7 @@ scanframes(int color)
 
 	/* check for empty list of frames */
 	cbp = sortframes[color];
-	if (cbp == (struct combostr *)0)
+	if (cbp == NULL)
 		return;
 
 	/* quick check for four in a row */
@@ -358,7 +358,7 @@ scanframes(int color)
 			free(ep);
 			elistcnt--;
 		}
-		sp->s_empty = (struct elist *)0;
+		sp->s_empty = NULL;
 		for (struct elist *ep = sp->s_nempty; ep != NULL; ep = nep) {
 			cbp = ep->e_combo;
 			if (cbp->c_combo.s <= sp->s_combo[color].s) {
@@ -372,11 +372,11 @@ scanframes(int color)
 			free(ep);
 			elistcnt--;
 		}
-		sp->s_nempty = (struct elist *)0;
+		sp->s_nempty = NULL;
 	}
 
 	/* remove old combos */
-	if ((cbp = sortcombos) != (struct combostr *)0) {
+	if ((cbp = sortcombos) != NULL) {
 		struct combostr *ncbp;
 
 		/* scan the list */
@@ -386,7 +386,7 @@ scanframes(int color)
 			free(cbp);
 			combocnt--;
 		} while ((cbp = ncbp) != ecbp);
-		sortcombos = (struct combostr *)0;
+		sortcombos = NULL;
 	}
 	combolen = 0;
 
@@ -568,7 +568,7 @@ addframes(int level)
 			elistcnt--;
 		}
 		sp->s_empty = sp->s_nempty;
-		sp->s_nempty = (struct elist *)0;
+		sp->s_nempty = NULL;
 	}
 
 	/* try to add frames to the uncompleted combos at level curlevel */
@@ -618,11 +618,11 @@ addframes(int level)
 	cbpp = [FAREA];
 	do {
 		cbp = *--cbpp;
-		if (cbp == (struct combostr *)0)
+		if (cbp == NULL)
 			continue;
-		*cbpp = (struct combostr *)0;
+		*cbpp = NULL;
 		ecbp = sortcombos;
-		if (ecbp == (struct combostr *)0)
+		if (ecbp == NULL)
 			sortcombos = cbp;
 		else {
 			/* append to sort list */
@@ -1045,7 +1045,7 @@ appendcombo(struct combostr *cbp, int co
 
 	combolen++;
 	ncbp = sortcombos;
-	if (ncbp == (struct combostr *)0) {
+	if (ncbp == NULL) {
 		sortcombos = cbp;
 		cbp->c_next = cbp;
 		cbp->c_prev = cbp;
@@ -1246,7 +1246,7 @@ inserted:
 
 	/* now check to see if this list of frames has already been seen */
 	cbp = hashcombos[inx = (int)(*scbpp - frames)];
-	if (cbp == (struct combostr *)0) {
+	if (cbp == NULL) {
 		/*
 		 * Easy case, this list hasn't been seen.
 		 * Add it to the hash list.



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:29:36 UTC 2022

Modified Files:
src/games/gomoku: bdinit.c pickmove.c

Log Message:
gomoku: use NULL instead of more verbose null pointer

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.36 -r1.37 src/games/gomoku/pickmove.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:24:54 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: clean up coordinate for the currently selected spot

There is no need to make this coordinate dependent on the board size.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.34 src/games/gomoku/bdisp.c:1.35
--- src/games/gomoku/bdisp.c:1.34	Thu May 19 22:19:18 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 22:24:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.34 2022/05/19 22:19:18 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.35 2022/05/19 22:24:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdisp.c,v 1.34 2022/05/19 22:19:18 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.35 2022/05/19 22:24:54 rillig Exp $");
 
 #include 
 #include 
@@ -345,7 +345,7 @@ get_coord(void)
 	nx = curx;
 	ny = cury;
 	for (;;) {
-		mvprintw(BSZ + 3, (BSZ - 6) / 2, "(%c %d) ",
+		mvprintw(BSZ + 3, 6, "(%c %d) ",
 		letters[curx + 1], cury + 1);
 		move(scr_y(cury + 1), scr_x(curx + 1));
 
@@ -462,7 +462,7 @@ get_coord(void)
 			return SAVE;
 		case ' ':
 		case '\r':
-			(void)mvaddstr(BSZ + 3, (BSZ - 6) / 2, "  ");
+			(void)mvaddstr(BSZ + 3, 6, "  ");
 			return PT(curx + 1, cury + 1);
 		}
 



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:24:54 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: clean up coordinate for the currently selected spot

There is no need to make this coordinate dependent on the board size.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/bdisp.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:19:18 UTC 2022

Modified Files:
src/games/gomoku: bdinit.c bdisp.c main.c makemove.c pickmove.c stoc.c

Log Message:
gomoku: clean up version control sections

Lint can handle these definitions, and the '#if 0' is redundant.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/games/gomoku/bdinit.c \
src/games/gomoku/makemove.c src/games/gomoku/stoc.c
cvs rdiff -u -r1.33 -r1.34 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.40 -r1.41 src/games/gomoku/main.c
cvs rdiff -u -r1.35 -r1.36 src/games/gomoku/pickmove.c

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

Modified files:

Index: src/games/gomoku/bdinit.c
diff -u src/games/gomoku/bdinit.c:1.17 src/games/gomoku/bdinit.c:1.18
--- src/games/gomoku/bdinit.c:1.17	Thu May 19 18:58:59 2022
+++ src/games/gomoku/bdinit.c	Thu May 19 22:19:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdinit.c,v 1.17 2022/05/19 18:58:59 rillig Exp $	*/
+/*	$NetBSD: bdinit.c,v 1.18 2022/05/19 22:19:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -33,13 +33,8 @@
  */
 
 #include 
-#ifndef lint
-#if 0
-static char sccsid[] = "from: @(#)bdinit.c	8.2 (Berkeley) 5/3/95";
-#else
-__RCSID("$NetBSD: bdinit.c,v 1.17 2022/05/19 18:58:59 rillig Exp $");
-#endif
-#endif /* not lint */
+/*	from: @(#)bdinit.c	8.2 (Berkeley) 5/3/95	*/
+__RCSID("$NetBSD: bdinit.c,v 1.18 2022/05/19 22:19:18 rillig Exp $");
 
 #include 
 #include "gomoku.h"
Index: src/games/gomoku/makemove.c
diff -u src/games/gomoku/makemove.c:1.17 src/games/gomoku/makemove.c:1.18
--- src/games/gomoku/makemove.c:1.17	Wed May 18 22:30:19 2022
+++ src/games/gomoku/makemove.c	Thu May 19 22:19:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemove.c,v 1.17 2022/05/18 22:30:19 rillig Exp $	*/
+/*	$NetBSD: makemove.c,v 1.18 2022/05/19 22:19:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -33,13 +33,8 @@
  */
 
 #include 
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)makemove.c	8.2 (Berkeley) 5/3/95";
-#else
-__RCSID("$NetBSD: makemove.c,v 1.17 2022/05/18 22:30:19 rillig Exp $");
-#endif
-#endif /* not lint */
+/*	@(#)makemove.c	8.2 (Berkeley) 5/3/95	*/
+__RCSID("$NetBSD: makemove.c,v 1.18 2022/05/19 22:19:18 rillig Exp $");
 
 #include "gomoku.h"
 
Index: src/games/gomoku/stoc.c
diff -u src/games/gomoku/stoc.c:1.17 src/games/gomoku/stoc.c:1.18
--- src/games/gomoku/stoc.c:1.17	Wed May 18 22:30:19 2022
+++ src/games/gomoku/stoc.c	Thu May 19 22:19:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: stoc.c,v 1.17 2022/05/18 22:30:19 rillig Exp $	*/
+/*	$NetBSD: stoc.c,v 1.18 2022/05/19 22:19:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -33,13 +33,8 @@
  */
 
 #include 
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)stoc.c	8.1 (Berkeley) 7/24/94";
-#else
-__RCSID("$NetBSD: stoc.c,v 1.17 2022/05/18 22:30:19 rillig Exp $");
-#endif
-#endif /* not lint */
+/*	@(#)stoc.c	8.1 (Berkeley) 7/24/94	*/
+__RCSID("$NetBSD: stoc.c,v 1.18 2022/05/19 22:19:18 rillig Exp $");
 
 #include 
 #include 

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.33 src/games/gomoku/bdisp.c:1.34
--- src/games/gomoku/bdisp.c:1.33	Thu May 19 19:52:56 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 22:19:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.33 2022/05/19 19:52:56 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.34 2022/05/19 22:19:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -33,13 +33,8 @@
  */
 
 #include 
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
-#else
-__RCSID("$NetBSD: bdisp.c,v 1.33 2022/05/19 19:52:56 rillig Exp $");
-#endif
-#endif /* not lint */
+/*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
+__RCSID("$NetBSD: bdisp.c,v 1.34 2022/05/19 22:19:18 rillig Exp $");
 
 #include 
 #include 

Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.40 src/games/gomoku/main.c:1.41
--- src/games/gomoku/main.c:1.40	Thu May 19 20:09:46 2022
+++ src/games/gomoku/main.c	Thu May 19 22:19:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.40 2022/05/19 20:09:46 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.41 2022/05/19 22:19:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -33,18 +33,10 @@
  */
 
 #include 
-#ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1994\
  The Regents of the University of California.  All rights reserved.");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c	8.4 (Berkeley) 5/4/95";
-#else
-__RCSID("$NetBSD: main.c,v 1.40 2022/05/19 20:09:46 rillig Exp $");
-#endif
-#endif /* not lint */
+/*	@(#)main.c	8.4 (Berkeley) 5/4/95	*/
+__RCSID("$NetBSD: main.c,v 1.41 2022/05/19 22:19:18 rillig Exp $");
 
 #include 
 #include 

Index: src/games/gomoku/pickmove.c
diff -u src/games/gomoku/pickmove.c:1.35 src/games/gomoku/pickmove.c:1.36
--- src/games/gomoku/pickmove.c:1.35	Thu May 19 18:58:59 2022
+++ src/games/gomoku/pickmove.c	Thu May 19 22:19:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pickmove.c,v 1.35 2022/05/19 

CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 22:19:18 UTC 2022

Modified Files:
src/games/gomoku: bdinit.c bdisp.c main.c makemove.c pickmove.c stoc.c

Log Message:
gomoku: clean up version control sections

Lint can handle these definitions, and the '#if 0' is redundant.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/games/gomoku/bdinit.c \
src/games/gomoku/makemove.c src/games/gomoku/stoc.c
cvs rdiff -u -r1.33 -r1.34 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.40 -r1.41 src/games/gomoku/main.c
cvs rdiff -u -r1.35 -r1.36 src/games/gomoku/pickmove.c

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



CVS commit: src/sys/opencrypto

2022-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 20:51:59 UTC 2022

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

Log Message:
opencrypto: Assert !cpu_intr_p() on dispatch and invoke.

These should only ever have been potentially called from hard
interrupt context by CRYPTO_F_CBIMM callbacks (CBIMM = call back
immediately).  CRYPTO_F_CBIMM is no more, so there is no more need to
allow this case of call from hard interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/opencrypto/crypto.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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.118 src/sys/opencrypto/crypto.c:1.119
--- src/sys/opencrypto/crypto.c:1.118	Thu May 19 20:51:46 2022
+++ src/sys/opencrypto/crypto.c	Thu May 19 20:51:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.118 2022/05/19 20:51:46 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.119 2022/05/19 20:51:59 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.118 2022/05/19 20:51:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.119 2022/05/19 20:51:59 riastradh Exp $");
 
 #include 
 #include 
@@ -1264,6 +1264,7 @@ crypto_dispatch(struct cryptop *crp)
 	struct crypto_crp_q *crp_q;
 
 	KASSERT(crp != NULL);
+	KASSERT(!cpu_intr_p());
 
 	DPRINTF("crp %p, alg %d\n", crp, crp->crp_desc->crd_alg);
 
@@ -1373,6 +1374,7 @@ crypto_kdispatch(struct cryptkop *krp)
 	struct crypto_crp_kq *crp_kq;
 
 	KASSERT(krp != NULL);
+	KASSERT(!cpu_intr_p());
 
 	cryptostats.cs_kops++;
 
@@ -1439,6 +1441,7 @@ crypto_kinvoke(struct cryptkop *krp, int
 	int error;
 
 	KASSERT(krp != NULL);
+	KASSERT(!cpu_intr_p());
 
 	/* Sanity checks. */
 	if (krp->krp_callback == NULL) {
@@ -1524,6 +1527,7 @@ crypto_invoke(struct cryptop *crp, int h
 	struct cryptocap *cap;
 
 	KASSERT(crp != NULL);
+	KASSERT(!cpu_intr_p());
 
 #ifdef CRYPTO_TIMING
 	if (crypto_timing)



CVS commit: src/sys/opencrypto

2022-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 20:51:59 UTC 2022

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

Log Message:
opencrypto: Assert !cpu_intr_p() on dispatch and invoke.

These should only ever have been potentially called from hard
interrupt context by CRYPTO_F_CBIMM callbacks (CBIMM = call back
immediately).  CRYPTO_F_CBIMM is no more, so there is no more need to
allow this case of call from hard interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/opencrypto/crypto.c

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



CVS commit: src/sys/opencrypto

2022-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 20:51:46 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: Nix CRYPTO_F_USER, CRYPTO_F_CBIMM, CRYPTO_F_CBIFSYNC.

CRYPTO_F_USER is no longer needed.  It was introduced in 2008 by
darran@ in crypto.c 1.30, cryptodev.c 1.45 in an attempt to avoid
double-free between the issuing thread and asynchronous callback.
But the `fix' didn't work.  In 2017, knakahara@ fixed it properly in
cryptodev.c 1.87 by distinguishing `the crypto operation has
completed' (CRYPTO_F_DONE) from `the callback is done touching the
crp object' (CRYPTO_F_DQRETQ, now renamed to CRYPTODEV_F_RET).

CRYPTO_F_CBIMM formerly served to invoke the callback synchronously
from the driver's interrupt completion routine, to reduce contention
on what was once a single cryptoret thread.  Now, there is a per-CPU
queue and softint for much cheaper processing, so there is less
motivation for this in the first place.  So let's remove the
complicated logic.  This means the callbacks never run in hard
interrupt context, which means we don't need to worry about recursion
into crypto_dispatch in hard interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.112 -r1.113 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.42 -r1.43 src/sys/opencrypto/cryptodev.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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.117 src/sys/opencrypto/crypto.c:1.118
--- src/sys/opencrypto/crypto.c:1.117	Tue May 17 10:32:58 2022
+++ src/sys/opencrypto/crypto.c	Thu May 19 20:51:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.117 2022/05/17 10:32:58 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.118 2022/05/19 20:51:46 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.117 2022/05/17 10:32:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.118 2022/05/19 20:51:46 riastradh Exp $");
 
 #include 
 #include 
@@ -1707,6 +1707,9 @@ crypto_kgetreq(int num __unused, int prf
 void
 crypto_done(struct cryptop *crp)
 {
+	int wasempty;
+	struct crypto_crp_ret_qs *qs;
+	struct crypto_crp_ret_q *crp_ret_q;
 
 	KASSERT(crp != NULL);
 
@@ -1720,70 +1723,19 @@ crypto_done(struct cryptop *crp)
 
 	crp->crp_flags |= CRYPTO_F_DONE;
 
-	/*
-	 * Normal case; queue the callback for the thread.
-	 *
-	 * The return queue is manipulated by the swi thread
-	 * and, potentially, by crypto device drivers calling
-	 * back to mark operations completed.  Thus we need
-	 * to mask both while manipulating the return queue.
-	 */
-  	if (crp->crp_flags & CRYPTO_F_CBIMM) {
-		/*
-	 	* Do the callback directly.  This is ok when the
-  	 	* callback routine does very little (e.g. the
-	 	* /dev/crypto callback method just does a wakeup).
-	 	*/
-#ifdef CRYPTO_TIMING
-		if (crypto_timing) {
-			/*
-		 	* NB: We must copy the timestamp before
-		 	* doing the callback as the cryptop is
-		 	* likely to be reclaimed.
-		 	*/
-			struct timespec t = crp->crp_tstamp;
-			crypto_tstat(_cb, );
-			crp->crp_callback(crp);
-			crypto_tstat(_finis, );
-		} else
-#endif
-		crp->crp_callback(crp);
-	} else {
-#if 0
-		if (crp->crp_flags & CRYPTO_F_USER) {
-			/*
-			 * TODO:
-			 * If crp->crp_flags & CRYPTO_F_USER and the used
-			 * encryption driver does all the processing in
-			 * the same context, we can skip enqueueing crp_ret_q
-			 * and softint_schedule(crypto_ret_si).
-			 */
-			DPRINTF("lid[%u]: crp %p CRYPTO_F_USER\n",
-CRYPTO_SESID2LID(crp->crp_sid), crp);
-		} else
-#endif
-		{
-			int wasempty;
-			struct crypto_crp_ret_qs *qs;
-			struct crypto_crp_ret_q *crp_ret_q;
-
-			qs = crypto_get_crp_ret_qs(crp->reqcpu);
-			crp_ret_q = >crp_ret_q;
-			wasempty = TAILQ_EMPTY(crp_ret_q);
-			DPRINTF("lid[%u]: queueing %p\n",
-CRYPTO_SESID2LID(crp->crp_sid), crp);
-			crp->crp_flags |= CRYPTO_F_ONRETQ;
-			TAILQ_INSERT_TAIL(crp_ret_q, crp, crp_next);
-			qs->crp_ret_q_len++;
-			if (wasempty && !qs->crp_ret_q_exit_flag) {
-DPRINTF("lid[%u]: waking cryptoret,"
-	"crp %p hit empty queue\n.",
-	CRYPTO_SESID2LID(crp->crp_sid), crp);
-softint_schedule_cpu(crypto_ret_si, crp->reqcpu);
-			}
-			crypto_put_crp_ret_qs(crp->reqcpu);
-		}
+	qs = crypto_get_crp_ret_qs(crp->reqcpu);
+	crp_ret_q = >crp_ret_q;
+	wasempty = TAILQ_EMPTY(crp_ret_q);
+	DPRINTF("lid[%u]: queueing %p\n", CRYPTO_SESID2LID(crp->crp_sid), crp);
+	crp->crp_flags |= CRYPTO_F_ONRETQ;
+	TAILQ_INSERT_TAIL(crp_ret_q, crp, crp_next);
+	qs->crp_ret_q_len++;
+	if (wasempty && !qs->crp_ret_q_exit_flag) {
+		DPRINTF("lid[%u]: waking cryptoret, crp %p hit empty queue\n.",
+		

CVS commit: src/sys/opencrypto

2022-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 20:51:46 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: Nix CRYPTO_F_USER, CRYPTO_F_CBIMM, CRYPTO_F_CBIFSYNC.

CRYPTO_F_USER is no longer needed.  It was introduced in 2008 by
darran@ in crypto.c 1.30, cryptodev.c 1.45 in an attempt to avoid
double-free between the issuing thread and asynchronous callback.
But the `fix' didn't work.  In 2017, knakahara@ fixed it properly in
cryptodev.c 1.87 by distinguishing `the crypto operation has
completed' (CRYPTO_F_DONE) from `the callback is done touching the
crp object' (CRYPTO_F_DQRETQ, now renamed to CRYPTODEV_F_RET).

CRYPTO_F_CBIMM formerly served to invoke the callback synchronously
from the driver's interrupt completion routine, to reduce contention
on what was once a single cryptoret thread.  Now, there is a per-CPU
queue and softint for much cheaper processing, so there is less
motivation for this in the first place.  So let's remove the
complicated logic.  This means the callbacks never run in hard
interrupt context, which means we don't need to worry about recursion
into crypto_dispatch in hard interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.112 -r1.113 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.42 -r1.43 src/sys/opencrypto/cryptodev.h

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 20:09:46 UTC 2022

Modified Files:
src/games/gomoku: main.c

Log Message:
gomoku: remove unreachable code at the end of main

In C99 mode, lint accepts when control gets to the end of main without
returning a value.  It does not know anything about __dead though.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/games/gomoku/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/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.39 src/games/gomoku/main.c:1.40
--- src/games/gomoku/main.c:1.39	Wed May 18 19:29:00 2022
+++ src/games/gomoku/main.c	Thu May 19 20:09:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.39 2022/05/18 19:29:00 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.40 2022/05/19 20:09:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994\
 #if 0
 static char sccsid[] = "@(#)main.c	8.4 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.39 2022/05/18 19:29:00 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.40 2022/05/19 20:09:46 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -353,8 +353,6 @@ again:
 		}
 	}
 	quit();
-	/* NOTREACHED */
-	return 0;
 }
 
 static int



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 20:09:46 UTC 2022

Modified Files:
src/games/gomoku: main.c

Log Message:
gomoku: remove unreachable code at the end of main

In C99 mode, lint accepts when control gets to the end of main without
returning a value.  It does not know anything about __dead though.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/games/gomoku/main.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 19:52:56 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: replace magic numbers with proper coordinate calculation


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.32 src/games/gomoku/bdisp.c:1.33
--- src/games/gomoku/bdisp.c:1.32	Thu May 19 19:16:38 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 19:52:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.32 2022/05/19 19:16:38 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.33 2022/05/19 19:52:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdisp.c,v 1.32 2022/05/19 19:16:38 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.33 2022/05/19 19:52:56 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -132,28 +132,33 @@ bdisp_init(void)
 void
 bdwho(bool update)
 {
-	int i, j;
+	int bw = (int)strlen(plyr[BLACK]);
+	int ww = (int)strlen(plyr[WHITE]);
+	int available = 3 + (1 + scr_x(BSZ) - scr_x(1)) + 3;
+	int fixed = (int)sizeof("BLACK/ (*) vs. WHITE/ (O)") - 1;
+	int total = fixed + bw + ww;
 
 	move(BSZ + 2, 0);
-	printw("  ");
-	i = (int)strlen(plyr[BLACK]);
-	j = (int)strlen(plyr[WHITE]);
-	int sx = (scr_x(BSZ) + scr_x(1)) / 2 - (25 + i + j) / 2;
-	if (sx >= 0) {
-		move(BSZ + 2, sx);
+	hline(' ', available);
+
+	if (total <= available) {
+		move(BSZ + 2, (available - total) / 2);
 		printw("BLACK/%s (*) vs. WHITE/%s (O)",
 		plyr[BLACK], plyr[WHITE]);
 	} else {
+		int remaining = available - fixed;
+		int half = remaining / 2;
+
+		if (bw <= half)
+			ww = remaining - bw;
+		else if (ww <= half)
+			bw = remaining - ww;
+		else
+			bw = half, ww = remaining - half;
+
 		move(BSZ + 2, 0);
-		if (i <= 10) {
-			j = 20 - i;
-		} else if (j <= 10) {
-			i = 20 - j;
-		} else {
-			i = j = 10;
-		}
 		printw("BLACK/%.*s (*) vs. WHITE/%.*s (O)",
-		i, plyr[BLACK], j, plyr[WHITE]);
+		bw, plyr[BLACK], ww, plyr[WHITE]);
 	}
 	if (update)
 		refresh();



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 19:52:56 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: replace magic numbers with proper coordinate calculation


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/games/gomoku/bdisp.c

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



CVS commit: src/sys/netipsec

2022-05-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 19 19:18:03 UTC 2022

Modified Files:
src/sys/netipsec: ipsec_input.c

Log Message:
PR/56840: Andrew Cagney: use the proper polarity hton/ntoh macros (no
functional change).
Factor out spi retrieving code into a function.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/netipsec/ipsec_input.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/netipsec/ipsec_input.c
diff -u src/sys/netipsec/ipsec_input.c:1.75 src/sys/netipsec/ipsec_input.c:1.76
--- src/sys/netipsec/ipsec_input.c:1.75	Sat Jan 26 21:08:48 2019
+++ src/sys/netipsec/ipsec_input.c	Thu May 19 15:18:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_input.c,v 1.75 2019/01/27 02:08:48 pgoyette Exp $	*/
+/*	$NetBSD: ipsec_input.c,v 1.76 2022/05/19 19:18:03 christos Exp $	*/
 /*	$FreeBSD: ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $	*/
 /*	$OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $	*/
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.75 2019/01/27 02:08:48 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.76 2022/05/19 19:18:03 christos Exp $");
 
 /*
  * IPsec input processing.
@@ -182,6 +182,29 @@ nat_t_ports_get(struct mbuf *m, uint16_t
 		*sport = *dport = 0;
 }
 
+static uint32_t
+spi_get(struct mbuf *m, int sproto, int skip)
+{
+	uint32_t spi;
+	uint16_t cpi;
+
+	switch (sproto) {
+	case IPPROTO_ESP:
+		m_copydata(m, skip, sizeof(spi), );
+		return spi;
+	case IPPROTO_AH:
+		m_copydata(m, skip + sizeof(spi), sizeof(spi), );
+		return spi;
+	case IPPROTO_IPCOMP:
+		m_copydata(m, skip + sizeof(cpi), sizeof(cpi), );
+		return htonl(ntohs(cpi));
+	default:
+		panic("%s called with bad protocol number: %d\n", __func__,
+		sproto);
+	}
+}
+
+
 /*
  * ipsec_common_input gets called when an IPsec-protected packet
  * is received by IPv4 or IPv6.  Its job is to find the right SA
@@ -222,18 +245,7 @@ ipsec_common_input(struct mbuf *m, int s
 	}
 
 	/* Retrieve the SPI from the relevant IPsec header */
-	if (sproto == IPPROTO_ESP) {
-		m_copydata(m, skip, sizeof(u_int32_t), );
-	} else if (sproto == IPPROTO_AH) {
-		m_copydata(m, skip + sizeof(u_int32_t), sizeof(u_int32_t), );
-	} else if (sproto == IPPROTO_IPCOMP) {
-		u_int16_t cpi;
-		m_copydata(m, skip + sizeof(u_int16_t), sizeof(u_int16_t), );
-		spi = ntohl(htons(cpi));
-	} else {
-		panic("%s called with bad protocol number: %d\n", __func__,
-		sproto);
-	}
+	spi = spi_get(m, sproto, skip);
 
 	/* find the source port for NAT-T */
 	nat_t_ports_get(m, , );



CVS commit: src/sys/netipsec

2022-05-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 19 19:18:03 UTC 2022

Modified Files:
src/sys/netipsec: ipsec_input.c

Log Message:
PR/56840: Andrew Cagney: use the proper polarity hton/ntoh macros (no
functional change).
Factor out spi retrieving code into a function.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/netipsec/ipsec_input.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 19:16:38 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: properly center the player's names


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.31 src/games/gomoku/bdisp.c:1.32
--- src/games/gomoku/bdisp.c:1.31	Thu May 19 18:58:59 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 19:16:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.31 2022/05/19 18:58:59 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.32 2022/05/19 19:16:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdisp.c,v 1.31 2022/05/19 18:58:59 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.32 2022/05/19 19:16:38 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -138,9 +138,9 @@ bdwho(bool update)
 	printw("  ");
 	i = (int)strlen(plyr[BLACK]);
 	j = (int)strlen(plyr[WHITE]);
-	if (i + j <= 20) {
-		/* TODO: properly center the text when i + j is even. */
-		move(BSZ + 2, 10 - (i + j) / 2);
+	int sx = (scr_x(BSZ) + scr_x(1)) / 2 - (25 + i + j) / 2;
+	if (sx >= 0) {
+		move(BSZ + 2, sx);
 		printw("BLACK/%s (*) vs. WHITE/%s (O)",
 		plyr[BLACK], plyr[WHITE]);
 	} else {
@@ -345,9 +345,8 @@ get_coord(void)
 	nx = curx;
 	ny = cury;
 	for (;;) {
-		/* TODO: replace with 'letters[curx + 1]' */
 		mvprintw(BSZ + 3, (BSZ - 6) / 2, "(%c %d) ",
-		'A' + ((curx > 7) ? (curx + 1) : curx), cury + 1);
+		letters[curx + 1], cury + 1);
 		move(scr_y(cury + 1), scr_x(curx + 1));
 
 		ch = getch();



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 19:16:38 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: properly center the player's names


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/games/gomoku/bdisp.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 18:58:59 UTC 2022

Modified Files:
src/games/gomoku: bdinit.c bdisp.c gomoku.h pickmove.c

Log Message:
gomoku: de-obfuscate screen coordinate calculation

Modern compilers optimize linear integer arithmetic, so there is no
reason to use strange or misleading formulas.

Replace several magic numbers with proper formulas.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.30 -r1.31 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.28 -r1.29 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/pickmove.c

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

Modified files:

Index: src/games/gomoku/bdinit.c
diff -u src/games/gomoku/bdinit.c:1.16 src/games/gomoku/bdinit.c:1.17
--- src/games/gomoku/bdinit.c:1.16	Wed May 18 22:35:13 2022
+++ src/games/gomoku/bdinit.c	Thu May 19 18:58:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdinit.c,v 1.16 2022/05/18 22:35:13 rillig Exp $	*/
+/*	$NetBSD: bdinit.c,v 1.17 2022/05/19 18:58:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)bdinit.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdinit.c,v 1.16 2022/05/18 22:35:13 rillig Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.17 2022/05/19 18:58:59 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -56,7 +56,7 @@ bdinit(struct spotstr *bp)
 
 	/* mark the borders as such */
 	sp = bp;
-	for (int i = 1 + BSZ + 1; --i >= 0; sp++) {
+	for (int i = 0; i < 1 + BSZ + 1; i++, sp++) {
 		sp->s_occ = BORDER;			/* top border */
 		sp->s_flags = BFLAGALL;
 	}
@@ -144,7 +144,7 @@ bdinit(struct spotstr *bp)
 	}
 
 	/* mark the borders as such */
-	for (int i = BSZ + 1; --i >= 0; sp++) {
+	for (int i = 0; i < BSZ + 1; i++, sp++) {
 		sp->s_occ = BORDER;			/* bottom border */
 		sp->s_flags = BFLAGALL;
 	}

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.30 src/games/gomoku/bdisp.c:1.31
--- src/games/gomoku/bdisp.c:1.30	Thu May 19 17:02:51 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 18:58:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.30 2022/05/19 17:02:51 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.31 2022/05/19 18:58:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdisp.c,v 1.30 2022/05/19 17:02:51 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.31 2022/05/19 18:58:59 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -53,6 +53,9 @@ __RCSID("$NetBSD: bdisp.c,v 1.30 2022/05
 static	int	lastline;
 static	char	pcolor[] = "*O.?";
 
+#define	scr_y(by)	(1 + (BSZ - 1) - ((by) - 1))
+#define	scr_x(bx)	(3 + 2 * ((bx) - 1))
+
 /*
  * Initialize screen display.
  */
@@ -101,23 +104,23 @@ bdisp_init(void)
 
 	/* top border */
 	for (int i = 1; i < BSZ + 1; i++) {
-		move(0, 2 * i + 1);
+		move(scr_y(BSZ + 1), scr_x(i));
 		addch(letters[i]);
 	}
 	/* left and right edges */
 	for (int j = BSZ + 1; --j > 0; ) {
-		move(20 - j, 0);
+		move(scr_y(j), 0);
 		printw("%2d ", j);
-		move(20 - j, 2 * (BSZ + 1) + 1);
+		move(scr_y(j), scr_x(BSZ) + 2);
 		printw("%d ", j);
 	}
 	/* bottom border */
 	for (int i = 1; i < BSZ + 1; i++) {
-		move(20, 2 * i + 1);
+		move(scr_y(0), scr_x(i));
 		addch(letters[i]);
 	}
 	bdwho(false);
-	move(0, 47);
+	move(0, TRANSCRIPT_COL + 1);
 	addstr("#  black  white");
 	lastline = 0;
 	bdisp();
@@ -131,16 +134,17 @@ bdwho(bool update)
 {
 	int i, j;
 
-	move(21, 0);
+	move(BSZ + 2, 0);
 	printw("  ");
 	i = (int)strlen(plyr[BLACK]);
 	j = (int)strlen(plyr[WHITE]);
 	if (i + j <= 20) {
-		move(21, 10 - (i + j) / 2);
+		/* TODO: properly center the text when i + j is even. */
+		move(BSZ + 2, 10 - (i + j) / 2);
 		printw("BLACK/%s (*) vs. WHITE/%s (O)",
 		plyr[BLACK], plyr[WHITE]);
 	} else {
-		move(21, 0);
+		move(BSZ + 2, 0);
 		if (i <= 10) {
 			j = 20 - i;
 		} else if (j <= 10) {
@@ -166,7 +170,7 @@ bdisp(void)
 
 	for (int j = BSZ + 1; --j > 0; ) {
 		for (int i = 1; i < BSZ + 1; i++) {
-			move(BSZ + 1 - j, 2 * i + 1);
+			move(scr_y(j), scr_x(i));
 			sp = [i + j * (BSZ + 1)];
 			if (debug > 1 && sp->s_occ == EMPTY) {
 if ((sp->s_flags & IFLAGALL) != 0)
@@ -331,18 +335,20 @@ get_line(char *buf, int size)
 int
 get_coord(void)
 {
+	/* XXX: These coordinates are 0-based, all others are 1-based. */
 	static int curx = BSZ / 2;
 	static int cury = BSZ / 2;
 	int ny, nx, ch;
 
-	BGOTO(cury, curx);
+	move(scr_y(cury + 1), scr_x(curx + 1));
 	refresh();
 	nx = curx;
 	ny = cury;
 	for (;;) {
+		/* TODO: replace with 'letters[curx + 1]' */
 		mvprintw(BSZ + 3, (BSZ - 6) / 2, "(%c %d) ",
 		'A' + ((curx > 7) ? (curx + 1) : curx), cury + 1);
-		BGOTO(cury, curx);
+		move(scr_y(cury + 1), scr_x(curx + 1));
 
 		ch = getch();
 		switch (ch) {

Index: 

CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 18:58:59 UTC 2022

Modified Files:
src/games/gomoku: bdinit.c bdisp.c gomoku.h pickmove.c

Log Message:
gomoku: de-obfuscate screen coordinate calculation

Modern compilers optimize linear integer arithmetic, so there is no
reason to use strange or misleading formulas.

Replace several magic numbers with proper formulas.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.30 -r1.31 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.28 -r1.29 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/pickmove.c

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



CVS commit: src

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 17:24:14 UTC 2022

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

Log Message:
lint: in strict bool mode, check function arguments more strictly

When a system header defined the constant FALSE = 0, that constant could
be passed as a bool argument.  On the other hand, the constant TRUE = 1
could not be passed in the same way.  Remove this inconsistency.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
cvs rdiff -u -r1.15 -r1.16 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/ckbool.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/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.13 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.14
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.13	Thu May 19 17:10:50 2022
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Thu May 19 17:24:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.13 2022/05/19 17:10:50 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.14 2022/05/19 17:24:14 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -234,7 +234,7 @@ pass_bool_to_function(void)
 # 235 "d_c99_bool_strict_syshdr.c"
 	);
 
-	/* TODO: make this a type error */
+	/* expect+5: error: argument #1 expects '_Bool', gets passed 'int' [334] */
 	take_bool(
 # 240 "d_c99_bool_strict_syshdr.c" 3 4
 	(/*CONSTCOND*/0)

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.15 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.16
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.15	Thu May 19 17:10:50 2022
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Thu May 19 17:24:14 2022
@@ -5,3 +5,4 @@ d_c99_bool_strict_syshdr.c(157): error: 
 d_c99_bool_strict_syshdr.c(172): error: operand of '!' must be bool, not 'int' [330]
 d_c99_bool_strict_syshdr.c(172): warning: function 'str_equal_bad' expects to return value [214]
 d_c99_bool_strict_syshdr.c(229): error: argument #1 expects '_Bool', gets passed 'int' [334]
+d_c99_bool_strict_syshdr.c(242): error: argument #1 expects '_Bool', gets passed 'int' [334]

Index: src/usr.bin/xlint/lint1/ckbool.c
diff -u src/usr.bin/xlint/lint1/ckbool.c:1.13 src/usr.bin/xlint/lint1/ckbool.c:1.14
--- src/usr.bin/xlint/lint1/ckbool.c:1.13	Sat Apr 16 22:21:10 2022
+++ src/usr.bin/xlint/lint1/ckbool.c	Thu May 19 17:24:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ckbool.c,v 1.13 2022/04/16 22:21:10 rillig Exp $ */
+/* $NetBSD: ckbool.c,v 1.14 2022/05/19 17:24:14 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include 
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckbool.c,v 1.13 2022/04/16 22:21:10 rillig Exp $");
+__RCSID("$NetBSD: ckbool.c,v 1.14 2022/05/19 17:24:14 rillig Exp $");
 #endif
 
 #include 
@@ -90,6 +90,9 @@ is_typeok_strict_bool_binary(op_t op,
 	if ((lt == BOOL) == (rt == BOOL))
 		return true;
 
+	if (op == FARG && rn->tn_sys)
+		return false;
+
 	if ((ln->tn_sys || rn->tn_sys) &&
 	(is_int_constant_zero(ln, lt) || is_int_constant_zero(rn, rt)))
 		return true;



CVS commit: src

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 17:24:14 UTC 2022

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

Log Message:
lint: in strict bool mode, check function arguments more strictly

When a system header defined the constant FALSE = 0, that constant could
be passed as a bool argument.  On the other hand, the constant TRUE = 1
could not be passed in the same way.  Remove this inconsistency.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
cvs rdiff -u -r1.15 -r1.16 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/ckbool.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

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 17:10:50 UTC 2022

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

Log Message:
tests/lint: extend tests for type mismatch in strict bool mode

Seen in games/gomoku when calling curses functions.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
cvs rdiff -u -r1.14 -r1.15 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.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/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.12 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.13
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.12	Wed Dec 22 15:36:37 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Thu May 19 17:10:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.12 2021/12/22 15:36:37 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.13 2022/05/19 17:10:50 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -193,13 +193,57 @@ controlling_expression_with_comma_operat
 	int c;
 
 	while (c = read_char(),
-# 191 "c_c99_bool_strict_syshdr.c" 3 4
+# 197 "d_c99_bool_strict_syshdr.c" 3 4
 	((int)((ctype_table + 1)[(
-# 193 "c_c99_bool_strict_syshdr.c"
+# 199 "d_c99_bool_strict_syshdr.c"
 		c
-# 195 "c_c99_bool_strict_syshdr.c" 3 4
+# 201 "d_c99_bool_strict_syshdr.c" 3 4
 	)] & 0x0040 /* Space */))
-# 197 "c_c99_bool_strict_syshdr.c"
+# 203 "d_c99_bool_strict_syshdr.c"
 	)
 		continue;
 }
+
+
+void take_bool(_Bool);
+
+/*
+ * On NetBSD, the header  defines TRUE or FALSE as integer
+ * constants with a CONSTCOND comment.  This comment suppresses legitimate
+ * warnings in user code; that's irrelevant for this test though.
+ *
+ * Several curses functions take bool as a parameter, for example keypad or
+ * leaveok.  As of 2022-05-19, lint does not complain when these functions
+ * get 0 instead of 'false' as an argument.  It does complain about 1 instead
+ * of 'true' though.
+ */
+void
+pass_bool_to_function(void)
+{
+
+	/* expect+5: error: argument #1 expects '_Bool', gets passed 'int' [334] */
+	take_bool(
+# 227 "d_c99_bool_strict_syshdr.c" 3 4
+	(/*CONSTCOND*/1)
+# 229 "d_c99_bool_strict_syshdr.c"
+	);
+
+	take_bool(
+# 233 "d_c99_bool_strict_syshdr.c" 3 4
+	__lint_true
+# 235 "d_c99_bool_strict_syshdr.c"
+	);
+
+	/* TODO: make this a type error */
+	take_bool(
+# 240 "d_c99_bool_strict_syshdr.c" 3 4
+	(/*CONSTCOND*/0)
+# 242 "d_c99_bool_strict_syshdr.c"
+	);
+
+	take_bool(
+# 246 "d_c99_bool_strict_syshdr.c" 3 4
+	__lint_false
+# 248 "d_c99_bool_strict_syshdr.c"
+	);
+}

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.14 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.15
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.14	Wed Dec 22 15:36:37 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Thu May 19 17:10:50 2022
@@ -4,3 +4,4 @@ d_c99_bool_strict_syshdr.c(80): error: o
 d_c99_bool_strict_syshdr.c(157): error: return value type mismatch (_Bool) and (int) [211]
 d_c99_bool_strict_syshdr.c(172): error: operand of '!' must be bool, not 'int' [330]
 d_c99_bool_strict_syshdr.c(172): warning: function 'str_equal_bad' expects to return value [214]
+d_c99_bool_strict_syshdr.c(229): error: argument #1 expects '_Bool', gets passed 'int' [334]



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

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 17:10:50 UTC 2022

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

Log Message:
tests/lint: extend tests for type mismatch in strict bool mode

Seen in games/gomoku when calling curses functions.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
cvs rdiff -u -r1.14 -r1.15 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 17:02:51 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: fix error message for small screen

- gomoku: Screen too small (need 8018d)
+ gomoku: Screen too small (need 80x24)


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/gomoku/bdisp.c

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



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 17:02:51 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: fix error message for small screen

- gomoku: Screen too small (need 8018d)
+ gomoku: Screen too small (need 80x24)


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.29 src/games/gomoku/bdisp.c:1.30
--- src/games/gomoku/bdisp.c:1.29	Thu May 19 16:58:39 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 17:02:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.29 2022/05/19 16:58:39 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.30 2022/05/19 17:02:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdisp.c,v 1.29 2022/05/19 16:58:39 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.30 2022/05/19 17:02:51 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -64,7 +64,7 @@ cursinit(void)
 		errx(EXIT_FAILURE, "Couldn't initialize screen");
 	}
 	if ((LINES < SCRNH) || (COLS < SCRNW)) {
-		errx(EXIT_FAILURE, "Screen too small (need %d%xd)",
+		errx(EXIT_FAILURE, "Screen too small (need %dx%d)",
 		SCRNW, SCRNH);
 	}
 	keypad(stdscr, true);



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 16:58:39 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: fix type mismatch in call to curses function

Not yet detected by lint, as lint is more permissive for type mismatches
if the value is a constant 0.  Being permissive doesn't make sense in
this case.  Now the calls to 'keypad' and 'leaveok' are consistent.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.28 src/games/gomoku/bdisp.c:1.29
--- src/games/gomoku/bdisp.c:1.28	Wed May 18 22:30:19 2022
+++ src/games/gomoku/bdisp.c	Thu May 19 16:58:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.28 2022/05/18 22:30:19 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.29 2022/05/19 16:58:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdisp.c,v 1.28 2022/05/18 22:30:19 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.29 2022/05/19 16:58:39 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -71,7 +71,7 @@ cursinit(void)
 	nonl();
 	noecho();
 	cbreak();
-	leaveok(stdscr, FALSE);
+	leaveok(stdscr, false);
 
 #if 0 /* no mouse support in netbsd curses yet */
 	mousemask(BUTTON1_CLICKED, NULL);



CVS commit: src/games/gomoku

2022-05-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May 19 16:58:39 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: fix type mismatch in call to curses function

Not yet detected by lint, as lint is more permissive for type mismatches
if the value is a constant 0.  Being permissive doesn't make sense in
this case.  Now the calls to 'keypad' and 'leaveok' are consistent.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/games/gomoku/bdisp.c

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



CVS commit: [netbsd-9] src/doc

2022-05-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May 19 16:25:11 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1456


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.95 -r1.1.2.96 src/doc/CHANGES-9.3

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



CVS commit: [netbsd-9] src/doc

2022-05-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May 19 16:25:11 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1456


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.95 -r1.1.2.96 src/doc/CHANGES-9.3

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

Modified files:

Index: src/doc/CHANGES-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.95 src/doc/CHANGES-9.3:1.1.2.96
--- src/doc/CHANGES-9.3:1.1.2.95	Tue May 17 13:49:43 2022
+++ src/doc/CHANGES-9.3	Thu May 19 16:25:11 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.95 2022/05/17 13:49:43 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.96 2022/05/19 16:25:11 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -1669,3 +1669,8 @@ common/lib/libc/atomic/atomic_c11_compar
 	Fix the copy error in ticket #1451.
 	[skrll, ticket #1453]
 
+sys/dev/pci/if_bge.c1.353
+
+	PR 56848: improve handling of bge(4) chips with ASF/IPMI firmware.
+	[buhrow, ticket #1456]
+



CVS commit: [netbsd-9] src/sys/dev/pci

2022-05-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May 19 16:24:20 UTC 2022

Modified Files:
src/sys/dev/pci [netbsd-9]: if_bge.c

Log Message:
Pull up following revision(s) (requested by buhrow in ticket #1456):

sys/dev/pci/if_bge.c: revision 1.353

For chips which contain an ASF/IPMI firmware, instruct the chip to shut
the host ASF firmware down when attaching the device so the IPMI BMC
can use the same physical port even when NetBSD doesn't have a
network configuration on the device.
By contrast, when the device gets a network configuration assigned to
it and bge_init() is called, the host ASF firmware is brought up so
both NetBSD and the IPMI BMc can use the same physical port.

This now matches FreeBSD behavior, as well as  behavior from NetBSD-5.2.

Tested on a Sunfire X2200-M2 system with the following chip:

bge1 at pci7 dev 4 function 1: Broadcom BCM5715 Gigabit Ethernet
bge1: interrupting at ioapic0 pin 11
bge1: HW config 00d4, 0014, ,  
bge1: ASIC BCM5715 A3 (0x9003), Ethernet address 00:1e:68:XX:XX:XX
bge1: setting short Tx thresholds
brgphy1 at bge1 phy 1: BCM5714 1000BASE-T/X media interface, rev. 0
brgphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 
1000baseT-FDX, auto


To generate a diff of this commit:
cvs rdiff -u -r1.335.2.1 -r1.335.2.2 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.335.2.1 src/sys/dev/pci/if_bge.c:1.335.2.2
--- src/sys/dev/pci/if_bge.c:1.335.2.1	Wed Nov 27 11:08:24 2019
+++ src/sys/dev/pci/if_bge.c	Thu May 19 16:24:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.335.2.1 2019/11/27 11:08:24 martin Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.335.2.2 2022/05/19 16:24:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.335.2.1 2019/11/27 11:08:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.335.2.2 2022/05/19 16:24:20 martin Exp $");
 
 #include 
 #include 
@@ -3646,7 +3646,7 @@ bge_attach(device_t parent, device_t sel
 	BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
 
 	bge_stop_fw(sc);
-	bge_sig_pre_reset(sc, BGE_RESET_START);
+	bge_sig_pre_reset(sc, BGE_RESET_SHUTDOWN);
 	if (bge_reset(sc))
 		aprint_error_dev(sc->bge_dev, "chip reset failed\n");
 
@@ -3680,8 +3680,8 @@ bge_attach(device_t parent, device_t sel
 	"HW config %08x, %08x, %08x, %08x %08x\n",
 	hwcfg, hwcfg2, hwcfg3, hwcfg4, hwcfg5);
 
-	bge_sig_legacy(sc, BGE_RESET_START);
-	bge_sig_post_reset(sc, BGE_RESET_START);
+	bge_sig_legacy(sc, BGE_RESET_SHUTDOWN);
+	bge_sig_post_reset(sc, BGE_RESET_SHUTDOWN);
 
 	if (bge_chipinit(sc)) {
 		aprint_error_dev(sc->bge_dev, "chip initialization failed\n");



CVS commit: [netbsd-9] src/sys/dev/pci

2022-05-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May 19 16:24:20 UTC 2022

Modified Files:
src/sys/dev/pci [netbsd-9]: if_bge.c

Log Message:
Pull up following revision(s) (requested by buhrow in ticket #1456):

sys/dev/pci/if_bge.c: revision 1.353

For chips which contain an ASF/IPMI firmware, instruct the chip to shut
the host ASF firmware down when attaching the device so the IPMI BMC
can use the same physical port even when NetBSD doesn't have a
network configuration on the device.
By contrast, when the device gets a network configuration assigned to
it and bge_init() is called, the host ASF firmware is brought up so
both NetBSD and the IPMI BMc can use the same physical port.

This now matches FreeBSD behavior, as well as  behavior from NetBSD-5.2.

Tested on a Sunfire X2200-M2 system with the following chip:

bge1 at pci7 dev 4 function 1: Broadcom BCM5715 Gigabit Ethernet
bge1: interrupting at ioapic0 pin 11
bge1: HW config 00d4, 0014, ,  
bge1: ASIC BCM5715 A3 (0x9003), Ethernet address 00:1e:68:XX:XX:XX
bge1: setting short Tx thresholds
brgphy1 at bge1 phy 1: BCM5714 1000BASE-T/X media interface, rev. 0
brgphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 
1000baseT-FDX, auto


To generate a diff of this commit:
cvs rdiff -u -r1.335.2.1 -r1.335.2.2 src/sys/dev/pci/if_bge.c

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



CVS commit: src/usr.bin/vmstat

2022-05-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 19 13:57:03 UTC 2022

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

Log Message:
Bump some column widths for "vmstat -mW".


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/vmstat/vmstat.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/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.252 src/usr.bin/vmstat/vmstat.c:1.253
--- src/usr.bin/vmstat/vmstat.c:1.252	Sun Feb 27 19:00:46 2022
+++ src/usr.bin/vmstat/vmstat.c	Thu May 19 13:57:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.252 2022/02/27 19:00:46 rillig Exp $ */
+/* $NetBSD: vmstat.c,v 1.253 2022/05/19 13:57:03 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.252 2022/02/27 19:00:46 rillig Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.253 2022/05/19 13:57:03 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1464,22 +1464,22 @@ dopool_sysctl(int verbose, int wide)
 
 	(void)printf("Memory resource pool statistics\n");
 	(void)printf(
-	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%5s%s%s\n",
+	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s\n",
 	wide ? 16 : 11, "Name",
 	wide ? 7 : 5, "Size",
-	wide ? 12 : 9, "Requests",
+	wide ? 13 : 9, "Requests",
 	wide ? 8 : 5, "Fail",
-	wide ? 12 : 9, "Releases",
+	wide ? 13 : 9, "Releases",
 	wide ? "InUse" : "",
 	wide ? "Avail" : "",
 	wide ? 11 : 6, "Pgreq",
 	wide ? 11 : 6, "Pgrel",
-	wide ? 8 : 6, "Npage",
+	wide ? 9 : 6, "Npage",
 	wide ? " PageSz" : "",
-	wide ? 7 : 6, "Hiwat",
+	wide ? 8 : 6, "Hiwat",
 	"Minpg",
-	wide ? 7 : 6, "Maxpg",
-	"Idle",
+	wide ? 9 : 6, "Maxpg",
+	wide ? 8 : 5, "Idle",
 	wide ? "   Flags" : "",
 	wide ? "   Util" : "");
 
@@ -1496,11 +1496,11 @@ dopool_sysctl(int verbose, int wide)
 		ovflw = 0;
 		PRWORD(ovflw, "%-*s", name_len, 0, pp->pr_wchan);
 		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 5, 1, pp->pr_size);
-		PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pp->pr_nget);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pp->pr_nget);
 		pool_totals.pt_nget += pp->pr_nget;
 		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pp->pr_nfail);
 		pool_totals.pt_nfail += pp->pr_nfail;
-		PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pp->pr_nput);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pp->pr_nput);
 		pool_totals.pt_nput += pp->pr_nput;
 		if (wide) {
 			PRWORD(ovflw, " %*" PRIu64, 9, 1, pp->pr_nout);
@@ -1512,14 +1512,14 @@ dopool_sysctl(int verbose, int wide)
 		pool_totals.pt_npagealloc += pp->pr_npagealloc;
 		PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pp->pr_npagefree);
 		pool_totals.pt_npagefree += pp->pr_npagefree;
-		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pp->pr_npages);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 9 : 6, 1, pp->pr_npages);
 		pool_totals.pt_npages += pp->pr_npages;
 		if (wide)
 			PRWORD(ovflw, " %*" PRIu64, 7, 1, pp->pr_pagesize);
-		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 6, 1, pp->pr_hiwat);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pp->pr_hiwat);
 		PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_minpages);
-		PRWORD(ovflw, " %*s", wide ? 7 : 6, 1, maxp);
-		PRWORD(ovflw, " %*" PRIu64, 5, 1, pp->pr_nidle);
+		PRWORD(ovflw, " %*s", wide ? 9 : 6, 1, maxp);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pp->pr_nidle);
 		if (wide)
 			PRWORD(ovflw, " 0x%0*" PRIx64, 6, 1,
 			pp->pr_flags);
@@ -1549,16 +1549,16 @@ dopool_sysctl(int verbose, int wide)
 	ovflw = 0;
 	PRWORD(ovflw, "%-*s", name_len, 0, "Totals");
 	PRWORD(ovflw, " %*s", wide ? 7 : 5, 1, "");
-	PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pool_totals.pt_nget);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pool_totals.pt_nget);
 	PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pool_totals.pt_nfail);
-	PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pool_totals.pt_nput);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pool_totals.pt_nput);
 	if (wide) {
 		PRWORD(ovflw, " %*" PRIu64, 9, 1, pool_totals.pt_nout);
 		PRWORD(ovflw, " %*" PRIu64, 9, 1, pool_totals.pt_nitems);
 	}
 	PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pool_totals.pt_npagealloc);
 	PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pool_totals.pt_npagefree);
-	PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pool_totals.pt_npages);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 9 : 6, 1, pool_totals.pt_npages);
 	(void)printf("\n");
 
 	inuse /= KILO;
@@ -1614,22 +1614,22 @@ dopool(int verbose, int wide)
 		if (first) {
 			(void)printf("Memory resource pool statistics\n");
 			(void)printf(
-			"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%5s%s%s\n",
+			"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s\n",
 			wide ? 16 : 11, 

CVS commit: src/usr.bin/vmstat

2022-05-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 19 13:57:03 UTC 2022

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

Log Message:
Bump some column widths for "vmstat -mW".


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/vmstat/vmstat.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/xen

2022-05-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May 19 09:54:27 UTC 2022

Modified Files:
src/sys/arch/xen/include: hypervisor.h
src/sys/arch/xen/x86: hypervisor_machdep.c
src/sys/arch/xen/xen: evtchn.c

Log Message:
Restore de EOI mechanism for pirq, using the newer hypervisor interface.
It is needed.
Hopefully fixes kern/56291, kern/56793, kern/55667


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/xen/xen/evtchn.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/xen/include/hypervisor.h
diff -u src/sys/arch/xen/include/hypervisor.h:1.52 src/sys/arch/xen/include/hypervisor.h:1.53
--- src/sys/arch/xen/include/hypervisor.h:1.52	Sat May  2 16:44:36 2020
+++ src/sys/arch/xen/include/hypervisor.h	Thu May 19 09:54:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.52 2020/05/02 16:44:36 bouyer Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.53 2022/05/19 09:54:27 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -159,6 +159,10 @@ extern volatile struct xencons_interface
 struct intrframe;
 struct cpu_info;
 void do_hypervisor_callback(struct intrframe *regs);
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+void hypervisor_prime_pirq_event(int, unsigned int);
+void hypervisor_ack_pirq_event(unsigned int);
+#endif /* XENPV && ( NPCI > 0 || NISA > 0 ) */
 
 extern int xen_version;
 #define XEN_MAJOR(x) (((x) & 0x) >> 16)

Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.39 src/sys/arch/xen/x86/hypervisor_machdep.c:1.40
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.39	Sat May  2 16:44:36 2020
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Thu May 19 09:54:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.39 2020/05/02 16:44:36 bouyer Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.40 2022/05/19 09:54:27 bouyer Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.39 2020/05/02 16:44:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.40 2022/05/19 09:54:27 bouyer Exp $");
 
 #include 
 #include 
@@ -388,6 +388,9 @@ evt_enable_event(unsigned int port, unsi
 {
 	KASSERT(args == NULL);
 	hypervisor_unmask_event(port);
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+	hypervisor_ack_pirq_event(port);
+#endif /* NPCI > 0 || NISA > 0 */
 }
 
 void

Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.96 src/sys/arch/xen/xen/evtchn.c:1.97
--- src/sys/arch/xen/xen/evtchn.c:1.96	Sun Nov 15 14:01:06 2020
+++ src/sys/arch/xen/xen/evtchn.c	Thu May 19 09:54:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.96 2020/11/15 14:01:06 bouyer Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.97 2022/05/19 09:54:27 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.96 2020/11/15 14:01:06 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.97 2022/05/19 09:54:27 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -105,11 +105,13 @@ static int virq_timer_to_evtch[XEN_LEGAC
 static int virq_to_evtch[NR_VIRQS];
 
 
-#if NPCI > 0 || NISA > 0
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
 /* event-channel <-> PIRQ mapping */
 static int pirq_to_evtch[NR_PIRQS];
+/* PIRQ needing notify */
+static int evtch_to_pirq_eoi[NR_EVENT_CHANNELS];
 int pirq_interrupt(void *);
-#endif
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
 
 static void xen_evtchn_mask(struct pic *, int);
 static void xen_evtchn_unmask(struct pic *, int);
@@ -235,11 +237,13 @@ events_default_setup(void)
 	for (i = 0; i < NR_VIRQS; i++)
 		virq_to_evtch[i] = -1;
 
-#if NPCI > 0 || NISA > 0
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
 	/* No PIRQ -> event mappings. */
 	for (i = 0; i < NR_PIRQS; i++)
 		pirq_to_evtch[i] = -1;
-#endif
+	for (i = 0; i < NR_EVENT_CHANNELS; i++)
+		evtch_to_pirq_eoi[i] = -1;
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
 
 	/* No event-channel are 'live' right now. */
 	for (i = 0; i < NR_EVENT_CHANNELS; i++) {
@@ -388,6 +392,9 @@ evtchn_do_event(int evtch, struct intrfr
 	}
 	x86_disable_intr();
 	hypervisor_unmask_event(evtch);
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+	hypervisor_ack_pirq_event(evtch);
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
 
 splx:
 	ci->ci_ilevel = ilevel;
@@ -621,7 +628,7 @@ unbind_virq_from_evtch(int virq)
 	return evtchn;
 }
 
-#if NPCI > 0 || NISA > 0
+#if defined(XENPV) && (NPCI > 0 || NISA > 0) 
 int
 get_pirq_to_evtch(int pirq)
 {
@@ -725,7 +732,9 @@ pirq_establish(int pirq, int evtch, int 
 		return NULL;
 	}
 
+	hypervisor_prime_pirq_event(pirq, evtch);
 	hypervisor_unmask_event(evtch);
+	hypervisor_ack_pirq_event(evtch);
 	return 

CVS commit: src/sys/arch/xen

2022-05-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May 19 09:54:27 UTC 2022

Modified Files:
src/sys/arch/xen/include: hypervisor.h
src/sys/arch/xen/x86: hypervisor_machdep.c
src/sys/arch/xen/xen: evtchn.c

Log Message:
Restore de EOI mechanism for pirq, using the newer hypervisor interface.
It is needed.
Hopefully fixes kern/56291, kern/56793, kern/55667


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/xen/xen/evtchn.c

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



CVS commit: src/lib/libcurses

2022-05-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May 19 07:41:26 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Set the last change pointer after adding a character at the bottom right
of a window.  This fixes the character missing in the LR of a window.
Thanks to uwe@ for pointing this out.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/libcurses/addbytes.c

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



CVS commit: src/lib/libcurses

2022-05-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May 19 07:41:26 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Set the last change pointer after adding a character at the bottom right
of a window.  This fixes the character missing in the LR of a window.
Thanks to uwe@ for pointing this out.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/libcurses/addbytes.c

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

Modified files:

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.63 src/lib/libcurses/addbytes.c:1.64
--- src/lib/libcurses/addbytes.c:1.63	Tue May  3 07:25:34 2022
+++ src/lib/libcurses/addbytes.c	Thu May 19 07:41:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.63 2022/05/03 07:25:34 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 blymn Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addbytes.c	8.4 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addbytes.c,v 1.63 2022/05/03 07:25:34 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -588,6 +588,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		}
 		lp = >alines[*y]->line[0];
 		(*lnp) = win->alines[*y];
+		*(*lnp)->lastchp = win->ch_off + win->maxx - 1;
 	} else {
 
 		/* clear the remaining of the current character */



CVS commit: src/lib/libpthread/arch/hppa

2022-05-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May 19 07:10:15 UTC 2022

Modified Files:
src/lib/libpthread/arch/hppa: pthread_md.S

Log Message:
Use RAS_{START,END}_ASM_HIDDEN


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libpthread/arch/hppa/pthread_md.S

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

Modified files:

Index: src/lib/libpthread/arch/hppa/pthread_md.S
diff -u src/lib/libpthread/arch/hppa/pthread_md.S:1.1 src/lib/libpthread/arch/hppa/pthread_md.S:1.2
--- src/lib/libpthread/arch/hppa/pthread_md.S:1.1	Sat May 16 22:20:40 2009
+++ src/lib/libpthread/arch/hppa/pthread_md.S	Thu May 19 07:10:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread_md.S,v 1.1 2009/05/16 22:20:40 ad Exp $	*/
+/*	$NetBSD: pthread_md.S,v 1.2 2022/05/19 07:10:15 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -29,6 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include 
 #include 
 
 LEAF_ENTRY(pthread__ras_simple_lock_init)
@@ -47,10 +48,10 @@ LEAF_ENTRY(pthread__ras_simple_lock_try)
 	ldo	15(%arg0),%arg0
 	depi	0,31,4,%arg0
 
-pthread__lock_ras_start:
+RAS_START_ASM_HIDDEN(pthread__lock)
 	ldw	0(%arg0),%ret0
 	stw	%r0,0(%arg0)		/* 0 == locked */
-pthread__lock_ras_end:
+RAS_END_ASM_HIDDEN(pthread__lock)
 
 	comiclr,= 0,%ret0,%ret0		/* if locked return 0 */
 	ldi	1,%ret0			/* else return 1 */



CVS commit: src/lib/libpthread/arch/hppa

2022-05-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May 19 07:10:15 UTC 2022

Modified Files:
src/lib/libpthread/arch/hppa: pthread_md.S

Log Message:
Use RAS_{START,END}_ASM_HIDDEN


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libpthread/arch/hppa/pthread_md.S

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



CVS commit: src/sys/arch/hppa/hppa

2022-05-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May 19 06:41:45 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa: intr.c lock_stubs.S

Log Message:
port-hppa/56837: RAS support is slightly incorrect within hppa kernel, too

While there isn't a bug here (the tf_iioq_tail handling is correct) apply
the change to make the conditional / ras symbols consistent with hppa_ras


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/hppa/intr.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/hppa/hppa/lock_stubs.S

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/hppa/hppa/intr.c
diff -u src/sys/arch/hppa/hppa/intr.c:1.6 src/sys/arch/hppa/hppa/intr.c:1.7
--- src/sys/arch/hppa/hppa/intr.c:1.6	Sat Feb 26 03:02:25 2022
+++ src/sys/arch/hppa/hppa/intr.c	Thu May 19 06:41:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.6 2022/02/26 03:02:25 macallan Exp $	*/
+/*	$NetBSD: intr.c,v 1.7 2022/05/19 06:41:45 skrll Exp $	*/
 /*	$OpenBSD: intr.c,v 1.27 2009/12/31 12:52:35 jsing Exp $	*/
 
 /*
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.6 2022/02/26 03:02:25 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.7 2022/05/19 06:41:45 skrll Exp $");
 
 #define __MUTEX_PRIVATE
 
@@ -339,8 +339,8 @@ hppa_intr(struct trapframe *frame)
 	extern char _lock_cas_ras_end[];
 
 	if (frame->tf_iisq_head == HPPA_SID_KERNEL &&
-	frame->tf_iioq_head >= (u_int)_lock_cas_ras_start &&
-	frame->tf_iioq_head <= (u_int)_lock_cas_ras_end) {
+	frame->tf_iioq_head > (u_int)_lock_cas_ras_start &&
+	frame->tf_iioq_head < (u_int)_lock_cas_ras_end) {
 		frame->tf_iioq_head = (u_int)_lock_cas_ras_start;
 		frame->tf_iioq_tail = (u_int)_lock_cas_ras_start + 4;
 	}
@@ -353,8 +353,8 @@ hppa_intr(struct trapframe *frame)
 	 * the owner value is left unset.
 	 */
 	if (frame->tf_iisq_head == HPPA_SID_KERNEL &&
-	frame->tf_iioq_head >= (u_int)mutex_enter_crit_start &&
-	frame->tf_iioq_head <= (u_int)mutex_enter_crit_end &&
+	frame->tf_iioq_head > (u_int)mutex_enter_crit_start &&
+	frame->tf_iioq_head < (u_int)mutex_enter_crit_end &&
 	frame->tf_ret0 != 0)
 		((kmutex_t *)frame->tf_arg0)->mtx_owner = (uintptr_t)curlwp;
 #endif

Index: src/sys/arch/hppa/hppa/lock_stubs.S
diff -u src/sys/arch/hppa/hppa/lock_stubs.S:1.28 src/sys/arch/hppa/hppa/lock_stubs.S:1.29
--- src/sys/arch/hppa/hppa/lock_stubs.S:1.28	Sun Mar 20 20:19:34 2022
+++ src/sys/arch/hppa/hppa/lock_stubs.S	Thu May 19 06:41:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.S,v 1.28 2022/03/20 20:19:34 andvar Exp $	*/
+/*	$NetBSD: lock_stubs.S,v 1.29 2022/05/19 06:41:45 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@@ -155,8 +155,8 @@ mutex_enter_crit_start:
 	GET_CURLWP(%t2)
 
 	bv	%r0(%rp)
-mutex_enter_crit_end:
 	 stw	%t2, MTX_OWNER(%arg0)
+mutex_enter_crit_end:
 EXIT(mutex_enter)
 
 #endif	/* !LOCKDEBUG */
@@ -171,8 +171,8 @@ _lock_cas_ras_start:
 	ldw	0(%arg0),%t1
 	comb,<>	%arg1, %t1, 1f
 	 copy	%t1,%ret0
-_lock_cas_ras_end:
 	stw	%arg2,0(%arg0)
+_lock_cas_ras_end:
 	copy	%arg1,%ret0
 1:
 	bv,n	%r0(%rp)



CVS commit: src/sys/arch/hppa/hppa

2022-05-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May 19 06:41:45 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa: intr.c lock_stubs.S

Log Message:
port-hppa/56837: RAS support is slightly incorrect within hppa kernel, too

While there isn't a bug here (the tf_iioq_tail handling is correct) apply
the change to make the conditional / ras symbols consistent with hppa_ras


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/hppa/intr.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/hppa/hppa/lock_stubs.S

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