CVS commit: [netbsd-7] src/doc

2016-12-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Dec 31 07:43:21 UTC 2016

Modified Files:
src/doc [netbsd-7]: CHANGES-7.1

Log Message:
tickets 1343, 1344


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.140 -r1.1.2.141 src/doc/CHANGES-7.1

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-7.1
diff -u src/doc/CHANGES-7.1:1.1.2.140 src/doc/CHANGES-7.1:1.1.2.141
--- src/doc/CHANGES-7.1:1.1.2.140	Tue Dec 27 07:12:32 2016
+++ src/doc/CHANGES-7.1	Sat Dec 31 07:43:21 2016
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1,v 1.1.2.140 2016/12/27 07:12:32 snj Exp $
+# $NetBSD: CHANGES-7.1,v 1.1.2.141 2016/12/31 07:43:21 snj Exp $
 
 A complete list of changes from the NetBSD 7.0 release to the NetBSD 7.1
 release:
@@ -7801,3 +7801,13 @@ sys/net/npf/lpm.c1.3
 	Fix kmem_free() in hashmap_remove().
 	[rmind, ticket #1340]
 
+sys/compat/linux/common/linux_sched.c		1.68
+
+	Fix linux affinity syscalls.  PR/50021
+	[rin, ticket #1343]
+
+xsrc/external/mit/xorg-server/dist/include/servermd.h 1.7
+
+	ARM is not always little endian.  PR/50356
+	[rin, ticket #1344]
+



CVS commit: [netbsd-7] xsrc/external/mit/xorg-server/dist/include

2016-12-30 Thread Soren Jacobsen
Module Name:xsrc
Committed By:   snj
Date:   Sat Dec 31 07:40:24 UTC 2016

Modified Files:
xsrc/external/mit/xorg-server/dist/include [netbsd-7]: servermd.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #1344):
xsrc/external/mit/xorg-server/dist/include/servermd.h: revision 1.7
PR/50356: Rin Okuyama: Arm is not always little endian.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.10.1 \
xsrc/external/mit/xorg-server/dist/include/servermd.h

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

Modified files:

Index: xsrc/external/mit/xorg-server/dist/include/servermd.h
diff -u xsrc/external/mit/xorg-server/dist/include/servermd.h:1.6 xsrc/external/mit/xorg-server/dist/include/servermd.h:1.6.10.1
--- xsrc/external/mit/xorg-server/dist/include/servermd.h:1.6	Tue Aug  2 07:15:06 2011
+++ xsrc/external/mit/xorg-server/dist/include/servermd.h	Sat Dec 31 07:40:24 2016
@@ -83,11 +83,15 @@ SOFTWARE.
 
 #endif /* __avr32__ */ 
 
-/* XXX arm is not always LE */
 #if defined(__arm32__) || defined(__arm__)
 
+#ifdef __ARMEB__
+#define IMAGE_BYTE_ORDERMSBFirst
+#define BITMAP_BIT_ORDERMSBFirst
+#else
 #define IMAGE_BYTE_ORDERLSBFirst
 #define BITMAP_BIT_ORDERLSBFirst
+#endif
 #define GLYPHPADBYTES   4
 
 #endif /* __arm32__ */



CVS commit: [netbsd-7] src/sys/compat/linux/common

2016-12-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Dec 31 07:38:31 UTC 2016

Modified Files:
src/sys/compat/linux/common [netbsd-7]: linux_sched.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1343):
sys/compat/linux/common/linux_sched.c: revision 1.68
PR/50021: Rin Okuyama: Fix linux affinity syscalls


To generate a diff of this commit:
cvs rdiff -u -r1.66.4.1 -r1.66.4.2 src/sys/compat/linux/common/linux_sched.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/compat/linux/common/linux_sched.c
diff -u src/sys/compat/linux/common/linux_sched.c:1.66.4.1 src/sys/compat/linux/common/linux_sched.c:1.66.4.2
--- src/sys/compat/linux/common/linux_sched.c:1.66.4.1	Sat Jan 17 12:10:54 2015
+++ src/sys/compat/linux/common/linux_sched.c	Sat Dec 31 07:38:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sched.c,v 1.66.4.1 2015/01/17 12:10:54 martin Exp $	*/
+/*	$NetBSD: linux_sched.c,v 1.66.4.2 2016/12/31 07:38:31 snj Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.66.4.1 2015/01/17 12:10:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.66.4.2 2016/12/31 07:38:31 snj Exp $");
 
 #include 
 #include 
@@ -65,6 +65,9 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sched.
 static int linux_clone_nptl(struct lwp *, const struct linux_sys_clone_args *,
 register_t *);
 
+/* Unlike Linux, dynamically calculate CPU mask size */
+#define	LINUX_CPU_MASK_SIZE (sizeof(long) * ((ncpu + LONG_BIT - 1) / LONG_BIT))
+
 #if DEBUG_LINUX
 #define DPRINTF(x) uprintf x
 #else
@@ -627,6 +630,10 @@ linux_sys_gettid(struct lwp *l, const vo
 	return 0;
 }
 
+/*
+ * The affinity syscalls assume that the layout of our cpu kcpuset is
+ * the same as linux's: a linear bitmask.
+ */
 int
 linux_sys_sched_getaffinity(struct lwp *l, const struct linux_sys_sched_getaffinity_args *uap, register_t *retval)
 {
@@ -635,39 +642,45 @@ linux_sys_sched_getaffinity(struct lwp *
 		syscallarg(unsigned int) len;
 		syscallarg(unsigned long *) mask;
 	} */
-	proc_t *p;
-	unsigned long *lp, *data;
-	int error, size, nb = ncpu;
+	struct lwp *t;
+	kcpuset_t *kcset;
+	size_t size;
+	cpuid_t i;
+	int error;
 
-	/* Unlike Linux, dynamically calculate cpu mask size */
-	size = sizeof(long) * ((ncpu + LONG_BIT - 1) / LONG_BIT);
+	size = LINUX_CPU_MASK_SIZE;
 	if (SCARG(uap, len) < size)
 		return EINVAL;
 
-	/* XXX: Pointless check.  TODO: Actually implement this. */
-	mutex_enter(proc_lock);
-	p = proc_find(SCARG(uap, pid));
-	mutex_exit(proc_lock);
-	if (p == NULL) {
+	/* Lock the LWP */
+	t = lwp_find2(SCARG(uap, pid), l->l_lid);
+	if (t == NULL)
 		return ESRCH;
-	}
-
-	/* 
-	 * return the actual number of CPU, tag all of them as available 
-	 * The result is a mask, the first CPU being in the least significant
-	 * bit.
-	 */
-	data = kmem_zalloc(size, KM_SLEEP);
-	lp = data;
-	while (nb > LONG_BIT) {
-		*lp++ = ~0UL;
-		nb -= LONG_BIT;
-	}
-	if (nb)
-		*lp = (1 << ncpu) - 1;
 
-	error = copyout(data, SCARG(uap, mask), size);
-	kmem_free(data, size);
+	/* Check the permission */
+	if (kauth_authorize_process(l->l_cred,
+	KAUTH_PROCESS_SCHEDULER_GETAFFINITY, t->l_proc, NULL, NULL, NULL)) {
+		mutex_exit(t->l_proc->p_lock);
+		return EPERM;
+	}
+
+	kcpuset_create(, true);
+	lwp_lock(t);
+	if (t->l_affinity != NULL)
+		kcpuset_copy(kcset, t->l_affinity);
+	else {
+		/*
+		 * All available CPUs should be masked when affinity has not
+		 * been set.
+		 */
+		kcpuset_zero(kcset);
+		for (i = 0; i < ncpu; i++)
+			kcpuset_set(kcset, i);
+	}
+	lwp_unlock(t);
+	mutex_exit(t->l_proc->p_lock);
+	error = kcpuset_copyout(kcset, (cpuset_t *)SCARG(uap, mask), size);
+	kcpuset_unuse(kcset, NULL);
 	*retval = size;
 	return error;
 }
@@ -680,17 +693,17 @@ linux_sys_sched_setaffinity(struct lwp *
 		syscallarg(unsigned int) len;
 		syscallarg(unsigned long *) mask;
 	} */
-	proc_t *p;
+	struct sys__sched_setaffinity_args ssa;
+	size_t size;
 
-	/* XXX: Pointless check.  TODO: Actually implement this. */
-	mutex_enter(proc_lock);
-	p = proc_find(SCARG(uap, pid));
-	mutex_exit(proc_lock);
-	if (p == NULL) {
-		return ESRCH;
-	}
+	size = LINUX_CPU_MASK_SIZE;
+	if (SCARG(uap, len) < size)
+		return EINVAL;
 
-	/* Let's ignore it */
-	DPRINTF(("%s\n", __func__));
-	return 0;
+	SCARG(, pid) = SCARG(uap, pid);
+	SCARG(, lid) = l->l_lid;
+	SCARG(, size) = size;
+	SCARG(, cpuset) = (cpuset_t *)SCARG(uap, mask);
+
+	return sys__sched_setaffinity(l, , retval);
 }



CVS commit: src/external/gpl3/binutils/dist/bfd

2016-12-30 Thread Brian Buhrow
Module Name:src
Committed By:   buhrow
Date:   Fri Dec 30 22:40:24 UTC 2016

Modified Files:
src/external/gpl3/binutils/dist/bfd: elf32-arm.c

Log Message:
Fix problem which prevents cross building on NetBSD systems which predate
NetBSD-6 or non-NetBSD systems.  See discussion on port-arm for details.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/binutils/dist/bfd/elf32-arm.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/gpl3/binutils/dist/bfd/elf32-arm.c
diff -u src/external/gpl3/binutils/dist/bfd/elf32-arm.c:1.10 src/external/gpl3/binutils/dist/bfd/elf32-arm.c:1.11
--- src/external/gpl3/binutils/dist/bfd/elf32-arm.c:1.10	Wed Oct 26 18:42:52 2016
+++ src/external/gpl3/binutils/dist/bfd/elf32-arm.c	Fri Dec 30 22:40:23 2016
@@ -3207,8 +3207,8 @@ ctz (unsigned int mask)
 #endif
 }
 
