CVS commit: src/sys

2018-06-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jun 26 04:32:35 UTC 2018

Modified Files:
src/sys/dev/i2c: axppmic.c ds1307.c i2c.c i2cvar.h
src/sys/kern: subr_autoconf.c
src/sys/sys: device.h

Log Message:
Change device_compatible_match() and iic_compatible_match() to return
the weighted match value and take an optional compatible-entry pointer,
rather than the other way around.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/i2c/axppmic.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/i2c/ds1307.c
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/i2c/i2c.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/i2c/i2cvar.h
cvs rdiff -u -r1.260 -r1.261 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.153 -r1.154 src/sys/sys/device.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/dev/i2c/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.12 src/sys/dev/i2c/axppmic.c:1.13
--- src/sys/dev/i2c/axppmic.c:1.12	Tue Jun 19 02:08:12 2018
+++ src/sys/dev/i2c/axppmic.c	Tue Jun 26 04:32:35 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.12 2018/06/19 02:08:12 thorpej Exp $ */
+/* $NetBSD: axppmic.c,v 1.13 2018/06/26 04:32:35 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.12 2018/06/19 02:08:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.13 2018/06/26 04:32:35 thorpej Exp $");
 
 #include 
 #include 
@@ -694,7 +694,7 @@ static void
 axppmic_attach(device_t parent, device_t self, void *aux)
 {
 	struct axppmic_softc *sc = device_private(self);
-	const struct device_compatible_entry *dce;
+	const struct device_compatible_entry *dce = NULL;
 	const struct axppmic_config *c;
 	struct axpreg_attach_args aaa;
 	struct i2c_attach_args *ia = aux;
@@ -702,7 +702,7 @@ axppmic_attach(device_t parent, device_t
 	uint32_t irq_mask;
 	void *ih;
 
-	dce = iic_compatible_match(ia, axppmic_compat_data, NULL);
+	(void) iic_compatible_match(ia, axppmic_compat_data, );
 	KASSERT(dce != NULL);
 	c = DEVICE_COMPAT_ENTRY_GET_PTR(dce);
 

Index: src/sys/dev/i2c/ds1307.c
diff -u src/sys/dev/i2c/ds1307.c:1.27 src/sys/dev/i2c/ds1307.c:1.28
--- src/sys/dev/i2c/ds1307.c:1.27	Mon Jun 18 17:07:07 2018
+++ src/sys/dev/i2c/ds1307.c	Tue Jun 26 04:32:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ds1307.c,v 1.27 2018/06/18 17:07:07 thorpej Exp $	*/
+/*	$NetBSD: ds1307.c,v 1.28 2018/06/26 04:32:35 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.27 2018/06/18 17:07:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.28 2018/06/26 04:32:35 thorpej Exp $");
 
 #include 
 #include 
@@ -249,8 +249,7 @@ dsrtc_model_by_compat(const struct i2c_a
 	const struct dsrtc_model *dm = NULL;
 	const struct device_compatible_entry *dce;
 
-	dce = iic_compatible_match(ia, dsrtc_compat_data, NULL);
-	if (dce != NULL)
+	if (iic_compatible_match(ia, dsrtc_compat_data, ))
 		dm = DEVICE_COMPAT_ENTRY_GET_PTR(dce);
 
 	return dm;

Index: src/sys/dev/i2c/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.64 src/sys/dev/i2c/i2c.c:1.65
--- src/sys/dev/i2c/i2c.c:1.64	Fri Jun 22 15:52:00 2018
+++ src/sys/dev/i2c/i2c.c	Tue Jun 26 04:32:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.c,v 1.64 2018/06/22 15:52:00 martin Exp $	*/
+/*	$NetBSD: i2c.c,v 1.65 2018/06/26 04:32:35 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.64 2018/06/22 15:52:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.65 2018/06/26 04:32:35 thorpej Exp $");
 
 #include 
 #include 
@@ -695,22 +695,22 @@ iic_fill_compat(struct i2c_attach_args *
  *	Match a device's "compatible" property against the list
  *	of compatible strings provided by the driver.
  */
