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

2020-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 21 01:58:30 UTC 2020

Modified Files:
src/lib/libc/arch/alpha/sys: __sigtramp2.S

Log Message:
Fix typo (thanks kamil@ for pointing it out).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/arch/alpha/sys/__sigtramp2.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/libc/arch/alpha/sys/__sigtramp2.S
diff -u src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.4 src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.5
--- src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.4	Wed Oct 21 01:55:07 2020
+++ src/lib/libc/arch/alpha/sys/__sigtramp2.S	Wed Oct 21 01:58:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: __sigtramp2.S,v 1.4 2020/10/21 01:55:07 thorpej Exp $	*/
+/*	$NetBSD: __sigtramp2.S,v 1.5 2020/10/21 01:58:30 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -81,7 +81,7 @@
  * The unwind entry includes one instruction slot prior to the trampoline
  * because the unwinder will look up to (return PC - 1 insn) while unwinding.
  * Normally this would be the jump / branch, but since there isn't one in
- * this case, we place an explcit nop there instead.
+ * this case, we place an explicit nop there instead.
  */
 	nop
 



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

2020-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 21 01:55:07 UTC 2020

Modified Files:
src/lib/libc/arch/alpha/sys: __sigtramp2.S

Log Message:
Add call frame unwind info to the Alpha signal trampoline.  Using
kamil@'s test program:

Before:
Backtrace 2 stack frames.
0x12a74  at ./test
0x3fffdca6550 <__sigtramp_siginfo_2> at /usr/lib/libc.so.12

After:
Backtrace 4 stack frames.
0x12a74  at ./test
0x3fffdca6554 <__sigtramp_siginfo_2> at /usr/lib/libc.so.12
0x12b10  at ./test
0x129b4 <___start+0x1a4> at ./test


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/alpha/sys/__sigtramp2.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/libc/arch/alpha/sys/__sigtramp2.S
diff -u src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.3 src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.4
--- src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.3	Wed Oct 21 01:24:05 2020
+++ src/lib/libc/arch/alpha/sys/__sigtramp2.S	Wed Oct 21 01:55:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: __sigtramp2.S,v 1.3 2020/10/21 01:24:05 thorpej Exp $	*/
+/*	$NetBSD: __sigtramp2.S,v 1.4 2020/10/21 01:55:07 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -39,10 +39,57 @@
  *		ucontext structure	[128] == sp + sizeof(siginfo_t)]
  *	sp->	siginfo structure	[0]
  */
+
+#define	CFI_OFFSET(r)	.cfi_offset r, SIZEOF_SIGINFO + UC_GREGS + r*8
+
+	.cfi_startproc simple
+	.cfi_signal_frame
+	.cfi_def_cfa _REG_SP, 0
+	CFI_OFFSET(_REG_V0)
+	CFI_OFFSET(_REG_T0)
+	CFI_OFFSET(_REG_T1)
+	CFI_OFFSET(_REG_T2)
+	CFI_OFFSET(_REG_T3)
+	CFI_OFFSET(_REG_T4)
+	CFI_OFFSET(_REG_T5)
+	CFI_OFFSET(_REG_T6)
+	CFI_OFFSET(_REG_T7)
+	CFI_OFFSET(_REG_S0)
+	CFI_OFFSET(_REG_S1)
+	CFI_OFFSET(_REG_S2)
+	CFI_OFFSET(_REG_S3)
+	CFI_OFFSET(_REG_S4)
+	CFI_OFFSET(_REG_S5)
+	CFI_OFFSET(_REG_S6)
+	CFI_OFFSET(_REG_A0)
+	CFI_OFFSET(_REG_A1)
+	CFI_OFFSET(_REG_A2)
+	CFI_OFFSET(_REG_A3)
+	CFI_OFFSET(_REG_A4)
+	CFI_OFFSET(_REG_A5)
+	CFI_OFFSET(_REG_T8)
+	CFI_OFFSET(_REG_T9)
+	CFI_OFFSET(_REG_T10)
+	CFI_OFFSET(_REG_T11)
+	CFI_OFFSET(_REG_RA)
+	CFI_OFFSET(_REG_T12)	/* a.k.a. _REG_PV */
+	CFI_OFFSET(_REG_AT)
+	CFI_OFFSET(_REG_GP)
+	CFI_OFFSET(_REG_SP)
+
+/*
+ * The unwind entry includes one instruction slot prior to the trampoline
+ * because the unwinder will look up to (return PC - 1 insn) while unwinding.
+ * Normally this would be the jump / branch, but since there isn't one in
+ * this case, we place an explcit nop there instead.
+ */
+	nop
+
 NESTED_NOPROFILE(__sigtramp_siginfo_2,0,0,ra,0,0)
 	ldgp	gp,0(ra)
 	lda	a0,(SIZEOF_SIGINFO)(sp)	/* get pointer to ucontext */
 	CALLSYS_NOERROR(setcontext)	/* and call setcontext() with it */
 	ldiq	a0,-1			/* if that failed, set an exit code */
 	CALLSYS_NOERROR(exit)		/* and call exit() */
+	.cfi_endproc
 END(__sigtramp_siginfo_2)



CVS commit: src/lib/libc/arch/alpha

2020-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 21 01:24:05 UTC 2020

Modified Files:
src/lib/libc/arch/alpha: genassym.cf
src/lib/libc/arch/alpha/gen: __setjmp14.S swapcontext.S
src/lib/libc/arch/alpha/sys: __sigtramp2.S getcontext.S

Log Message:
- Consistently use _REG_* defines from assym.h to mean register numbers,
  not offsets (i.e. *8 to get the offset).
- Define and use SIZEOF_SIGINFO and UC_GREGS constants, rather than
  hard-code magic numbers.

NFC -- same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/arch/alpha/genassym.cf
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/arch/alpha/gen/__setjmp14.S
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/alpha/gen/swapcontext.S
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/arch/alpha/sys/__sigtramp2.S
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/alpha/sys/getcontext.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/libc/arch/alpha/genassym.cf
diff -u src/lib/libc/arch/alpha/genassym.cf:1.2 src/lib/libc/arch/alpha/genassym.cf:1.3
--- src/lib/libc/arch/alpha/genassym.cf:1.2	Mon Apr 28 20:22:55 2008
+++ src/lib/libc/arch/alpha/genassym.cf	Wed Oct 21 01:24:04 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.2 2008/04/28 20:22:55 martin Exp $
+#	$NetBSD: genassym.cf,v 1.3 2020/10/21 01:24:04 thorpej Exp $
 
 #
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,41 +34,41 @@ include 
 include 
 include 
 
-define _REG_V0		8*_REG_V0	/* 0 */
-define _REG_T0		8*_REG_T0	/* 1 */
-define _REG_T1		8*_REG_T1	/* 2 */
-define _REG_T2		8*_REG_T2	/* 3 */
-define _REG_T3		8*_REG_T3	/* 4 */
-define _REG_T4		8*_REG_T4	/* 5 */
-define _REG_T5		8*_REG_T5	/* 6 */
-define _REG_T6		8*_REG_T6	/* 7 */
-define _REG_T7		8*_REG_T7	/* 8 */
-define _REG_S0		8*_REG_S0	/* 9 */
-define _REG_S1		8*_REG_S1	/* 10 */
-define _REG_S2		8*_REG_S2	/* 11 */
-define _REG_S3		8*_REG_S3	/* 12 */
-define _REG_S4		8*_REG_S4	/* 13 */
-define _REG_S5		8*_REG_S5	/* 14 */
-define _REG_S6		8*_REG_S6	/* 15 */
-define _REG_A0		8*_REG_A0	/* 16 */
-define _REG_A1		8*_REG_A1	/* 17 */
-define _REG_A2		8*_REG_A2	/* 18 */
-define _REG_A3		8*_REG_A3	/* 19 */
-define _REG_A4		8*_REG_A4	/* 20 */
-define _REG_A5		8*_REG_A5	/* 21 */
-define _REG_T8		8*_REG_T8	/* 22 */
-define _REG_T9		8*_REG_T9	/* 23 */
-define _REG_T10		8*_REG_T10	/* 24 */
-define _REG_T11		8*_REG_T11	/* 25 */
-define _REG_RA		8*_REG_RA	/* 26 */
-define _REG_T12		8*_REG_T12	/* 27 */
-define _REG_PV		8*_REG_PV	/* 27 */
-define _REG_AT		8*_REG_AT	/* 28 */
-define _REG_GP		8*_REG_GP	/* 29 */
-define _REG_SP		8*_REG_SP	/* 30 */
-define _REG_UNIQUE	8*_REG_UNIQUE	/* 31 */
-define _REG_PC		8*_REG_PC	/* 32 */
-define _REG_PS		8*_REG_PS	/* 33 */
+define _REG_V0		_REG_V0		/* 0 */
+define _REG_T0		_REG_T0		/* 1 */
+define _REG_T1		_REG_T1		/* 2 */
+define _REG_T2		_REG_T2		/* 3 */
+define _REG_T3		_REG_T3		/* 4 */
+define _REG_T4		_REG_T4		/* 5 */
+define _REG_T5		_REG_T5		/* 6 */
+define _REG_T6		_REG_T6		/* 7 */
+define _REG_T7		_REG_T7		/* 8 */
+define _REG_S0		_REG_S0		/* 9 */
+define _REG_S1		_REG_S1		/* 10 */
+define _REG_S2		_REG_S2		/* 11 */
+define _REG_S3		_REG_S3		/* 12 */
+define _REG_S4		_REG_S4		/* 13 */
+define _REG_S5		_REG_S5		/* 14 */
+define _REG_S6		_REG_S6		/* 15 */
+define _REG_A0		_REG_A0		/* 16 */
+define _REG_A1		_REG_A1		/* 17 */
+define _REG_A2		_REG_A2		/* 18 */
+define _REG_A3		_REG_A3		/* 19 */
+define _REG_A4		_REG_A4		/* 20 */
+define _REG_A5		_REG_A5		/* 21 */
+define _REG_T8		_REG_T8		/* 22 */
+define _REG_T9		_REG_T9		/* 23 */
+define _REG_T10		_REG_T10	/* 24 */
+define _REG_T11		_REG_T11	/* 25 */
+define _REG_RA		_REG_RA		/* 26 */
+define _REG_T12		_REG_T12	/* 27 */
+define _REG_PV		_REG_PV		/* 27 */
+define _REG_AT		_REG_AT		/* 28 */
+define _REG_GP		_REG_GP		/* 29 */
+define _REG_SP		_REG_SP		/* 30 */
+define _REG_UNIQUE	_REG_UNIQUE	/* 31 */
+define _REG_PC		_REG_PC		/* 32 */
+define _REG_PS		_REG_PS		/* 33 */
 
 define	SC_ONSTACK	offsetof(struct sigcontext, sc_onstack)
 define	SC_SP		offsetof(struct sigcontext, sc_sp)