-#ifndef __NetBSD__
-static inline int
+#if !defined (__NetBSD__) || (__NetBSD_Version__ < 6) 
+unsigned int
 popcount (unsigned int mask)
 {
 #if GCC_VERSION >= 3004



CVS commit: src

2016-12-30 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 30 22:38:39 UTC 2016

Modified Files:
src/distrib/sets/lists/comp: mi
src/lib/libcurses: Makefile curses.h curses_private.h curses_screen.3
screen.c setterm.c

Log Message:
Add the POSIX filter() function to libcurses.


To generate a diff of this commit:
cvs rdiff -u -r1.2083 -r1.2084 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.71 -r1.72 src/lib/libcurses/Makefile
cvs rdiff -u -r1.107 -r1.108 src/lib/libcurses/curses.h
cvs rdiff -u -r1.51 -r1.52 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/curses_screen.3
cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/screen.c
cvs rdiff -u -r1.54 -r1.55 src/lib/libcurses/setterm.c

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2083 src/distrib/sets/lists/comp/mi:1.2084
--- src/distrib/sets/lists/comp/mi:1.2083	Thu Dec 22 16:32:31 2016
+++ src/distrib/sets/lists/comp/mi	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2083 2016/12/22 16:32:31 maya Exp $
+#	$NetBSD: mi,v 1.2084 2016/12/30 22:38:38 roy Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -6380,6 +6380,7 @@
 ./usr/share/man/cat3/field_type.0		comp-c-catman		.cat
 ./usr/share/man/cat3/field_userptr.0		comp-c-catman		.cat
 ./usr/share/man/cat3/fileno.0			comp-c-catman		.cat
+./usr/share/man/cat3/filter.0			comp-c-catman		.cat
 ./usr/share/man/cat3/finite.0			comp-c-catman		.cat
 ./usr/share/man/cat3/finitef.0			comp-c-catman		.cat
 ./usr/share/man/cat3/flags_to_string.0		comp-c-catman		.cat
@@ -13720,6 +13721,7 @@
 ./usr/share/man/html3/field_type.html		comp-c-htmlman		html
 ./usr/share/man/html3/field_userptr.html	comp-c-htmlman		html
 ./usr/share/man/html3/fileno.html		comp-c-htmlman		html
+./usr/share/man/html3/filter.html		comp-c-htmlman		html
 ./usr/share/man/html3/finite.html		comp-c-htmlman		html
 ./usr/share/man/html3/finitef.html		comp-c-htmlman		html
 ./usr/share/man/html3/flags_to_string.html	comp-c-htmlman		html
@@ -20973,6 +20975,7 @@
 ./usr/share/man/man3/field_type.3		comp-c-man		.man
 ./usr/share/man/man3/field_userptr.3		comp-c-man		.man
 ./usr/share/man/man3/fileno.3			comp-c-man		.man
+./usr/share/man/man3/filter.3			comp-c-man		.man
 ./usr/share/man/man3/finite.3			comp-c-man		.man
 ./usr/share/man/man3/finitef.3			comp-c-man		.man
 ./usr/share/man/man3/flags_to_string.3		comp-c-man		.man

Index: src/lib/libcurses/Makefile
diff -u src/lib/libcurses/Makefile:1.71 src/lib/libcurses/Makefile:1.72
--- src/lib/libcurses/Makefile:1.71	Sat Jul  5 22:31:32 2014
+++ src/lib/libcurses/Makefile	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.71 2014/07/05 22:31:32 dholland Exp $
+#	$NetBSD: Makefile,v 1.72 2016/12/30 22:38:38 roy Exp $
 #	@(#)Makefile	8.2 (Berkeley) 1/2/94
 
 .include 
@@ -75,7 +75,7 @@ MLINKS+= curses_addch.3 addch.3 curses_a
 	 curses_refresh.3 doupdate.3 curses_window.3 dupwin.3 \
 	 curses_tty.3 echo.3 curses_echochar.3 echochar.3 \
 	 curses_screen.3 endwin.3 curses_clear.3 erase.3 \
-	 curses_tty.3 erasechar.3 \
+	 curses_tty.3 erasechar.3 curses_screen.3 filter.3 \
 	 curses_tty.3 flash.3 curses_tty.3 flushinp.3 \
 	 curses_refresh.3 flushok.3 \
 	 curses_termcap.3 fullname.3 curses_attributes.3 getattrs.3  \

Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.107 src/lib/libcurses/curses.h:1.108
--- src/lib/libcurses/curses.h:1.107	Mon Jun  8 12:38:57 2015
+++ src/lib/libcurses/curses.h	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.h,v 1.107 2015/06/08 12:38:57 joerg Exp $	*/
+/*	$NetBSD: curses.h,v 1.108 2016/12/30 22:38:38 roy Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -638,6 +638,7 @@ int	 doupdate(void);
 int	 echo(void);
 int	 endwin(void);
 char erasechar(void);
+void	 filter(void);
 int	 flash(void);
 int	 flushinp(void);
 int	 flushok(WINDOW *, bool);

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.51 src/lib/libcurses/curses_private.h:1.52
--- src/lib/libcurses/curses_private.h:1.51	Sun Oct 23 21:20:56 2016
+++ src/lib/libcurses/curses_private.h	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.51 2016/10/23 21:20:56 christos Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.52 2016/12/30 22:38:38 roy Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -252,6 +252,7 @@ struct __screen {
 	int resized;
 	wchar_t *unget_list;
 	int unget_len, unget_pos;
+	int filtered;
 #ifdef HAVE_WCHAR
 #define MB_LEN_MAX 8
 #define MAX_CBUF_SIZE MB_LEN_MAX

Index: src/lib/libcurses/curses_screen.3
diff -u src/lib/libcurses/curses_screen.3:1.15 src/lib/libcurses/curses_screen.3:1.16
--- src/lib/libcurses/curses_screen.3:1.15	Sat Apr 21 12:27:28 2012
+++ src/lib/libcurses/curses_screen.3	

CVS commit: src/usr.bin/fstat

2016-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 30 21:08:23 UTC 2016

Modified Files:
src/usr.bin/fstat: fstat.c misc.c

Log Message:
Print the interface for bpf.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/fstat/misc.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/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.110 src/usr.bin/fstat/fstat.c:1.111
--- src/usr.bin/fstat/fstat.c:1.110	Tue Dec 22 18:35:21 2015
+++ src/usr.bin/fstat/fstat.c	Fri Dec 30 16:08:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.c,v 1.110 2015/12/22 23:35:21 christos Exp $	*/
+/*	$NetBSD: fstat.c,v 1.111 2016/12/30 21:08:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)fstat.c	8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.110 2015/12/22 23:35:21 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.111 2016/12/30 21:08:23 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -651,23 +651,23 @@ vtrans(struct vnode *vp, int i, int flag
 		char buf[1024];
 		(void)snprintb(buf, sizeof(buf), VNODE_FLAGBITS,
 		vn.v_iflag | vn.v_vflag | vn.v_uflag);
-		(void)printf(" flags %s\n", buf);
+		(void)printf("  flags %s\n", buf);
 		return;
 	} else if (badtype) {
-		(void)printf(" - -  %10s-\n", badtype);
+		(void)printf("  - -  %10s-\n", badtype);
 		return;
 	}
 	if (nflg)
-		(void)printf(" %2llu,%-2llu",
+		(void)printf("  %2llu,%-2llu",
 		(unsigned long long)major(fst.fsid),
 		(unsigned long long)minor(fst.fsid));
 	else
-		(void)printf(" %-8s", getmnton(vn.v_mount));
+		(void)printf("  %-8s", getmnton(vn.v_mount));
 	if (nflg)
 		(void)snprintf(mode, sizeof mode, "%o", fst.mode);
 	else
 		strmode(fst.mode, mode);
-	(void)printf(" %7"PRIu64" %*s", fst.fileid, nflg ? 5 : 10, mode);
+	(void)printf("  %7"PRIu64" %*s", fst.fileid, nflg ? 5 : 10, mode);
 	switch (vn.v_type) {
 	case VBLK:
 	case VCHR: {

Index: src/usr.bin/fstat/misc.c
diff -u src/usr.bin/fstat/misc.c:1.16 src/usr.bin/fstat/misc.c:1.17
--- src/usr.bin/fstat/misc.c:1.16	Sat Jan 23 11:12:03 2016
+++ src/usr.bin/fstat/misc.c	Fri Dec 30 16:08:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.16 2016/01/23 16:12:03 christos Exp $	*/
+/*	$NetBSD: misc.c,v 1.17 2016/12/30 21:08:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: misc.c,v 1.16 2016/01/23 16:12:03 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.17 2016/12/30 21:08:23 christos Exp $");
 
 #include 
 #include 
@@ -113,12 +113,25 @@ static int
 p_bpf(struct file *f)
 {
 	struct bpf_d bpf;
+	struct bpf_if bi;
+	struct ifnet ifn;
+
+	strlcpy(ifn.if_xname, "???", sizeof(ifn.if_xname));
 
 	if (!KVM_READ(f->f_data, , sizeof(bpf))) {
 		dprintf("can't read bpf at %p for pid %d", f->f_data, Pid);
 		return 0;
 	}
-	(void)printf("* bpf rec=%lu, dr=%lu, cap=%lu, pid=%lu",
+	if (bpf.bd_bif != NULL) {
+		if (!KVM_READ(bpf.bd_bif, , sizeof(bi)))
+			dprintf("can't read bpf interface at %p for pid %d",
+			bpf.bd_bif, Pid);
+		if (bi.bif_ifp != NULL)
+			if (!KVM_READ(bi.bif_ifp, , sizeof(ifn)))
+dprintf("can't read net interfsace"
+" at %p for pid %d", bi.bif_ifp, Pid);
+	}
+	(void)printf("* bpf@%s rec=%lu, dr=%lu, cap=%lu, pid=%lu", ifn.if_xname,
 	bpf.bd_rcount, bpf.bd_dcount, bpf.bd_ccount,
 	(unsigned long)bpf.bd_pid);
 	if (bpf.bd_promisc)



CVS commit: src/usr.sbin/npf/npfd

2016-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 30 19:55:46 UTC 2016

Modified Files:
src/usr.sbin/npf/npfd: Makefile npfd.c npfd.h npfd_log.c

Log Message:
flesh this out more.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/npf/npfd/Makefile \
src/usr.sbin/npf/npfd/npfd.h
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/npf/npfd/npfd.c \
src/usr.sbin/npf/npfd/npfd_log.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.sbin/npf/npfd/Makefile
diff -u src/usr.sbin/npf/npfd/Makefile:1.2 src/usr.sbin/npf/npfd/Makefile:1.3
--- src/usr.sbin/npf/npfd/Makefile:1.2	Tue Dec 27 20:25:48 2016
+++ src/usr.sbin/npf/npfd/Makefile	Fri Dec 30 14:55:46 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2016/12/28 01:25:48 christos Exp $
+# $NetBSD: Makefile,v 1.3 2016/12/30 19:55:46 christos Exp $
 #
 # Public Domain
 #
@@ -6,11 +6,12 @@
 NOMAN=
 PROG=		npfd
 
+#DBG=-g
 SRCS=		npfd.c npfd_log.c
 CPPFLAGS+=	-I${.CURDIR}
 
-LDADD+=		-lnpf -lpcap
-DPADD+=		${LIBNPF} ${LIBPCAP}
+LDADD+=		-lnpf -lpcap -lutil
+DPADD+=		${LIBNPF} ${LIBPCAP} ${LIBUTIL}
 
 WARNS=		5
 NOLINT=		# disabled deliberately
Index: src/usr.sbin/npf/npfd/npfd.h
diff -u src/usr.sbin/npf/npfd/npfd.h:1.2 src/usr.sbin/npf/npfd/npfd.h:1.3
--- src/usr.sbin/npf/npfd/npfd.h:1.2	Tue Dec 27 20:25:48 2016
+++ src/usr.sbin/npf/npfd/npfd.h	Fri Dec 30 14:55:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd.h,v 1.2 2016/12/28 01:25:48 christos Exp $	*/
+/*	$NetBSD: npfd.h,v 1.3 2016/12/30 19:55:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -42,12 +42,13 @@
 struct npf_log;
 typedef struct npfd_log npfd_log_t;
 
-npfd_log_t *	npfd_log_create(unsigned);
+npfd_log_t *	npfd_log_create(const char *, const char *, int);
 void		npfd_log_destroy(npfd_log_t *);
 int		npfd_log_getsock(npfd_log_t *);
-bool		npfd_log_reopen(npfd_log_t *);
+bool		npfd_log_reopen(npfd_log_t *, bool);
 void		npfd_log(npfd_log_t *);
 void		npfd_log_stats(npfd_log_t *);
+void		npfd_log_flush(npfd_log_t *);
 
 
 #endif

Index: src/usr.sbin/npf/npfd/npfd.c
diff -u src/usr.sbin/npf/npfd/npfd.c:1.3 src/usr.sbin/npf/npfd/npfd.c:1.4
--- src/usr.sbin/npf/npfd/npfd.c:1.3	Tue Dec 27 22:02:54 2016
+++ src/usr.sbin/npf/npfd/npfd.c	Fri Dec 30 14:55:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd.c,v 1.3 2016/12/28 03:02:54 christos Exp $	*/
+/*	$NetBSD: npfd.c,v 1.4 2016/12/30 19:55:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,9 +30,10 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfd.c,v 1.3 2016/12/28 03:02:54 christos Exp $");
+__RCSID("$NetBSD: npfd.c,v 1.4 2016/12/30 19:55:46 christos Exp $");
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -42,6 +43,7 @@ __RCSID("$NetBSD: npfd.c,v 1.3 2016/12/2
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -70,33 +72,31 @@ npfd_getctl(void)
 }
 
 static void
-npfd_event_loop(void)
+npfd_event_loop(npfd_log_t *log, int delay)
 {
 	struct pollfd pfd;
-	npfd_log_t *log;
 
-	log = npfd_log_create(0);
-	if (log == NULL)
-		exit(EXIT_FAILURE);
 	pfd.fd = npfd_log_getsock(log);
 	pfd.events = POLLHUP | POLLIN;
 
 	while  (!done) {
 		if (hup) {
 			hup = false;
-			npfd_log_reopen(log);
+			npfd_log_reopen(log, false);
 		}
 		if (stats) {
 			stats = false;
 			npfd_log_stats(log);
+			npfd_log_flush(log);
 		}
-		switch (poll(, 1, 1000)) {
+		switch (poll(, 1, delay)) {
 		case -1:
 			if (errno == EINTR)
 continue;
 			syslog(LOG_ERR, "poll failed: %m");
 			exit(EXIT_FAILURE);
 		case 0:
+			npfd_log_flush(log);
 			continue;
 		default:
 			npfd_log(log);
@@ -115,7 +115,7 @@ sighandler(int sig)
 		break;
 	case SIGTERM:
 	case SIGINT:
-		hup = true;
+		done = true;
 		break;
 	case SIGINFO:
 	case SIGQUIT:
@@ -123,38 +123,96 @@ sighandler(int sig)
 		break;
 	default:
 		syslog(LOG_ERR, "Unhandled signal %d", sig);
+		break;
 	}
 }
 
+static __dead void
+usage(void)
+{
+	fprintf(stderr, "Usage: %s [-D] [-d ] [-i ]"
+	" [-p ] [-s ] expression\n", getprogname());
+	exit(EXIT_FAILURE);
+}
+
+static char *
+copyargs(int argc, char **argv)
+{
+	if (argc == 0)
+		return NULL;
+
+	size_t len = 0, p = 0;
+	char *buf = NULL;
+
+	for (int i = 0; i < argc; i++) {
+		size_t l = strlen(argv[i]);
+		if (p + l + 1 >= len)
+			buf = erealloc(buf, len = p + l + 1);
+		memcpy(buf + p, argv[i], l);
+		p += l;
+		buf[p++] = i == argc - 1 ? '\0' : ' ';
+	}
+	return buf;
+}
+
 int
 main(int argc, char **argv)
 {
 	bool daemon_off = false;
 	int ch;
 
-	while ((ch = getopt(argc, argv, "d")) != -1) {
+	int delay = 60 * 1000;
+	const char *iface = "npflog0";
+	int snaplen = 116;
+	char *pidname = NULL;
+
+	int fd = npfd_getctl();
+	(void)close(fd);
+
+	while ((ch = getopt(argc, argv, "Dd:i:p:s:")) != -1) {
 		switch (ch) {
-		case 'd':
+		case 'D':
 			daemon_off = true;
 			break;
+		case 'd':
+			delay = atoi(optarg) * 1000;
+			break;
+		case 'i':
+			iface = 

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

2016-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 30 19:53:08 UTC 2016

Modified Files:
src/usr.bin/xlint/lint1: cgram.y scan.l

Log Message:
- add buffer bounded attribute
- allow empty attributes


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/scan.l

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/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.90 src/usr.bin/xlint/lint1/cgram.y:1.91
--- src/usr.bin/xlint/lint1/cgram.y:1.90	Thu Dec 29 22:36:51 2016
+++ src/usr.bin/xlint/lint1/cgram.y	Fri Dec 30 14:53:08 2016
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.90 2016/12/30 03:36:51 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.91 2016/12/30 19:53:08 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.90 2016/12/30 03:36:51 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.91 2016/12/30 19:53:08 christos Exp $");
 #endif
 
 #include 
@@ -202,6 +202,7 @@ anonymize(sym_t *s)
 %token 		T_AT_ALIGNED
 %token 		T_AT_ALWAYS_INLINE
 %token 		T_AT_BOUNDED
+%token 		T_AT_BUFFER
 %token 		T_AT_COLD
 %token 		T_AT_CONSTRUCTOR
 %token 		T_AT_DEPRECATED
@@ -260,7 +261,6 @@ anonymize(sym_t *s)
 %type		struct_spec
 %type		enum_spec
 %type		type_attribute
-%type		type_attribute_spec
 %type			struct_tag
 %type			enum_tag
 %type		struct
@@ -511,13 +511,18 @@ type_attribute_format_type:
 	| T_AT_FORMAT_STRFTIME
 	;
 
+type_attribute_bounded_type:
+	  T_AT_MINBYTES
+	| T_AT_STRING
+	| T_AT_BUFFER
+	;
+
 type_attribute_spec:
-	  T_AT_DEPRECATED
+	  /* empty */	
+	| T_AT_DEPRECATED
 	| T_AT_ALIGNED T_LPARN constant T_RPARN
-	| T_AT_BOUNDED T_LPARN T_AT_MINBYTES T_COMMA constant T_COMMA
-	  constant T_RPARN
-	| T_AT_BOUNDED T_LPARN T_AT_STRING T_COMMA constant T_COMMA
-	  constant T_RPARN
+	| T_AT_BOUNDED T_LPARN type_attribute_bounded_type
+	  T_COMMA constant T_COMMA constant T_RPARN
 	| T_AT_SENTINEL T_LPARN constant T_RPARN
 	| T_AT_FORMAT_ARG T_LPARN constant T_RPARN
 	| T_AT_NONNULL T_LPARN constant T_RPARN
@@ -732,8 +737,7 @@ member_declaration_list_with_rbrace:
 	;
 
 opt_type_attribute:
-	  /* empty */ {
-	}
+	  /* empty */
 	| type_attribute
 	;
 

Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.75 src/usr.bin/xlint/lint1/scan.l:1.76
--- src/usr.bin/xlint/lint1/scan.l:1.75	Thu Dec 29 21:16:36 2016
+++ src/usr.bin/xlint/lint1/scan.l	Fri Dec 30 14:53:08 2016
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.75 2016/12/30 02:16:36 christos Exp $ */
+/* $NetBSD: scan.l,v 1.76 2016/12/30 19:53:08 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.75 2016/12/30 02:16:36 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.76 2016/12/30 19:53:08 christos Exp $");
 #endif
 
 #include 
@@ -217,6 +217,7 @@ static	struct	kwtab {
 	{ "auto",	T_SCLASS,	AUTO,	0,	0,	  0,0,0,0,1 },
 	{ "bounded",	T_AT_BOUNDED,	0,	0,	0,	  0,0,1,1,5 },
 	{ "break",	T_BREAK,	0,	0,	0,	  0,0,0,0,1 },
+	{ "buffer",	T_AT_BUFFER,	0,	0,	0,	  0,0,1,1,5 },
 	{ "case",	T_CASE,		0,	0,	0,	  0,0,0,0,1 },
 	{ "char",	T_TYPE,		0,	CHAR,	0,	  0,0,0,0,1 },
 	{ "cold",	T_AT_COLD,	0,	0,	0,	  0,0,1,1,5 },



CVS commit: src/doc

2016-12-30 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 30 19:45:21 UTC 2016

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note import of openresolv-3.9.0


To generate a diff of this commit:
cvs rdiff -u -r1.1387 -r1.1388 src/doc/3RDPARTY
cvs rdiff -u -r1.2229 -r1.2230 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.1387 src/doc/3RDPARTY:1.1388
--- src/doc/3RDPARTY:1.1387	Fri Dec 30 00:36:41 2016
+++ src/doc/3RDPARTY	Fri Dec 30 19:45:21 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1387 2016/12/30 00:36:41 wiz Exp $
+#	$NetBSD: 3RDPARTY,v 1.1388 2016/12/30 19:45:21 roy Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -992,8 +992,8 @@ Location:	external/bsd/openpam/dist
 Notes:
 
 Package:	openresolv
-Version:	3.8.0
-Current Vers:	3.8.0
+Version:	3.9.0
+Current Vers:	3.9.0
 Maintainer:	roy
 Archive Site:	ftp://roy.marples.name/pub/openresolv/
 Home Page:	http://roy.marples.name/projects/openresolv/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2229 src/doc/CHANGES:1.2230
--- src/doc/CHANGES:1.2229	Thu Dec 29 11:50:23 2016
+++ src/doc/CHANGES	Fri Dec 30 19:45:21 2016
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2229 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2230 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -439,3 +439,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 		systat, crash, pstat and kgmon.  [mrg 20161222]
 	OpenSSH: Imported 7.4. [christos 20161224]
 	dreamcast: Add preliminary "G1-ATA" IDE HDD support. [tsutsui 20161229]
+	resolvconf(8): Import openresolv-3.9.0 [roy 20161230]



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

2016-12-30 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 30 19:43:36 UTC 2016

Modified Files:
src/external/bsd/openresolv/dist: resolvconf.8.in resolvconf.conf.5.in

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/openresolv/dist/resolvconf.8.in
cvs rdiff -u -r1.16 -r1.17 \
src/external/bsd/openresolv/dist/resolvconf.conf.5.in

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/openresolv/dist/resolvconf.8.in
diff -u src/external/bsd/openresolv/dist/resolvconf.8.in:1.8 src/external/bsd/openresolv/dist/resolvconf.8.in:1.9
--- src/external/bsd/openresolv/dist/resolvconf.8.in:1.8	Thu Apr 28 08:16:09 2016
+++ src/external/bsd/openresolv/dist/resolvconf.8.in	Fri Dec 30 19:43:36 2016
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 23, 2016
+.Dd November 29, 2016
 .Dt RESOLVCONF 8
 .Os
 .Sh NAME
@@ -45,6 +45,8 @@
 .Fl il Ar pattern
 .Nm
 .Fl u
+.Nm
+.Fl Fl version
 .Sh DESCRIPTION
 .Nm
 manages
@@ -106,7 +108,7 @@ See
 .Xr resolvconf.conf 5
 for how to configure
 .Nm
-to use a local name server.
+to use a local name server and how to remove the private marking.
 .Pp
 .Nm
 can mark an interfaces
@@ -126,9 +128,9 @@ on the
 .Ar interface .
 .Pp
 Here are some options for the above commands:-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
 .It Fl f
-Ignore non existant interfaces.
+Ignore non existent interfaces.
 Only really useful for deleting interfaces.
 .It Fl m Ar metric
 Set the metric of the interface when adding it, default of 0.
@@ -146,7 +148,7 @@ as exclusive when adding, otherwise only
 .Pp
 .Nm
 has some more commands for general usage:-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
 .It Fl i Ar pattern
 List the interfaces and protocols, optionally matching
 .Ar pattern ,
@@ -168,12 +170,15 @@ to update all its subscribers.
 .Nm
 does not update the subscribers when adding a resolv.conf that matches
 what it already has for that interface.
+.It Fl Fl version
+Echo the resolvconf version to
+.Em stdout .
 .El
 .Pp
 .Nm
 also has some commands designed to be used by it's subscribers and
 system startup:-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
 .It Fl I
 Initialise the state directory
 .Pa @VARDIR@ .
@@ -223,7 +228,7 @@ Here are some suggested protocol tags to
 .Pa resolv.conf
 file registered on an
 .Ar interface Ns No :-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
 .It dhcp
 Dynamic Host Configuration Protocol.
 Initial versions of

Index: src/external/bsd/openresolv/dist/resolvconf.conf.5.in
diff -u src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.16 src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.17
--- src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.16	Thu Apr 28 08:17:04 2016
+++ src/external/bsd/openresolv/dist/resolvconf.conf.5.in	Fri Dec 30 19:43:36 2016
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 23, 2016
+.Dd December 29, 2016
 .Dt RESOLVCONF.CONF 5
 .Os
 .Sh NAME
@@ -69,6 +69,11 @@ If unset, defaults to the following:-
 These interfaces will be processed next, unless they have a metric.
 If unset, defaults to the following:-
 .D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
+.It Sy inclusive_interfaces
+Ignore any exlcusive marking for these interfaces.
+This is handy when 3rd party integrations force the
+.Nm resolvconf -x
+option and you want to disable it easily.
 .It Sy local_nameservers
 If unset, defaults to the following:-
 .D1 127.* 0.0.0.0 255.255.255.255 ::1
@@ -102,6 +107,11 @@ Requires a local nameserver other than l
 This is equivalent to the
 .Nm resolvconf -p
 option.
+.It Sy public_interfaces
+Force these interface to be public, overriding the private marking.
+This is handy when 3rd party integrations force the
+.Nm resolvconf -p
+option and you want to disable it easily.
 .It Sy replace
 Is a space separated list of replacement keywords.
 The syntax is this:



CVS import: src/external/bsd/openresolv/dist

2016-12-30 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 30 19:42:05 UTC 2016

Update of /cvsroot/src/external/bsd/openresolv/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv20805

Log Message:
Import openresolv-3.9.0 with the following changes:
  *  Added --version option
  *  Fix pdns_recursor restart command
  *  Append a newline when restoring resolv.conf
  *  public_interfaces overrides private interface markings
  *  Fix runit support
  *  inclusive_interfaces overrides exclusive interface markings

Status:

Vendor Tag: roy
Release Tags:   openresolv-3-9-0

U src/external/bsd/openresolv/dist/README
U src/external/bsd/openresolv/dist/resolvconf.in
C src/external/bsd/openresolv/dist/resolvconf.8.in
C src/external/bsd/openresolv/dist/resolvconf.conf.5.in
U src/external/bsd/openresolv/dist/libc.in
U src/external/bsd/openresolv/dist/dnsmasq.in
U src/external/bsd/openresolv/dist/named.in
U src/external/bsd/openresolv/dist/pdnsd.in
U src/external/bsd/openresolv/dist/unbound.in

2 conflicts created by this import.
Use the following command to help the merge:

cvs checkout -jroy:yesterday -jroy src/external/bsd/openresolv/dist



CVS commit: src/sys/arch/sparc64

2016-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 30 18:30:19 UTC 2016

Modified Files:
src/sys/arch/sparc64/include: reg.h
src/sys/arch/sparc64/sparc64: process_machdep.c

Log Message:
- make fpreg{32,64} actually members of fsstate{32,64}.
- allocate fpstate if we did not have one and we need to write it.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/include/reg.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sparc64/sparc64/process_machdep.c

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

Modified files:

Index: src/sys/arch/sparc64/include/reg.h
diff -u src/sys/arch/sparc64/include/reg.h:1.14 src/sys/arch/sparc64/include/reg.h:1.15
--- src/sys/arch/sparc64/include/reg.h:1.14	Tue Jul 12 03:51:34 2011
+++ src/sys/arch/sparc64/include/reg.h	Fri Dec 30 13:30:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: reg.h,v 1.14 2011/07/12 07:51:34 mrg Exp $ */
+/*	$NetBSD: reg.h,v 1.15 2016/12/30 18:30:19 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -178,24 +178,6 @@ struct fp_qentry {
 	int	fq_instr;		/* the instruction itself */
 };
 
