CVS commit: src/sys/kern

2023-11-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 19 04:13:38 UTC 2023

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

Log Message:
eventfd(2): Omit needless micro-optimization causing PR kern/57703.

Unfortunately, owing to PR kern/57705 and PR misc/57706, it isn't
convenient to flip the xfail switch on a test for this bug.  So we'll
do that separately.  (But I did verify that a rumpified version of
the test postd to PR kern/57703 failed without this change, and
passed with this change.)

PR kern/57703

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/kern/sys_eventfd.c

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

Modified files:

Index: src/sys/kern/sys_eventfd.c
diff -u src/sys/kern/sys_eventfd.c:1.9 src/sys/kern/sys_eventfd.c:1.10
--- src/sys/kern/sys_eventfd.c:1.9	Thu Feb 17 16:28:29 2022
+++ src/sys/kern/sys_eventfd.c	Sun Nov 19 04:13:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_eventfd.c,v 1.9 2022/02/17 16:28:29 thorpej Exp $	*/
+/*	$NetBSD: sys_eventfd.c,v 1.10 2023/11/19 04:13:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_eventfd.c,v 1.9 2022/02/17 16:28:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_eventfd.c,v 1.10 2023/11/19 04:13:37 riastradh Exp $");
 
 /*
  * eventfd
@@ -69,8 +69,6 @@ struct eventfd {
 	eventfd_t	efd_val;
 	int64_t		efd_nwaiters;
 	bool		efd_restarting;
-	bool		efd_has_read_waiters;
-	bool		efd_has_write_waiters;
 	bool		efd_is_semaphore;
 
 	/*
@@ -117,8 +115,6 @@ eventfd_destroy(struct eventfd * const e
 {
 
 	KASSERT(efd->efd_nwaiters == 0);
-	KASSERT(efd->efd_has_read_waiters == false);
-	KASSERT(efd->efd_has_write_waiters == false);
 
 	cv_destroy(>efd_read_wait);
 	cv_destroy(>efd_write_wait);
@@ -155,10 +151,8 @@ eventfd_wait(struct eventfd * const efd,
 	}
 
 	if (is_write) {
-		efd->efd_has_write_waiters = true;
 		waitcv = >efd_write_wait;
 	} else {
-		efd->efd_has_read_waiters = true;
 		waitcv = >efd_read_wait;
 	}
 
@@ -194,17 +188,11 @@ eventfd_wake(struct eventfd * const efd,
 	int pollev;
 
 	if (is_write) {
-		if (efd->efd_has_read_waiters) {
-			waitcv = >efd_read_wait;
-			efd->efd_has_read_waiters = false;
-		}
+		waitcv = >efd_read_wait;
 		sel = >efd_read_sel;
 		pollev = POLLIN | POLLRDNORM;
 	} else {
-		if (efd->efd_has_write_waiters) {
-			waitcv = >efd_write_wait;
-			efd->efd_has_write_waiters = false;
-		}
+		waitcv = >efd_write_wait;
 		sel = >efd_write_sel;
 		pollev = POLLOUT | POLLWRNORM;
 	}
@@ -537,14 +525,8 @@ eventfd_fop_restart(file_t * const fp)
 
 	if (efd->efd_nwaiters != 0) {
 		efd->efd_restarting = true;
-		if (efd->efd_has_read_waiters) {
-			cv_broadcast(>efd_read_wait);
-			efd->efd_has_read_waiters = false;
-		}
-		if (efd->efd_has_write_waiters) {
-			cv_broadcast(>efd_write_wait);
-			efd->efd_has_write_waiters = false;
-		}
+		cv_broadcast(>efd_read_wait);
+		cv_broadcast(>efd_write_wait);
 	}
 
 	mutex_exit(>efd_lock);



CVS commit: src/sys/kern

2023-11-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 19 04:13:38 UTC 2023

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

Log Message:
eventfd(2): Omit needless micro-optimization causing PR kern/57703.

Unfortunately, owing to PR kern/57705 and PR misc/57706, it isn't
convenient to flip the xfail switch on a test for this bug.  So we'll
do that separately.  (But I did verify that a rumpified version of
the test postd to PR kern/57703 failed without this change, and
passed with this change.)

PR kern/57703

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/kern/sys_eventfd.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/m68k/fpe

2023-11-18 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Nov 19 03:58:15 UTC 2023

Modified Files:
src/sys/arch/m68k/fpe: fpu_rem.c

Log Message:
m68k: Remove an unused variable since rev 1.1.
Detected by clang15 (nono emulator has imported and used this FPE).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/m68k/fpe/fpu_rem.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/m68k/fpe

2023-11-18 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Nov 19 03:58:15 UTC 2023

Modified Files:
src/sys/arch/m68k/fpe: fpu_rem.c

Log Message:
m68k: Remove an unused variable since rev 1.1.
Detected by clang15 (nono emulator has imported and used this FPE).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/m68k/fpe/fpu_rem.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/m68k/fpe/fpu_rem.c
diff -u src/sys/arch/m68k/fpe/fpu_rem.c:1.17 src/sys/arch/m68k/fpe/fpu_rem.c:1.18
--- src/sys/arch/m68k/fpe/fpu_rem.c:1.17	Thu Feb  5 12:22:06 2015
+++ src/sys/arch/m68k/fpe/fpu_rem.c	Sun Nov 19 03:58:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu_rem.c,v 1.17 2015/02/05 12:22:06 isaki Exp $	*/
+/*	$NetBSD: fpu_rem.c,v 1.18 2023/11/19 03:58:15 isaki Exp $	*/
 
 /*
  * Copyright (c) 1995  Ken Nakata
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu_rem.c,v 1.17 2015/02/05 12:22:06 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_rem.c,v 1.18 2023/11/19 03:58:15 isaki Exp $");
 
 #include 
 #include 
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: fpu_rem.c,v 
  *signQ := signX EOR signY. Record whether MOD or REM
  *is requested.
  *
- *   Step 2.  Set L := expo(X)-expo(Y), k := 0, Q := 0.
+ *   Step 2.  Set L := expo(X)-expo(Y), Q := 0.
  *If (L < 0) then
  *   R := X, go to Step 4.
  *else
@@ -59,8 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: fpu_rem.c,v 
  *3.1 If R = Y, then { Q := Q + 1, R := 0, go to Step 7. }
  *3.2 If R > Y, then { R := R - Y, Q := Q + 1}
  *3.3 If j = 0, go to Step 4.
- *3.4 k := k + 1, j := j - 1, Q := 2Q, R := 2R. Go to
- *Step 3.1.
+ *3.4 j := j - 1, Q := 2Q, R := 2R. Go to Step 3.1.
  *
  *   Step 4.  R := signX*R.
  *
@@ -105,7 +104,7 @@ __fpu_modrem(struct fpemu *fe, int is_mo
 	static struct fpn X, Y;
 	struct fpn *x, *y, *r;
 	uint32_t signX, signY, signQ;
-	int j, k, l, q;
+	int j, l, q;
 	int cmp;
 
 	if (ISNAN(>fe_f1) || ISNAN(>fe_f2))
@@ -138,7 +137,6 @@ __fpu_modrem(struct fpemu *fe, int is_mo
 	 * Step 2
 	 */
 	l = x->fp_exp - y->fp_exp;