@@ -82,3 +82,7 @@ define	SC_FP_CONTROL	offsetof(struct sig
 define	SC_MASK		offsetof(struct sigcontext, sc_mask)
 define	SC_RESERVED	offsetof(struct sigcontext, sc_reserved)
 define	SC_XXX		offsetof(struct sigcontext, sc_xxx)
+
+define	SIZEOF_SIGINFO	sizeof(siginfo_t)
+
+define	UC_GREGS	offsetof(ucontext_t, uc_mcontext.__gregs)

Index: src/lib/libc/arch/alpha/gen/__setjmp14.S
diff -u src/lib/libc/arch/alpha/gen/__setjmp14.S:1.7 src/lib/libc/arch/alpha/gen/__setjmp14.S:1.8
--- src/lib/libc/arch/alpha/gen/__setjmp14.S:1.7	Thu Jan 23 03:08:50 2014
+++ src/lib/libc/arch/alpha/gen/__setjmp14.S	Wed Oct 21 01:24:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: __setjmp14.S,v 1.7 2014/01/23 03:08:50 christos Exp $ */
+/* $NetBSD: __setjmp14.S,v 1.8 2020/10/21 01:24:05 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -46,16 

CVS commit: src

2020-10-20 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct 20 23:27:58 UTC 2020

Modified Files:
src/share/man/man3: queue.3
src/sys/sys: queue.h

Log Message:
Remove the CIRCLEQ API from queue(3)

It was marked deprecated in NetBSD 7 and already removed from
FreeBSD in 2000 and OpenBSD in 2015.

Proposed on tech-kern@.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/share/man/man3/queue.3
cvs rdiff -u -r1.74 -r1.75 src/sys/sys/queue.h

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

Modified files:

Index: src/share/man/man3/queue.3
diff -u src/share/man/man3/queue.3:1.60 src/share/man/man3/queue.3:1.61
--- src/share/man/man3/queue.3:1.60	Mon Jun 18 02:48:56 2018
+++ src/share/man/man3/queue.3	Tue Oct 20 23:27:57 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: queue.3,v 1.60 2018/06/18 02:48:56 eadler Exp $
+.\"	$NetBSD: queue.3,v 1.61 2020/10/20 23:27:57 kamil Exp $
 .\"
 .\" Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -1091,3 +1091,13 @@ and
 .Nm STAILQ
 functions first appeared in
 .Fx 2.1.5 .
+.Pp
+The
+.Nm CIRCLEQ
+functions first appeared in
+.Bx 4.4
+and were deprecated in
+.Nx 7
+and removed in
+.Nx 10
+due to the pointer aliasing violations.

Index: src/sys/sys/queue.h
diff -u src/sys/sys/queue.h:1.74 src/sys/sys/queue.h:1.75
--- src/sys/sys/queue.h:1.74	Sat Mar 23 12:01:18 2019
+++ src/sys/sys/queue.h	Tue Oct 20 23:27:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: queue.h,v 1.74 2019/03/23 12:01:18 maxv Exp $	*/
+/*	$NetBSD: queue.h,v 1.75 2020/10/20 23:27:58 kamil Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -69,14 +69,6 @@
  * after an existing element, at the head of the list, or at the end of
  * the list. A tail queue may be traversed in either direction.
  *
- * A circle queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or after
- * an existing element, at the head of the list, or at the end of the list.
- * A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
- *
  * For details on the use of these macros, see the queue(3) manual page.
  */
 
@@ -663,192 +655,4 @@ struct {\
 	((struct type *)(void *)\
 		((char *)((head)->stqh_last) - offsetof(struct type, field
 
-
-#ifndef _KERNEL
-/*
- * Circular queue definitions. Do not use. We still keep the macros
- * for compatibility but because of pointer aliasing issues their use
- * is discouraged!
- */
-
-/*
- * __launder_type():  We use this ugly hack to work around the compiler
- * noticing that two types may not alias each other and elide tests in code.
- * We hit this in the CIRCLEQ macros when comparing 'struct name *' and
- * 'struct type *' (see CIRCLEQ_HEAD()).  Modern compilers (such as GCC
- * 4.8) declare these comparisons as always false, causing the code to
- * not run as designed.
- *
- * This hack is only to be used for comparisons and thus can be fully const.
- * Do not use for assignment.
- *
- * If we ever choose to change the ABI of the CIRCLEQ macros, we could fix
- * this by changing the head/tail sentinal values, but see the note above
- * this one.
- */
-static __inline const void * __launder_type(const void *);
-static __inline const void *
-__launder_type(const void *__x)
-{
-	__asm __volatile("" : "+r" (__x));
-	return __x;
-}
-
-#if defined(QUEUEDEBUG)
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)\
-	if ((head)->cqh_first != CIRCLEQ_ENDC(head) &&			\
-	(head)->cqh_first->field.cqe_prev != CIRCLEQ_ENDC(head))	\
-		QUEUEDEBUG_ABORT("CIRCLEQ head forw %p %s:%d", (head),	\
-		  __FILE__, __LINE__);\
-	if ((head)->cqh_last != CIRCLEQ_ENDC(head) &&			\
-	(head)->cqh_last->field.cqe_next != CIRCLEQ_ENDC(head))	\
-		QUEUEDEBUG_ABORT("CIRCLEQ head back %p %s:%d", (head),	\
-		  __FILE__, __LINE__);
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)			\
-	if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) {		\
-		if ((head)->cqh_last != (elm))\
-			QUEUEDEBUG_ABORT("CIRCLEQ elm last %p %s:%d",	\
-			(elm), __FILE__, __LINE__);			\
-	} else {			\
-		if ((elm)->field.cqe_next->field.cqe_prev != (elm))	\
-			QUEUEDEBUG_ABORT("CIRCLEQ elm forw %p %s:%d",	\
-			(elm), __FILE__, __LINE__);			\
-	}\
-	if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) {		\
-		if ((head)->cqh_first != (elm))\
-			QUEUEDEBUG_ABORT("CIRCLEQ elm first %p %s:%d",	\
-			(elm), __FILE__, __LINE__);			\
-	} else {			\
-		if ((elm)->field.cqe_prev->field.cqe_next != (elm))	\
-			QUEUEDEBUG_ABORT("CIRCLEQ elm prev %p %s:%d",	\
-			(elm), __FILE__, __LINE__);			\
-	}
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)			\
-	(elm)->field.cqe_next = (void *)1L;\
-	(elm)->field.cqe_prev 

CVS commit: src/usr.bin/make

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 23:15:23 UTC 2020

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

Log Message:
make(1): document parameter to Var_Parse


To generate a diff of this commit:
cvs rdiff -u -r1.578 -r1.579 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.578 src/usr.bin/make/var.c:1.579
--- src/usr.bin/make/var.c:1.578	Sun Oct 18 17:19:54 2020
+++ src/usr.bin/make/var.c	Tue Oct 20 23:15:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.578 2020/10/18 17:19:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.579 2020/10/20 23:15:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.578 2020/10/18 17:19:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.579 2020/10/20 23:15:23 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3445,6 +3445,10 @@ ValidShortVarname(char varname, const ch
  *	modifiers and find its value by applying the modifiers to the
  *	original value.
  *
+ *	When parsing a condition in ParseEmptyArg, pp may also point to
+ *	the "y" of "empty(VARNAME:Modifiers)", which is syntactically
+ *	identical.
+ *
  * Input:
  *	str		The string to parse
  *	ctxt		The context for the variable



CVS commit: src/usr.bin/make

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 23:04:35 UTC 2020

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

Log Message:
make(1): remove strange off-by-one feature in SuffSuffGetSuffix

The code worked as intended, yet it was strange to modify cp[1] to
temporarily shorten a string.  Using cp[0] for this purpose is common
style.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.198 src/usr.bin/make/suff.c:1.199
--- src/usr.bin/make/suff.c:1.198	Tue Oct 20 21:15:47 2020
+++ src/usr.bin/make/suff.c	Tue Oct 20 23:04:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.198 2020/10/20 21:15:47 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.199 2020/10/20 23:04:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.198 2020/10/20 21:15:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.199 2020/10/20 23:04:35 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -238,16 +238,14 @@ struct SuffSuffGetSuffixArgs {
 char *name_end;
 };
 
-/* See if suff is a suffix of str. str->ename should point to THE END
- * of the string to check. (THE END == the null byte)
+/* See if suff is a suffix of str.
  *
  * Input:
  *	s		possible suffix
  *	str		string to examine
  *
  * Results:
- *	NULL if it ain't, pointer to character in str before suffix if
- *	it is.
+ *	NULL if it ain't, pointer to the start of suffix in str if it is.
  */
 static char *
 SuffSuffGetSuffix(const Suff *s, const struct SuffSuffGetSuffixArgs *str)
@@ -266,7 +264,7 @@ SuffSuffGetSuffix(const Suff *s, const s
 	p2--;
 }
 
-return p1 == s->name - 1 ? p2 : NULL;
+return p1 == s->name - 1 ? p2 + 1 : NULL;
 }
 
 /* Predicate form of SuffSuffGetSuffix, for Lst_Find. */