-struct fpstate64 {
-	u_int	fs_regs[64];		/* our view is 64 32-bit registers */
-	int64_t	fs_fsr;			/* %fsr */
-	int	fs_gsr;			/* graphics state reg */
-	int	fs_qsize;		/* actual queue depth */
-	struct	fp_qentry fs_queue[FP_QSIZE];	/* queue contents */
-};
-
-/* 
- * For 32-bit emulations.
- */
-struct fpstate32 {
-	u_int	fs_regs[32];		/* our view is 32 32-bit registers */
-	int	fs_fsr;			/* %fsr */
-	int	fs_qsize;		/* actual queue depth */
-	struct	fp_qentry fs_queue[FP_QSIZE];	/* queue contents */
-};
-
 /*
  * The actual FP registers are made accessible (c.f. ptrace(2)) through
  * a `struct fpreg';  relies on the
@@ -207,6 +189,15 @@ struct fpreg64 {
 	int	fr_gsr;			/* graphics state reg */
 };
 
+struct fpstate64 {
+	struct fpreg64 fs_reg;
+#define fs_regs fs_reg.fr_regs
+#define fs_fsr fs_reg.fr_fsr
+#define fs_gsr fs_reg.fr_gsr
+	int	fs_qsize;		/* actual queue depth */
+	struct	fp_qentry fs_queue[FP_QSIZE];	/* queue contents */
+};
+
 /*
  * 32-bit fpreg used by 32-bit sparc CPUs
  */