-const struct device_compatible_entry *
+int
 iic_compatible_match(const struct i2c_attach_args *ia,
 		 const struct device_compatible_entry *compats,
-		 int *match_resultp)
+		 const struct device_compatible_entry **matching_entryp)
 {
-	const struct device_compatible_entry *dce;
-	int match_weight;
+	int match_result;
 
-	dce = device_compatible_match(ia->ia_compat, ia->ia_ncompat,
-  compats, _weight);
-	if (dce != NULL && match_resultp != NULL) {
-		*match_resultp = MIN(I2C_MATCH_DIRECT_COMPATIBLE + match_weight,
- I2C_MATCH_DIRECT_COMPATIBLE_MAX);
+	match_result = device_compatible_match(ia->ia_compat, ia->ia_ncompat,
+	   compats, matching_entryp);
+	if (match_result) {
+		match_result =
+		MIN(I2C_MATCH_DIRECT_COMPATIBLE + match_result - 1,
+			I2C_MATCH_DIRECT_COMPATIBLE_MAX);
 	}
 
-	return dce;
+	return match_result;
 }
 
 /*
@@ -735,8 +735,7 @@ iic_use_direct_match(const struct i2c_at
 	}
 
 	if (ia->ia_ncompat > 0 && ia->ia_compat != NULL) {
-		if (iic_compatible_match(ia, compats, match_resultp) 

CVS commit: src/share/misc

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun 26 00:06:09 UTC 2018

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Document sanitizers in acronyms.comp

Added: ASan, CFI, DFSan, ESan, HWASan, LSan, MSan, TSan, UBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.208 src/share/misc/acronyms.comp:1.209
--- src/share/misc/acronyms.comp:1.208	Mon Jun 25 19:56:54 2018
+++ src/share/misc/acronyms.comp	Tue Jun 26 00:06:08 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.208 2018/06/25 19:56:54 sevan Exp $
+$NetBSD: acronyms.comp,v 1.209 2018/06/26 00:06:08 kamil Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -77,6 +77,7 @@ ARR	address range register
 ARU	audio response unit
 AS	autonomous system
 ASA	Adaptive Security Appliance
+ASAN	Address Sanitizer
 ASC	advanced smart cache
 ASCII	American Standard Code for Information Interchange
 ASD	agile software development
@@ -204,6 +205,7 @@ CF	compact flash
 CFB	cipher feedback
 CFG	context-free grammar
 CFG	control-flow graph
+CFI	control-flow integrity sanitizer
 CG	control gate
 CGA	Color Graphics Adapter
 CGI	common gateway interface
@@ -336,6 +338,7 @@ DFA	deterministic finite automaton
 DFC	data flow control
 DFS	depth first search
 DFS	distributed file system
+DFSAN	Data Flow Sanitizer
 DFT	diagnostic function test
 DFT	discrete Fourier transform
 DGL	data generation language
@@ -459,6 +462,7 @@ ERD	emergency recovery disk
 ERD	entity relationship diagram
 ERE	extended regular expression
 ERST	error record serialization table
+ESAN	Efficiency Sanitizer
 ESB	enterprise service bus
 ESDRAM	enhanced synchronous dynamic random access memory
 ESS	electronic switching system
@@ -591,6 +595,7 @@ HTTP	Hypertext Transfer Protocol
 HTTPS	Hypertext Transfer Protocol Secure
 HVM	hardware virtual machine
 HVDS	High-Voltage Differential Signaling
+HWASAN	Hardware-assisted Address Sanitizer
 HZ	Hertz
 I2O	intelligent input/output
 IA	information assurance
@@ -753,6 +758,7 @@ LRC	longitudinal redundancy check
 LRM	left-to-right mark
 LRO	left-to-right override
 LRU	least recently used
+LSAN	Leak Sanitizer
 LSB	Linux standards base
 LSB	least significant {bit,byte}
 LSI	large scale integration
@@ -856,6 +862,7 @@ MQTT	Message Queuing Telemetry Transport
 MR	modem ready
 MRU	most recently used
 MS	Microsoft
+MSAN	Memory Sanitizer
 MSB	most significant {bit,byte}
 MSE	mean square error
 MSF	minutes seconds frames
@@ -1398,6 +1405,7 @@ TS	terminal services
 TS	time series
 TS	time stamp
 TS	transport stream
+TSAN	Thread Sanitizer
 TSC	time stamp counter
 TSD	time stamp disable
 TSDB	time series database
@@ -1421,6 +1429,7 @@ UAF	use-after-free
 UART	universal asynchronous receiver/transmitter
 UAT	user acceptance testing
 UB	undefined behavior
+UBSAN	Undefined Behavior Sanitizer
 UC	uncacheable
 UCS	uniform-cost search
 UDMA	ultra DMA



CVS commit: src/share/misc

2018-06-25 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Jun 25 19:56:54 UTC 2018

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Add HVDS, LVDS, RDRAM


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.207 src/share/misc/acronyms.comp:1.208
--- src/share/misc/acronyms.comp:1.207	Sun Jun 24 19:48:46 2018
+++ src/share/misc/acronyms.comp	Mon Jun 25 19:56:54 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.207 2018/06/24 19:48:46 sevan Exp $
+$NetBSD: acronyms.comp,v 1.208 2018/06/25 19:56:54 sevan Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -590,6 +590,7 @@ HTT	hyper-threading technology
 HTTP	Hypertext Transfer Protocol
 HTTPS	Hypertext Transfer Protocol Secure
 HVM	hardware virtual machine
+HVDS	High-Voltage Differential Signaling
 HZ	Hertz
 I2O	intelligent input/output
 IA	information assurance
@@ -771,6 +772,7 @@ LUN	logical unit number
 LV	logical volume
 LVM	logical volume management
 LVT	local vector table
+LVDS	Low-Voltage Differential Signaling
 LWP	light-weight process
 LZW	Lempel Ziv Welch
 MAC	mandatory access control
@@ -1130,6 +1132,7 @@ RDBMS	relational database management sys
 RDF	Resource Description Framework
 RDM	relational data model
 RDMA	remote direct memory access
+RDRAM	Rambus DRAM
 RE	regular expression
 REST	representational state transfer
 RF	radio frequency



CVS commit: src/external/bsd/tmux/dist

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:41:25 UTC 2018

Modified Files:
src/external/bsd/tmux/dist: window-copy.c

Log Message:
Avoid UB in tmux/window_copy_add_formats()

Do not perform NULL pointer arithmetics.

Reported with MKSANITIZER/UBSan.

The patch proposed by upstream https://github.com/tmux/tmux/issues/1382


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/tmux/dist/window-copy.c

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

Modified files:

Index: src/external/bsd/tmux/dist/window-copy.c
diff -u src/external/bsd/tmux/dist/window-copy.c:1.7 src/external/bsd/tmux/dist/window-copy.c:1.8
--- src/external/bsd/tmux/dist/window-copy.c:1.7	Thu Oct 12 22:17:35 2017
+++ src/external/bsd/tmux/dist/window-copy.c	Mon Jun 25 18:41:25 2018
@@ -2418,12 +2418,11 @@ void
 window_copy_add_formats(struct window_pane *wp, struct format_tree *ft)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
-	struct screen			*s = >screen;
 
 	if (wp->mode != _copy_mode)
 		return;
 
-	format_add(ft, "selection_present", "%d", s->sel.flag);
+	format_add(ft, "selection_present", "%d", data->screen.sel.flag);
 	format_add(ft, "scroll_position", "%d", data->oy);
 }
 



CVS commit: src/external/bsd/nvi/dist/common

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:36:36 UTC 2018

Modified Files:
src/external/bsd/nvi/dist/common: log1.c

Log Message:
Include  for offsetof(3)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/log1.c

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

Modified files:

Index: src/external/bsd/nvi/dist/common/log1.c
diff -u src/external/bsd/nvi/dist/common/log1.c:1.5 src/external/bsd/nvi/dist/common/log1.c:1.6
--- src/external/bsd/nvi/dist/common/log1.c:1.5	Mon Jun 25 17:42:34 2018
+++ src/external/bsd/nvi/dist/common/log1.c	Mon Jun 25 18:36:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $	*/
+/*	$NetBSD: log1.c,v 1.6 2018/06/25 18:36:36 kamil Exp $	*/
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp  (Berkeley) Date: 2002/03/02 23:12:13 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $");
+__RCSID("$NetBSD: log1.c,v 1.6 2018/06/25 18:36:36 kamil Exp $");
 #endif
 
 #include 
@@ -30,6 +30,7 @@ __RCSID("$NetBSD: log1.c,v 1.5 2018/06/2
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 



CVS commit: src/usr.bin/chpass

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:05:25 UTC 2018

Modified Files:
src/usr.bin/chpass: Makefile

Log Message:
Specify SANITIZER_RENAME_SYMBOL in chpass

Rename local versions of getpwent getpwnam getpwnam_r getpwuid getpwuid_r
(all of the symbols are namespaced) in order to remove symbol clash with
libc.

This program uses code directly from libc.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/chpass/Makefile

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/chpass/Makefile
diff -u src/usr.bin/chpass/Makefile:1.15 src/usr.bin/chpass/Makefile:1.16
--- src/usr.bin/chpass/Makefile:1.15	Mon May 28 12:06:25 2007
+++ src/usr.bin/chpass/Makefile	Mon Jun 25 18:05:25 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.15 2007/05/28 12:06:25 tls Exp $
+#	$NetBSD: Makefile,v 1.16 2018/06/25 18:05:25 kamil Exp $
 #	@(#)Makefile	8.2 (Berkeley) 4/2/94
 
 .include 
@@ -22,6 +22,11 @@ LDADD+=	-lrpcsvc
 .else
 SRCS+=	getpwent.c
 CPPFLAGS.getpwent.c=-UYP
+SANITIZER_RENAME_SYMBOL+=	__getpwent50
+SANITIZER_RENAME_SYMBOL+=	__getpwnam50
+SANITIZER_RENAME_SYMBOL+=	__getpwnam_r50
+SANITIZER_RENAME_SYMBOL+=	__getpwuid50
+SANITIZER_RENAME_SYMBOL+=	__getpwuid_r50
 .endif
 
 DPADD+= ${LIBUTIL}



CVS commit: src/external/gpl2/xcvs

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:03:56 UTC 2018

Modified Files:
src/external/gpl2/xcvs: Makefile.inc

Log Message:
Specify SANITIZER_RENAME_SYMBOL in cvs

Rename local versions of regcomp regerror regexec regfree in order to
remove symbol clash with libc.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/gpl2/xcvs/Makefile.inc

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

Modified files:

Index: src/external/gpl2/xcvs/Makefile.inc
diff -u src/external/gpl2/xcvs/Makefile.inc:1.4 src/external/gpl2/xcvs/Makefile.inc:1.5
--- src/external/gpl2/xcvs/Makefile.inc:1.4	Sat Jan 30 16:47:00 2016
+++ src/external/gpl2/xcvs/Makefile.inc	Mon Jun 25 18:03:56 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.4 2016/01/30 16:47:00 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.5 2018/06/25 18:03:56 kamil Exp $
 
 .include 
 
@@ -24,3 +24,5 @@ COBJDIR!=cd $(.CURDIR)/../../lib/libcvs 
 LIBDIFF=	${DOBJDIR}/libdiff.a
 LIBCVS=		${COBJDIR}/libcvs.a
 .endif
+
+SANITIZER_RENAME_SYMBOL+=	regcomp regerror regexec regfree



CVS commit: src/external/gpl2/grep

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:02:49 UTC 2018

Modified Files:
src/external/gpl2/grep: Makefile.inc

Log Message:
Specify SANITIZER_RENAME_SYMBOL in grep

Rename local versions of regcomp regerror regexec regfree in order to
remove symbol clash with libc.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/gpl2/grep/Makefile.inc

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

Modified files:

Index: src/external/gpl2/grep/Makefile.inc
diff -u src/external/gpl2/grep/Makefile.inc:1.1 src/external/gpl2/grep/Makefile.inc:1.2
--- src/external/gpl2/grep/Makefile.inc:1.1	Sun Jan 10 22:16:40 2016
+++ src/external/gpl2/grep/Makefile.inc	Mon Jun 25 18:02:49 2018
@@ -1,7 +1,9 @@
-#	$NetBSD: Makefile.inc,v 1.1 2016/01/10 22:16:40 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.2 2018/06/25 18:02:49 kamil Exp $
 
 .include 
 
+SANITIZER_RENAME_SYMBOL+=	regcomp regerror regexec regfree
+
 WARNS=	0
 
 IDIST=	${NETBSDSRCDIR}/external/gpl2/grep/dist



CVS commit: src/external/gpl2/diffutils

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:01:13 UTC 2018

Modified Files:
src/external/gpl2/diffutils: Makefile.inc

Log Message:
Specify SANITIZER_RENAME_SYMBOL in diffutils

Rename local versions of regcomp regerror regexec regfree in order to
remove symbol clash with libc.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/gpl2/diffutils/Makefile.inc

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

Modified files:

Index: src/external/gpl2/diffutils/Makefile.inc
diff -u src/external/gpl2/diffutils/Makefile.inc:1.1 src/external/gpl2/diffutils/Makefile.inc:1.2
--- src/external/gpl2/diffutils/Makefile.inc:1.1	Wed Jan 13 03:39:28 2016
+++ src/external/gpl2/diffutils/Makefile.inc	Mon Jun 25 18:01:13 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.1 2016/01/13 03:39:28 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.2 2018/06/25 18:01:13 kamil Exp $
 
 WARNS=	0
 
@@ -6,3 +6,5 @@ IDIST=	${NETBSDSRCDIR}/external/gpl2/dif
 
 CPPFLAGS+=	-DLOCALEDIR=\"/usr/share/locale\" -DHAVE_CONFIG_H \
 		-I${IDIST}/../include -I${IDIST}/lib
+
+SANITIZER_RENAME_SYMBOL+=	regcomp regerror regexec regfree



CVS commit: src/external/bsd/nvi

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 18:00:34 UTC 2018

Modified Files:
src/external/bsd/nvi: Makefile.inc

Log Message:
Specify SANITIZER_RENAME_SYMBOL in nvi

Rename local versions of regcomp regerror regexec regfree in order to
remove symbol clash with libc.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/Makefile.inc

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

Modified files:

Index: src/external/bsd/nvi/Makefile.inc
diff -u src/external/bsd/nvi/Makefile.inc:1.5 src/external/bsd/nvi/Makefile.inc:1.6
--- src/external/bsd/nvi/Makefile.inc:1.5	Sat Jan 21 22:27:43 2017
+++ src/external/bsd/nvi/Makefile.inc	Mon Jun 25 18:00:34 2018
@@ -1,7 +1,9 @@
-#	$NetBSD: Makefile.inc,v 1.5 2017/01/21 22:27:43 rin Exp $
+#	$NetBSD: Makefile.inc,v 1.6 2018/06/25 18:00:34 kamil Exp $
 
 .include 
 
+SANITIZER_RENAME_SYMBOL+=	regcomp regerror regexec regfree
+
 DIST= ${NETBSDSRCDIR}/external/bsd/nvi/dist
 .PATH: ${DIST}
 BINDIR=/usr/bin



CVS commit: src/share/mk

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 17:58:36 UTC 2018

Modified Files:
src/share/mk: bsd.lib.mk bsd.prog.mk

Log Message:
Add a framework for renaming symbols in libc for MKSANITIZER

A new keyword SANITIZER_RENAME_SYMBOL. It's a variable that has specified
a list of symbols to be renamed in a processor in order to remove naming
conflicts with public symbols in libc/m/pthread/rt.

This renaming will occur for libraries and programs.
A symbol with a conflicting 'name', will be renamed to '__mksanitizer_name'.

Based on an idea by 


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/share/mk/bsd.lib.mk
cvs rdiff -u -r1.314 -r1.315 src/share/mk/bsd.prog.mk

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

Modified files:

Index: src/share/mk/bsd.lib.mk
diff -u src/share/mk/bsd.lib.mk:1.375 src/share/mk/bsd.lib.mk:1.376
--- src/share/mk/bsd.lib.mk:1.375	Thu Jun 21 11:24:38 2018
+++ src/share/mk/bsd.lib.mk	Mon Jun 25 17:58:36 2018
@@ -1,9 +1,17 @@
-#	$NetBSD: bsd.lib.mk,v 1.375 2018/06/21 11:24:38 kamil Exp $
+#	$NetBSD: bsd.lib.mk,v 1.376 2018/06/25 17:58:36 kamil Exp $
 #	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
 
 .include 
 .include 
 .include 
+
+# Rename the local function definitions to not conflict with libc/rt/pthread/m.
+.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
+.	for _symbol in ${SANITIZER_RENAME_SYMBOL}
+CPPFLAGS+=	-D${_symbol}=__mksanitizer_${_symbol}
+.	endfor
+.endif
+
 # Pull in  here so we can override its .c.o rule
 .include 
 

Index: src/share/mk/bsd.prog.mk
diff -u src/share/mk/bsd.prog.mk:1.314 src/share/mk/bsd.prog.mk:1.315
--- src/share/mk/bsd.prog.mk:1.314	Thu Jun 21 11:24:38 2018
+++ src/share/mk/bsd.prog.mk	Mon Jun 25 17:58:36 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.prog.mk,v 1.314 2018/06/21 11:24:38 kamil Exp $
+#	$NetBSD: bsd.prog.mk,v 1.315 2018/06/25 17:58:36 kamil Exp $
 #	@(#)bsd.prog.mk	8.2 (Berkeley) 4/2/94
 
 .ifndef HOSTPROG
@@ -13,6 +13,13 @@ CFLAGS+=	${SANITIZERFLAGS}
 CXXFLAGS+=	${SANITIZERFLAGS}
 LDFLAGS+=	${SANITIZERFLAGS}
 
+# Rename the local function definitions to not conflict with libc/rt/pthread/m.
+.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
+.	for _symbol in ${SANITIZER_RENAME_SYMBOL}
+CPPFLAGS+=	-D${_symbol}=__mksanitizer_${_symbol}
+.	endfor
+.endif
+
 #
 # Definitions and targets shared among all programs built by a single
 # Makefile.



CVS commit: src/external/bsd/nvi/dist/common

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 17:42:34 UTC 2018

Modified Files:
src/external/bsd/nvi/dist/common: log1.c

Log Message:
Avoid unportable offsetof(3) calculation in nvi in log1.c

Detected with MKSANITIZER/UBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/log1.c

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

Modified files:

Index: src/external/bsd/nvi/dist/common/log1.c
diff -u src/external/bsd/nvi/dist/common/log1.c:1.4 src/external/bsd/nvi/dist/common/log1.c:1.5
--- src/external/bsd/nvi/dist/common/log1.c:1.4	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/common/log1.c	Mon Jun 25 17:42:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: log1.c,v 1.4 2014/01/26 21:43:45 christos Exp $	*/
+/*	$NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $	*/
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp  (Berkeley) Date: 2002/03/02 23:12:13 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: log1.c,v 1.4 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $");
 #endif
 
 #include 
@@ -88,7 +88,7 @@ typedef struct {
 chardata[sizeof(u_char) /* type */ + sizeof(db_recno_t)];
 CHAR_T  str[1];
 } log_t;
-#define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0)
+#define CHAR_T_OFFSET (offsetof(log_t, str))
 
 /*
  * log_init --



CVS commit: src/usr.bin/jot

2018-06-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 25 14:29:17 UTC 2018

Modified Files:
src/usr.bin/jot: jot.1 jot.c

Log Message:
Don't require any arguments as the usage indicates; simplifies the code
and the documentation: now "jot" works like "jot -" used to (and continues
to). From Ingo Schwarze


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/jot/jot.1
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/jot/jot.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/jot/jot.1
diff -u src/usr.bin/jot/jot.1:1.15 src/usr.bin/jot/jot.1:1.16
--- src/usr.bin/jot/jot.1:1.15	Mon Jul  3 17:34:19 2017
+++ src/usr.bin/jot/jot.1	Mon Jun 25 10:29:17 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: jot.1,v 1.15 2017/07/03 21:34:19 wiz Exp $
+.\"	$NetBSD: jot.1,v 1.16 2018/06/25 14:29:17 christos Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)jot.1	8.1 (Berkeley) 6/6/93
 .\"
-.Dd January 5, 2016
+.Dd June 25, 2018
 .Dt JOT 1
 .Os
 .Sh NAME
@@ -104,8 +104,7 @@ in which case the data are inserted rath
 The last four arguments indicate, respectively,
 the number of data, the lower bound, the upper bound,
 and the step size or, for random data, the seed.
-While at least one of them must appear,
-any of the other three may be omitted, and
+Any argument may be omitted, and
 will be considered as such if given as
 .Dq - .
 Any three of these arguments determines the fourth.

Index: src/usr.bin/jot/jot.c
diff -u src/usr.bin/jot/jot.c:1.25 src/usr.bin/jot/jot.c:1.26
--- src/usr.bin/jot/jot.c:1.25	Sun Apr 12 07:19:18 2009
+++ src/usr.bin/jot/jot.c	Mon Jun 25 10:29:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: jot.c,v 1.25 2009/04/12 11:19:18 lukem Exp $	*/
+/*	$NetBSD: jot.c,v 1.26 2018/06/25 14:29:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)jot.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: jot.c,v 1.25 2009/04/12 11:19:18 lukem Exp $");
+__RCSID("$NetBSD: jot.c,v 1.26 2018/06/25 14:29:17 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -216,9 +216,7 @@ getargs(int argc, char *argv[])
 argv[0]);
 			have |= REPS;
 		}
-		break;
 	case 0:
-		usage();
 		break;
 	default:
 		errx(EXIT_FAILURE,



CVS commit: src/sys/dev/ppbus

2018-06-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 25 13:28:12 UTC 2018

Modified Files:
src/sys/dev/ppbus: if_plip.c

Log Message:
 KNF & fix typo. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ppbus/if_plip.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/ppbus/if_plip.c
diff -u src/sys/dev/ppbus/if_plip.c:1.28 src/sys/dev/ppbus/if_plip.c:1.29
--- src/sys/dev/ppbus/if_plip.c:1.28	Sun Jun 25 12:27:13 2017
+++ src/sys/dev/ppbus/if_plip.c	Mon Jun 25 13:28:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_plip.c,v 1.28 2017/06/25 12:27:13 maxv Exp $ */
+/* $NetBSD: if_plip.c,v 1.29 2018/06/25 13:28:12 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1997 Poul-Henning Kamp
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.28 2017/06/25 12:27:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.29 2018/06/25 13:28:12 msaitoh Exp $");
 
 /*
  * Parallel port TCP/IP interfaces added.  I looked at the driver from
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 
  * This driver sends two bytes (0x08, 0x00) in front of each packet,
  * to allow us to distinguish another format later.
  *
- * Now added an Linux/Crynwr compatibility mode which is enabled using
+ * Now added a Linux/Crynwr compatibility mode which is enabled using
  * IF_LINK0 - Tim Wilkinson.
  *
  * TODO:
@@ -194,7 +194,7 @@ static void lpinittables(void);
 static void lpfreetables(void);
 static int lpioctl(struct ifnet *, u_long, void *);
 static int lpoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
-	const struct rtentry *);
+const struct rtentry *);
 static void lpstart(struct ifnet *);
 static void lp_intr(void *);
 
@@ -205,7 +205,7 @@ lp_probe(device_t parent, cfdata_t match
 	struct ppbus_attach_args * args = aux;
 
 	/* Fail if ppbus is not interrupt capable */
-	if(args->capabilities & PPBUS_HAS_INTR)
+	if (args->capabilities & PPBUS_HAS_INTR)
 		return 1;
 
 	printf("%s(%s): not an interrupt-driven port.\n", __func__,
@@ -243,7 +243,7 @@ lp_attach(device_t parent, device_t self
 
 	bpf_attach(ifp, DLT_NULL, sizeof(u_int32_t));
 
-	if(lp_count++ == 0)
+	if (lp_count++ == 0)
 		lpinittables();
 	printf("\n");
 }
@@ -255,8 +255,8 @@ lp_detach(device_t self, int flags)
 	struct lp_softc * lp = device_private(self);
 	device_t ppbus = device_parent(self);
 
-	if(lp->sc_dev_ok) {
-		if(!(flags & DETACH_QUIET))
+	if (lp->sc_dev_ok) {
+		if (!(flags & DETACH_QUIET))
 			LP_PRINTF("%s(%s): device not properly attached! "
 "Skipping detach\n", __func__,
 device_xname(self));
@@ -264,33 +264,33 @@ lp_detach(device_t self, int flags)
 	}
 
 	/* If interface is up, bring it down and release ppbus */
-	if(lp->sc_if.if_flags & IFF_RUNNING) {
+	if (lp->sc_if.if_flags & IFF_RUNNING) {
 		ppbus_wctr(ppbus, 0x00);
 		if_detach(>sc_if);
 		error = ppbus_remove_handler(ppbus, lp_intr);
-		if(error) {
-			if(!(flags & DETACH_QUIET))
+		if (error) {
+			if (!(flags & DETACH_QUIET))
 LP_PRINTF("%s(%s): unable to remove interrupt "
 	"callback.\n", __func__,
 	device_xname(self));
-			if(!(flags & DETACH_FORCE))
+			if (!(flags & DETACH_FORCE))
 return error;
 		}
 		error = ppbus_release_bus(ppbus, self, 0, 0);
-		if(error) {
-			if(!(flags & DETACH_QUIET))
+		if (error) {
+			if (!(flags & DETACH_QUIET))
 LP_PRINTF("%s(%s): error releasing bus %s.\n",
 	__func__, device_xname(self),
 	device_xname(ppbus));
-			if(!(flags & DETACH_FORCE))
+			if (!(flags & DETACH_FORCE))
 return error;
 		}
 	}
 
-	if(lp->sc_ifbuf)
+	if (lp->sc_ifbuf)
 		free(lp->sc_ifbuf, M_DEVBUF);
 
-	if(--lp_count == 0)
+	if (--lp_count == 0)
 		lpfreetables();
 	return error;
 }
@@ -301,7 +301,7 @@ lp_detach(device_t self, int flags)
  * precalculate them when we initialize.
  */
 static void
-lpinittables (void)
+lpinittables(void)
 {
 	int i;
 
@@ -311,14 +311,14 @@ lpinittables (void)
 	if (!ctxmith)
 		ctxmith = malloc(4*LPIPTBLSIZE, M_DEVBUF, M_WAITOK);
 
-	for(i = 0; i < LPIPTBLSIZE; i++) {
+	for (i = 0; i < LPIPTBLSIZE; i++) {
 		ctxmith[i] = (i & 0xF0) >> 4;
 		ctxmitl[i] = 0x10 | (i & 0x0F);
 		ctrecvh[i] = (i & 0x78) << 1;
 		ctrecvl[i] = (i & 0x78) >> 3;
 	}
 
-	for(i = 0; i < LPIPTBLSIZE; i++) {
+	for (i = 0; i < LPIPTBLSIZE; i++) {
 		txmith[i] = ((i & 0x80) >> 3) | ((i & 0x70) >> 4) | 0x08;
 		txmitl[i] = ((i & 0x08) << 1) | (i & 0x07);
 		trecvh[i] = ((~i) & 0x80) | ((i & 0x38) << 1);
@@ -328,7 +328,7 @@ lpinittables (void)
 
 /* Free translation tables */
 static void
-lpfreetables (void)
+lpfreetables(void)
 {
 	if (txmith)
 		free(txmith, M_DEVBUF);
@@ -353,7 +353,7 @@ lpioctl(struct ifnet *ifp, u_long cmd, v
 	error = 0;
 	s = splnet();
 
-	if(sc->sc_dev_ok) {
+	if (sc->sc_dev_ok) {
 		LP_PRINTF("%s(%s): device not properly attached!", __func__,
 			device_xname(dev));
 		error = ENODEV;
@@ -377,15 

CVS commit: [netbsd-8] src/doc

2018-06-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 25 13:01:26 UTC 2018

Modified Files:
src/doc [netbsd-8]: CHANGES-8.0

Log Message:
Ticket #904, ammend #892


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.218 -r1.1.2.219 src/doc/CHANGES-8.0

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-8.0
diff -u src/doc/CHANGES-8.0:1.1.2.218 src/doc/CHANGES-8.0:1.1.2.219
--- src/doc/CHANGES-8.0:1.1.2.218	Sun Jun 24 09:51:46 2018
+++ src/doc/CHANGES-8.0	Mon Jun 25 13:01:26 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.218 2018/06/24 09:51:46 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.219 2018/06/25 13:01:26 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -13994,8 +13994,10 @@ crypto/external/bsd/openssl/dist/crypto/
 
 
 lib/libc/sys/sched.c1.5
+tests/lib/libc/gen/posix_spawn/t_spawnattr.c	1.2,1.3
 
 	Return PRI_NONE for sched_get_priority_m{in,ax} and SCHED_OTHER.
+	Fix broken test, don't use SCHED_OTHER.
 	[maya, ticket #892]
 
 sys/netinet6/icmp6.c1.228,1.230
@@ -14106,3 +14108,13 @@ sys/sys/param.h	changed manually
 
 	Welcome to 8.0 RC2
 
+distrib/common/Makefile.bootcd			1.40
+
+	Do not put debug.tgz and xdebug.tgz onto install CDs.
+	[martin, ticket #904]
+
+tests/lib/libc/gen/posix_spawn/t_spawnattr.c
+distrib/common/Makefile.bootcd
+doc/CHANGES-8.0
+
+	Tag moved for additional RC2 pullups (#892, #904)



CVS commit: [netbsd-8] src/distrib/common

2018-06-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 25 12:59:27 UTC 2018

Modified Files:
src/distrib/common [netbsd-8]: Makefile.bootcd

Log Message:
Pull up following revision(s) (requested by martin in ticket #904):

distrib/common/Makefile.bootcd: revision 1.40

Do not put debug.tgz and xdebug.tgz onto install CDs (a lot of them
grow out of bounds and for some architectures can not turn into DVDs).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.4.1 src/distrib/common/Makefile.bootcd

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

Modified files:

Index: src/distrib/common/Makefile.bootcd
diff -u src/distrib/common/Makefile.bootcd:1.38 src/distrib/common/Makefile.bootcd:1.38.4.1
--- src/distrib/common/Makefile.bootcd:1.38	Thu Feb 16 02:37:32 2017
+++ src/distrib/common/Makefile.bootcd	Mon Jun 25 12:59:27 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootcd,v 1.38 2017/02/16 02:37:32 christos Exp $
+#	$NetBSD: Makefile.bootcd,v 1.38.4.1 2018/06/25 12:59:27 martin Exp $
 #
 # Makefile snipped to create a CD/DVD ISO
 #
@@ -185,6 +185,8 @@ copy-releasedir:
 		${TOOL_PAX} ${PAX_TIMESTAMP}\
 			-rw -pe ${PAX_v}\
 			${CDRELEASE_EXCLUDE}\
+			-s ',./binary/sets/debug.tgz,,gp'		\
+			-s ',./binary/sets/xdebug.tgz,,gp'		\
 			. $$release_destdir; \
 		cd "${CUROBJDIR}";	\
 	fi



CVS commit: [netbsd-8] src/tests/lib/libc/gen/posix_spawn

2018-06-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 25 12:55:01 UTC 2018

Modified Files:
src/tests/lib/libc/gen/posix_spawn [netbsd-8]: t_spawnattr.c

Log Message:
Additionally pull up following revision(s) (requested by maya in ticket #892):

tests/lib/libc/gen/posix_spawn/t_spawnattr.c: revision 1.2,1.3

Don't use SCHED_OTHER.

Fix broken test: we can't assume that the current schedule priority range
will overlap with the requested scheduler range, so get the new scheduler
range, and then try to find a different priority. If that fails (to find
a different scheduling range), give up here.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.34.1 \
src/tests/lib/libc/gen/posix_spawn/t_spawnattr.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/gen/posix_spawn/t_spawnattr.c
diff -u src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.1 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.1.34.1
--- src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.1	Mon Feb 13 21:03:08 2012
+++ src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c	Mon Jun 25 12:55:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawnattr.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
+/* $NetBSD: t_spawnattr.c,v 1.1.34.1 2018/06/25 12:55:01 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -45,37 +45,33 @@
 #define MAX(a, b)	(a) > (b) ? (a) : (b)
 #define MIN(a, b)	(a) > (b) ? (b) : (a)
 
-static int get_different_scheduler(void);
-static int get_different_priority(void);
-
 static int
-get_different_scheduler()
+get_different_scheduler(void)
 {
-	int scheduler, max, min, new;
-
-	max = MAX(MAX(SCHED_FIFO, SCHED_OTHER), SCHED_RR);
-	min = MIN(MIN(SCHED_FIFO, SCHED_OTHER), SCHED_RR);
+	/*
+	 * We don't want to use SCHED_OTHER because it does not have
+	 * different priorities.
+	 */
 
 	/* get current schedule policy */
-	scheduler = sched_getscheduler(0);
-	
-	/* new scheduler */
-	new = (scheduler + 1);
-	if (new > max)
-		new = min;
-
-	return new;
+	switch (sched_getscheduler(0)) {
+	case SCHED_RR:
+		return SCHED_FIFO;
+	case SCHED_FIFO:
+	case SCHED_OTHER:
+		return SCHED_RR;
+	default:
+		abort();
+	}
 }
 
 static int
-get_different_priority()
+get_different_priority(int scheduler)
 {
-	int scheduler, max, min, new, priority;
+	int min, max, new, priority;
 	struct sched_param param;
 
-	/* get current schedule policy */
-	scheduler = sched_getscheduler(0);
-
+	/* Get the priority range for the new scheduler */
 	max = sched_get_priority_max(scheduler);
 	min = sched_get_priority_min(scheduler);
 
@@ -83,10 +79,13 @@ get_different_priority()
 	priority = param.sched_priority;
 	
 	/* new schedule policy */
-	new = (priority + 1);
-	if (new > max)
-		new = min;
+	for (new = min; new <= max; new++)
+		if (priority != new)
+			break;
 	
+	ATF_REQUIRE_MSG(priority != new, "could not find different priority");
+	printf("min %d max %d for scheduler %d, returning %d\n",
+	min, max, scheduler, new);
 	return new;
 }
 
@@ -119,8 +118,9 @@ ATF_TC_BODY(t_spawnattr, tc)
 	posix_spawnattr_init();
 
 	scheduler = get_different_scheduler();
-	priority = get_different_priority();
+	priority = get_different_priority(scheduler);
 	sp.sched_priority = priority;
+	printf("using scheduler %d, priority %d\n", scheduler, priority);
 	
 	sigemptyset();
 	sigaddset(, SIGUSR1);



CVS commit: src/distrib/common

2018-06-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 25 12:18:22 UTC 2018

Modified Files:
src/distrib/common: Makefile.bootcd

Log Message:
Do not put debug.tgz and xdebug.tgz onto install CDs (a lot of them
grow out of bounds and for some architectures can not turn into DVDs).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/distrib/common/Makefile.bootcd

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

Modified files:

Index: src/distrib/common/Makefile.bootcd
diff -u src/distrib/common/Makefile.bootcd:1.39 src/distrib/common/Makefile.bootcd:1.40
--- src/distrib/common/Makefile.bootcd:1.39	Fri Sep  8 09:50:44 2017
+++ src/distrib/common/Makefile.bootcd	Mon Jun 25 12:18:22 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootcd,v 1.39 2017/09/08 09:50:44 martin Exp $
+#	$NetBSD: Makefile.bootcd,v 1.40 2018/06/25 12:18:22 martin Exp $
 #
 # Makefile snipped to create a CD/DVD ISO
 #
@@ -189,6 +189,8 @@ copy-releasedir:
 		${TOOL_PAX} ${PAX_TIMESTAMP}\
 			-rw -pe ${PAX_v}\
 			${CDRELEASE_EXCLUDE}\
+			-s ',./binary/sets/debug.tgz,,gp'		\
+			-s ',./binary/sets/xdebug.tgz,,gp'		\
 			. $$release_destdir; \
 		cd "${CUROBJDIR}";	\
 	fi



CVS commit: [pgoyette-compat] src/external/cddl/osnet/dev/fbt

2018-06-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun 25 11:22:57 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/fbt [pgoyette-compat]: fbt.c

Log Message:
Adapt to new world order - mod_required is no a pointer to an array.


To generate a diff of this commit:
cvs rdiff -u -r1.23.2.2 -r1.23.2.3 src/external/cddl/osnet/dev/fbt/fbt.c

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

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.23.2.2 src/external/cddl/osnet/dev/fbt/fbt.c:1.23.2.3
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.23.2.2	Mon Jun 25 07:25:14 2018
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Mon Jun 25 11:22:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.23.2.2 2018/06/25 07:25:14 pgoyette Exp $	*/
+/*	$NetBSD: fbt.c,v 1.23.2.3 2018/06/25 11:22:57 pgoyette Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -284,7 +284,7 @@ fbt_provide_module(void *arg, modctl_t *
 	 * dependency are ineligible for FBT tracing.
 	 */
 	for (i = 0; i < mod->mod_nrequired; i++) {
-		if (strncmp(module_name(mod->mod_required[i]),
+		if (strncmp(module_name((*mod->mod_required)[i]),
 			"dtrace", 6) == 0)
 			return;
 	}



CVS commit: src/share/man/man9

2018-06-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jun 25 10:53:47 UTC 2018

Modified Files:
src/share/man/man9: bpf.9

Log Message:
Remove superfluous Pp.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/bpf.9

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/man9/bpf.9
diff -u src/share/man/man9/bpf.9:1.4 src/share/man/man9/bpf.9:1.5
--- src/share/man/man9/bpf.9:1.4	Mon Jun 25 03:22:14 2018
+++ src/share/man/man9/bpf.9	Mon Jun 25 10:53:47 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: bpf.9,v 1.4 2018/06/25 03:22:14 msaitoh Exp $
+.\" $NetBSD: bpf.9,v 1.5 2018/06/25 10:53:47 wiz Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -36,7 +36,6 @@
 .Sh DESCRIPTION
 .Nm
 is called via an operations vector described by the following struct:
-.Pp
 .Bd -literal
 struct bpf_ops {
 void (*bpf_attach)(struct ifnet *, u_int, u_int, struct bpf_if **);



CVS commit: [pgoyette-compat] src/sys/sys

2018-06-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun 25 10:11:21 UTC 2018

Modified Files:
src/sys/sys [pgoyette-compat]: module.h

Log Message:
Resolve conflict correctly!


To generate a diff of this commit:
cvs rdiff -u -r1.41.14.9 -r1.41.14.10 src/sys/sys/module.h

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

Modified files:

Index: src/sys/sys/module.h
diff -u src/sys/sys/module.h:1.41.14.9 src/sys/sys/module.h:1.41.14.10
--- src/sys/sys/module.h:1.41.14.9	Mon Jun 25 07:22:54 2018
+++ src/sys/sys/module.h	Mon Jun 25 10:11:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: module.h,v 1.41.14.9 2018/06/25 07:22:54 pgoyette Exp $	*/
+/*	$NetBSD: module.h,v 1.41.14.10 2018/06/25 10:11:21 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -250,8 +250,9 @@ typedef struct modctl_load {
 enum modctl {
 	MODCTL_LOAD,		/* modctl_load_t *ml */
 	MODCTL_UNLOAD,		/* char *name */
-	MODCTL_STAT,		/* struct iovec *buffer */
-	MODCTL_EXISTS		/* enum: 0: load, 1: autoload */
+	MODCTL_OSTAT,		/* struct iovec *buffer */
+	MODCTL_EXISTS,		/* enum: 0: load, 1: autoload */
+	MODCTL_STAT		/* struct iovec *buffer */
 };
 
 /*



CVS commit: src/sys/dev/pcmcia

2018-06-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 25 09:57:26 UTC 2018

Modified Files:
src/sys/dev/pcmcia: if_malo_pcmcia.c

Log Message:
 Simplify bpf_mtap() call. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pcmcia/if_malo_pcmcia.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/pcmcia/if_malo_pcmcia.c
diff -u src/sys/dev/pcmcia/if_malo_pcmcia.c:1.16 src/sys/dev/pcmcia/if_malo_pcmcia.c:1.17
--- src/sys/dev/pcmcia/if_malo_pcmcia.c:1.16	Mon Jan 22 14:40:53 2018
+++ src/sys/dev/pcmcia/if_malo_pcmcia.c	Mon Jun 25 09:57:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_malo_pcmcia.c,v 1.16 2018/01/22 14:40:53 maxv Exp $	*/
+/*	$NetBSD: if_malo_pcmcia.c,v 1.17 2018/06/25 09:57:25 msaitoh Exp $	*/
 /*  $OpenBSD: if_malo.c,v 1.65 2009/03/29 21:53:53 sthen Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.16 2018/01/22 14:40:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.17 2018/06/25 09:57:25 msaitoh Exp $");
 
 #ifdef _MODULE
 #include 
@@ -522,8 +522,7 @@ cmalo_start(struct ifnet *ifp)
 
 	IFQ_DEQUEUE(>if_snd, m);
 
-	if (ifp->if_bpf)
-		bpf_ops->bpf_mtap(ifp->if_bpf, m);
+	bpf_mtap(ifp, m);
 
 	if (cmalo_tx(sc, m) != 0)
 		ifp->if_oerrors++;



CVS commit: src/share/mk

2018-06-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 25 09:38:46 UTC 2018

Modified Files:
src/share/mk: bsd.README

Log Message:
Rephrase the documentation of MKSANITIZER

Based on the feedback from  and .


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 src/share/mk/bsd.README

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

Modified files:

Index: src/share/mk/bsd.README
diff -u src/share/mk/bsd.README:1.376 src/share/mk/bsd.README:1.377
--- src/share/mk/bsd.README:1.376	Sun Jun 24 20:40:58 2018
+++ src/share/mk/bsd.README	Mon Jun 25 09:38:46 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.README,v 1.376 2018/06/24 20:40:58 kamil Exp $
+#	$NetBSD: bsd.README,v 1.377 2018/06/25 09:38:46 kamil Exp $
 #	@(#)bsd.README	8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
@@ -392,7 +392,7 @@ MKSANITIZER	if "yes", use the selected s
 		"address". A selection of available sanitizers:
 			address:	A memory error detector (default)
 			thread:		A data race detector
-			memory:		An uninitializer read detector
+			memory:		An uninitialized memory read detector
 			undefined:	An undefined behavior detector
 			leak:		A memory leak detector
 			dataflow:	A general data flow analysis
@@ -400,12 +400,11 @@ MKSANITIZER	if "yes", use the selected s
 			safe-stack:	Protect against stack-based corruption
 			scudo:		The Scudo Hardened allocator
 		It's possible to specify multiple sanitizers within the
-		USE_SANITIZER option (comma separated) and some combinations of
-		them work. The USE_SANITIZER value is passed to the -fsanitize=
-		argument to a compiler.
+		USE_SANITIZER option (comma separated). The USE_SANITIZER value
+		is passed to the -fsanitize= argument to the compiler.
 		Additional arguments can be passed through SANITIZERFLAGS.
-		The list of supported features depends on the compiler version
-		and target CPU architecture.
+		The list of supported features and their valid combinations
+		depends on the compiler version and target CPU architecture.
 
 MKSHARE		If "no", act as "MKCATPAGES=no MKDOC=no MKHTML=no MKINFO=no
 		MKMAN=no MKNLS=no".



CVS commit: src

2018-06-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 25 09:32:28 UTC 2018

Modified Files:
src/doc: TODO.smpnet
src/sys/dev/pci: if_lmc.c if_lmc.h

Log Message:
 Move txintr_setup() stuff from lmc_interrupt() and do it in ifnet_start().
Now we can use bpf_mtap() in the TX path. Not tested.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/doc/TODO.smpnet
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/if_lmc.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/if_lmc.h

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

Modified files:

Index: src/doc/TODO.smpnet
diff -u src/doc/TODO.smpnet:1.19 src/doc/TODO.smpnet:1.20
--- src/doc/TODO.smpnet:1.19	Tue Feb 27 14:28:01 2018
+++ src/doc/TODO.smpnet	Mon Jun 25 09:32:28 2018
@@ -1,4 +1,4 @@
-$NetBSD: TODO.smpnet,v 1.19 2018/02/27 14:28:01 maxv Exp $
+$NetBSD: TODO.smpnet,v 1.20 2018/06/25 09:32:28 msaitoh Exp $
 
 MP-safe components
 ==
@@ -104,7 +104,7 @@ This is the list of the functions that h
 
  - sca_frame_process() @ sys/dev/ic/hd64570.c
  - en_intr() @ sys/dev/ic/midway.c
- - rxintr_cleanup() and txintr_cleanup() @ sys/dev/pci/if_lmc.c
+ - rxintr_cleanup() @ sys/dev/pci/if_lmc.c
  - ipr_rx_data_rdy() @ sys/netisdn/i4b_ipr.c
 
 Ideally we should make the functions run in softint somehow, but we don't have

Index: src/sys/dev/pci/if_lmc.c
diff -u src/sys/dev/pci/if_lmc.c:1.64 src/sys/dev/pci/if_lmc.c:1.65
--- src/sys/dev/pci/if_lmc.c:1.64	Wed Feb  7 06:18:11 2018
+++ src/sys/dev/pci/if_lmc.c	Mon Jun 25 09:32:28 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_lmc.c,v 1.64 2018/02/07 06:18:11 mrg Exp $ */
+/* $NetBSD: if_lmc.c,v 1.65 2018/06/25 09:32:28 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2002-2006 David Boggs. 
@@ -74,7 +74,7 @@
  */
 
 # include 
-__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.64 2018/02/07 06:18:11 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.65 2018/06/25 09:32:28 msaitoh Exp $");
 # include 	/* OS version */
 # include "opt_inet.h"	/* INET6, INET */
 # include "opt_altq_enabled.h" /* ALTQ */
@@ -3388,7 +3388,7 @@ ifnet_output(struct ifnet *ifp, struct m
 }
   else
 /* Process tx pkts; do not process rx pkts. */
-lmc_interrupt(sc, 0, 0);
+ifnet_start(ifp);
 
   return error;
   }
@@ -3466,9 +3466,43 @@ static void  /* context: process */
 ifnet_start(struct ifnet *ifp)
   {
   softc_t *sc = IFP2SC(ifp);
+  int activity;
 
-  /* Process tx pkts; do not process rx pkts. */
-  lmc_interrupt(sc, 0, 0);
+  /* Do this FIRST!  Otherwise UPs deadlock and MPs spin. */
+  WRITE_CSR(sc, TLP_STATUS, READ_CSR(sc, TLP_STATUS));
+
+  /* If any CPU is inside this critical section, then */
+  /*  other CPUs should go away without doing anything. */
+  if (BOTTOM_TRYLOCK(sc) == 0)
+{
+sc->status.cntrs.lck_intr++;
+return;
+}
+
+  /* In Linux, pci_alloc_consistent() means DMA */
+  /*  descriptors do not need explicit syncing? */
+#if BSD
+  {
+  struct desc_ring *ring = >txring;
+  DMA_SYNC(sc->txring.map, sc->txring.size_descs,
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+  }
+#endif
+
+  do
+{
+activity = txintr_setup(sc);
+} while (activity);
+
+#if BSD
+  {
+  struct desc_ring *ring = >txring;
+  DMA_SYNC(sc->txring.map, sc->txring.size_descs,
+   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+  }
+#endif
+
+  BOTTOM_UNLOCK(sc);
   }
 
 static void  /* context: softirq */
@@ -4294,7 +4328,7 @@ rxintr_cleanup(softc_t *sc)
 sc->status.cntrs.ipackets++;
 
 /* Berkeley Packet Filter */
-LMC_BPF_MTAP(sc, first_mbuf);
+bpf_mtap_softint(sc->ifp, first_mbuf);
 
 /* Give this good packet to the network stacks. */
 sc->quota--;
@@ -,9 +4478,6 @@ txintr_cleanup(softc_t *sc)
 /* Include CRC and one flag byte in output byte count. */
 sc->status.cntrs.obytes += m->m_pkthdr.len + sc->config.crc_len +1;
 sc->status.cntrs.opackets++;
-
-/* Berkeley Packet Filter */
-LMC_BPF_MTAP(sc, m);
 	}
 
   m_freem(m);
@@ -4564,6 +4595,9 @@ txintr_setup(softc_t *sc)
   /* Enqueue the mbuf; txintr_cleanup will free it. */
   mbuf_enqueue(ring, sc->tx_mbuf);
 
+  /* Berkeley Packet Filter */
+  bpf_mtap(sc->ifp, sc->tx_mbuf);
+
   /* The transmitter has room for another packet. */
   sc->tx_mbuf = NULL;
 
@@ -4969,7 +5003,6 @@ lmc_interrupt(void *arg, int quota, int 
   do
 {
 activity  = txintr_cleanup(sc);
-activity += txintr_setup(sc);
 activity += rxintr_cleanup(sc);
 activity += rxintr_setup(sc);
 } while (activity);

Index: src/sys/dev/pci/if_lmc.h
diff -u src/sys/dev/pci/if_lmc.h:1.24 src/sys/dev/pci/if_lmc.h:1.25
--- src/sys/dev/pci/if_lmc.h:1.24	Tue Jan 24 09:05:28 2017
+++ src/sys/dev/pci/if_lmc.h	Mon Jun 25 09:32:28 2018
@@ -1,5 +1,5 @@
 /*-
- * $NetBSD: if_lmc.h,v 1.24 2017/01/24 09:05:28 ozaki-r Exp $
+ * $NetBSD: if_lmc.h,v 1.25 2018/06/25 09:32:28 msaitoh Exp $
  *
  * Copyright (c) 2002-2006 David Boggs. 

CVS commit: [pgoyette-compat] src/sys/kern

2018-06-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun 25 08:50:10 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
Finish de-confliction


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.9 -r1.130.2.10 src/sys/kern/kern_module.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_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.9 src/sys/kern/kern_module.c:1.130.2.10
--- src/sys/kern/kern_module.c:1.130.2.9	Mon Jun 25 07:22:54 2018
+++ src/sys/kern/kern_module.c	Mon Jun 25 08:50:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.9 2018/06/25 07:22:54 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.10 2018/06/25 08:50:10 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.9 2018/06/25 07:22:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.10 2018/06/25 08:50:10 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1105,7 +1105,6 @@ module_do_load(const char *name, bool is
 #endif
 			SLIST_REMOVE_HEAD(_stack, pe_entry);
 			module_free(mod);
-			depth--;
 			return error;
 		}
 		TAILQ_INSERT_TAIL(pending, mod, mod_chain);
@@ -1332,7 +1331,6 @@ module_do_load(const char *name, bool is
 	TAILQ_REMOVE(pending, mod, mod_chain);
 	SLIST_REMOVE_HEAD(_stack, pe_entry);
 	module_free(mod);
-	depth--;
 	return error;
 }
 



CVS commit: [pgoyette-compat] src/sys

2018-06-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun 25 07:22:54 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c
src/sys/sys [pgoyette-compat]: module.h

Log Message:
Resolve conflicts with HEAD


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.8 -r1.130.2.9 src/sys/kern/kern_module.c
cvs rdiff -u -r1.41.14.8 -r1.41.14.9 src/sys/sys/module.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/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.8 src/sys/kern/kern_module.c:1.130.2.9
--- src/sys/kern/kern_module.c:1.130.2.8	Mon Apr  2 00:18:43 2018
+++ src/sys/kern/kern_module.c	Mon Jun 25 07:22:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.8 2018/04/02 00:18:43 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.9 2018/06/25 07:22:54 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.8 2018/04/02 00:18:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.9 2018/06/25 07:22:54 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -65,6 +65,21 @@ struct modlistmodule_list = TAIL
 struct modlistmodule_builtins = TAILQ_HEAD_INITIALIZER(module_builtins);
 static struct modlist module_bootlist = TAILQ_HEAD_INITIALIZER(module_bootlist);
 
+struct module_callbacks {
+	TAILQ_ENTRY(module_callbacks) modcb_list;
+	void (*modcb_load)(struct module *);
+	void (*modcb_unload)(struct module *);
+};
+TAILQ_HEAD(modcblist, module_callbacks);
+static struct modcblist modcblist;
+
+static module_t *module_netbsd;
+static const modinfo_t module_netbsd_modinfo = {
+	.mi_version = __NetBSD_Version__,
+	.mi_class = MODULE_CLASS_MISC,
+	.mi_name = "netbsd"
+};
+
 static module_t	*module_active;
 bool		module_verbose_on;
 #ifdef MODULAR_DEFAULT_AUTOLOAD
@@ -84,11 +99,14 @@ int (*module_load_vfs_vec)(const char *,
 
 static kauth_listener_t	module_listener;
 
+static specificdata_domain_t module_specificdata_domain;
+
 /* Ensure that the kernel's link set isn't empty. */
 static modinfo_t module_dummy;
 __link_set_add_rodata(modules, module_dummy);
 
 static module_t	*module_newmodule(modsrc_t);
+static void	module_free(module_t *);
 static void	module_require_force(module_t *);
 static int	module_do_load(const char *, bool, int, prop_dictionary_t,
 		module_t **, modclass_t modclass, bool);
@@ -107,6 +125,9 @@ static bool	module_merge_dicts(prop_dict
 static void	sysctl_module_setup(void);
 static int	sysctl_module_autotime(SYSCTLFN_PROTO);
 
+static void	module_callback_load(struct module *);
+static void	module_callback_unload(struct module *);
+
 #define MODULE_CLASS_MATCH(mi, modclass) \
 	((modclass) == MODULE_CLASS_ANY || (modclass) == (mi)->mi_class)
 
@@ -117,6 +138,13 @@ module_incompat(const modinfo_t *mi, int
 	mi->mi_name, modclass, mi->mi_class);
 }
 
+struct module *
+module_kernel(void)
+{
+
+	return module_netbsd;
+}
+
 /*
  * module_error:
  *
@@ -153,6 +181,30 @@ module_print(const char *fmt, ...)
 	}
 }
 
+/*
+ * module_name:
+ *
+ *	Utility function: return the module's name.
+ */
+const char *
+module_name(struct module *mod)
+{
+
+	return mod->mod_info->mi_name;
+}
+
+/*
+ * module_source:
+ *
+ *	Utility function: return the module's source.
+ */
+modsrc_t
+module_source(struct module *mod)
+{
+
+	return mod->mod_source;
+}
+
 static int
 module_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
 void *arg0, void *arg1, void *arg2, void *arg3)
@@ -180,12 +232,25 @@ module_newmodule(modsrc_t source)
 
 	mod = kmem_zalloc(sizeof(*mod), KM_SLEEP);
 	mod->mod_source = source;
-	mod->mod_info = NULL;
-	mod->mod_flags = 0;
+	specificdata_init(module_specificdata_domain, >mod_sdref);
 	return mod;
 }
 
 /*
+ * Free a module_t
+ */
+static void
+module_free(module_t *mod)
+{
+
+	specificdata_fini(module_specificdata_domain, >mod_sdref);
+	if (mod->mod_required)
+		kmem_free(mod->mod_required, mod->mod_arequired *
+		sizeof(module_t));
+	kmem_free(mod, sizeof(*mod));
+}
+
+/*
  * Require the -f (force) flag to load a module
  */
 static void
@@ -281,7 +346,7 @@ module_builtin_add(modinfo_t *const *mip
 	if (rv != 0) {
 		for (i = 0; i < nmodinfo; i++) {
 			if (modp[i])
-kmem_free(modp[i], sizeof(*modp[i]));
+module_free(modp[i]);
 		}
 	}
 	kmem_free(modp, sizeof(*modp) * nmodinfo);
@@ -348,6 +413,7 @@ module_init(void)
 	}
 	cv_init(_thread_cv, "mod_unld");
 	mutex_init(_thread_lock, MUTEX_DEFAULT, IPL_NONE);
+	TAILQ_INIT();
 
 #ifdef MODULAR	/* XXX */
 	module_init_md();
@@ -374,6 +440,11 @@ module_init(void)
 	}
 
 	sysctl_module_setup();
+	module_specificdata_domain = specificdata_domain_create();
+
+	module_netbsd = module_newmodule(MODULE_SOURCE_KERNEL);
+	module_netbsd->mod_refcnt = 1;
+	module_netbsd->mod_info = _netbsd_modinfo;
 }
 
 /*