@@ -638,9 +636,9 @@ SuffRebuildGraph(GNode *transform, Suff 
 
 	/* Null-terminate the source suffix in order to find it. */
 	/* XXX: don't modify strings, not even temporarily */
-	cp[1] = '\0';
+	cp[0] = '\0';
 	s2 = FindSuffByName(transform->name);
-	cp[1] = s->name[0];		/* restore */
+	cp[0] = s->name[0];		/* restore */
 
 	if (s2 != NULL) {
 	/* establish the proper relationship */



CVS commit: src/sys

2020-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 20 23:03:30 UTC 2020

Modified Files:
src/sys/arch/arm/fdt: arm_simplefb.c arm_simplefb.h
src/sys/arch/evbarm/fdt: fdt_machdep.c
src/sys/dev/fdt: simplefb.c
src/sys/dev/pci: pciconf.c pciconf.h

Log Message:
Instead of trying to prevent pciconf from reconfiguring the firmware's
framebuffer, instead allow MD code to register callbacks. If a resource is
changed, the driver can unmap the old resource and remap the new. Do this
with simplefb so the console doesn't explode when the VGA device is
(potentially) reconfigured at boot.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/arm_simplefb.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/arm_simplefb.h
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/evbarm/fdt/fdt_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/simplefb.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/pciconf.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/pciconf.h

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

Modified files:

Index: src/sys/arch/arm/fdt/arm_simplefb.c
diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.2 src/sys/arch/arm/fdt/arm_simplefb.c:1.3
--- src/sys/arch/arm/fdt/arm_simplefb.c:1.2	Mon Oct 19 01:12:14 2020
+++ src/sys/arch/arm/fdt/arm_simplefb.c	Tue Oct 20 23:03:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_simplefb.c,v 1.2 2020/10/19 01:12:14 rin Exp $ */
+/* $NetBSD: arm_simplefb.c,v 1.3 2020/10/20 23:03:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.2 2020/10/19 01:12:14 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.3 2020/10/20 23:03:30 jmcneill Exp $");
 
 #include 
 #include 
@@ -85,6 +85,10 @@ static struct wsdisplay_accessops arm_si
 static struct vcons_data arm_simplefb_vcons_data;
 static struct vcons_screen arm_simplefb_screen;
 
+static bus_addr_t arm_simplefb_addr;
+static bus_size_t arm_simplefb_size;
+static bus_space_handle_t arm_simplefb_bsh;
+
 static int
 arm_simplefb_find_node(void)
 {
@@ -157,6 +161,29 @@ arm_simplefb_pollc(void *v, int on)
 {
 }
 
+static void
+arm_simplefb_reconfig(void *arg, uint64_t new_addr)
+{
+	struct arm_simplefb_softc * const sc = _simplefb_softc;
+	struct rasops_info *ri = _simplefb_screen.scr_ri;
+	bus_space_tag_t bst = _generic_bs_tag;
+
+	bus_space_unmap(bst, arm_simplefb_bsh, arm_simplefb_size);
+	bus_space_map(bst, new_addr, arm_simplefb_size,
+	BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, _simplefb_bsh);
+
+	sc->sc_bits = bus_space_vaddr(bst, arm_simplefb_bsh);
+	ri->ri_bits = sc->sc_bits;
+
+	arm_simplefb_addr = (bus_addr_t)new_addr;
+}
+
+uint64_t
+arm_simplefb_physaddr(void)
+{
+	return arm_simplefb_addr;
+}
+
 void
 arm_simplefb_preattach(void)
 {
@@ -205,6 +232,10 @@ arm_simplefb_preattach(void)
 	BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, ) != 0)
 		return;
 
+	arm_simplefb_addr = addr;
+	arm_simplefb_size = size;
+	arm_simplefb_bsh = bsh;
+
 	sc->sc_width = width;
 	sc->sc_height = height;
 	sc->sc_depth = depth;
@@ -240,9 +271,10 @@ arm_simplefb_preattach(void)
 #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
 	/*
 	 * Let the PCI resource allocator know about our framebuffer. This
-	 * protects the VGA device BARs from being reprogrammed when we the
-	 * framebuffer is located in VRAM.
+	 * lets us know if the FB base address changes so we can remap the
+	 * framebuffer if necessary.
 	 */
-	pciconf_resource_reserve(PCI_CONF_MAP_MEM, addr, size);
+	pciconf_resource_reserve(PCI_CONF_MAP_MEM, addr, size,
+	arm_simplefb_reconfig, NULL);
 #endif
 }

Index: src/sys/arch/arm/fdt/arm_simplefb.h
diff -u src/sys/arch/arm/fdt/arm_simplefb.h:1.1 src/sys/arch/arm/fdt/arm_simplefb.h:1.2
--- src/sys/arch/arm/fdt/arm_simplefb.h:1.1	Sat Oct 10 15:25:31 2020
+++ src/sys/arch/arm/fdt/arm_simplefb.h	Tue Oct 20 23:03:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_simplefb.h,v 1.1 2020/10/10 15:25:31 jmcneill Exp $ */
+/* $NetBSD: arm_simplefb.h,v 1.2 2020/10/20 23:03:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -33,5 +33,6 @@
 #define _ARM_ARM_SIMPLEFB_H
 
 void		arm_simplefb_preattach(void);
+uint64_t	arm_simplefb_physaddr(void);
 
 #endif /* !_ARM_ARM_SIMPLEFB_H */

Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.76 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.77
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.76	Mon Oct 19 01:12:14 2020
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Tue Oct 20 23:03:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.76 2020/10/19 01:12:14 rin Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.77 2020/10/20 23:03:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.76 2020/10/19 01:12:14 rin 

CVS commit: src/usr.bin/make

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 22:50:55 UTC 2020

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

Log Message:
make(1): clean up parsing code for dependency lines

The variable names "line" and "cp" were not appropriate for some of the
functions where they point to a single word, not to the whole line.

The const parameters were only necessary during refactoring, to make
sure that no unintended aliasing happens between the local variables.
This kind of bugs has already happened a few times in the last months,
and it requires full test coverage of all edge cases, which is not
achieved yet.

In ParseErrorNoDependency, lstart was always the same as line.


To generate a diff of this commit:
cvs rdiff -u -r1.394 -r1.395 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.394 src/usr.bin/make/parse.c:1.395
--- src/usr.bin/make/parse.c:1.394	Mon Oct 19 21:57:37 2020
+++ src/usr.bin/make/parse.c	Tue Oct 20 22:50:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.394 2020/10/19 21:57:37 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.395 2020/10/20 22:50:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.394 2020/10/19 21:57:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.395 2020/10/20 22:50:55 rillig Exp $");
 
 /* types and constants */
 
@@ -1021,11 +1021,11 @@ FindMainTarget(void)
  * cvs/rcs merges.
  */
 static void
-ParseErrorNoDependency(const char *lstart, const char *line)
+ParseErrorNoDependency(const char *lstart)
 {
-if ((strncmp(line, "<<", 6) == 0) ||
-	(strncmp(line, "==", 6) == 0) ||
-	(strncmp(line, ">>", 6) == 0))
+if ((strncmp(lstart, "<<", 6) == 0) ||
+	(strncmp(lstart, "==", 6) == 0) ||
+	(strncmp(lstart, ">>", 6) == 0))
 	Parse_Error(PARSE_FATAL,
 		"Makefile appears to contain unresolved cvs/rcs/??? merge conflicts");
 else if (lstart[0] == '.') {
@@ -1108,9 +1108,9 @@ ParseDependencyTargetWord(/*const*/ char
  *	.ORDER		Must set initial predecessor to NULL
  */
 static void
-ParseDoDependencyTargetSpecial(ParseSpecial *const inout_specType,
-			   const char *const line,
-			   SearchPathList **const inout_paths)
+ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType,
+			   const char *line,
+			   SearchPathList **inout_paths)
 {
 switch (*inout_specType) {
 case ExPath:
@@ -1165,8 +1165,7 @@ ParseDoDependencyTargetSpecial(ParseSpec
  * Call on the suffix module to give us a path to modify.
  */
 static Boolean
-ParseDoDependencyTargetPath(const char *const line,
-			SearchPathList **const inout_paths)
+ParseDoDependencyTargetPath(const char *line, SearchPathList **inout_paths)
 {
 SearchPath *path;
 
@@ -1189,10 +1188,8 @@ ParseDoDependencyTargetPath(const char *
  * See if it's a special target and if so set specType to match it.
  */
 static Boolean
-ParseDoDependencyTarget(const char *const line,
-			ParseSpecial *const inout_specType,
-			GNodeType *out_tOp,
-			SearchPathList **inout_paths)
+ParseDoDependencyTarget(const char *line, ParseSpecial *inout_specType,
+			GNodeType *out_tOp, SearchPathList **inout_paths)
 {
 int keywd;
 
@@ -1224,8 +1221,7 @@ ParseDoDependencyTarget(const char *cons
 }
 
 static void
-ParseDoDependencyTargetMundane(char *const line,
-			   StringList *const curTargs)
+ParseDoDependencyTargetMundane(char *line, StringList *curTargs)
 {
 if (Dir_HasWildcards(line)) {
 	/*
@@ -1282,7 +1278,7 @@ ParseDoDependencyTargetExtraWarn(char **
 }
 
 static void
-ParseDoDependencyCheckSpec(ParseSpecial const specType)
+ParseDoDependencyCheckSpec(ParseSpecial specType)
 {
 switch (specType) {
 default:
@@ -1308,8 +1304,7 @@ ParseDoDependencyCheckSpec(ParseSpecial 
 }
 
 static Boolean
-ParseDoDependencyParseOp(char **const pp, const char *const lstart,
-			 GNodeType *const out_op)
+ParseDoDependencyParseOp(char **pp, const char *lstart, GNodeType *out_op)
 {
 const char *cp = *pp;
 
@@ -1351,8 +1346,7 @@ ClearPaths(SearchPathList *paths)
 }
 
 static void
-ParseDoDependencySourcesEmpty(ParseSpecial const specType,
-			  SearchPathList *const paths)
+ParseDoDependencySourcesEmpty(ParseSpecial specType, SearchPathList *paths)
 {
 switch (specType) {
 case Suffixes:
@@ -1418,27 +1412,27 @@ AddToPaths(const char *dir, SearchPathLi
  * and will cause make to do a new chdir to that path.
  */
 static void
-ParseDoDependencySourceSpecial(ParseSpecial const specType, char *const line,
-			   SearchPathList *const paths)
+ParseDoDependencySourceSpecial(ParseSpecial specType, char *word,
+			   SearchPathList *paths)
 {
 switch (specType) {
 case Suffixes:
-	Suff_AddSuffix(line, );
+	Suff_AddSuffix(word, );

CVS commit: src/sys/kern

2020-10-20 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Oct 20 22:31:21 UTC 2020

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

Log Message:
Include missing . Hopefully fix build for everyone except vax,
for which process_machep.c is missing.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/sys_process_lwpstatus.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_process_lwpstatus.c
diff -u src/sys/kern/sys_process_lwpstatus.c:1.2 src/sys/kern/sys_process_lwpstatus.c:1.3
--- src/sys/kern/sys_process_lwpstatus.c:1.2	Tue Oct 20 20:28:55 2020
+++ src/sys/kern/sys_process_lwpstatus.c	Tue Oct 20 22:31:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_process_lwpstatus.c,v 1.2 2020/10/20 20:28:55 christos Exp $	*/
+/*	$NetBSD: sys_process_lwpstatus.c,v 1.3 2020/10/20 22:31:20 rin Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_process_lwpstatus.c,v 1.2 2020/10/20 20:28:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process_lwpstatus.c,v 1.3 2020/10/20 22:31:20 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_process_
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef PTRACE_REGS_ALIGN



CVS commit: src/usr.bin/make

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 21:15:47 UTC 2020

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

Log Message:
make(1): improve debug messages for suff.c

Especially for the null suffix, the previous message was hard to read.
Who would guess that in "inserting (0)", there is an empty string before
the parenthesis?  The new format uses quotes to make the suffixes
clearly visible.

While here, improve some local variable names.  In a file that defines
both Suff and Src, using s for a variable is just too ambiguous.  The
variable name l can easily be confused with a 1, so name it list
instead.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.197 src/usr.bin/make/suff.c:1.198
--- src/usr.bin/make/suff.c:1.197	Tue Oct 20 20:55:35 2020
+++ src/usr.bin/make/suff.c	Tue Oct 20 21:15:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.197 2020/10/20 20:55:35 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.198 2020/10/20 21:15:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,12 +129,14 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.197 2020/10/20 20:55:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.198 2020/10/20 21:15:47 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
 #define SUFF_DEBUG2(fmt, arg1, arg2) DEBUG2(SUFF, fmt, arg1, arg2)
 #define SUFF_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(SUFF, fmt, arg1, arg2, arg3)
+#define SUFF_DEBUG4(fmt, arg1, arg2, arg3, arg4) \
+	DEBUG4(SUFF, fmt, arg1, arg2, arg3, arg4)
 
 typedef List SuffList;
 typedef ListNode SuffListNode;
@@ -297,14 +299,12 @@ SuffGNHasName(const void *gn, const void
 	/*** Maintenance Functions /
 
 static void
-SuffUnRef(void *lp, void *sp)
+SuffUnRef(SuffList *list, Suff *suff)
 {
-SuffList *l = lp;
-
-SuffListNode *ln = Lst_FindDatum(l, sp);
+SuffListNode *ln = Lst_FindDatum(list, suff);
 if (ln != NULL) {
-	Lst_Remove(l, ln);
-	((Suff *)sp)->refCount--;
+	Lst_Remove(list, ln);
+	suff->refCount--;
 }
 }
 
@@ -320,7 +320,7 @@ SuffFree(void *sp)
 if (s == emptySuff)
 	emptySuff = NULL;
 
-#ifdef notdef
+#if 0
 /* We don't delete suffixes in order, so we cannot use this */
 if (s->refCount)
 	Punt("Internal error deleting suffix `%s' with refcount = %d", s->name,
@@ -338,48 +338,43 @@ SuffFree(void *sp)
 
 /* Remove the suffix from the list, and free if it is otherwise unused. */
 static void
-SuffRemove(SuffList *l, Suff *s)
+SuffRemove(SuffList *list, Suff *suff)
 {
-SuffUnRef(l, s);
-if (s->refCount == 0) {
-	SuffUnRef(sufflist, s);
-	SuffFree(s);
+SuffUnRef(list, suff);
+if (suff->refCount == 0) {
+	SuffUnRef(sufflist, suff);
+	SuffFree(suff);
 }
 }
 
-/* Insert the suffix into the list keeping the list ordered by suffix numbers.
- *
- * Input:
- *	l		the list where in s should be inserted
- *	s		the suffix to insert
- */
+/* Insert the suffix into the list, keeping the list ordered by suffix
+ * numbers. */
 static void
-SuffInsert(SuffList *l, Suff *s)
+SuffInsert(SuffList *list, Suff *suff)
 {
-SuffListNode *ln;		/* current element in l we're examining */
-Suff  *s2 = NULL;	/* the suffix descriptor in this element */
+SuffListNode *ln;
+Suff *listSuff = NULL;
 
-for (ln = l->first; ln != NULL; ln = ln->next) {
-	s2 = ln->datum;
-	if (s2->sNum >= s->sNum) {
+for (ln = list->first; ln != NULL; ln = ln->next) {
+	listSuff = ln->datum;
+	if (listSuff->sNum >= suff->sNum)
 	break;
-	}
 }
 
-SUFF_DEBUG2("inserting %s(%d)...", s->name, s->sNum);
-
 if (ln == NULL) {
-	SUFF_DEBUG0("at end of list\n");
-	Lst_Append(l, s);
-	s->refCount++;
-	Lst_Append(s->ref, l);
-} else if (s2->sNum != s->sNum) {
-	SUFF_DEBUG2("before %s(%d)\n", s2->name, s2->sNum);
-	Lst_InsertBefore(l, ln, s);
-	s->refCount++;
-	Lst_Append(s->ref, l);
+	SUFF_DEBUG2("inserting \"%s\" (%d) at end of list\n",
+		suff->name, suff->sNum);
+	Lst_Append(list, suff);
+	suff->refCount++;
+	Lst_Append(suff->ref, list);
+} else if (listSuff->sNum != suff->sNum) {
+	SUFF_DEBUG4("inserting \"%s\" (%d) before \"%s\" (%d)\n",
+		suff->name, suff->sNum, listSuff->name, listSuff->sNum);
+	Lst_InsertBefore(list, ln, suff);
+	suff->refCount++;
+	Lst_Append(suff->ref, list);
 } else {
-	SUFF_DEBUG0("already there\n");
+	SUFF_DEBUG2("\"%s\" (%d) is already there\n", suff->name, suff->sNum);
 }
 }
 



CVS commit: src/usr.bin/make

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 20:55:35 UTC 2020

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

Log Message:
make(1): inline SuffSuffIsPrefix into SuffParseTransform


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.196 src/usr.bin/make/suff.c:1.197
--- src/usr.bin/make/suff.c:1.196	Tue Oct 20 20:51:15 2020
+++ src/usr.bin/make/suff.c	Tue Oct 20 20:55:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.196 2020/10/20 20:51:15 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.197 2020/10/20 20:55:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.196 2020/10/20 20:51:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.197 2020/10/20 20:55:35 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -287,15 +287,6 @@ FindSuffByName(const char *name)
 return NULL;
 }
 
-/* See if the suffix name is a prefix of the string. Care must be taken when
- * using this to search for transformations and what-not, since there could
- * well be two suffixes, one of which is a prefix of the other... */
-static Boolean
-SuffSuffIsPrefix(const void *s, const void *str)
-{
-return SuffStrIsPrefix(((const Suff *)s)->name, str) != NULL;
-}
-
 /* See if the graph node has the desired name. */
 static Boolean
 SuffGNHasName(const void *gn, const void *desiredName)
@@ -451,7 +442,8 @@ SuffParseTransform(const char *str, Suff
  */
 for (ln = sufflist->first; ln != NULL; ln = ln->next) {
 	Suff *src = ln->datum;
-if (!SuffSuffIsPrefix(src, str))
+
+	if (SuffStrIsPrefix(src->name, str) == NULL)
 	continue;
 
 	if (str[src->nameLen] == '\0') {



CVS commit: src/usr.bin/make

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 20:51:15 UTC 2020

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

Log Message:
make(1): untangle SuffParseTransform

That function was probably not meant to be a brain-twister, but the
convoluted loop combined with Lst_Find/Lst_FindFrom and the deeply
indented second pass for the single suffix made the code harder to
understand than necessary.

No functional change intended, that's why I had to split and enable the
test suffixes.mk first.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.195 src/usr.bin/make/suff.c:1.196
--- src/usr.bin/make/suff.c:1.195	Mon Oct 19 21:57:37 2020
+++ src/usr.bin/make/suff.c	Tue Oct 20 20:51:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.195 2020/10/19 21:57:37 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.196 2020/10/20 20:51:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.195 2020/10/19 21:57:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.196 2020/10/20 20:51:15 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -431,29 +431,17 @@ Suff_ClearSuffixes(void)
 suffNull->flags = SUFF_NULL;
 }
 
-/* Parse a transformation string to find its two component suffixes.
+/* Parse a transformation string such as ".c.o" to find its two component
+ * suffixes (the source ".c" and the target ".o").  If there are no such
+ * suffixes, try a single-suffix transformation as well.
  *
- * Input:
- *	str		String being parsed
- *	out_src		Place to store source of trans.
- *	out_targ	Place to store target of trans.
- *
- * Results:
- *	TRUE if the string is a valid transformation, FALSE otherwise.
+ * Return TRUE if the string is a valid transformation.
  */
 static Boolean
 SuffParseTransform(const char *str, Suff **out_src, Suff **out_targ)
 {
-SuffListNode *srcLn;	/* element in suffix list of trans source*/
-Suff *src;			/* Source of transformation */
-const char *str2;		/* Extra pointer (maybe target suffix) */
-SuffListNode *singleLn;	/* element in suffix list of any suffix
- * that exactly matches str */
-Suff *single = NULL;	/* Source of possible transformation to
- * null suffix */
-
-srcLn = NULL;
-singleLn = NULL;
+SuffListNode *ln;
+Suff *singleSrc = NULL;
 
 /*
  * Loop looking first for a suffix that matches the start of the
@@ -461,39 +449,15 @@ SuffParseTransform(const char *str, Suff
  * we can find two that meet these criteria, we've successfully
  * parsed the string.
  */
-for (;;) {
-	if (srcLn == NULL) {
-	srcLn = Lst_Find(sufflist, SuffSuffIsPrefix, str);
-	} else {
-	srcLn = Lst_FindFrom(sufflist, srcLn->next, SuffSuffIsPrefix, str);
-	}
-	if (srcLn == NULL) {
-	/*
-	 * Ran out of source suffixes -- no such rule
-	 */
-	if (singleLn != NULL) {
-		/*
-		 * Not so fast Mr. Smith! There was a suffix that encompassed
-		 * the entire string, so we assume it was a transformation
-		 * to the null suffix (thank you POSIX). We still prefer to
-		 * find a double rule over a singleton, hence we leave this
-		 * check until the end.
-		 *
-		 * XXX: Use emptySuff over suffNull?
-		 */
-		*out_src = single;
-		*out_targ = suffNull;
-		return TRUE;
-	}
-	return FALSE;
-	}
-	src = srcLn->datum;
-	str2 = str + src->nameLen;
-	if (*str2 == '\0') {
-	single = src;
-	singleLn = srcLn;
+for (ln = sufflist->first; ln != NULL; ln = ln->next) {
+	Suff *src = ln->datum;
+if (!SuffSuffIsPrefix(src, str))
+	continue;
+
+	if (str[src->nameLen] == '\0') {
+	singleSrc = src;
 	} else {
-	Suff *targ = FindSuffByName(str2);
+	Suff *targ = FindSuffByName(str + src->nameLen);
 	if (targ != NULL) {
 		*out_src = src;
 		*out_targ = targ;
@@ -501,6 +465,22 @@ SuffParseTransform(const char *str, Suff
 	}
 	}
 }
+
+if (singleSrc != NULL) {
+	/*
+	 * Not so fast Mr. Smith! There was a suffix that encompassed
+	 * the entire string, so we assume it was a transformation
+	 * to the null suffix (thank you POSIX). We still prefer to
+	 * find a double rule over a singleton, hence we leave this
+	 * check until the end.
+	 *
+	 * XXX: Use emptySuff over suffNull?
+	 */
+	*out_src = singleSrc;
+	*out_targ = suffNull;
+	return TRUE;
+}
+return FALSE;
 }
 
 /* Return TRUE if the given string is a transformation rule, that is, a



CVS commit: src

2020-10-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 20 20:36:53 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/make: t_make.sh
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: suff-add-later.exp suff-add-later.mk
suff-clear-regular.exp suff-clear-regular.mk suff-clear-single.exp
suff-clear-single.mk suff-transform-endless.exp
suff-transform-endless.mk suff-transform-expand.exp
suff-transform-expand.mk suff-transform-select.exp
suff-transform-select.mk
Removed Files:
src/usr.bin/make/unit-tests: suffixes.exp suffixes.mk

Log Message:
make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail.  That's complicated
enough already.

PR bin/49086


To generate a diff of this commit:
cvs rdiff -u -r1.943 -r1.944 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/make/t_make.sh
cvs rdiff -u -r1.168 -r1.169 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/suff-add-later.exp \
src/usr.bin/make/unit-tests/suff-add-later.mk \
src/usr.bin/make/unit-tests/suff-clear-regular.exp \
src/usr.bin/make/unit-tests/suff-clear-regular.mk \
src/usr.bin/make/unit-tests/suff-clear-single.exp \
src/usr.bin/make/unit-tests/suff-clear-single.mk \
src/usr.bin/make/unit-tests/suff-transform-endless.exp \
src/usr.bin/make/unit-tests/suff-transform-endless.mk \
src/usr.bin/make/unit-tests/suff-transform-expand.exp \
src/usr.bin/make/unit-tests/suff-transform-expand.mk \
src/usr.bin/make/unit-tests/suff-transform-select.exp \
src/usr.bin/make/unit-tests/suff-transform-select.mk
cvs rdiff -u -r1.1 -r0 src/usr.bin/make/unit-tests/suffixes.exp
cvs rdiff -u -r1.3 -r0 src/usr.bin/make/unit-tests/suffixes.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.943 src/distrib/sets/lists/tests/mi:1.944
--- src/distrib/sets/lists/tests/mi:1.943	Sun Oct 18 16:33:18 2020
+++ src/distrib/sets/lists/tests/mi	Tue Oct 20 20:36:53 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.943 2020/10/18 16:33:18 rillig Exp $
+# $NetBSD: mi,v 1.944 2020/10/20 20:36:53 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4987,12 +4987,24 @@
 ./usr/tests/usr.bin/make/unit-tests/shell-ksh.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/shell-sh.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/shell-sh.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-add-later.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-add-later.mktests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-regular.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-regular.mk			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-single.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-single.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-main.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-main.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.mktests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/suffixes.exptests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/suffixes.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.mk			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.mk			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-select.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-select.mk			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suffixes.exptests-obsolete		obsolete
+./usr/tests/usr.bin/make/unit-tests/suffixes.mk	tests-obsolete		obsolete
 

CVS commit: src/sys/arch

2020-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 20 20:36:08 UTC 2020

Modified Files:
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/alpha/conf: files.alpha
src/sys/arch/amd64/conf: files.amd64
src/sys/arch/arm/conf: files.arm
src/sys/arch/hppa/conf: files.hppa
src/sys/arch/i386/conf: files.i386
src/sys/arch/ia64/conf: files.ia64
src/sys/arch/m68k/conf: files.m68k
src/sys/arch/mips/conf: files.mips
src/sys/arch/powerpc/conf: files.powerpc
src/sys/arch/riscv/conf: files.riscv
src/sys/arch/sh3/conf: files.sh3
src/sys/arch/sparc/conf: files.sparc
src/sys/arch/sparc64/conf: files.sparc64
src/sys/arch/usermode/conf: files.usermode

Log Message:
harmonize process_machdep.c inclusion.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.192 -r1.193 src/sys/arch/alpha/conf/files.alpha
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/amd64/conf/files.amd64
cvs rdiff -u -r1.162 -r1.163 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hppa/conf/files.hppa
cvs rdiff -u -r1.405 -r1.406 src/sys/arch/i386/conf/files.i386
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/ia64/conf/files.ia64
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/m68k/conf/files.m68k
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/mips/conf/files.mips
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/powerpc/conf/files.powerpc
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/conf/files.riscv
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/sh3/conf/files.sh3
cvs rdiff -u -r1.160 -r1.161 src/sys/arch/sparc/conf/files.sparc
cvs rdiff -u -r1.161 -r1.162 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/usermode/conf/files.usermode

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/aarch64/conf/files.aarch64
diff -u src/sys/arch/aarch64/conf/files.aarch64:1.28 src/sys/arch/aarch64/conf/files.aarch64:1.29
--- src/sys/arch/aarch64/conf/files.aarch64:1.28	Tue Sep 29 15:58:49 2020
+++ src/sys/arch/aarch64/conf/files.aarch64	Tue Oct 20 16:36:06 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.aarch64,v 1.28 2020/09/29 19:58:49 jmcneill Exp $
+#	$NetBSD: files.aarch64,v 1.29 2020/10/20 20:36:06 christos Exp $
 
 defflag opt_cpuoptions.h	AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h	AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -98,7 +98,7 @@ file	arch/aarch64/aarch64/fusu.S
 file	arch/aarch64/aarch64/idle_machdep.S
 file	arch/aarch64/aarch64/kobj_machdep.c		modular
 file	arch/aarch64/aarch64/lock_stubs.S
-file	arch/aarch64/aarch64/process_machdep.c
+file	arch/aarch64/aarch64/process_machdep.c		ptrace | coredump | procfs
 file	arch/aarch64/aarch64/procfs_machdep.c		procfs
 file	arch/aarch64/aarch64/sig_machdep.c
 file	arch/aarch64/aarch64/sys_machdep.c

Index: src/sys/arch/alpha/conf/files.alpha
diff -u src/sys/arch/alpha/conf/files.alpha:1.192 src/sys/arch/alpha/conf/files.alpha:1.193
--- src/sys/arch/alpha/conf/files.alpha:1.192	Sun Sep 27 19:59:37 2020
+++ src/sys/arch/alpha/conf/files.alpha	Tue Oct 20 16:36:07 2020
@@ -1,4 +1,4 @@
-# $NetBSD: files.alpha,v 1.192 2020/09/27 23:59:37 thorpej Exp $
+# $NetBSD: files.alpha,v 1.193 2020/10/20 20:36:07 christos Exp $
 #
 # alpha-specific configuration info
 
@@ -381,7 +381,7 @@ file	arch/alpha/alpha/machdep.c
 file	arch/alpha/alpha/mainbus.c
 file	arch/alpha/alpha/patch.c
 file	arch/alpha/alpha/pmap.c
-file	arch/alpha/alpha/process_machdep.c
+file	arch/alpha/alpha/process_machdep.c	ptrace | coredump | procfs
 file	arch/alpha/alpha/procfs_machdep.c	procfs
 file	arch/alpha/alpha/prom.c
 file	arch/alpha/alpha/sys_machdep.c

Index: src/sys/arch/amd64/conf/files.amd64
diff -u src/sys/arch/amd64/conf/files.amd64:1.118 src/sys/arch/amd64/conf/files.amd64:1.119
--- src/sys/arch/amd64/conf/files.amd64:1.118	Mon Oct 19 15:33:01 2020
+++ src/sys/arch/amd64/conf/files.amd64	Tue Oct 20 16:36:07 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.amd64,v 1.118 2020/10/19 19:33:01 christos Exp $
+#	$NetBSD: files.amd64,v 1.119 2020/10/20 20:36:07 christos Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -47,7 +47,7 @@ file	kern/subr_disk_mbr.c			disk
 file	arch/amd64/amd64/gdt.c			machdep
 file	arch/amd64/amd64/machdep.c		machdep
 file	arch/amd64/amd64/prekern.c		kaslr
-file	arch/amd64/amd64/process_machdep.c	machdep & ptrace
+file	arch/amd64/amd64/process_machdep.c	machdep & (ptrace | coredump | procfs)
 file	arch/amd64/amd64/trap.c			machdep
 file	arch/x86/x86/fpu.c			machdep
 file	arch/x86/x86/dbregs.c			machdep

Index: src/sys/arch/arm/conf/files.arm
diff -u src/sys/arch/arm/conf/files.arm:1.162 src/sys/arch/arm/conf/files.arm:1.163
--- src/sys/arch/arm/conf/files.arm:1.162	Tue Sep 29 15:58:49 2020
+++ src/sys/arch/arm/conf/files.arm	Tue Oct 20 16:36:07 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.arm,v 1.162 2020/09/29 19:58:49 

CVS commit: src/sys

2020-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 20 20:28:55 UTC 2020

Modified Files:
src/sys/kern: sys_process_lwpstatus.c sys_ptrace_common.c
src/sys/sys: ptrace.h

Log Message:
Basic register read/write functionality and lwp setting are always provided
by the kernel because they are needed by multiple things
(ptrace/procfs/coredump), so move them to sys_process_lwpstatus (this file
should be renamed to sys_process_common.c?)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/sys_process_lwpstatus.c
cvs rdiff -u -r1.86 -r1.87 src/sys/kern/sys_ptrace_common.c
cvs rdiff -u -r1.71 -r1.72 src/sys/sys/ptrace.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/kern/sys_process_lwpstatus.c
diff -u src/sys/kern/sys_process_lwpstatus.c:1.1 src/sys/kern/sys_process_lwpstatus.c:1.2
--- src/sys/kern/sys_process_lwpstatus.c:1.1	Fri Jan  3 22:46:19 2020
+++ src/sys/kern/sys_process_lwpstatus.c	Tue Oct 20 16:28:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_process_lwpstatus.c,v 1.1 2020/01/04 03:46:19 kamil Exp $	*/
+/*	$NetBSD: sys_process_lwpstatus.c,v 1.2 2020/10/20 20:28:55 christos Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,19 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_process_lwpstatus.c,v 1.1 2020/01/04 03:46:19 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process_lwpstatus.c,v 1.2 2020/10/20 20:28:55 christos Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_ptrace.h"
+#include "opt_ktrace.h"
+#include "opt_pax.h"
+#include "opt_compat_netbsd32.h"
+#endif
+
+#if defined(__HAVE_COMPAT_NETBSD32) && !defined(COMPAT_NETBSD32) \
+&& !defined(_RUMPKERNEL)
+#define COMPAT_NETBSD32
+#endif
 
 #include 
 #include 
@@ -35,6 +47,9 @@ __KERNEL_RCSID(0, "$NetBSD: sys_process_
 #include 
 #include 
 
+#ifndef PTRACE_REGS_ALIGN
+#define PTRACE_REGS_ALIGN /* nothing */
+#endif
 
 void
 ptrace_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
@@ -67,3 +82,203 @@ process_read_lwpstatus(struct lwp *l, st
 
 	ptrace_read_lwpstatus(l, pls);
 }
+
+int
+ptrace_update_lwp(struct proc *t, struct lwp **lt, lwpid_t lid)
+{
+	if (lid == 0 || lid == (*lt)->l_lid || t->p_nlwps == 1)
+		return 0;
+
+	mutex_enter(t->p_lock);
+	lwp_delref2(*lt);
+
+	*lt = lwp_find(t, lid);
+	if (*lt == NULL) {
+		mutex_exit(t->p_lock);
+		return ESRCH;
+	}
+
+	if ((*lt)->l_flag & LW_SYSTEM) {
+		mutex_exit(t->p_lock);
+		*lt = NULL;
+		return EINVAL;
+	}
+
+	lwp_addref(*lt);
+	mutex_exit(t->p_lock);
+
+	return 0;
+}
+
+int
+process_validfpregs(struct lwp *l)
+{
+
+#if defined(PT_SETFPREGS) || defined(PT_GETFPREGS)
+	return (l->l_flag & LW_SYSTEM) == 0;
+#else
+	return 0;
+#endif
+}
+
+int
+process_validregs(struct lwp *l)
+{
+
+#if defined(PT_SETREGS) || defined(PT_GETREGS)
+	return (l->l_flag & LW_SYSTEM) == 0;
+#else
+	return 0;
+#endif
+}
+
+int
+process_validdbregs(struct lwp *l)
+{
+
+#if defined(PT_SETDBREGS) || defined(PT_GETDBREGS)
+	return (l->l_flag & LW_SYSTEM) == 0;
+#else
+	return 0;
+#endif
+}
+
+#ifdef PT_REGISTERS
+static int
+proc_regio(struct lwp *l, struct uio *uio, size_t ks, ptrace_regrfunc_t r,
+ptrace_regwfunc_t w)
+{
+	char buf[1024] PTRACE_REGS_ALIGN;
+	int error;
+	char *kv;
+	size_t kl;
+
+	if (ks > sizeof(buf))
+		return E2BIG;
+
+	if (uio->uio_offset < 0 || uio->uio_offset > (off_t)ks)
+		return EINVAL;
+
+	kv = buf + uio->uio_offset;
+	kl = ks - uio->uio_offset;
+
+	if (kl > uio->uio_resid)
+		kl = uio->uio_resid;
+
+	error = (*r)(l, buf, );
+	if (error == 0)
+		error = uiomove(kv, kl, uio);
+	if (error == 0 && uio->uio_rw == UIO_WRITE) {
+		if (l->l_stat != LSSTOP)
+			error = EBUSY;
+		else
+			error = (*w)(l, buf, ks);
+	}
+
+	uio->uio_offset = 0;
+	return error;
+}
+#endif
+
+int
+process_doregs(struct lwp *curl /*tracer*/,
+struct lwp *l /*traced*/,
+struct uio *uio)
+{
+#if defined(PT_GETREGS) || defined(PT_SETREGS)
+	size_t s;
+	ptrace_regrfunc_t r;
+	ptrace_regwfunc_t w;
+
+#ifdef COMPAT_NETBSD32
+	const bool pk32 = (curl->l_proc->p_flag & PK_32) != 0;
+
+	if (__predict_false(pk32)) {
+		if ((l->l_proc->p_flag & PK_32) == 0) {
+			// 32 bit tracer can't trace 64 bit process
+			return EINVAL;
+		}
+		s = sizeof(process_reg32);
+		r = __FPTRCAST(ptrace_regrfunc_t, process_read_regs32);
+		w = __FPTRCAST(ptrace_regwfunc_t, process_write_regs32);
+	} else
+#endif
+	{
+		s = sizeof(struct reg);
+		r = __FPTRCAST(ptrace_regrfunc_t, process_read_regs);
+		w = __FPTRCAST(ptrace_regwfunc_t, process_write_regs);
+	}
+	return proc_regio(l, uio, s, r, w);
+#else
+	return EINVAL;
+#endif
+}
+
+int
+process_dofpregs(struct lwp *curl /*tracer*/,
+struct lwp *l /*traced*/,
+struct uio *uio)
+{
+#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
+	size_t s;
+	ptrace_regrfunc_t r;
+	ptrace_regwfunc_t w;
+
+#ifdef COMPAT_NETBSD32
+	const bool pk32 = (curl->l_proc->p_flag & PK_32) != 0;
+
+	if 

CVS commit: src/sys

2020-10-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Oct 20 18:17:58 UTC 2020

Modified Files:
src/sys/arch/mac68k/dev: if_mc.c
src/sys/arch/macppc/dev: am79c950.c
src/sys/dev/ic: am7990.c am79900.c

Log Message:
le(4): add link status change reporting to drivers which support it

Reviewed by thorpej@
Tested by martin@


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/mac68k/dev/if_mc.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/macppc/dev/am79c950.c
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/ic/am7990.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ic/am79900.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/mac68k/dev/if_mc.c
diff -u src/sys/arch/mac68k/dev/if_mc.c:1.55 src/sys/arch/mac68k/dev/if_mc.c:1.56
--- src/sys/arch/mac68k/dev/if_mc.c:1.55	Thu Jan 30 06:30:52 2020
+++ src/sys/arch/mac68k/dev/if_mc.c	Tue Oct 20 18:17:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mc.c,v 1.55 2020/01/30 06:30:52 martin Exp $	*/
+/*	$NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.55 2020/01/30 06:30:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -455,6 +455,7 @@ struct mc_softc *sc = arg;
 	 * Pretend we have carrier; if we don't this will be cleared
 	 * shortly.
 	 */
+	const int ocarrier = sc->sc_havecarrier;
 	sc->sc_havecarrier = 1;
 
 	if (ir & XMTINT)
@@ -462,6 +463,10 @@ struct mc_softc *sc = arg;
 
 	if (ir & RCVINT)
 		mc_rint(sc);
+
+	if (sc->sc_havecarrier != ocarrier)
+		if_link_state_change(>sc_if,
+		sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
 }
 
 integrate void

Index: src/sys/arch/macppc/dev/am79c950.c
diff -u src/sys/arch/macppc/dev/am79c950.c:1.49 src/sys/arch/macppc/dev/am79c950.c:1.50
--- src/sys/arch/macppc/dev/am79c950.c:1.49	Tue Feb  4 13:47:34 2020
+++ src/sys/arch/macppc/dev/am79c950.c	Tue Oct 20 18:17:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: am79c950.c,v 1.49 2020/02/04 13:47:34 martin Exp $	*/
+/*	$NetBSD: am79c950.c,v 1.50 2020/10/20 18:17:58 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.49 2020/02/04 13:47:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.50 2020/10/20 18:17:58 roy Exp $");
 
 #include "opt_inet.h"
 
@@ -458,6 +458,7 @@ mcintr(void *arg)
 	 * Pretend we have carrier; if we don't this will be cleared
 	 * shortly.
 	 */
+	const int ocarrier = sc->sc_havecarrier;
 	sc->sc_havecarrier = 1;
 
 	if (ir & XMTINT)
@@ -466,6 +467,10 @@ mcintr(void *arg)
 	if (ir & RCVINT)
 		mc_rint(sc);
 
+	if (sc->sc_havecarrier != ocarrier)
+		if_link_state_change(>sc_if,
+		sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
+
 	return 1;
 }
 

Index: src/sys/dev/ic/am7990.c
diff -u src/sys/dev/ic/am7990.c:1.82 src/sys/dev/ic/am7990.c:1.83
--- src/sys/dev/ic/am7990.c:1.82	Thu Mar 19 02:31:28 2020
+++ src/sys/dev/ic/am7990.c	Tue Oct 20 18:17:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: am7990.c,v 1.82 2020/03/19 02:31:28 thorpej Exp $	*/
+/*	$NetBSD: am7990.c,v 1.83 2020/10/20 18:17:58 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.82 2020/03/19 02:31:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.83 2020/10/20 18:17:58 roy Exp $");
 
 #include 
 #include 
@@ -435,6 +435,7 @@ am7990_intr(void *arg)
 	 * Pretend we have carrier; if we don't this will be cleared
 	 * shortly.
 	 */
+	const int ocarrier = sc->sc_havecarrier;
 	sc->sc_havecarrier = 1;
 
 	if (isr & LE_C0_RINT)
@@ -442,6 +443,10 @@ am7990_intr(void *arg)
 	if (isr & LE_C0_TINT)
 		am7990_tint(sc);
 
+	if (sc->sc_havecarrier != ocarrier)
+		if_link_state_change(ifp,
+		sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
+
 	rnd_add_uint32(>rnd_source, isr);
 
 	return (1);

Index: src/sys/dev/ic/am79900.c
diff -u src/sys/dev/ic/am79900.c:1.30 src/sys/dev/ic/am79900.c:1.31
--- src/sys/dev/ic/am79900.c:1.30	Thu Mar 19 02:31:28 2020
+++ src/sys/dev/ic/am79900.c	Tue Oct 20 18:17:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: am79900.c,v 1.30 2020/03/19 02:31:28 thorpej Exp $	*/
+/*	$NetBSD: am79900.c,v 1.31 2020/10/20 18:17:58 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am79900.c,v 1.30 2020/03/19 02:31:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am79900.c,v 1.31 2020/10/20 18:17:58 roy Exp $");
 
 #include 
 #include 
@@ -456,6 +456,7 @@ am79900_intr(void *arg)
 	 * Pretend we have carrier; if we don't this will be cleared
 	 * shortly.
 	 */
+	const int ocarrier = sc->sc_havecarrier;
 	sc->sc_havecarrier = 1;
 
 	if (isr & LE_C0_RINT)
@@ -463,6 

CVS commit: src/sys/kern

2020-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 20 13:47:30 UTC 2020

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

Log Message:
only define hooks for 32 bit cores if we need them.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/kern/kern_core.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/kern_core.c
diff -u src/sys/kern/kern_core.c:1.31 src/sys/kern/kern_core.c:1.32
--- src/sys/kern/kern_core.c:1.31	Mon Oct 19 15:33:02 2020
+++ src/sys/kern/kern_core.c	Tue Oct 20 09:47:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_core.c,v 1.31 2020/10/19 19:33:02 christos Exp $	*/
+/*	$NetBSD: kern_core.c,v 1.32 2020/10/20 13:47:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.31 2020/10/19 19:33:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.32 2020/10/20 13:47:30 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -88,7 +88,9 @@ coredump_modcmd(modcmd_t cmd, void *arg)
 		MODULE_HOOK_SET(coredump_write_hook, coredump_write);
 		MODULE_HOOK_SET(coredump_offset_hook, coredump_offset);
 		MODULE_HOOK_SET(coredump_netbsd_hook, real_coredump_netbsd);
+#if !defined(_LP64) || defined(COMPAT_NETBSD32)
 		MODULE_HOOK_SET(coredump_elf32_hook, real_coredump_elf32);
+#endif
 #ifdef _LP64
 		MODULE_HOOK_SET(coredump_elf64_hook, real_coredump_elf64);
 #endif
@@ -103,7 +105,9 @@ coredump_modcmd(modcmd_t cmd, void *arg)
 #ifdef _LP64
 		MODULE_HOOK_UNSET(coredump_elf64_hook);
 #endif
+#if !defined(_LP64) || defined(COMPAT_NETBSD32)
 		MODULE_HOOK_UNSET(coredump_elf32_hook);
+#endif
 		MODULE_HOOK_UNSET(coredump_netbsd_hook);
 		MODULE_HOOK_UNSET(coredump_offset_hook);
 		MODULE_HOOK_UNSET(coredump_write_hook);



CVS commit: src/sys/kern

2020-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 20 13:16:26 UTC 2020

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

Log Message:
Fix build for _LP64 machines that don't have COMPAT_NETBSD32 (alpha, ia64)


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/kern/kern_sig.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/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.391 src/sys/kern/kern_sig.c:1.392
--- src/sys/kern/kern_sig.c:1.391	Mon Oct 19 15:33:02 2020
+++ src/sys/kern/kern_sig.c	Tue Oct 20 09:16:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.391 2020/10/19 19:33:02 christos Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.392 2020/10/20 13:16:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.391 2020/10/19 19:33:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.392 2020/10/20 13:16:26 christos Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -2356,6 +2356,7 @@ coredump_netbsd(struct lwp *l, struct co
 	return retval;
 }
 
+#if !defined(_LP64) || defined(COMPAT_NETBSD32)
 int
 coredump_elf32(struct lwp *l, struct coredump_iostate *iocookie)
 {
@@ -2364,6 +2365,7 @@ coredump_elf32(struct lwp *l, struct cor
 	MODULE_HOOK_CALL(coredump_elf32_hook, (l, iocookie), ENOSYS, retval);
 	return retval;
 }
+#endif
 
 #ifdef _LP64
 int



CVS commit: src/sys/external/bsd/drm2/dist/drm/radeon

2020-10-20 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Tue Oct 20 09:53:59 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_atombios_dp.c

Log Message:
add header file hack to resolve conflict of ALIGN macro. (on __BIG_ENDIAN)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.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/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c:1.2 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c:1.2	Tue Jan  7 13:51:38 2020
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c	Tue Oct 20 09:53:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_atombios_dp.c,v 1.2 2020/01/07 13:51:38 msaitoh Exp $	*/
+/*	$NetBSD: radeon_atombios_dp.c,v 1.3 2020/10/20 09:53:59 ryo Exp $	*/
 
 /*
  * Copyright 2007-8 Advanced Micro Devices, Inc.
@@ -27,7 +27,7 @@
  *  Jerome Glisse
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_atombios_dp.c,v 1.2 2020/01/07 13:51:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_atombios_dp.c,v 1.3 2020/10/20 09:53:59 ryo Exp $");
 
 #include 
 #include 
@@ -37,6 +37,8 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_atomb
 #include "atom-bits.h"
 #include 
 
+#include 
+
 /* move these to drm_dp_helper.c/h */
 #define DP_LINK_CONFIGURATION_SIZE 9
 #define DP_DPCD_SIZE DP_RECEIVER_CAP_SIZE



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 08:57:45 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_AUDIOINFO_EX as an alias of SNDCTL_AUDIOINFO


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libossaudio/soundcard.h

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

Modified files:

Index: src/lib/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.53 src/lib/libossaudio/ossaudio.c:1.54
--- src/lib/libossaudio/ossaudio.c:1.53	Tue Oct 20 06:53:37 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Oct 20 08:57:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.54 2020/10/20 08:57:45 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.54 2020/10/20 08:57:45 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1045,6 +1045,13 @@ mixer_oss4_ioctl(int fd, unsigned long c
 
 	switch (com) {
 	case SNDCTL_AUDIOINFO:
+	/*
+	 * SNDCTL_AUDIOINFO_EX is intended for underlying hardware devices
+	 * that are to be opened in "exclusive mode" (bypassing the normal
+	 * kernel mixer for exclusive control). NetBSD does not support
+	 * bypassing the kernel mixer, so it's an alias of SNDCTL_AUDIOINFO.
+	 */
+	case SNDCTL_AUDIOINFO_EX:
 	case SNDCTL_ENGINEINFO:
 		devno = 0;
 		tmpai = (struct oss_audioinfo*)argp;

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.29 src/lib/libossaudio/soundcard.h:1.30
--- src/lib/libossaudio/soundcard.h:1.29	Tue Oct 20 06:33:52 2020
+++ src/lib/libossaudio/soundcard.h	Tue Oct 20 08:57:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.29 2020/10/20 06:33:52 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.30 2020/10/20 08:57:45 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -418,6 +418,7 @@ typedef struct oss_audioinfo {
 #define SNDCTL_MIX_ENUMINFO	_IOWR ('X',8, oss_mixer_enuminfo)
 #define SNDCTL_MIXERINFO	_IOWR ('X',10, oss_mixerinfo)
 #define SNDCTL_ENGINEINFO	_IOWR ('X',12, oss_audioinfo)
+#define SNDCTL_AUDIOINFO_EX	_IOWR ('X',13, oss_audioinfo)
 #define SNDCTL_MIX_DESCRIPTION	_IOWR ('X',14, oss_mixer_enuminfo)
 
 #define MIXT_DEVROOT	 	0 /* Used for default classes */



CVS commit: src/sys/dev/mii

2020-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct 20 08:53:34 UTC 2020

Modified Files:
src/sys/dev/mii: makphy.c

Log Message:
Add Intel I347-AT4.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/mii/makphy.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/mii/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.66 src/sys/dev/mii/makphy.c:1.67
--- src/sys/dev/mii/makphy.c:1.66	Mon Aug  3 07:25:59 2020
+++ src/sys/dev/mii/makphy.c	Tue Oct 20 08:53:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.66 2020/08/03 07:25:59 msaitoh Exp $	*/
+/*	$NetBSD: makphy.c,v 1.67 2020/10/20 08:53:34 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.66 2020/08/03 07:25:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.67 2020/10/20 08:53:34 msaitoh Exp $");
 
 #include 
 #include 
@@ -117,6 +117,7 @@ static const struct mii_phydesc makphys[
 	MII_PHY_DESC(xxMARVELL, E3016),
 	MII_PHY_DESC(xxMARVELL, E3082),
 	MII_PHY_DESC(xxMARVELL, PHYG65G),
+	MII_PHY_DESC(xxMARVELL, I347),
 	MII_PHY_END,
 };
 



CVS commit: src/lib/libossaudio

2020-10-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Oct 20 07:52:05 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libossaudio/ossaudio.3

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

Modified files:

Index: src/lib/libossaudio/ossaudio.3
diff -u src/lib/libossaudio/ossaudio.3:1.26 src/lib/libossaudio/ossaudio.3:1.27
--- src/lib/libossaudio/ossaudio.3:1.26	Tue Oct 20 06:43:55 2020
+++ src/lib/libossaudio/ossaudio.3	Tue Oct 20 07:52:04 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.26 2020/10/20 06:43:55 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.27 2020/10/20 07:52:04 wiz Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -115,7 +115,7 @@ is not currently implemented as in OSSv4
 global volume.
 Applications need to provide samples with the appropriate gain.
 .It
-Linux, 
+Linux,
 .Fx ,
 and Solaris provide
 .Pa /dev/dsp



CVS commit: src/doc

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 07:52:46 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
doc/CHANGES: Added support for the OSSv4 Mixer API


To generate a diff of this commit:
cvs rdiff -u -r1.2748 -r1.2749 src/doc/CHANGES

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
diff -u src/doc/CHANGES:1.2748 src/doc/CHANGES:1.2749
--- src/doc/CHANGES:1.2748	Sat Oct 17 16:25:24 2020
+++ src/doc/CHANGES	Tue Oct 20 07:52:45 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2748 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2749 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -295,3 +295,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	dhcpcd: Update to version 9.3.1 [roy 20201012]
 	tzdata updated to 2020c  [kre 20201017]
 	tzcode: Updated to 2020c. [christos 20201017]
+	ossaudio(3): Added support for the OSSv4 Mixer API [nia 20201017]



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:53:38 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Plug a fd leak in the new mixer API


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libossaudio/ossaudio.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/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.52 src/lib/libossaudio/ossaudio.c:1.53
--- src/lib/libossaudio/ossaudio.c:1.52	Mon Oct 19 10:28:47 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Oct 20 06:53:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1328,9 +1328,9 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			return newfd;
 		mdi.index = ei->ctrl - 1;
 		retval = ioctl(newfd, AUDIO_MIXER_DEVINFO, );
+		tmperrno = errno;
+		close(newfd);
 		if (retval < 0) {
-			tmperrno = errno;
-			close(newfd);
 			errno = tmperrno;
 			return retval;
 		}
@@ -1343,7 +1343,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 ei->strindex[i] = noffs;
 len = strlen(mdi.un.e.member[i].label.name) + 1;
 if ((noffs + len) >= sizeof(ei->strings)) {
-close(newfd);
 errno = ENOMEM;
 return -1;
 }
@@ -1359,7 +1358,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 ei->strindex[i] = noffs;
 len = strlen(mdi.un.s.member[i].label.name) + 1;
 if ((noffs + len) >= sizeof(ei->strings)) {
-close(newfd);
 errno = ENOMEM;
 return -1;
 }
@@ -1369,7 +1367,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			}
 			break;
 		default:
-			close(newfd);
 			errno = EINVAL;
 			return -1;
 		}



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:43:56 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: Bump date


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libossaudio/ossaudio.3

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

Modified files:

Index: src/lib/libossaudio/ossaudio.3
diff -u src/lib/libossaudio/ossaudio.3:1.25 src/lib/libossaudio/ossaudio.3:1.26
--- src/lib/libossaudio/ossaudio.3:1.25	Tue Oct 20 06:43:34 2020
+++ src/lib/libossaudio/ossaudio.3	Tue Oct 20 06:43:55 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.25 2020/10/20 06:43:34 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.26 2020/10/20 06:43:55 nia Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 16, 2020
+.Dd October 20, 2020
 .Dt OSSAUDIO 3
 .Os
 .Sh NAME



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:43:34 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio(3): Turn BUGS section into a list of potential compat issues


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libossaudio/ossaudio.3

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

Modified files:

Index: src/lib/libossaudio/ossaudio.3
diff -u src/lib/libossaudio/ossaudio.3:1.24 src/lib/libossaudio/ossaudio.3:1.25
--- src/lib/libossaudio/ossaudio.3:1.24	Sat Oct 17 09:04:59 2020
+++ src/lib/libossaudio/ossaudio.3	Tue Oct 20 06:43:34 2020
@@ -1,10 +1,10 @@
-.\"	$NetBSD: ossaudio.3,v 1.24 2020/10/17 09:04:59 wiz Exp $
+.\"	$NetBSD: ossaudio.3,v 1.25 2020/10/20 06:43:34 nia Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to The NetBSD Foundation
-.\" by Lennart Augustsson,
+.\" by Lennart Augustsson and Nia Alarie.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -50,7 +50,7 @@ interfaces for new programs, and this em
 building code written for other operating systems.
 .Ss Mixer Control Map
 The following table summarizes the mappings from native interface
-device names to OSS mixer controls.
+device names to OSSv3 mixer controls.
 .Bl -column ".Sy Native Device Name" "SOUND_MIXER_SPEAKER"
 .It Sy "Native Device Name" Ta Sy "OSS Mixer Control"
 .It *.mic Ta SOUND_MIXER_MIC
@@ -98,16 +98,24 @@ It remains the preferred API in
 .Fx
 and Solaris, and a large body of code exists supporting it.
 .Sh BUGS
-The emulation is incomplete, covering most of OSSv3 and some of OSSv4.
-Some obscure features are not included, but the essential ioctls used
-by the majority of software are covered.
-.Pp
-The emulation uses a #define for
-.Fn ioctl
-so some obscure programs
-can fail to compile.
-.Pp
-Linux,
+.Bl -bullet
+.It
+The emulation is incomplete.
+Some less popular features are not emulated (e.g. sync groups), but the
+essential ioctls used by the majority of software are covered.
+.It
+.Nx
+.Dv AUDIO_MIXER_SET
+control types cannot be accurately represented in the OSSv4 mixer API,
+so are treated as enums.
+.It
+Per-stream volume (i.e.
+.Dv SNDCTL_DSP_SETPLAYVOL )
+is not currently implemented as in OSSv4, and will instead modify the
+global volume.
+Applications need to provide samples with the appropriate gain.
+.It
+Linux, 
 .Fx ,
 and Solaris provide
 .Pa /dev/dsp
@@ -120,7 +128,7 @@ and
 devices this compatibility layer must be accessed through on
 .Nx .
 However, changing this is typically trivial when porting programs.
-.Pp
+.It
 The emulation only covers
 .Fn ioctl ,
 there are other differences as well.
@@ -131,3 +139,9 @@ whereas
 .Nx 1.3
 returns
 .Dv EAGAIN .
+.It
+The emulation uses a #define for
+.Fn ioctl
+so some obscure programs
+can fail to compile.
+.El



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:33:52 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
ossaudio(3): Add some endian-specific U16 formats

for compatibility with FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libossaudio/soundcard.h

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

Modified files:

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.28 src/lib/libossaudio/soundcard.h:1.29
--- src/lib/libossaudio/soundcard.h:1.28	Mon Oct 19 10:28:47 2020
+++ src/lib/libossaudio/soundcard.h	Tue Oct 20 06:33:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.28 2020/10/19 10:28:47 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.29 2020/10/20 06:33:52 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -111,6 +111,8 @@
 /* Need native 16 bit format which depends on byte order */
 #include 
 #if _BYTE_ORDER == _LITTLE_ENDIAN
+#define  AFMT_U16_NE AFMT_U16_LE
+#define  AFMT_U16_OE AFMT_U16_BE
 #define  AFMT_S16_NE AFMT_S16_LE
 #define  AFMT_S16_OE AFMT_S16_BE
 #define  AFMT_S24_NE AFMT_S24_LE
@@ -118,6 +120,8 @@
 #define  AFMT_S32_NE AFMT_S32_LE
 #define  AFMT_S32_OE AFMT_S32_BE
 #else
+#define  AFMT_U16_NE AFMT_U16_BE
+#define  AFMT_U16_OE AFMT_U16_LE
 #define  AFMT_S16_NE AFMT_S16_BE
 #define  AFMT_S16_OE AFMT_S16_LE
 #define  AFMT_S24_NE AFMT_S24_BE