@@ -215,6 +206,15 @@ struct fpreg32 {
 	int	fr_fsr;			/* %fsr */
 };
 
+/* 
+ * For 32-bit emulations.
+ */
+struct fpstate32 {
+	struct fpreg32 fs_reg;
+	int	fs_qsize;		/* actual queue depth */
+	struct	fp_qentry fs_queue[FP_QSIZE];	/* queue contents */
+};
+
 #if defined(__arch64__)
 /* Here we gotta do naughty things to let gdb work on 32-bit binaries */
 #define reg		reg64

Index: src/sys/arch/sparc64/sparc64/process_machdep.c
diff -u src/sys/arch/sparc64/sparc64/process_machdep.c:1.24 src/sys/arch/sparc64/sparc64/process_machdep.c:1.25
--- src/sys/arch/sparc64/sparc64/process_machdep.c:1.24	Fri Jan  3 19:10:03 2014
+++ src/sys/arch/sparc64/sparc64/process_machdep.c	Fri Dec 30 13:30:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.24 2014/01/04 00:10:03 dsl Exp $ */
+/*	$NetBSD: process_machdep.c,v 1.25 2016/12/30 18:30:19 christos Exp $ */
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.24 2014/01/04 00:10:03 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.25 2016/12/30 18:30:19 christos Exp $");
 
 #include 
 #include 