-	k = 0;
 	CPYFPN(r, x);
 	if (l >= 0) {
 		r->fp_exp -= l;
@@ -168,7 +166,6 @@ __fpu_modrem(struct fpemu *fe, int is_mo
 goto Step4;
 
 			/* Step 3.4 */
-			k++;
 			j--;
 			q += q;
 			r->fp_exp++;



CVS commit: src/usr.bin/make

2023-11-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 18 20:19:08 UTC 2023

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

Log Message:
make: clean up the modifier ':[...]'

No functional change.


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

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1068 src/usr.bin/make/var.c:1.1069
--- src/usr.bin/make/var.c:1.1068	Thu Nov  2 06:09:07 2023
+++ src/usr.bin/make/var.c	Sat Nov 18 20:19:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1068 2023/11/02 06:09:07 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1069 2023/11/18 20:19:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1068 2023/11/02 06:09:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1069 2023/11/18 20:19:08 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3236,7 +3236,6 @@ static ApplyModifierResult
 ApplyModifier_Words(const char **pp, ModChain *ch)
 {
 	Expr *expr = ch->expr;
-	const char *estr;
 	int first, last;
 	const char *p;
 	LazyBuf estrBuf;
@@ -3246,7 +3245,7 @@ ApplyModifier_Words(const char **pp, Mod
 	if (!ParseModifierPart(pp, ']', expr->emode, ch, ))
 		return AMR_CLEANUP;
 	festr = LazyBuf_DoneGet();
-	estr = festr.str;
+	p = festr.str;
 
 	if (!IsDelimiter(**pp, ch))
 		goto bad_modifier;		/* Found junk after ']' */
@@ -3254,13 +3253,13 @@ ApplyModifier_Words(const char **pp, Mod
 	if (!ModChain_ShouldEval(ch))
 		goto ok;
 
-	if (estr[0] == '\0')
-		goto bad_modifier;			/* Found ":[]". */
+	if (p[0] == '\0')
+		goto bad_modifier;		/* Found ":[]". */
 
-	if (estr[0] == '#' && estr[1] == '\0') {	/* Found ":[#]" */
-		if (ch->oneBigWord) {
+	if (strcmp(p, "#") == 0) {		/* Found ":[#]" */
+		if (ch->oneBigWord)
 			Expr_SetValueRefer(expr, "1");
-		} else {
+		else {
 			Buffer buf;
 
 			SubstringWords words = Expr_Words(expr);
@@ -3275,49 +3274,37 @@ ApplyModifier_Words(const char **pp, Mod
 		goto ok;
 	}
 
-	if (estr[0] == '*' && estr[1] == '\0') {	/* Found ":[*]" */
+	if (strcmp(p, "*") == 0) {		/* ":[*]" */
 		ch->oneBigWord = true;
 		goto ok;
 	}
 
-	if (estr[0] == '@' && estr[1] == '\0') {	/* Found ":[@]" */
+	if (strcmp(p, "@") == 0) {		/* ":[@]" */
 		ch->oneBigWord = false;
 		goto ok;
 	}
 
-	/*
-	 * We expect estr to contain a single integer for :[N], or two
-	 * integers separated by ".." for :[start..end].
-	 */
-	p = estr;
+	/* Expect ":[N]" or ":[start..end]" */
 	if (!TryParseIntBase0(, ))
-		goto bad_modifier;	/* Found junk instead of a number */
+		goto bad_modifier;
 
-	if (p[0] == '\0') {		/* Found only one integer in :[N] */
+	if (p[0] == '\0')			/* ":[N]" */
 		last = first;
-	} else if (p[0] == '.' && p[1] == '.' && p[2] != '\0') {
-		/* Expecting another integer after ".." */
+	else if (strncmp(p, "..", 2) == 0) {
 		p += 2;
 		if (!TryParseIntBase0(, ) || *p != '\0')
-			goto bad_modifier; /* Found junk after ".." */
+			goto bad_modifier;
 	} else
-		goto bad_modifier;	/* Found junk instead of ".." */
+		goto bad_modifier;
 
-	/*
-	 * Now first and last are properly filled in, but we still have to
-	 * check for 0 as a special case.
-	 */
-	if (first == 0 && last == 0) {
-		/* ":[0]" or perhaps ":[0..0]" */
+	if (first == 0 && last == 0) {		/* ":[0]" or ":[0..0]" */
 		ch->oneBigWord = true;
 		goto ok;
 	}
 
-	/* ":[0..N]" or ":[N..0]" */
-	if (first == 0 || last == 0)
+	if (first == 0 || last == 0)		/* ":[0..N]" or ":[N..0]" */
 		goto bad_modifier;
 
-	/* Normal case: select the words described by first and last. */
 	Expr_SetValueOwn(expr,
 	VarSelectWords(Expr_Str(expr), first, last,
 		ch->sep, ch->oneBigWord));



CVS commit: src/usr.bin/make

2023-11-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 18 20:19:08 UTC 2023

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

Log Message:
make: clean up the modifier ':[...]'

No functional change.


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

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



CVS commit: src/tests/kernel

2023-11-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 18 19:46:55 UTC 2023

Modified Files:
src/tests/kernel: t_fdrestart.c

Log Message:
t_fdrestart: Mark some tests no longer xfail.

Backing out ad's changes last month seemed to fix the symptoms
(although I'm pretty sure this logic is still broken, more to come).

PR kern/57659


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/t_fdrestart.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/kernel/t_fdrestart.c
diff -u src/tests/kernel/t_fdrestart.c:1.3 src/tests/kernel/t_fdrestart.c:1.4
--- src/tests/kernel/t_fdrestart.c:1.3	Sun Oct 15 15:18:17 2023
+++ src/tests/kernel/t_fdrestart.c	Sat Nov 18 19:46:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fdrestart.c,v 1.3 2023/10/15 15:18:17 riastradh Exp $	*/
+/*	$NetBSD: t_fdrestart.c,v 1.4 2023/11/18 19:46:55 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #define	_KMEMUSER		/* ERESTART */
 
 #include 
-__RCSID("$NetBSD: t_fdrestart.c,v 1.3 2023/10/15 15:18:17 riastradh Exp $");
+__RCSID("$NetBSD: t_fdrestart.c,v 1.4 2023/11/18 19:46:55 riastradh Exp $");
 
 #include 
 #include 
@@ -198,7 +198,6 @@ ATF_TC_BODY(pipe_read, tc)
 	memset(F, 0, sizeof(*F));
 	F->op = 
 	F->fd = fd[0];
-	atf_tc_expect_fail("PR kern/57659");
 	testfdrestart(F);
 }
 
@@ -240,7 +239,6 @@ ATF_TC_BODY(socketpair_read, tc)
 	memset(F, 0, sizeof(*F));
 	F->op = 
 	F->fd = fd[0];
-	atf_tc_expect_fail("PR kern/57659");
 	testfdrestart(F);
 }
 
@@ -261,7 +259,6 @@ ATF_TC_BODY(socketpair_write, tc)
 	memset(F, 0, sizeof(*F));
 	F->op = 
 	F->fd = fd[0];
-	atf_tc_expect_fail("PR kern/57659");
 	testfdrestart(F);
 }
 



CVS commit: src/tests/kernel

2023-11-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 18 19:46:55 UTC 2023

Modified Files:
src/tests/kernel: t_fdrestart.c

Log Message:
t_fdrestart: Mark some tests no longer xfail.

Backing out ad's changes last month seemed to fix the symptoms
(although I'm pretty sure this logic is still broken, more to come).

PR kern/57659


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/t_fdrestart.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/make/unit-tests

2023-11-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 18 19:25:43 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.mk

Log Message:
tests/make: test parsing of the ':?' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-ifelse.mk

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