CVS commit: src/distrib/dreamcast/ramdisk

2020-11-27 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Nov 28 05:16:07 UTC 2020

Modified Files:
src/distrib/dreamcast/ramdisk: Makefile

Log Message:
Try to shrink ramdiskbin binary.

-Os
-rwxr-xr-x  1 tsutsui  wheel  1371212 Nov 28 14:09 obj.dreamcast/ramdiskbin*

-Os -fno-unwind-tables
-rwxr-xr-x  1 tsutsui  wheel  1366000 Nov 28 14:10 obj.dreamcast/ramdiskbin*

-Os -fno-unwind-tables -DNDEBUG
-rwxr-xr-x  1 tsutsui  wheel  1359700 Nov 28 14:11 obj.dreamcast/ramdiskbin*


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/distrib/dreamcast/ramdisk/Makefile

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

Modified files:

Index: src/distrib/dreamcast/ramdisk/Makefile
diff -u src/distrib/dreamcast/ramdisk/Makefile:1.15 src/distrib/dreamcast/ramdisk/Makefile:1.16
--- src/distrib/dreamcast/ramdisk/Makefile:1.15	Sun Dec 29 18:26:17 2019
+++ src/distrib/dreamcast/ramdisk/Makefile	Sat Nov 28 05:16:06 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.15 2019/12/29 18:26:17 christos Exp $
+#	$NetBSD: Makefile,v 1.16 2020/11/28 05:16:06 tsutsui Exp $
 
 .include 
 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
@@ -8,7 +8,8 @@ IMAGESIZE=	1440k
 MAKEFS_FLAGS+=	-f 15
 
 WARNS=		1
-DBG=		-Os
+DBG=		-Os -fno-unwind-tables
+DBG+=		-DNDEBUG		# to remove assert(3) macro
 
 CRUNCHBIN=	ramdiskbin
 LISTS=		${.CURDIR}/list # ${DISTRIBDIR}/common/list.sysinst



CVS commit: src/sys/uvm

2020-11-27 Thread Yorick Hardy
Module Name:src
Committed By:   yhardy
Date:   Fri Nov 27 22:32:43 UTC 2020

Modified Files:
src/sys/uvm: uvm_mremap.c

Log Message:
uvm_mremap: reference the appropriate backing object.

The previous approach was appropriate for anonymous
memory and device objects, which continue to work in
the same way.

OK: chs@
Fixes: PR 55237


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/uvm/uvm_mremap.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/uvm/uvm_mremap.c
diff -u src/sys/uvm/uvm_mremap.c:1.20 src/sys/uvm/uvm_mremap.c:1.21
--- src/sys/uvm/uvm_mremap.c:1.20	Sun Feb 23 15:46:43 2020
+++ src/sys/uvm/uvm_mremap.c	Fri Nov 27 22:32:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_mremap.c,v 1.20 2020/02/23 15:46:43 ad Exp $	*/
+/*	$NetBSD: uvm_mremap.c,v 1.21 2020/11/27 22:32:43 yhardy Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2009 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_mremap.c,v 1.20 2020/02/23 15:46:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_mremap.c,v 1.21 2020/11/27 22:32:43 yhardy Exp $");
 
 #include 
 #include 
@@ -80,10 +80,8 @@ uvm_mapent_extend(struct vm_map *map, va
 			error = E2BIG; /* XXX */
 			goto done;
 		}
-		rw_enter(uobj->vmobjlock, RW_WRITER);
-		KASSERT(uobj->uo_refs > 0);
-		atomic_inc_uint(>uo_refs);
-		rw_exit(uobj->vmobjlock);
+		if (uobj->pgops->pgo_reference)
+			uobj->pgops->pgo_reference(uobj);
 		reserved_entry->object.uvm_obj = uobj;
 		reserved_entry->offset = newoffset;
 	}



CVS commit: src/sys/kern

2020-11-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 27 20:11:33 UTC 2020

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

Log Message:
ipi: Membar audit.


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

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

Modified files:

Index: src/sys/kern/subr_ipi.c
diff -u src/sys/kern/subr_ipi.c:1.8 src/sys/kern/subr_ipi.c:1.9
--- src/sys/kern/subr_ipi.c:1.8	Tue Sep  8 16:00:35 2020
+++ src/sys/kern/subr_ipi.c	Fri Nov 27 20:11:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_ipi.c,v 1.8 2020/09/08 16:00:35 riastradh Exp $	*/
+/*	$NetBSD: subr_ipi.c,v 1.9 2020/11/27 20:11:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.8 2020/09/08 16:00:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.9 2020/11/27 20:11:33 riastradh Exp $");
 
 #include 
 #include 
@@ -187,8 +187,11 @@ ipi_mark_pending(u_int ipi_id, struct cp
 	KASSERT(ipi_id < IPI_MAXREG);
 	KASSERT(kpreempt_disabled());
 
-	/* Mark as pending and send an IPI. */
-	if (membar_consumer(), (ci->ci_ipipend[i] & bitm) == 0) {
+	/* Mark as pending and return true if not previously marked. */
+	if ((atomic_load_acquire(>ci_ipipend[i]) & bitm) == 0) {
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+		membar_exit();
+#endif
 		atomic_or_32(>ci_ipipend[i], bitm);
 		return true;
 	}
@@ -261,6 +264,8 @@ ipi_trigger_broadcast(u_int ipi_id, bool
 
 /*
  * put_msg: insert message into the mailbox.
+ *
+ * Caller is responsible for issuing membar_exit first.
  */
 static inline void
 put_msg(ipi_mbox_t *mbox, ipi_msg_t *msg)
@@ -268,8 +273,7 @@ put_msg(ipi_mbox_t *mbox, ipi_msg_t *msg
 	int count = SPINLOCK_BACKOFF_MIN;
 again:
 	for (u_int i = 0; i < IPI_MSG_MAX; i++) {
-		if (__predict_true(mbox->msg[i] == NULL) &&
-		atomic_cas_ptr(>msg[i], NULL, msg) == NULL) {
+		if (atomic_cas_ptr(>msg[i], NULL, msg) == NULL) {
 			return;
 		}
 	}
@@ -295,12 +299,12 @@ ipi_cpu_handler(void)
 	for (u_int i = 0; i < IPI_BITWORDS; i++) {
 		uint32_t pending, bit;
 
-		if (ci->ci_ipipend[i] == 0) {
+		if (atomic_load_relaxed(>ci_ipipend[i]) == 0) {
 			continue;
 		}
 		pending = atomic_swap_32(>ci_ipipend[i], 0);
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-		membar_producer();
+		membar_enter();
 #endif
 		while ((bit = ffs(pending)) != 0) {
 			const u_int ipi_id = (i << IPI_BITW_SHIFT) | --bit;
@@ -327,10 +331,10 @@ ipi_msg_cpu_handler(void *arg __unused)
 		ipi_msg_t *msg;
 
 		/* Get the message. */
-		if ((msg = mbox->msg[i]) == NULL) {
+		if ((msg = atomic_load_acquire(>msg[i])) == NULL) {
 			continue;
 		}
-		mbox->msg[i] = NULL;
+		atomic_store_relaxed(>msg[i], NULL);
 
 		/* Execute the handler. */
 		KASSERT(msg->func);
@@ -338,7 +342,7 @@ ipi_msg_cpu_handler(void *arg __unused)
 
 		/* Ack the request. */
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-		membar_producer();
+		membar_exit();
 #endif
 		atomic_dec_uint(>_pending);
 	}
@@ -360,7 +364,9 @@ ipi_unicast(ipi_msg_t *msg, struct cpu_i
 	KASSERT(curcpu() != ci);
 
 	msg->_pending = 1;
-	membar_producer();
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+	membar_exit();
+#endif
 
 	put_msg(_mboxes[id], msg);
 	ipi_trigger(IPI_SYNCH_ID, ci);
@@ -384,7 +390,9 @@ ipi_multicast(ipi_msg_t *msg, const kcpu
 
 	local = !!kcpuset_isset(target, cpu_index(self));
 	msg->_pending = kcpuset_countset(target) - local;
-	membar_producer();
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+	membar_exit();
+#endif
 
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		cpuid_t id;
@@ -420,7 +428,9 @@ ipi_broadcast(ipi_msg_t *msg, bool skip_
 	KASSERT(kpreempt_disabled());
 
 	msg->_pending = ncpu - 1;
-	membar_producer();
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+	membar_exit();
+#endif
 
 	/* Broadcast IPIs for remote CPUs. */
 	for (CPU_INFO_FOREACH(cii, ci)) {
@@ -448,8 +458,8 @@ ipi_wait(ipi_msg_t *msg)
 {
 	int count = SPINLOCK_BACKOFF_MIN;
 
-	while (msg->_pending) {
-		KASSERT(msg->_pending < ncpu);
+	while (atomic_load_acquire(>_pending)) {
+		KASSERT(atomic_load_relaxed(>_pending) < ncpu);
 		SPINLOCK_BACKOFF(count);
 	}
 }



CVS commit: src/sys/dev/tprof

2020-11-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 27 20:10:25 UTC 2020

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

Log Message:
tprof: Use percpu rather than a MAXCPUS-element array.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/tprof/tprof.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/tprof/tprof.c
diff -u src/sys/dev/tprof/tprof.c:1.14 src/sys/dev/tprof/tprof.c:1.15
--- src/sys/dev/tprof/tprof.c:1.14	Fri Jul 13 07:56:29 2018
+++ src/sys/dev/tprof/tprof.c	Fri Nov 27 20:10:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof.c,v 1.14 2018/07/13 07:56:29 maxv Exp $	*/
+/*	$NetBSD: tprof.c,v 1.15 2020/11/27 20:10:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2008,2009,2010 YAMAMOTO Takashi,
@@ -27,20 +27,21 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.14 2018/07/13 07:56:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.15 2020/11/27 20:10:25 riastradh Exp $");
 
 #include 
 #include 
 #include 
 
-#include 
-#include 
 #include 
+#include 
+#include 
 #include 
 #include 
+#include 
 #include 
-#include 
 #include 
+#include 
 
 #include 
 #include 
@@ -97,7 +98,7 @@ static lwp_t *tprof_owner;
 static STAILQ_HEAD(, tprof_buf) tprof_list; /* L: global buffer list */
 static u_int tprof_nbuf_on_list;	/* L: # of buffers on tprof_list */
 static struct workqueue *tprof_wq;
-static tprof_cpu_t tprof_cpus[MAXCPUS] __aligned(CACHE_LINE_SIZE);
+static struct percpu *tprof_cpus __read_mostly;	/* tprof_cpu_t * */
 static u_int tprof_samples_per_buf;
 
 static tprof_backend_t *tprof_backend;	/* S: */
@@ -116,8 +117,20 @@ static struct tprof_stat tprof_stat;	/* 
 static tprof_cpu_t *
 tprof_cpu(struct cpu_info *ci)
 {
+	tprof_cpu_t **cp, *c;
 
-	return _cpus[cpu_index(ci)];
+	/*
+	 * As long as xcalls are blocked -- e.g., by kpreempt_disable
+	 * -- the percpu object will not be swapped and destroyed.  We
+	 * can't write to it, because the data may have already been
+	 * moved to a new buffer, but we can safely read from it.
+	 */
+	kpreempt_disable();
+	cp = percpu_getptr_remote(tprof_cpus, ci);
+	c = *cp;
+	kpreempt_enable();
+
+	return c;
 }
 
 static tprof_cpu_t *
@@ -132,7 +145,7 @@ tprof_buf_alloc(void)
 {
 	tprof_buf_t *new;
 	u_int size = tprof_samples_per_buf;
-	
+
 	new = kmem_alloc(TPROF_BUF_BYTESIZE(size), KM_SLEEP);
 	new->b_used = 0;
 	new->b_size = size;
@@ -682,9 +695,31 @@ tprofattach(int nunits)
 MODULE(MODULE_CLASS_DRIVER, tprof, NULL);
 
 static void
+tprof_cpu_init(void *vcp, void *vcookie, struct cpu_info *ci)
+{
+	tprof_cpu_t **cp = vcp, *c;
+
+	c = kmem_zalloc(sizeof(*c), KM_SLEEP);
+	c->c_buf = NULL;
+	c->c_cpuid = cpu_index(ci);
+	*cp = c;
+}
+
+static void
+tprof_cpu_fini(void *vcp, void *vcookie, struct cpu_info *ci)
+{
+	tprof_cpu_t **cp = vcp, *c;
+
+	c = *cp;
+	KASSERT(c->c_cpuid == cpu_index(ci));
+	KASSERT(c->c_buf == NULL);
+	kmem_free(c, sizeof(*c));
+	*cp = NULL;
+}
+
+static void
 tprof_driver_init(void)
 {
-	unsigned int i;
 
 	mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(_reader_lock, MUTEX_DEFAULT, IPL_NONE);
@@ -692,18 +727,15 @@ tprof_driver_init(void)
 	cv_init(_cv, "tprof");
 	cv_init(_reader_cv, "tprof_rd");
 	STAILQ_INIT(_list);
-	for (i = 0; i < __arraycount(tprof_cpus); i++) {
-		tprof_cpu_t * const c = _cpus[i];
-
-		c->c_buf = NULL;
-		c->c_cpuid = i;
-	}
+	tprof_cpus = percpu_create(sizeof(tprof_cpu_t *),
+	tprof_cpu_init, tprof_cpu_fini, NULL);
 }
 
 static void
 tprof_driver_fini(void)
 {
 
+	percpu_free(tprof_cpus, sizeof(tprof_cpu_t *));
 	mutex_destroy(_lock);
 	mutex_destroy(_reader_lock);
 	mutex_destroy(_startstop_lock);



CVS commit: src/doc

2020-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 27 17:01:18 UTC 2020

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
new acpica


To generate a diff of this commit:
cvs rdiff -u -r1.1761 -r1.1762 src/doc/3RDPARTY
cvs rdiff -u -r1.2754 -r1.2755 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/3RDPARTY
diff -u src/doc/3RDPARTY:1.1761 src/doc/3RDPARTY:1.1762
--- src/doc/3RDPARTY:1.1761	Fri Nov 20 08:33:07 2020
+++ src/doc/3RDPARTY	Fri Nov 27 12:01:18 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1761 2020/11/20 13:33:07 roy Exp $
+#	$NetBSD: 3RDPARTY,v 1.1762 2020/11/27 17:01:18 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -41,12 +41,12 @@
 #
 
 Package:	acpica
-Version:	20200717
-Current Vers:	20200717
+Version:	20201113
+Current Vers:	20201113
 Maintainer:	Intel
 Archive Site:	http://www.acpica.org/downloads/
 Home Page:	http://www.acpica.org/
-Date:		2020-08-02
+Date:		2020-11-27
 Mailing List:	de...@acpica.org
 License:	BSD-like
 Responsible:	jruoho

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2754 src/doc/CHANGES:1.2755
--- src/doc/CHANGES:1.2754	Fri Nov 20 08:33:07 2020
+++ src/doc/CHANGES	Fri Nov 27 12:01:18 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2754 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2755 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -302,3 +302,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	kernel: Better default for kern.maxfiles for systems with
 		larger RAM [simonb 20201112]
 	dhcpcd: Update to version 9.3.3 [roy 20201120]
+	acpi(4): Updated ACPICA to 20201113. [christos 20201127]



CVS commit: src/sys/external/bsd/acpica/dist

2020-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 27 16:58:33 UTC 2020

Modified Files:
src/sys/external/bsd/acpica/dist/compiler: aslcompiler.l aslload.c
aslopcodes.c aslprepkg.c aslutils.c aslxref.c
src/sys/external/bsd/acpica/dist/debugger: dbexec.c dbinput.c
dbmethod.c
src/sys/external/bsd/acpica/dist/disassembler: dmbuffer.c dmcstyle.c
src/sys/external/bsd/acpica/dist/events: evregion.c evrgnini.c
src/sys/external/bsd/acpica/dist/include: acdebug.h acexcep.h acpixf.h
actbl1.h actypes.h
src/sys/external/bsd/acpica/dist/namespace: nsrepair2.c
src/sys/external/bsd/acpica/dist/os_specific/service_layers:
oslinuxtbl.c

Log Message:
merge conflicts


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l
cvs rdiff -u -r1.19 -r1.20 \
src/sys/external/bsd/acpica/dist/compiler/aslload.c \
src/sys/external/bsd/acpica/dist/compiler/aslxref.c
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/acpica/dist/compiler/aslopcodes.c
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/acpica/dist/compiler/aslprepkg.c
cvs rdiff -u -r1.26 -r1.27 \
src/sys/external/bsd/acpica/dist/compiler/aslutils.c
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/acpica/dist/debugger/dbexec.c
cvs rdiff -u -r1.22 -r1.23 \
src/sys/external/bsd/acpica/dist/debugger/dbinput.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/acpica/dist/debugger/dbmethod.c
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/acpica/dist/disassembler/dmbuffer.c
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/acpica/dist/disassembler/dmcstyle.c
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/acpica/dist/events/evregion.c
cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/acpica/dist/events/evrgnini.c
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/acpica/dist/include/acdebug.h
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/acpica/dist/include/acexcep.h
cvs rdiff -u -r1.27 -r1.28 src/sys/external/bsd/acpica/dist/include/acpixf.h
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/acpica/dist/include/actbl1.h
cvs rdiff -u -r1.22 -r1.23 src/sys/external/bsd/acpica/dist/include/actypes.h
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/acpica/dist/namespace/nsrepair2.c
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/acpica/dist/os_specific/service_layers/oslinuxtbl.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/acpica/dist/compiler/aslcompiler.l
diff -u src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l:1.17 src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l:1.18
--- src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l:1.17	Sun Aug  2 16:25:54 2020
+++ src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l	Fri Nov 27 11:58:32 2020
@@ -171,8 +171,8 @@ NamePathTail[.]{NameSeg}
 /*
  * Begin standard ASL grammar
  */
-[0-9][a-zA-Z0-9]*{ AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
-count (1); return (PARSEOP_INTEGER); }
+[0-9][a-zA-Z0-9]*{ count (1); AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
+ return (PARSEOP_INTEGER); }
 
 "Include"   { count (1); return (PARSEOP_INCLUDE); }
 "External"  { count (1); return (PARSEOP_EXTERNAL); }
@@ -733,7 +733,6 @@ NamePathTail[.]{NameSeg}
  * the required length.
  */
 strcpy (s, "");
-AcpiUtStrupr (AslCompilertext);
 }
 memcpy (s, AslCompilertext, strlen (AslCompilertext));
 AslCompilerlval.s = s;
@@ -743,7 +742,6 @@ NamePathTail[.]{NameSeg}
 {NameString}{ char *s;
 count (0);
 s=UtLocalCacheCalloc (strlen (AslCompilertext)+1);
-AcpiUtStrupr (AslCompilertext);
 strcpy (s, AslCompilertext);
 AslCompilerlval.s = s;
 DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s);

Index: src/sys/external/bsd/acpica/dist/compiler/aslload.c
diff -u src/sys/external/bsd/acpica/dist/compiler/aslload.c:1.19 src/sys/external/bsd/acpica/dist/compiler/aslload.c:1.20
--- src/sys/external/bsd/acpica/dist/compiler/aslload.c:1.19	Sun Aug  2 16:25:54 2020
+++ src/sys/external/bsd/acpica/dist/compiler/aslload.c	Fri Nov 27 11:58:32 2020
@@ -1296,9 +1296,16 @@ LdNamespace2Begin (
 return (AE_OK);
 }
 
-/* Save the target node 

CVS import: src/sys/external/bsd/acpica/dist

2020-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 27 16:56:59 UTC 2020

Update of /cvsroot/src/sys/external/bsd/acpica/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv28901

Log Message:
13 November 2020. Summary of changes for version 20201113:

This release is available at https://acpica.org/downloads

1) ACPICA kernel-resident subsystem:

Interpreter: fixed a memory leak by using use existing buffer in
_HID repair. There was a memory leak that occurred when a _CID
object is defined as a package containing string objects. When _CID
is checked for any possible repairs, it calls a helper function to
repair _HID (because _CID basically contains multiple _HID entries).
The _HID repair function assumes that string objects are standalone
objects that are not contained inside of any packages. The _HID
repair function replaced the string object with a brand new object
and attempted to delete the old object by decrementing the reference
count of the old object. Strings inside of packages have a reference
count of 2 so the _HID repair function leaves this object in a
dangling state and causes a memory leak. Instead of allocating a
brand new object and removing the old object, use the existing
object when repairing the _HID object.

Added function trace macros to improve namespace debugging. The
namespace repair mechanism does not have function tracing macros.
Add several trace macros to improve debuggability.

Handle "orphan" _REG methods for GPIO OpRegions. Before this change
AcpiEvExecuteRegMethods() had special handling to handle "orphan"
(no matching OpRegion declared) _REG methods for EC nodes. On Intel
Cherry Trail devices there are 2 possible ACPI OpRegions for
accessing GPIOs. The standard GeneralPurposeIo OpRegion and the
Cherry Trail - specific UserDefined 0x9X OpRegions. Having 2
different types of OpRegions leads to potential issues with checks
for OpRegion availability, or in other words checks if _REG has
been called for the OpRegion which the ACPI code wants to use.
Except for the "orphan" EC handling, ACPICA core does not call _REG
on an ACPI node which does not define an OpRegion matching the type
being registered; and the reference design DSDT, from which most
Cherry Trail DSDTs are derived, does not define GeneralPurposeIo,
nor UserDefined(0x93) OpRegions for the GPO2 (UID 3) device, because
no pins were assigned ACPI controlled functions in the reference
design. Together this leads to the perfect storm, at least on the
Cherry Trail based Medion Akayo E1239T. This design does use a GPO2
pin from its ACPI code and has added the Cherry Trail specific
UserDefined(0x93) opregion to its GPO2 ACPI node to access this
pin. But it uses a "has _REG been called" availability check for
the standard GeneralPurposeIo OpRegion. This clearly is a bug in
the DSDT, but this does work under Windows. This issue leads to
the intel vbtn driver reporting the device always being in tablet-mode
at boot, even if it is in laptop mode. Which in turn causes userspace
to ignore touchpad events. So in other words, this issue causes
the touchpad to not work at boot. This change fixes this by extending
the "orphan" _REG method handling to also apply to GPIO address-space
handlers.

2) iASL Compiler/Disassembler and ACPICA tools:

iASL: Added more info to namespace dump file (-ln option). In a
separate section of the dump file (after the main namespace dump),
emit the full pathname for each namespace node, its type, and the
ASL filename and line number where it is declared.

AcpiHelp: Added an option to display/decode iASL exceptions. Option
is: -x [Hex Value] where "Hex Value" is the iASL exception code.
If Hex Value is omitted, all iASL exceptions are displayed.

iASL: Use StringLiteral instead of StringData for some ASL macros.
The use of the stringData rule allows for some "string" oriented
opcodes (Such as ToString, ToHexString, etc.) None of which make
sense with the macros in question. This change modifies the StringData
part of the rule for these macros to a simple string literal - thus
disallowing the use of ToString, ToHexString, etc.  The following
ASL operators (macros) are affected:  EisaId Fprintf Printf ToUuid
Unicode Note: The MS compiler requires the use of string literals
for these operators also.

iASL: Added a remark for an unknown UUID: ASL_MSG_UUID_NOT_FOUND.
Search the list of "known" UUIDs for the input to the ToUUID macro.

Added 5 new UUIDs to the known UUID table. All related to NVDIMM
and the NFIT table.

Status:

Vendor Tag: intel
Release Tags:   acpica-20201113

U src/sys/external/bsd/acpica/dist/changes.txt
U src/sys/external/bsd/acpica/dist/Makefile
U src/sys/external/bsd/acpica/dist/generate/lint/files.lnt
U src/sys/external/bsd/acpica/dist/generate/lint/lint.bat
U src/sys/external/bsd/acpica/dist/generate/lint/lset.bat
U src/sys/external/bsd/acpica/dist/generate/lint/options.lnt
U src/sys/external/bsd/acpica/dist/generate/lint/readme.txt
U 

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

2020-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 27 16:50:02 UTC 2020

Modified Files:
src/tests/lib/libc/string: t_memmem.c

Log Message:
map enough space for both the page we write and the guard so that we make
sure we own the guard page before we set its protection to none. This fixes
random SEGVs where the page we set protection to none probably belonged to
the dynamic linker. Reported by gson@


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_memmem.c

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

Modified files:

Index: src/tests/lib/libc/string/t_memmem.c
diff -u src/tests/lib/libc/string/t_memmem.c:1.5 src/tests/lib/libc/string/t_memmem.c:1.6
--- src/tests/lib/libc/string/t_memmem.c:1.5	Fri Nov 27 10:37:06 2020
+++ src/tests/lib/libc/string/t_memmem.c	Fri Nov 27 11:50:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */
+/*	$NetBSD: t_memmem.c,v 1.6 2020/11/27 16:50:02 christos Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -105,11 +105,12 @@ ATF_TC_BODY(memmem_oob, tc)
 {
 	static const char str[] = "abcde";
 	size_t pg = getpagesize();
-	char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE,
+	char *src = mmap(NULL, 2 * pg, PROT_READ|PROT_WRITE,
 	MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
 	ATF_CHECK(src != MAP_FAILED);
 	char *guard = mmap(src + pg, pg,
 	PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0);
+printf("%p\n", guard);
 	for (size_t i = 2; i < 5; i++) {
 		char *search = src + pg - i;
 		char match[sizeof(str)];



CVS commit: src/lib/libc/sys

2020-11-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Nov 27 16:42:00 UTC 2020

Modified Files:
src/lib/libc/sys: pipe.2

Log Message:
Refine the documentation

Sort includes.
Correct the historical note, pipe first appeared in AT UNIX v3.
Document ENOMEM.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/sys/pipe.2

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/sys/pipe.2
diff -u src/lib/libc/sys/pipe.2:1.31 src/lib/libc/sys/pipe.2:1.32
--- src/lib/libc/sys/pipe.2:1.31	Wed Oct 25 17:44:50 2017
+++ src/lib/libc/sys/pipe.2	Fri Nov 27 16:42:00 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pipe.2,v 1.31 2017/10/25 17:44:50 abhinav Exp $
+.\"	$NetBSD: pipe.2,v 1.32 2020/11/27 16:42:00 kamil Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)pipe.2	8.1 (Berkeley) 6/4/93
 .\"
-.Dd January 23, 2012
+.Dd November 27, 2020
 .Dt PIPE 2
 .Os
 .Sh NAME
@@ -42,8 +42,8 @@
 .In unistd.h
 .Ft int
 .Fn pipe "int fildes[2]"
-.In unistd.h
 .In fcntl.h
+.In unistd.h
 .Ft int
 .Fn pipe2 "int fildes[2]" "int flags"
 .Sh DESCRIPTION
@@ -59,7 +59,7 @@ The first descriptor connects to the
 .Em read end
 of the pipe,
 and the second connects to the
-.Em write end  ,
+.Em write end ,
 so that data written to
 .Fa fildes[1]
 appears on (i.e., can be read from)
@@ -130,6 +130,8 @@ address violation.
 Too many descriptors are active.
 .It Bq Er ENFILE
 The system file table is full.
+.It Bq Er ENOMEM
+Not enough kernel memory to establish a pipe.
 .El
 .Pp
 .Fn pipe2
@@ -154,7 +156,11 @@ function conforms to
 A
 .Fn pipe
 function call appeared in
-.At v6 .
+.At v3 .
+Since
+.At v4 ,
+it allocates two distinct file descriptors.
+.Pp
 The
 .Fn pipe2
 function is inspired from Linux and appeared in



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

2020-11-27 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Nov 27 15:37:06 UTC 2020

Modified Files:
src/tests/lib/libc/string: t_memmem.c

Log Message:
delete trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_memmem.c

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

Modified files:

Index: src/tests/lib/libc/string/t_memmem.c
diff -u src/tests/lib/libc/string/t_memmem.c:1.4 src/tests/lib/libc/string/t_memmem.c:1.5
--- src/tests/lib/libc/string/t_memmem.c:1.4	Mon Oct 15 17:55:28 2018
+++ src/tests/lib/libc/string/t_memmem.c	Fri Nov 27 15:37:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_memmem.c,v 1.4 2018/10/15 17:55:28 christos Exp $ */
+/*	$NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -107,7 +107,7 @@ ATF_TC_BODY(memmem_oob, tc)
 	size_t pg = getpagesize();
 	char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE,
 	MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
-	ATF_CHECK(src != MAP_FAILED); 
+	ATF_CHECK(src != MAP_FAILED);
 	char *guard = mmap(src + pg, pg,
 	PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0);
 	for (size_t i = 2; i < 5; i++) {



CVS commit: src/sys/fs/ptyfs

2020-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 27 14:43:57 UTC 2020

Modified Files:
src/sys/fs/ptyfs: ptyfs.h ptyfs_subr.c ptyfs_vnops.c

Log Message:
make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/ptyfs/ptyfs.h
cvs rdiff -u -r1.33 -r1.34 src/sys/fs/ptyfs/ptyfs_subr.c
cvs rdiff -u -r1.61 -r1.62 src/sys/fs/ptyfs/ptyfs_vnops.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/fs/ptyfs/ptyfs.h
diff -u src/sys/fs/ptyfs/ptyfs.h:1.15 src/sys/fs/ptyfs/ptyfs.h:1.16
--- src/sys/fs/ptyfs/ptyfs.h:1.15	Fri Jan 17 15:08:08 2020
+++ src/sys/fs/ptyfs/ptyfs.h	Fri Nov 27 09:43:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs.h,v 1.15 2020/01/17 20:08:08 ad Exp $	*/
+/*	$NetBSD: ptyfs.h,v 1.16 2020/11/27 14:43:57 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -140,7 +140,7 @@ struct ptyfs_args {
 
 #define UIO_MX 32
 
-#define PTYFS_FILENO(pty, type) \
+#define PTYFS_FILENO(type, pty) \
 ((type == PTYFSroot) ? 2 : \
  pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2
 

Index: src/sys/fs/ptyfs/ptyfs_subr.c
diff -u src/sys/fs/ptyfs/ptyfs_subr.c:1.33 src/sys/fs/ptyfs/ptyfs_subr.c:1.34
--- src/sys/fs/ptyfs/ptyfs_subr.c:1.33	Wed Oct 15 11:00:03 2014
+++ src/sys/fs/ptyfs/ptyfs_subr.c	Fri Nov 27 09:43:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs_subr.c,v 1.33 2014/10/15 15:00:03 christos Exp $	*/
+/*	$NetBSD: ptyfs_subr.c,v 1.34 2020/11/27 14:43:57 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_subr.c,v 1.33 2014/10/15 15:00:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_subr.c,v 1.34 2020/11/27 14:43:57 christos Exp $");
 
 #include 
 #include 
@@ -162,7 +162,7 @@ ptyfs_get_node(ptyfstype type, int pty)
 	pp = malloc(sizeof(struct ptyfsnode), M_TEMP, M_WAITOK);
 	pp->ptyfs_pty = pty;
 	pp->ptyfs_type = type;
-	pp->ptyfs_fileno = PTYFS_FILENO(pty, type);
+	pp->ptyfs_fileno = PTYFS_FILENO(type, pty);
 	if (pp->ptyfs_type == PTYFSroot)
 		pp->ptyfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|
 		S_IROTH|S_IXOTH;

Index: src/sys/fs/ptyfs/ptyfs_vnops.c
diff -u src/sys/fs/ptyfs/ptyfs_vnops.c:1.61 src/sys/fs/ptyfs/ptyfs_vnops.c:1.62
--- src/sys/fs/ptyfs/ptyfs_vnops.c:1.61	Tue Nov 24 11:38:31 2020
+++ src/sys/fs/ptyfs/ptyfs_vnops.c	Fri Nov 27 09:43:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs_vnops.c,v 1.61 2020/11/24 16:38:31 christos Exp $	*/
+/*	$NetBSD: ptyfs_vnops.c,v 1.62 2020/11/27 14:43:57 christos Exp $	*/
 
 /*
  * Copyright (c) 1993, 1995
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.61 2020/11/24 16:38:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.62 2020/11/27 14:43:57 christos Exp $");
 
 #include 
 #include 
@@ -715,7 +715,7 @@ ptyfs_readdir(void *v)
 
 	for (; i < 2; i++) {
 		/* `.' and/or `..' */
-		dp->d_fileno = PTYFS_FILENO(0, PTYFSroot);
+		dp->d_fileno = PTYFS_FILENO(PTYFSroot, 0);
 		dp->d_namlen = i + 1;
 		(void)memcpy(dp->d_name, "..", dp->d_namlen);
 		dp->d_name[i + 1] = '\0';
@@ -731,7 +731,7 @@ ptyfs_readdir(void *v)
 		n = ptyfs_next_active(vp->v_mount, i - 2);
 		if (n < 0)
 			break;
-		dp->d_fileno = PTYFS_FILENO(n, PTYFSpts);
+		dp->d_fileno = PTYFS_FILENO(PTYFSpts, n);
 		dp->d_namlen = snprintf(dp->d_name, sizeof(dp->d_name),
 		"%lld", (long long)(n));
 		dp->d_type = DT_CHR;



CVS commit: src/usr.bin/make/unit-tests

2020-11-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 27 08:39:07 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: depsrc-meta.mk

Log Message:
make(1): clean up after a successful .META test


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-meta.mk

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/unit-tests/depsrc-meta.mk
diff -u src/usr.bin/make/unit-tests/depsrc-meta.mk:1.3 src/usr.bin/make/unit-tests/depsrc-meta.mk:1.4
--- src/usr.bin/make/unit-tests/depsrc-meta.mk:1.3	Fri Nov 27 08:36:11 2020
+++ src/usr.bin/make/unit-tests/depsrc-meta.mk	Fri Nov 27 08:39:07 2020
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc-meta.mk,v 1.3 2020/11/27 08:36:11 rillig Exp $
+# $NetBSD: depsrc-meta.mk,v 1.4 2020/11/27 08:39:07 rillig Exp $
 #
 # Tests for the special source .META in dependency declarations.
 
@@ -20,6 +20,7 @@ depsrc-meta-target: .META
 check-results:
 	@echo 'Targets from meta mode:'
 	@awk '/^TARGET/ { print "| " $$0 }' depsrc-meta-target.meta
+	@rm depsrc-meta-target.meta
 
 .else
 



CVS commit: src/usr.bin/make/unit-tests

2020-11-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 27 08:36:11 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: depsrc-meta.exp depsrc-meta.mk

Log Message:
make(1): add very basic test about meta mode

This test is just meant to cover the existing code, it still needs to be
cleaned up to serve as a tutorial and to highlight the really
interesting points.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/depsrc-meta.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-meta.mk

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/unit-tests/depsrc-meta.exp
diff -u src/usr.bin/make/unit-tests/depsrc-meta.exp:1.1 src/usr.bin/make/unit-tests/depsrc-meta.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-meta.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-meta.exp	Fri Nov 27 08:36:10 2020
@@ -1 +1,5 @@
+Skipping meta for actual-test: no commands
+Skipping meta for .END: .SPECIAL
+Targets from meta mode:
+| TARGET depsrc-meta-target
 exit status 0

Index: src/usr.bin/make/unit-tests/depsrc-meta.mk
diff -u src/usr.bin/make/unit-tests/depsrc-meta.mk:1.2 src/usr.bin/make/unit-tests/depsrc-meta.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-meta.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-meta.mk	Fri Nov 27 08:36:11 2020
@@ -1,8 +1,30 @@
-# $NetBSD: depsrc-meta.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-meta.mk,v 1.3 2020/11/27 08:36:11 rillig Exp $
 #
 # Tests for the special source .META in dependency declarations.
 
 # TODO: Implementation
+# TODO: Explanation
+
+.if make(actual-test)
+
+.MAKEFLAGS: -dM
+.MAKE.MODE=	meta curDirOk=true
+
+actual-test: depsrc-meta-target
+depsrc-meta-target: .META
+	@> ${.TARGET}-file
+	@rm -f ${.TARGET}-file
+
+.elif make(check-results)
+
+check-results:
+	@echo 'Targets from meta mode:'
+	@awk '/^TARGET/ { print "| " $$0 }' depsrc-meta-target.meta
+
+.else
 
 all:
-	@:;
+	@${MAKE} -f ${MAKEFILE} actual-test
+	@${MAKE} -f ${MAKEFILE} check-results
+
+.endif



CVS commit: src/usr.bin/make

2020-11-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 27 08:18:14 UTC 2020

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

Log Message:
make(1): inline meta_file_t for printCMD

This struct had only been necessary as long as printCMD was a callback
to Lst_ForEach or Lst_ForEachUntil.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/meta.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/meta.c
diff -u src/usr.bin/make/meta.c:1.149 src/usr.bin/make/meta.c:1.150
--- src/usr.bin/make/meta.c:1.149	Fri Nov 27 08:07:26 2020
+++ src/usr.bin/make/meta.c	Fri Nov 27 08:18:14 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.149 2020/11/27 08:07:26 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.150 2020/11/27 08:18:14 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -370,32 +370,27 @@ any_is_submake(GNode *gn)
 return FALSE;
 }
 
-typedef struct meta_file_s {
-FILE *fp;
-GNode *gn;
-} meta_file_t;
-
 static void
-printCMD(const char *cmd, meta_file_t *mfp)
+printCMD(const char *cmd, FILE *fp, GNode *gn)
 {
 char *cmd_freeIt = NULL;
 
 if (strchr(cmd, '$')) {
-	(void)Var_Subst(cmd, mfp->gn, VARE_WANTRES, _freeIt);
+	(void)Var_Subst(cmd, gn, VARE_WANTRES, _freeIt);
 	/* TODO: handle errors */
 	cmd = cmd_freeIt;
 }
-fprintf(mfp->fp, "CMD %s\n", cmd);
+fprintf(fp, "CMD %s\n", cmd);
 free(cmd_freeIt);
 }
 
 static void
-printCMDs(GNode *gn, meta_file_t *mf)
+printCMDs(GNode *gn, FILE *fp)
 {
 GNodeListNode *ln;
 
 for (ln = gn->commands->first; ln != NULL; ln = ln->next)
-	printCMD(ln->datum, mf);
+	printCMD(ln->datum, fp, gn);
 }
 
 /*
@@ -474,7 +469,7 @@ meta_needed(GNode *gn, const char *dname
 static FILE *
 meta_create(BuildMon *pbm, GNode *gn)
 {
-meta_file_t mf;
+FILE *fp;
 char buf[MAXPATHLEN];
 char objdir[MAXPATHLEN];
 char **ptr;
@@ -484,7 +479,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 const char *cp;
 void *objdir_freeIt;
 
-mf.fp = NULL;
+fp = NULL;
 
 dname = Var_Value(".OBJDIR", gn, _freeIt);
 tname = GNode_VarTarget(gn);
@@ -524,28 +519,26 @@ meta_create(BuildMon *pbm, GNode *gn)
 DEBUG1(META, "meta_create: %s\n", fname);
 #endif
 
-if ((mf.fp = fopen(fname, "w")) == NULL)
+if ((fp = fopen(fname, "w")) == NULL)
 	err(1, "Could not open meta file '%s'", fname);
 
-fprintf(mf.fp, "# Meta data file %s\n", fname);
-
-mf.gn = gn;
+fprintf(fp, "# Meta data file %s\n", fname);
 
-printCMDs(gn, );
+printCMDs(gn, fp);
 
-fprintf(mf.fp, "CWD %s\n", getcwd(buf, sizeof buf));
-fprintf(mf.fp, "TARGET %s\n", tname);
+fprintf(fp, "CWD %s\n", getcwd(buf, sizeof buf));
+fprintf(fp, "TARGET %s\n", tname);
 cp = GNode_VarOodate(gn);
 if (cp && *cp) {
-	fprintf(mf.fp, "OODATE %s\n", cp);
+	fprintf(fp, "OODATE %s\n", cp);
 }
 if (metaEnv) {
 	for (ptr = environ; *ptr != NULL; ptr++)
-	fprintf(mf.fp, "ENV %s\n", *ptr);
+	fprintf(fp, "ENV %s\n", *ptr);
 }
 
-fprintf(mf.fp, "-- command output --\n");
-fflush(mf.fp);
+fprintf(fp, "-- command output --\n");
+fflush(fp);
 
 Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL);
 Var_Append(".MAKE.META.CREATED", fname, VAR_GLOBAL);
@@ -557,7 +550,7 @@ meta_create(BuildMon *pbm, GNode *gn)
  out:
 bmake_free(objdir_freeIt);
 
-return mf.fp;
+return fp;
 }
 
 static Boolean



CVS commit: src/usr.bin/make

2020-11-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 27 08:07:27 UTC 2020

Modified Files:
src/usr.bin/make: lst.c lst.h make.c meta.c

Log Message:
make(1): inline Lst_ForEachUntil in meta mode

This means no more unnecessary void pointers in function signatures and
no more abstraction level at checking a single element of a list.  In
most cases it is more appropriate to define a function that operates on
the list as a whole, thereby hiding implementation details like the
ListNode from the caller.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/lst.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/make/lst.h
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/make/make.c
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/make/meta.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/lst.c
diff -u src/usr.bin/make/lst.c:1.93 src/usr.bin/make/lst.c:1.94
--- src/usr.bin/make/lst.c:1.93	Tue Nov 24 19:46:29 2020
+++ src/usr.bin/make/lst.c	Fri Nov 27 08:07:26 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.93 2020/11/24 19:46:29 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.94 2020/11/27 08:07:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.93 2020/11/24 19:46:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.94 2020/11/27 08:07:26 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -198,20 +198,6 @@ Lst_FindDatum(List *list, const void *da
 	return NULL;
 }
 
-int
-Lst_ForEachUntil(List *list, LstActionUntilProc proc, void *procData)
-{
-	ListNode *ln;
-	int result = 0;
-
-	for (ln = list->first; ln != NULL; ln = ln->next) {
-		result = proc(ln->datum, procData);
-		if (result != 0)
-			break;
-	}
-	return result;
-}
-
 /* Move all nodes from src to the end of dst.
  * The source list is destroyed and freed. */
 void

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.86 src/usr.bin/make/lst.h:1.87
--- src/usr.bin/make/lst.h:1.86	Tue Nov 24 19:46:29 2020
+++ src/usr.bin/make/lst.h	Fri Nov 27 08:07:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.86 2020/11/24 19:46:29 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.87 2020/11/27 08:07:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -104,8 +104,6 @@ struct List {
 
 /* Free the datum of a node, called before freeing the node itself. */
 typedef void LstFreeProc(void *);
-/* An action for Lst_ForEachUntil and Lst_ForEachUntilConcurrent. */
-typedef int LstActionUntilProc(void *datum, void *args);
 
 /* Create or destroy a list */
 
@@ -146,14 +144,6 @@ void LstNode_Set(ListNode *, void *);
 /* Set the value of the node to NULL. Having NULL in a list is unusual. */
 void LstNode_SetNull(ListNode *);
 
-/* Iterating over a list, using a callback function */
-
-/* Run the action for each datum of the list, until the action returns
- * non-zero.
- *
- * During this iteration, the list must not be modified structurally. */
-int Lst_ForEachUntil(List *, LstActionUntilProc, void *);
-
 /* Using the list as a queue */
 
 /* Add a datum at the tail of the queue. */

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.217 src/usr.bin/make/make.c:1.218
--- src/usr.bin/make/make.c:1.217	Tue Nov 24 23:13:09 2020
+++ src/usr.bin/make/make.c	Fri Nov 27 08:07:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.217 2020/11/24 23:13:09 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.218 2020/11/27 08:07:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -102,7 +102,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.217 2020/11/24 23:13:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.218 2020/11/27 08:07:26 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -1032,9 +1032,9 @@ MakePrintStatusOrder(GNode *gn)
 
 static void MakePrintStatusList(GNodeList *, int *);
 
-/* Print the status of a top-level node, viz. it being up-to-date already
+/*
+ * Print the status of a top-level node, viz. it being up-to-date already
  * or not created due to an error in a lower level.
- * Callback function for Make_Run via Lst_ForEachUntil.
  */
 static Boolean
 MakePrintStatus(GNode *gn, int *errors)

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.148 src/usr.bin/make/meta.c:1.149
--- src/usr.bin/make/meta.c:1.148	Mon Nov 23 23:44:03 2020
+++ src/usr.bin/make/meta.c	Fri Nov 27 08:07:26 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.148 2020/11/23 23:44:03 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.149 2020/11/27 08:07:26 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -312,17 +312,15 @@ meta_name(char *mname, size_t mnamelen,
  * Return true if running ${.MAKE}
  * Bypassed if target is flagged .MAKE
  */
-static int
-is_submake(void *cmdp,