@@ -198,28 +198,29 @@ process_set_pc(struct lwp *l, void *addr
 	return (0);
 }
 
+extern const struct fpstate64 initfpstate;
+
 int
 process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz)
 {
-	extern const struct fpstate64 initfpstate;
-	const struct fpstate64	*statep = 
-	struct fpreg32		*regp = (struct fpreg32 *)regs;
-	int i;
+	const struct fpstate64 *fs;
 
-	if (l->l_md.md_fpstate)
-		statep = l->l_md.md_fpstate;
+	if ((fs = l->l_md.md_fpstate) == NULL)
+		fs = 
 #ifdef __arch64__
 	if (!(curproc->p_flag & PK_32)) {
 		/* 64-bit mode -- copy out fregs */
-		/* NOTE: struct fpreg == struct fpstate */
-		memcpy(regs, statep, sizeof(struct fpreg64));
+		*regs = fs->fs_reg;
 		return 0;
 	}
 #endif
+
+	struct fpreg32 *regp = (struct fpreg32 *)regs;
+
 	/* 32-bit mode -- copy out & convert 32-bit fregs */
-	for (i = 0; i < 32; i++)
-		regp->fr_regs[i] = statep->fs_regs[i];
-	regp->fr_fsr = statep->fs_fsr;
+	for (size_t i = 0; i < __arraycount(regp->fr_regs); i++)
+		regp->fr_regs[i] = fs->fs_regs[i];
+	regp->fr_fsr = fs->fs_fsr;
 
 	return 0;
 }
@@ -227,28 +228,27 @@ process_read_fpregs(struct lwp *l, struc
 int
 process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz)
 {
-	struct fpstate64	*statep;
-	const struct fpreg32	*regp = (const struct fpreg32 *)regs;
-	int i;
+	struct fpstate64	*fs;
 
-	statep = l->l_md.md_fpstate;
-	if (statep == NULL)
-		return EINVAL;
+	if ((fs = l->l_md.md_fpstate) == NULL) {
+		fs = kmem_zalloc(sizeof(*fs), KM_SLEEP);
+		l->l_md.md_fpstate = fs;
+	} else
+		fs->fs_qsize = 0;
 
 #ifdef __arch64__
 	if (!(curproc->p_flag & PK_32)) {
 		/* 64-bit mode 

CVS commit: src/sys/arch/sparc

2016-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 30 17:54:43 UTC 2016

Modified Files:
src/sys/arch/sparc/include: reg.h
src/sys/arch/sparc/sparc: process_machdep.c trap.c

Log Message:
- allocate state if we did not have any in fpregs
- make fpstate explicitly start with fpregs for better type checking
- use c11 initializers


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc/include/reg.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/sparc/process_machdep.c
cvs rdiff -u -r1.195 -r1.196 src/sys/arch/sparc/sparc/trap.c

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

Modified files:

Index: src/sys/arch/sparc/include/reg.h
diff -u src/sys/arch/sparc/include/reg.h:1.8 src/sys/arch/sparc/include/reg.h:1.9
--- src/sys/arch/sparc/include/reg.h:1.8	Sun Dec 11 07:19:06 2005
+++ src/sys/arch/sparc/include/reg.h	Fri Dec 30 12:54:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: reg.h,v 1.8 2005/12/11 12:19:06 christos Exp $ */
+/*	$NetBSD: reg.h,v 1.9 2016/12/30 17:54:43 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -102,9 +102,15 @@ struct fp_qentry {
 	int	*fq_addr;		/* the instruction's address */
 	int	fq_instr;		/* the instruction itself */
 };
+
+struct fpreg {
+	u_int	fr_regs[32];		/* our view is 32 32-bit registers */
+	int	fr_fsr;			/* %fsr */
+};
 struct fpstate {
-	u_int	fs_regs[32];		/* our view is 32 32-bit registers */
-	int	fs_fsr;			/* %fsr */
+	struct fpreg fs_reg;
+#define fs_regs fs_reg.fr_regs
+#define fs_fsr	fs_reg.fr_fsr
 	int	fs_qsize;		/* actual queue depth */
 	struct	fp_qentry fs_queue[FP_QSIZE];	/* queue contents */
 };
@@ -114,9 +120,5 @@ struct fpstate {
  * a `struct fpreg';  relies on the
  * fact that `fpreg' is a prefix of `fpstate'.
  */
-struct fpreg {
-	u_int	fr_regs[32];		/* our view is 32 32-bit registers */
-	int	fr_fsr;			/* %fsr */
-};
 
 #endif /* _MACHINE_REG_H_ */

Index: src/sys/arch/sparc/sparc/process_machdep.c
diff -u src/sys/arch/sparc/sparc/process_machdep.c:1.18 src/sys/arch/sparc/sparc/process_machdep.c:1.19
--- src/sys/arch/sparc/sparc/process_machdep.c:1.18	Fri Jan  3 19:10:03 2014
+++ src/sys/arch/sparc/sparc/process_machdep.c	Fri Dec 30 12:54:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.18 2014/01/04 00:10:03 dsl Exp $ */
+/*	$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $ */
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.18 2014/01/04 00:10:03 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $");
 
 #include 
 #include 
@@ -109,67 +109,71 @@ __KERNEL_RCSID(0, "$NetBSD: process_mach
 #include 
 
 int
-process_read_regs(struct lwp *p, struct reg *regs)
+process_read_regs(struct lwp *l, struct reg *regs)
 {
 
 	/* NOTE: struct reg == struct trapframe */
-	memcpy((void *)regs, p->l_md.md_tf, sizeof(struct reg));
-	return (0);
+	memcpy(regs, l->l_md.md_tf, sizeof(*regs));
+	return 0;
 }
 
 int
-process_write_regs(struct lwp *p, const struct reg *regs)
+process_write_regs(struct lwp *l, const struct reg *regs)
 {
-	int	psr = p->l_md.md_tf->tf_psr & ~PSR_ICC;
+	int	psr = l->l_md.md_tf->tf_psr & ~PSR_ICC;
 
-	memcpy(p->l_md.md_tf, regs, sizeof(struct reg));
-	p->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC);
-	return (0);
+	memcpy(l->l_md.md_tf, regs, sizeof(*regs));
+	l->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC);
+	return 0;
 }
 
 int
-process_sstep(struct lwp *p, int sstep)
+process_sstep(struct lwp *l, int sstep)
 {
 
 	if (sstep)
-		return (EINVAL);
-	return (0);
+		return EINVAL;
+	return 0;
 }
 
 int
-process_set_pc(struct lwp *p, void *addr)
+process_set_pc(struct lwp *l, void *addr)
 {
 
-	p->l_md.md_tf->tf_pc = (u_int)addr;
-	p->l_md.md_tf->tf_npc = (u_int)addr + 4;
-	return (0);
+	l->l_md.md_tf->tf_pc = (u_int)addr;
+	l->l_md.md_tf->tf_npc = (u_int)addr + 4;
+	return 0;
 }
 
+extern struct fpstate	initfpstate;
+
 int
-process_read_fpregs(struct lwp *p, struct fpreg *regs, size_t *sz)
+process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz)
 {
-	extern struct fpstate	initfpstate;
-	struct fpstate		*statep = 
+	struct fpstate *fs;
+
+	if ((fs = l->l_md.md_fpstate) == NULL)
+		fs = 
 
-	/* NOTE: struct fpreg == prefix of struct fpstate */
-	if (p->l_md.md_fpstate)
-		statep = p->l_md.md_fpstate;
-	memcpy(regs, statep, sizeof(struct fpreg));
-	return (0);
+	*regs = fs->fs_reg;
+	return 0;
 }
 
 int
-process_write_fpregs(struct lwp *p, const struct fpreg *regs, size_t sz)
+process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz)
 {
+	struct fpstate *fs;
 
-	if (p->l_md.md_fpstate == NULL)
-		return (EINVAL);
+	if ((fs = l->l_md.md_fpstate) == NULL) {
+		fs = kmem_zalloc(sizeof(*fs), KM_SLEEP);
+		l->l_md.md_fpstate = fs;
+	} else {
+		/* Reset FP queue in this process `fpstate' */
+		fs->fs_qsize = 

CVS commit: src/tests/kernel

2016-12-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec 30 17:29:34 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.h

Log Message:
Remove unused macro for ATF_TP_ADD_TC_HAVE_DBREGS

This code is unused.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/kernel/t_ptrace_wait.h

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

Modified files:

Index: src/tests/kernel/t_ptrace_wait.h
diff -u src/tests/kernel/t_ptrace_wait.h:1.4 src/tests/kernel/t_ptrace_wait.h:1.5
--- src/tests/kernel/t_ptrace_wait.h:1.4	Sat Dec 17 03:43:38 2016
+++ src/tests/kernel/t_ptrace_wait.h	Fri Dec 30 17:29:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.4 2016/12/17 03:43:38 christos Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.5 2016/12/30 17:29:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -418,12 +418,6 @@ check_happy(unsigned n)
 #define ATF_TP_ADD_TC_HAVE_FPREGS(a,b)
 #endif
 
-#if defined(HAVE_DBREGS)
-#define ATF_TP_ADD_TC_HAVE_DBREGS(a,b)	ATF_TP_ADD_TC(a,b)
-#else
-#define ATF_TP_ADD_TC_HAVE_DBREGS(a,b)
-#endif
-
 #if defined(PT_STEP)
 #define ATF_TP_ADD_TC_PT_STEP(a,b)	ATF_TP_ADD_TC(a,b)
 #else