CVS commit: src/lib/libutil

2013-05-02 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May  2 07:17:10 UTC 2013

Modified Files:
src/lib/libutil: Makefile
Added Files:
src/lib/libutil: getbyteorder.3 getbyteorder.c

Log Message:
Add getbyteorder() call.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/lib/libutil/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libutil/getbyteorder.3 \
src/lib/libutil/getbyteorder.c

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

Modified files:

Index: src/lib/libutil/Makefile
diff -u src/lib/libutil/Makefile:1.73 src/lib/libutil/Makefile:1.74
--- src/lib/libutil/Makefile:1.73	Sat Apr  7 16:44:39 2012
+++ src/lib/libutil/Makefile	Thu May  2 07:17:09 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.73 2012/04/07 16:44:39 christos Exp $
+#	$NetBSD: Makefile,v 1.74 2013/05/02 07:17:09 matt Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
@@ -11,7 +11,8 @@ WARNS?=	5
 LIB=	util
 CPPFLAGS+=-DLIBC_SCCS -I${.CURDIR}
 LINTFLAGS+=-w
-SRCS+=	efun.c getbootfile.c getlabelsector.c getmaxpartitions.c \
+SRCS+=	efun.c \
+	getbootfile.c getbyteorder.c getlabelsector.c getmaxpartitions.c \
 	getfsspecname.c getmntopts.c getrawpartition.c getdiskrawname.c \
 	disklabel_dkcksum.c disklabel_scan.c \
 	if_media.c \
@@ -22,7 +23,8 @@ SRCS+=	efun.c getbootfile.c getlabelsect
 	secure_path.c sockaddr_snprintf.c stat_flags.c \
 	strpct.c ttyaction.c ttymsg.c
 
-MAN=	efun.3 getbootfile.3 getfstypename.3 getlabelsector.3 \
+MAN=	efun.3 \
+	getbootfile.3 getbyteorder.3 getfstypename.3 getlabelsector.3 \
 	getmaxpartitions.3 getmntopts.3 getrawpartition.3 \
 	getdiskrawname.3 getfsspecname.3 \
 	login.3 login_cap.3 loginx.3 \

Added files:

Index: src/lib/libutil/getbyteorder.3
diff -u /dev/null src/lib/libutil/getbyteorder.3:1.1
--- /dev/null	Thu May  2 07:17:10 2013
+++ src/lib/libutil/getbyteorder.3	Thu May  2 07:17:09 2013
@@ -0,0 +1,59 @@
+.\	$NetBSD: getbyteorder.3,v 1.1 2013/05/02 07:17:09 matt Exp $
+.\
+.\ Copyright (c) 1996 The NetBSD Foundation, Inc.
+.\ All rights reserved.
+.\
+.\ This code is derived from software contributed to The NetBSD Foundation
+.\ by Jason R. Thorpe.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\ POSSIBILITY OF SUCH DAMAGE.
+.\
+.Dd May 1, 2013
+.Dt GETBYTEORDER 3
+.Os
+.Sh NAME
+.Nm getbyteorder
+.Nd get the current byte order
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.In util.h
+.In sys/endian.h
+.Ft int
+.Fn getbyteorder void
+.Sh DESCRIPTION
+.Fn getbyteorder
+returns LITTLE_ENDIAN, BIG_ENDIAN,
+or \-1 in case of an error, setting the global
+.Va errno
+variable.
+The possible values for
+.Va errno
+are the same as in
+.Xr sysctl 3 .
+.Sh SEE ALSO
+.Xr sysctl 3
+.Sh HISTORY
+The
+.Fn getbyteorder
+function call appeared in
+.Nx 7 .
Index: src/lib/libutil/getbyteorder.c
diff -u /dev/null src/lib/libutil/getbyteorder.c:1.1
--- /dev/null	Thu May  2 07:17:10 2013
+++ src/lib/libutil/getbyteorder.c	Thu May  2 07:17:10 2013
@@ -0,0 +1,54 @@
+/*	$NetBSD: getbyteorder.c,v 1.1 2013/05/02 07:17:10 matt Exp $	*/
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or 

CVS commit: src/include

2013-05-02 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May  2 07:17:36 UTC 2013

Modified Files:
src/include: util.h

Log Message:
Add getbyteorder(void) prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/include/util.h

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

Modified files:

Index: src/include/util.h
diff -u src/include/util.h:1.64 src/include/util.h:1.65
--- src/include/util.h:1.64	Sun Nov  4 23:25:59 2012
+++ src/include/util.h	Thu May  2 07:17:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.h,v 1.64 2012/11/04 23:25:59 christos Exp $	*/
+/*	$NetBSD: util.h,v 1.65 2013/05/02 07:17:35 matt Exp $	*/
 
 /*-
  * Copyright (c) 1995
@@ -73,6 +73,7 @@ struct sockaddr;
 char	   *flags_to_string(unsigned long, const char *);
 pid_t		forkpty(int *, char *, struct termios *, struct winsize *);
 const char *getbootfile(void);
+int		getbyteorder(void);
 off_t		getlabeloffset(void);
 int		getlabelsector(void);
 int		getlabelusesmbr(void);



CVS commit: src/lib/librump

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 11:32:44 UTC 2013

Modified Files:
src/lib/librump: rump.3

Log Message:
update and bump date


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/librump/rump.3

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

Modified files:

Index: src/lib/librump/rump.3
diff -u src/lib/librump/rump.3:1.11 src/lib/librump/rump.3:1.12
--- src/lib/librump/rump.3:1.11	Tue Apr 30 21:21:24 2013
+++ src/lib/librump/rump.3	Thu May  2 11:32:44 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: rump.3,v 1.11 2013/04/30 21:21:24 pooka Exp $
+.\ $NetBSD: rump.3,v 1.12 2013/05/02 11:32:44 pooka Exp $
 .\
 .\ Copyright (c) 2008-2011 Antti Kantee.  All rights reserved.
 .\
@@ -23,65 +23,58 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd March 25, 2011
+.Dd May 2, 2013
 .Dt RUMP 3
 .Os
 .Sh NAME
 .Nm rump
-.Nd The Rump Anykernel
+.Nd Rump Kernel
 .Sh LIBRARY
 rump Library (librump, \-lrump)
 .Sh SYNOPSIS
 .In rump/rump.h
-.In rump/rump_syscalls.h
 .Sh DESCRIPTION
-.Nm
-is part of the realization of a flexible anykernel architecture for
-.Nx .
-An anykernel architecture enables using kernel code in a number of
-different kernel models.
-These models include, but are not limited to, the original monolithic
-kernel, a microkernel server, or an exokernel style application
-library.
-.Nm
-itself makes it possible to run unmodified kernel components in a regular
-userspace process.
-Most of the time unmodified means unmodified source code, but some
-architectures can also execute unmodified kernel module binaries
-in userspace.
-Examples of different use models are running file system drivers
-as userspace servers (see
-.Xr p2k 3 )
-and being able to write standalone applications which understand
-file system images.
-.Pp
-Regardless of the kernel model used, a rump kernel is a fullfledged
-kernel with its own virtual namespaces,
-including a file system hierarchy, CPUs, TCP/UDP
-ports, device driver attachments and file descriptors.
-This means that any modification to the system state on the host
-running the rump kernel will not show up in the rump kernel and
-vice versa.
-A rump kernel may also be significantly more lightweight than the
-host, and might not include for example file system support
-at all.
-.Pp
-Clients using services provided by rump kernels can exist either
-in the same process as the rump kernel or in other processes.
-Local clients access the rump kernel through direct function calls.
-They also naturally have access to the kernel memory space.
-This document is geared towards local clients.
-For more information on remote clients,
-see
-.Xr rump_sp 7 .
-It is also possible to use unmodified application binaries as
-remote clients with
+A rump kernel is a virtualized kernel instance which retains only part
+of the NetBSD kernel.
+Rump kernels are aimed at virtualizing kernel drivers and do not support
+for example creating processes, managing virtual memory address spaces
+or scheduling threads.
+These features are unnecessary overhead when virtualizing drivers.
+Rump kernels are created by linking a desired set of components together.
+On NetBSD, these components are available as userspace libraries with
+the prefix
+.Pa librump .
+The high-level
+.Xr rumpuser 3
+hypercall interface is used by a rump kernel to request resources and
+services from the host it runs on.
+Like any virtualized kernel, a rump kernel also provides its own set
+of namespaces, such as a file system hierarchy and TCP ports,
+that are independent of the ones on the host and of any other rump
+kernel instances.
+It should be noted that the presence of the provided namespaces
+depends on the components that the rump kernel was constructed with.
+.Pp
+Since a rump kernel does not provide support for applications processes,
+existing entities are used as rump kernel clients.
+The relationship between the client and the rump kernel defines the
+execution model of the rump kernel.
+A local client will reside in the same address space and manipulate the
+rump kernel with function calls and direct memory references.
+Remote and microkernel clients are disjoint from the rump kernel
+and make requests though various protocols, see for example
+.Xr p2k 3 ,
+.Xr rump_sp 7
+and
 .Xr rumphijack 3 .
+Remote clients will also work over a TCP/IP network, or other similar
+communication medium.
 .Pp
 A rump kernel is bootstrapped by calling
 .Fn rump_init .
-Before bootstrapping the kernel, it is possible to control its
-functionality by setting various environment variables:
+A number of environment variables set before a rump kernel is bootstrapped
+will affect how it works.
+Some examples includes:
 .Bl -tag -width RUMP_MEMLIMITXX
 .It Dv RUMP_NCPU
 If set, indicates the number of virtual CPUs configured into a
@@ -96,8 +89,11 @@ If set to 0, prevents 

CVS commit: src/sys/arch

2013-05-02 Thread KIYOHARA Takashi
Module Name:src
Committed By:   kiyohara
Date:   Thu May  2 12:09:40 UTC 2013

Modified Files:
src/sys/arch: README

Log Message:
Add description for epoc32.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/README

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/README
diff -u src/sys/arch/README:1.59 src/sys/arch/README:1.60
--- src/sys/arch/README:1.59	Sun Jan 29 10:32:53 2012
+++ src/sys/arch/README	Thu May  2 12:09:40 2013
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.59 2012/01/29 10:32:53 tsutsui Exp $
+$NetBSD: README,v 1.60 2013/05/02 12:09:40 kiyohara Exp $
 
 acorn26	arm	2509	Acorn ARM2- and ARM3-based machines
 acorn32	arm	2008	Acorn computers Ltd. ARM 6/7/SA based machines
@@ -15,6 +15,7 @@ cesfic	m68k	20010514	FIC8234 VME process
 cobalt	mipsel,mips64el	2319	Cobalt Networks Microservers
 dreamcast	sh3el	20010107	SEGA Dreamcast
 emips	mipseb	20110126	Machines based on Extensible MIPS
+epoc32	arm	20130502	32bit EPOC OS machines
 evbarm	armeb	20010905	ARM-based eval boards
 evbmips	mipseb,mipsel,mips64eb,mips64el	20020307	MIPS-based eval boards
 evbppc	powerpc,powerpc64	20021209	PowerPC-based eval boards



CVS commit: src/lib/librumpuser

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 12:27:08 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser.3

Log Message:
expand the intended usage of rumpuser_open()


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librumpuser/rumpuser.3

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

Modified files:

Index: src/lib/librumpuser/rumpuser.3
diff -u src/lib/librumpuser/rumpuser.3:1.3 src/lib/librumpuser/rumpuser.3:1.4
--- src/lib/librumpuser/rumpuser.3:1.3	Tue Apr 30 21:18:40 2013
+++ src/lib/librumpuser/rumpuser.3	Thu May  2 12:27:08 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.3 2013/04/30 21:18:40 pooka Exp $
+.\ $NetBSD: rumpuser.3,v 1.4 2013/05/02 12:27:08 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -111,13 +111,15 @@ which returned
 .Ft int
 .Fn rumpuser_open const char *name int mode int *fdp
 .Pp
-Open a file for I/O.
-Notably, there needs to be no mapping between
+Open
 .Fa name
-and the host, but for example on a POSIX system it may be convenient
-to let
+for I/O and associate a file descriptor with it.
+Notably, there needs to be no mapping between
 .Fa name
-denote the host file system namespace.
+and the host's file system namespace.
+For example, it is possible to associate the file descriptor with
+device I/O registers for special values of
+.Fa name .
 .Bl -tag -width xalignmentx
 .It Fa name
 the identifier of the file to open for I/O



CVS commit: src/distrib/sets/lists/comp

2013-05-02 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May  2 13:30:12 UTC 2013

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
Add getbyteorder manpages.


To generate a diff of this commit:
cvs rdiff -u -r1.1819 -r1.1820 src/distrib/sets/lists/comp/mi

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.1819 src/distrib/sets/lists/comp/mi:1.1820
--- src/distrib/sets/lists/comp/mi:1.1819	Sun Apr 28 04:05:39 2013
+++ src/distrib/sets/lists/comp/mi	Thu May  2 13:30:10 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1819 2013/04/28 04:05:39 joerg Exp $
+#	$NetBSD: mi,v 1.1820 2013/05/02 13:30:10 matt Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -5801,6 +5801,7 @@
 ./usr/share/man/cat3/getbkgd.0			comp-c-catman		.cat
 ./usr/share/man/cat3/getbootfile.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getbsize.0			comp-c-catman		.cat
+./usr/share/man/cat3/getbyteorder.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getc.0			comp-c-catman		.cat
 ./usr/share/man/cat3/getc_unlocked.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getcap.0			comp-obsolete		obsolete
@@ -12335,6 +12336,7 @@
 ./usr/share/man/html3/getbkgd.html		comp-c-htmlman		html
 ./usr/share/man/html3/getbootfile.html		comp-c-htmlman		html
 ./usr/share/man/html3/getbsize.html		comp-c-htmlman		html
+./usr/share/man/html3/getbyteorder.html		comp-c-htmlman		html
 ./usr/share/man/html3/getc.html			comp-c-htmlman		html
 ./usr/share/man/html3/getc_unlocked.html	comp-c-htmlman		html
 ./usr/share/man/html3/getcap.html		comp-obsolete		obsolete
@@ -18783,6 +18785,7 @@
 ./usr/share/man/man3/getbkgd.3			comp-c-man		.man
 ./usr/share/man/man3/getbootfile.3		comp-c-man		.man
 ./usr/share/man/man3/getbsize.3			comp-c-man		.man
+./usr/share/man/man3/getbyteorder.3		comp-c-man		.man
 ./usr/share/man/man3/getc.3			comp-c-man		.man
 ./usr/share/man/man3/getc_unlocked.3		comp-c-man		.man
 ./usr/share/man/man3/getcap.3			comp-obsolete		obsolete



CVS commit: src/sys/miscfs/genfs

2013-05-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  2 14:49:51 UTC 2013

Modified Files:
src/sys/miscfs/genfs: genfs.h

Log Message:
Fix (harmless) typo in struct genfs_rename_ops::gro_lookup prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/miscfs/genfs/genfs.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/miscfs/genfs/genfs.h
diff -u src/sys/miscfs/genfs/genfs.h:1.30 src/sys/miscfs/genfs/genfs.h:1.31
--- src/sys/miscfs/genfs/genfs.h:1.30	Tue May  8 23:53:26 2012
+++ src/sys/miscfs/genfs/genfs.h	Thu May  2 14:49:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs.h,v 1.30 2012/05/08 23:53:26 riastradh Exp $	*/
+/*	$NetBSD: genfs.h,v 1.31 2013/05/02 14:49:51 riastradh Exp $	*/
 
 #ifndef	_MISCFS_GENFS_GENFS_H_
 #define	_MISCFS_GENFS_GENFS_H_
@@ -108,7 +108,7 @@ struct genfs_rename_ops {
 	struct vnode *dvp, struct componentname *cnp, void *de,
 	struct vnode *vp);
 	int (*gro_lookup)(struct mount *mp, struct vnode *dvp,
-	struct componentname *cnp, void *fde_ret, struct vnode **vp_ret);
+	struct componentname *cnp, void *de_ret, struct vnode **vp_ret);
 	int (*gro_genealogy)(struct mount *mp, kauth_cred_t cred,
 	struct vnode *fdvp, struct vnode *tdvp,
 	struct vnode **intermediate_node_ret);



CVS commit: src/lib/librumpuser

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 15:32:20 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser.3

Log Message:
add HISTORY


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/librumpuser/rumpuser.3

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

Modified files:

Index: src/lib/librumpuser/rumpuser.3
diff -u src/lib/librumpuser/rumpuser.3:1.4 src/lib/librumpuser/rumpuser.3:1.5
--- src/lib/librumpuser/rumpuser.3:1.4	Thu May  2 12:27:08 2013
+++ src/lib/librumpuser/rumpuser.3	Thu May  2 15:32:19 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.4 2013/05/02 12:27:08 pooka Exp $
+.\ $NetBSD: rumpuser.3,v 1.5 2013/05/02 15:32:19 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -609,3 +609,8 @@ Routines which do not return an integer 
 .%J Aalto University Doctoral Dissertations
 .%T Flexible Operating System Internals: The Design and Implementation of the Anykernel and Rump Kernerls
 .Re
+.Sh HISTORY
+The rump kernel hypercall API was first introduced in
+.Nx 5 .
+The API described above first appeared in
+.Nx 7 .



CVS commit: src/lib/librumpuser

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 16:49:08 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser_pth.c

Log Message:
Clear rwlock's writer field when releasing the lock.  Otherwise it might
have been possible for readers to reach visibility before writer
when another CPU took the lock, thus leading the previous owner to
incorrectly think that it still owned the lock in rw_write_held().

Also, remove duplicate clause from assert().


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/librumpuser/rumpuser_pth.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.21 src/lib/librumpuser/rumpuser_pth.c:1.22
--- src/lib/librumpuser/rumpuser_pth.c:1.21	Tue Apr 30 13:29:28 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Thu May  2 16:49:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.21 2013/04/30 13:29:28 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.22 2013/05/02 16:49:08 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.21 2013/04/30 13:29:28 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.22 2013/05/02 16:49:08 pooka Exp $);
 #endif /* !lint */
 
 #include assert.h
@@ -65,8 +65,9 @@ do {	\
 } while (/*CONSTCOND*/0)
 #define RURW_CLRWRITE(rw)		\
 do {	\
-	assert(rw-readers == -1  RURW_AMWRITER(rw));			\
+	assert(RURW_AMWRITER(rw));	\
 	rw-readers = 0;		\
+	rw-writer = NULL;		\
 } while (/*CONSTCOND*/0)
 #define RURW_INCREAD(rw)		\
 do {	\



CVS commit: src

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 20:33:54 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser_pth.c
src/sys/rump/librump/rumpkern: locks.c

Log Message:
Retry enabling spin mutexes.  We should be able to avoid poking the
scheduler by just making wakeup from cv_wait() honor the same locking
order as when a spin mutex is acquired though mutex_enter().
*fingers crossed*


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/librumpuser/rumpuser_pth.c
cvs rdiff -u -r1.60 -r1.61 src/sys/rump/librump/rumpkern/locks.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.23 src/lib/librumpuser/rumpuser_pth.c:1.24
--- src/lib/librumpuser/rumpuser_pth.c:1.23	Thu May  2 19:14:59 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Thu May  2 20:33:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.23 2013/05/02 19:14:59 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.24 2013/05/02 20:33:54 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.23 2013/05/02 19:14:59 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.24 2013/05/02 20:33:54 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -378,17 +378,53 @@ rumpuser_cv_destroy(struct rumpuser_cv *
 	free(cv);
 }
 
+static void
+cv_unschedule(struct rumpuser_mtx *mtx, int *nlocks)
+{
+
+	rumpkern_unsched(nlocks, mtx);
+	mtxexit(mtx);
+}
+
+static void
+cv_reschedule(struct rumpuser_mtx *mtx, int nlocks)
+{
+
+	/*
+	 * If the cv interlock is a spin mutex, we must first release
+	 * the mutex that was reacquired by pthread_cond_wait(),
+	 * acquire the CPU context and only then relock the mutex.
+	 * This is to preserve resource allocation order so that
+	 * we don't deadlock.  Non-spinning mutexes don't have this
+	 * problem since they don't use a hold-and-wait approach
+	 * to acquiring the mutex wrt the rump kernel CPU context.
+	 *
+	 * The more optimal solution would be to rework rumpkern_sched()
+	 * so that it's possible to tell the scheduler
+	 * if you need to block, drop this lock first, but I'm not
+	 * going poking there without some numbers on how often this
+	 * path is taken for spin mutexes.
+	 */
+	if ((mtx-flags  (RUMPUSER_MTX_SPIN | RUMPUSER_MTX_KMUTEX)) ==
+	(RUMPUSER_MTX_SPIN | RUMPUSER_MTX_KMUTEX)) {
+		NOFAIL_ERRNO(pthread_mutex_unlock(mtx-pthmtx));
+		rumpkern_sched(nlocks, mtx);
+		rumpuser_mutex_enter_nowrap(mtx);
+	} else {
+		mtxenter(mtx);
+		rumpkern_sched(nlocks, mtx);
+	}
+}
+
 void
 rumpuser_cv_wait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx)
 {
 	int nlocks;
 
 	cv-nwaiters++;
-	rumpkern_unsched(nlocks, mtx);
-	mtxexit(mtx);
+	cv_unschedule(mtx, nlocks);
 	NOFAIL_ERRNO(pthread_cond_wait(cv-pthcv, mtx-pthmtx));
-	mtxenter(mtx);
-	rumpkern_sched(nlocks, mtx);
+	cv_reschedule(mtx, nlocks);
 	cv-nwaiters--;
 }
 
@@ -420,8 +456,7 @@ rumpuser_cv_timedwait(struct rumpuser_cv
 	clock_gettime(CLOCK_REALTIME, ts);
 
 	cv-nwaiters++;
-	rumpkern_unsched(nlocks, mtx);
-	mtxexit(mtx);
+	cv_unschedule(mtx, nlocks);
 
 	ts.tv_sec += sec;
 	ts.tv_nsec += nsec;
@@ -430,8 +465,8 @@ rumpuser_cv_timedwait(struct rumpuser_cv
 		ts.tv_nsec -= 1000*1000*1000;
 	}
 	rv = pthread_cond_timedwait(cv-pthcv, mtx-pthmtx, ts);
-	mtxenter(mtx);
-	rumpkern_sched(nlocks, mtx);
+
+	cv_reschedule(mtx, nlocks);
 	cv-nwaiters--;
 
 	ET(rv);

Index: src/sys/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.60 src/sys/rump/librump/rumpkern/locks.c:1.61
--- src/sys/rump/librump/rumpkern/locks.c:1.60	Tue Apr 30 00:03:53 2013
+++ src/sys/rump/librump/rumpkern/locks.c	Thu May  2 20:33:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: locks.c,v 1.60 2013/04/30 00:03:53 pooka Exp $	*/
+/*	$NetBSD: locks.c,v 1.61 2013/05/02 20:33:54 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: locks.c,v 1.60 2013/04/30 00:03:53 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: locks.c,v 1.61 2013/05/02 20:33:54 pooka Exp $);
 
 #include sys/param.h
 #include sys/kmem.h
@@ -113,11 +113,9 @@ mutex_init(kmutex_t *mtx, kmutex_type_t 
 		isspin = 1;
 	}
 
-#if 0
 	/* spin mutex support needs some cpu scheduler rework  */
 	if (isspin)
 		ruflags |= RUMPUSER_MTX_SPIN;
-#endif
 	rumpuser_mutex_init((struct rumpuser_mtx **)mtx, ruflags);
 	ALLOCK(mtx, mutex_lockops);
 }
@@ -144,7 +142,7 @@ mutex_spin_enter(kmutex_t *mtx)
 {
 
 	WANTLOCK(mtx, false, false);
-	rumpuser_mutex_enter(RUMPMTX(mtx));
+	rumpuser_mutex_enter_nowrap(RUMPMTX(mtx));
 	LOCKED(mtx, false);
 }
 



CVS commit: src/sys/rump/librump/rumpkern

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 20:37:33 UTC 2013

Modified Files:
src/sys/rump/librump/rumpkern: locks.c

Log Message:
g/c stale comment


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/rump/librump/rumpkern/locks.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/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.61 src/sys/rump/librump/rumpkern/locks.c:1.62
--- src/sys/rump/librump/rumpkern/locks.c:1.61	Thu May  2 20:33:54 2013
+++ src/sys/rump/librump/rumpkern/locks.c	Thu May  2 20:37:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: locks.c,v 1.61 2013/05/02 20:33:54 pooka Exp $	*/
+/*	$NetBSD: locks.c,v 1.62 2013/05/02 20:37:32 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: locks.c,v 1.61 2013/05/02 20:33:54 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: locks.c,v 1.62 2013/05/02 20:37:32 pooka Exp $);
 
 #include sys/param.h
 #include sys/kmem.h
@@ -113,7 +113,6 @@ mutex_init(kmutex_t *mtx, kmutex_type_t 
 		isspin = 1;
 	}
 
-	/* spin mutex support needs some cpu scheduler rework  */
 	if (isspin)
 		ruflags |= RUMPUSER_MTX_SPIN;
 	rumpuser_mutex_init((struct rumpuser_mtx **)mtx, ruflags);



CVS commit: src/libexec/ld.elf_so

2013-05-02 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May  2 21:11:04 UTC 2013

Modified Files:
src/libexec/ld.elf_so: headers.c

Log Message:
Print out PT_DYNAMIC address for objmain.
Print out _DYNAMIC too.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/libexec/ld.elf_so/headers.c

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

Modified files:

Index: src/libexec/ld.elf_so/headers.c
diff -u src/libexec/ld.elf_so/headers.c:1.47 src/libexec/ld.elf_so/headers.c:1.48
--- src/libexec/ld.elf_so/headers.c:1.47	Thu Apr 25 13:45:15 2013
+++ src/libexec/ld.elf_so/headers.c	Thu May  2 21:11:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: headers.c,v 1.47 2013/04/25 13:45:15 matt Exp $	 */
+/*	$NetBSD: headers.c,v 1.48 2013/05/02 21:11:03 matt Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: headers.c,v 1.47 2013/04/25 13:45:15 matt Exp $);
+__RCSID($NetBSD: headers.c,v 1.48 2013/05/02 21:11:03 matt Exp $);
 #endif /* not lint */
 
 #include err.h
@@ -403,6 +403,8 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, 
 
 		case PT_DYNAMIC:
 			obj-dynamic = (Elf_Dyn *)(uintptr_t)vaddr;
+			dbg((headers: PT_DYNAMIC %p phsize %zu,
+			obj-dynamic, (size_t)ph-p_memsz));
 			break;
 
 #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)



CVS commit: src/libexec/ld.elf_so

2013-05-02 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May  2 21:11:18 UTC 2013

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
Print out _DYNAMIC too.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/libexec/ld.elf_so/rtld.c

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

Modified files:

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.161 src/libexec/ld.elf_so/rtld.c:1.162
--- src/libexec/ld.elf_so/rtld.c:1.161	Sun Dec 16 23:00:46 2012
+++ src/libexec/ld.elf_so/rtld.c	Thu May  2 21:11:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.161 2012/12/16 23:00:46 dsl Exp $	 */
+/*	$NetBSD: rtld.c,v 1.162 2013/05/02 21:11:18 matt Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: rtld.c,v 1.161 2012/12/16 23:00:46 dsl Exp $);
+__RCSID($NetBSD: rtld.c,v 1.162 2013/05/02 21:11:18 matt Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -443,12 +443,14 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
 	debug = 1;
 	dbg((sp = %p, argc = %ld, argv = %p %s relocbase %p, sp,
 	(long)sp[2], sp[3], (char *) sp[3], (void *)relocbase));
-#if 0
+#if 1
 	dbg((got is at %p, dynamic is at %p, _GLOBAL_OFFSET_TABLE_,
 	_DYNAMIC));
 #endif
+#if 0
 	dbg((_ctype_ is %p, _ctype_));
 #endif
+#endif
 
 	sp += 2;		/* skip over return argument space */
 	argv = (const char **) sp[1];



CVS commit: src

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 21:35:19 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser.3 rumpuser_pth.c
src/sys/rump/include/rump: rumpuser.h
src/sys/rump/librump/rumpkern: locks.c

Log Message:
Push rwlock upgrade and downgrade into the hypervisor where there's
at least a chance to implement them with minimal fuss.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/librumpuser/rumpuser.3
cvs rdiff -u -r1.24 -r1.25 src/lib/librumpuser/rumpuser_pth.c
cvs rdiff -u -r1.101 -r1.102 src/sys/rump/include/rump/rumpuser.h
cvs rdiff -u -r1.62 -r1.63 src/sys/rump/librump/rumpkern/locks.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser.3
diff -u src/lib/librumpuser/rumpuser.3:1.6 src/lib/librumpuser/rumpuser.3:1.7
--- src/lib/librumpuser/rumpuser.3:1.6	Thu May  2 19:14:59 2013
+++ src/lib/librumpuser/rumpuser.3	Thu May  2 21:35:19 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.6 2013/05/02 19:14:59 pooka Exp $
+.\ $NetBSD: rumpuser.3,v 1.7 2013/05/02 21:35:19 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -561,30 +561,38 @@ will never be called for that particular
 .Fn rumpuser_rw_init struct rumpuser_rw **rwp
 .Pp
 .Ft void
-.Fn rumpuser_rw_enter struct rumpuser_rw *rw int writelock
+.Fn rumpuser_rw_enter struct rumpuser_rw *rw const enum rumprwlock lk
 .Pp
 .Ft int
-.Fn rumpuser_rw_tryenter struct rumpuser_rw *rw int writelock
+.Fn rumpuser_rw_tryenter struct rumpuser_rw *rw const enum rumprwlock lk
 .Pp
-.Ft void
-.Fn rumpuser_rw_exit struct rumpuser_rw *rw
+.Ft int
+.Fn rumpuser_rw_tryupgrade struct rumpuser_rw *rw
 .Pp
 .Ft void
-.Fn rumpuser_rw_destroy struct rumpuser_rw *rw
+.Fn rumpuser_rw_downgrade struct rumpuser_rw *rw
 .Pp
 .Ft void
-.Fn rumpuser_rw_held struct rumpuser_rw *rw int *heldp
+.Fn rumpuser_rw_exit struct rumpuser_rw *rw
 .Pp
 .Ft void
-.Fn rumpuser_rw_rdheld struct rumpuser_rw *rw int *heldp
+.Fn rumpuser_rw_destroy struct rumpuser_rw *rw
 .Pp
 .Ft void
-.Fn rumpuser_rw_wrheld struct rumpuser_rw *rw int *heldp
-.Pp
-Read/write locks acquire an exclusive version of the lock if the
-.Fa writelock
-parameter is non-zero and a shared lock otherwise.
+.Fo rumpuser_rw_held
+.Fa struct rumpuser_rw *rw const enum rumprwlock lk int *heldp
+.Fc
 .Pp
+Read/write locks provide either shared or exclusive locking.
+The possible values for
+.Fa lk
+are
+.Dv RUMPUSER_RW_READER
+and
+.Dv RUMPUSER_RW_WRITER .
+Upgrading means trying to migrate from an already owned shared
+lock to an exclusive lock and downgrading means migrating from
+an already owned exclusive lock to a shared lock.
 .Pp
 .Ft void
 .Fn rumpuser_cv_init struct rumpuser_cv **cvp

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.24 src/lib/librumpuser/rumpuser_pth.c:1.25
--- src/lib/librumpuser/rumpuser_pth.c:1.24	Thu May  2 20:33:54 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Thu May  2 21:35:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.24 2013/05/02 20:33:54 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.25 2013/05/02 21:35:19 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.24 2013/05/02 20:33:54 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.25 2013/05/02 21:35:19 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -286,40 +286,72 @@ rumpuser_rw_init(struct rumpuser_rw **rw
 }
 
 void
-rumpuser_rw_enter(struct rumpuser_rw *rw, int iswrite)
+rumpuser_rw_enter(struct rumpuser_rw *rw, const enum rumprwlock lk)
 {
 
-	if (iswrite) {
+	switch (lk) {
+	case RUMPUSER_RW_WRITER:
 		if (pthread_rwlock_trywrlock(rw-pthrw) != 0)
 			KLOCK_WRAP(NOFAIL_ERRNO(
 			pthread_rwlock_wrlock(rw-pthrw)));
 		RURW_SETWRITE(rw);
-	} else {
+		break;
+	case RUMPUSER_RW_READER:
 		if (pthread_rwlock_tryrdlock(rw-pthrw) != 0)
 			KLOCK_WRAP(NOFAIL_ERRNO(
 			pthread_rwlock_rdlock(rw-pthrw)));
 		RURW_INCREAD(rw);
+		break;
 	}
 }
 
 int
-rumpuser_rw_tryenter(struct rumpuser_rw *rw, int iswrite)
+rumpuser_rw_tryenter(struct rumpuser_rw *rw, const enum rumprwlock lk)
 {
 	int rv;
 
-	if (iswrite) {
+	switch (lk) {
+	case RUMPUSER_RW_WRITER:
 		rv = pthread_rwlock_trywrlock(rw-pthrw);
 		if (rv == 0)
 			RURW_SETWRITE(rw);
-	} else {
+		break;
+	case RUMPUSER_RW_READER:
 		rv = pthread_rwlock_tryrdlock(rw-pthrw);
 		if (rv == 0)
 			RURW_INCREAD(rw);
+		break;
+	default:
+		rv = EINVAL;
+		break;
 	}
 
 	ET(rv);
 }
 
+int
+rumpuser_rw_tryupgrade(struct rumpuser_rw *rw)
+{
+
+	/* not supported by pthreads */
+	ET(EBUSY);
+}
+
+void
+rumpuser_rw_downgrade(struct rumpuser_rw *rw)
+{
+
+	/*
+	 * I guess this is not strictly speaking correct,
+	 * but the option is to provide a complete implementation
+	 * of rwlocks 

CVS commit: src/external/mit/xorg/lib/pixman

2013-05-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May  2 21:40:58 UTC 2013

Modified Files:
src/external/mit/xorg/lib/pixman: Makefile

Log Message:
Comment out iwmmxt. hi jared.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/mit/xorg/lib/pixman/Makefile

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

Modified files:

Index: src/external/mit/xorg/lib/pixman/Makefile
diff -u src/external/mit/xorg/lib/pixman/Makefile:1.21 src/external/mit/xorg/lib/pixman/Makefile:1.22
--- src/external/mit/xorg/lib/pixman/Makefile:1.21	Thu Feb 28 12:40:47 2013
+++ src/external/mit/xorg/lib/pixman/Makefile	Thu May  2 21:40:57 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.21 2013/02/28 12:40:47 macallan Exp $
+#	$NetBSD: Makefile,v 1.22 2013/05/02 21:40:57 skrll Exp $
 
 NOLINT=	1	# defined
 
@@ -71,9 +71,9 @@ SRCS+=		pixman-arm-neon.c		\
 		pixman-arm-neon-asm-bilinear.S
 CPPFLAGS+=	-DUSE_ARM_NEON
 # ARM iwMMX
-SRCS+=		pixman-mmx.c
-COPTS.pixman-mmx.c=	-mcpu=iwmmxt
-CPPFLAGS+=	-DUSE_ARM_IWMMXT
+#SRCS+=		pixman-mmx.c
+#COPTS.pixman-mmx.c=	-mcpu=iwmmxt
+#CPPFLAGS+=	-DUSE_ARM_IWMMXT
 .endif
 
 .if ${MACHINE} == evbmips



CVS commit: src

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 21:45:29 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser.c
src/sys/rump/include/rump: rumpuser.h
src/sys/rump/librump/rumpkern: intr.c rump.c

Log Message:
Ok, maybe using int64 for nanoseconds in the (sec,nsec) tuple was
a bit too future-proof.  I think long is enough there (let's just
hope nobody redefines nano).  Also, make seconds signed just in
case someone wants their clock to be in 1901.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r1.102 -r1.103 src/sys/rump/include/rump/rumpuser.h
cvs rdiff -u -r1.39 -r1.40 src/sys/rump/librump/rumpkern/intr.c
cvs rdiff -u -r1.267 -r1.268 src/sys/rump/librump/rumpkern/rump.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser.c
diff -u src/lib/librumpuser/rumpuser.c:1.49 src/lib/librumpuser/rumpuser.c:1.50
--- src/lib/librumpuser/rumpuser.c:1.49	Wed May  1 17:17:54 2013
+++ src/lib/librumpuser/rumpuser.c	Thu May  2 21:45:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.49 2013/05/01 17:17:54 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.50 2013/05/02 21:45:29 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser.c,v 1.49 2013/05/01 17:17:54 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.50 2013/05/02 21:45:29 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -395,7 +395,7 @@ rumpuser_iovwrite(int fd, const struct r
 }
 
 int
-rumpuser_clock_gettime(enum rumpclock rclk, uint64_t *sec, uint64_t *nsec)
+rumpuser_clock_gettime(enum rumpclock rclk, int64_t *sec, long *nsec)
 {
 	struct timespec ts;
 	clockid_t clk;
@@ -428,7 +428,7 @@ rumpuser_clock_gettime(enum rumpclock rc
 }
 
 int
-rumpuser_clock_sleep(enum rumpclock clk, uint64_t sec, uint64_t nsec)
+rumpuser_clock_sleep(enum rumpclock clk, int64_t sec, long nsec)
 {
 	struct timespec rqt, rmt;
 	int nlocks;

Index: src/sys/rump/include/rump/rumpuser.h
diff -u src/sys/rump/include/rump/rumpuser.h:1.102 src/sys/rump/include/rump/rumpuser.h:1.103
--- src/sys/rump/include/rump/rumpuser.h:1.102	Thu May  2 21:35:19 2013
+++ src/sys/rump/include/rump/rumpuser.h	Thu May  2 21:45:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.h,v 1.102 2013/05/02 21:35:19 pooka Exp $	*/
+/*	$NetBSD: rumpuser.h,v 1.103 2013/05/02 21:45:28 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -114,8 +114,8 @@ int rumpuser_iovwrite(int, const struct 
  */
 
 enum rumpclock { RUMPUSER_CLOCK_RELWALL, RUMPUSER_CLOCK_ABSMONO };
-int rumpuser_clock_gettime(enum rumpclock, uint64_t *, uint64_t *);
-int rumpuser_clock_sleep(enum rumpclock, uint64_t, uint64_t);
+int rumpuser_clock_gettime(enum rumpclock, int64_t *, long *);
+int rumpuser_clock_sleep(enum rumpclock, int64_t, long);
 
 /*
  * host information retrieval

Index: src/sys/rump/librump/rumpkern/intr.c
diff -u src/sys/rump/librump/rumpkern/intr.c:1.39 src/sys/rump/librump/rumpkern/intr.c:1.40
--- src/sys/rump/librump/rumpkern/intr.c:1.39	Tue Apr 30 16:03:44 2013
+++ src/sys/rump/librump/rumpkern/intr.c	Thu May  2 21:45:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.39 2013/04/30 16:03:44 pooka Exp $	*/
+/*	$NetBSD: intr.c,v 1.40 2013/05/02 21:45:28 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008-2010 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intr.c,v 1.39 2013/04/30 16:03:44 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: intr.c,v 1.40 2013/05/02 21:45:28 pooka Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -100,7 +100,8 @@ static void
 doclock(void *noarg)
 {
 	struct timespec thetick, curclock;
-	uint64_t sec, nsec;
+	int64_t sec;
+	long nsec;
 	int error;
 	extern int hz;
 

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.267 src/sys/rump/librump/rumpkern/rump.c:1.268
--- src/sys/rump/librump/rumpkern/rump.c:1.267	Thu May  2 19:15:01 2013
+++ src/sys/rump/librump/rumpkern/rump.c	Thu May  2 21:45:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.267 2013/05/02 19:15:01 pooka Exp $	*/
+/*	$NetBSD: rump.c,v 1.268 2013/05/02 21:45:28 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rump.c,v 1.267 2013/05/02 19:15:01 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: rump.c,v 1.268 2013/05/02 21:45:28 pooka Exp $);
 
 #include sys/systm.h
 #define ELFSIZE ARCH_ELFSIZE
@@ -235,7 +235,8 @@ rump_init(void)
 {
 	char buf[256];
 	struct timespec ts;
-	uint64_t sec, nsec;
+	int64_t sec;
+	long nsec;
 	struct lwp *l;
 	int i, numcpu;
 



CVS commit: src/lib/librumpuser

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 21:47:12 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser.3

Log Message:
update for previous change


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/librumpuser/rumpuser.3

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

Modified files:

Index: src/lib/librumpuser/rumpuser.3
diff -u src/lib/librumpuser/rumpuser.3:1.7 src/lib/librumpuser/rumpuser.3:1.8
--- src/lib/librumpuser/rumpuser.3:1.7	Thu May  2 21:35:19 2013
+++ src/lib/librumpuser/rumpuser.3	Thu May  2 21:47:12 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.7 2013/05/02 21:35:19 pooka Exp $
+.\ $NetBSD: rumpuser.3,v 1.8 2013/05/02 21:47:12 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -276,7 +276,7 @@ If this is not possible, the hypervisor 
 retain semantics.
 .Pp
 .Ft int
-.Fn rumpuser_clock_gettime enum rumpclock clk uint64_t *sec uint64_t *nsec
+.Fn rumpuser_clock_gettime enum rumpclock clk int64_t *sec long *nsec
 .Pp
 .Bl -tag -width xalignmentx
 .It Fa clk
@@ -294,7 +294,7 @@ return value for nanoseconds
 .El
 .Pp
 .Ft int
-.Fn rumpuser_clock_sleep enum rumpclock clk uint64_t sec uint64_t nsec
+.Fn rumpuser_clock_sleep enum rumpclock clk int64_t sec long nsec
 .Bl -tag -width xalignmentx
 .It Fa clk
 In case of



CVS commit: src/lib/librumpuser

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu May  2 22:07:58 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser_pth.c

Log Message:
reorder for better locality.  no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/librumpuser/rumpuser_pth.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.25 src/lib/librumpuser/rumpuser_pth.c:1.26
--- src/lib/librumpuser/rumpuser_pth.c:1.25	Thu May  2 21:35:19 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Thu May  2 22:07:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.25 2013/05/02 21:35:19 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.26 2013/05/02 22:07:57 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.25 2013/05/02 21:35:19 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.26 2013/05/02 22:07:57 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -47,64 +47,6 @@ __RCSID($NetBSD: rumpuser_pth.c,v 1.25 
 
 #include rumpuser_int.h
 
-static pthread_key_t curlwpkey;
-
-struct rumpuser_mtx {
-	pthread_mutex_t pthmtx;
-	struct lwp *owner;
-	int flags;
-};
-
-#define RURW_AMWRITER(rw) (rw-writer == rumpuser_curlwp()		\
- rw-readers == -1)
-#define RURW_HASREAD(rw)  (rw-readers  0)
-
-#define RURW_SETWRITE(rw)		\
-do {	\
-	assert(rw-readers == 0);	\
-	rw-writer = rumpuser_curlwp();	\
-	rw-readers = -1;		\
-} while (/*CONSTCOND*/0)
-#define RURW_CLRWRITE(rw)		\
-do {	\
-	assert(RURW_AMWRITER(rw));	\
-	rw-readers = 0;		\
-	rw-writer = NULL;		\
-} while (/*CONSTCOND*/0)
-#define RURW_INCREAD(rw)		\
-do {	\
-	pthread_spin_lock(rw-spin);	\
-	assert(rw-readers = 0);	\
-	++(rw)-readers;		\
-	pthread_spin_unlock(rw-spin);	\
-} while (/*CONSTCOND*/0)
-#define RURW_DECREAD(rw)		\
-do {	\
-	pthread_spin_lock(rw-spin);	\
-	assert(rw-readers  0);	\
-	--(rw)-readers;		\
-	pthread_spin_unlock(rw-spin);	\
-} while (/*CONSTCOND*/0)
-
-struct rumpuser_rw {
-	pthread_rwlock_t pthrw;
-	pthread_spinlock_t spin;
-	int readers;
-	struct lwp *writer;
-};
-
-struct rumpuser_cv {
-	pthread_cond_t pthcv;
-	int nwaiters;
-};
-
-void
-rumpuser__thrinit(void)
-{
-
-	pthread_key_create(curlwpkey, NULL);
-}
-
 int
 rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname,
 	int joinable, int priority, int cpuidx, void **ptcookie)
@@ -170,6 +112,12 @@ rumpuser_thread_join(void *ptcookie)
 	ET(rv);
 }
 
+struct rumpuser_mtx {
+	pthread_mutex_t pthmtx;
+	struct lwp *owner;
+	int flags;
+};
+
 void
 rumpuser_mutex_init(struct rumpuser_mtx **mtx, int flags)
 {
@@ -274,6 +222,48 @@ rumpuser_mutex_owner(struct rumpuser_mtx
 	*lp = mtx-owner;
 }
 
+/*
+ * rwlocks
+ */
+
+struct rumpuser_rw {
+	pthread_rwlock_t pthrw;
+	pthread_spinlock_t spin;
+	int readers;
+	struct lwp *writer;
+};
+
+#define RURW_AMWRITER(rw) (rw-writer == rumpuser_curlwp()		\
+ rw-readers == -1)
+#define RURW_HASREAD(rw)  (rw-readers  0)
+
+#define RURW_SETWRITE(rw)		\
+do {	\
+	assert(rw-readers == 0);	\
+	rw-writer = rumpuser_curlwp();	\
+	rw-readers = -1;		\
+} while (/*CONSTCOND*/0)
+#define RURW_CLRWRITE(rw)		\
+do {	\
+	assert(RURW_AMWRITER(rw));	\
+	rw-readers = 0;		\
+	rw-writer = NULL;		\
+} while (/*CONSTCOND*/0)
+#define RURW_INCREAD(rw)		\
+do {	\
+	pthread_spin_lock(rw-spin);	\
+	assert(rw-readers = 0);	\
+	++(rw)-readers;		\
+	pthread_spin_unlock(rw-spin);	\
+} while (/*CONSTCOND*/0)
+#define RURW_DECREAD(rw)		\
+do {	\
+	pthread_spin_lock(rw-spin);	\
+	assert(rw-readers  0);	\
+	--(rw)-readers;		\
+	pthread_spin_unlock(rw-spin);	\
+} while (/*CONSTCOND*/0)
+
 void
 rumpuser_rw_init(struct rumpuser_rw **rw)
 {
@@ -386,6 +376,15 @@ rumpuser_rw_held(struct rumpuser_rw *rw,
 	}
 }
 
+/*
+ * condvar
+ */
+
+struct rumpuser_cv {
+	pthread_cond_t pthcv;
+	int nwaiters;
+};
+
 void
 rumpuser_cv_init(struct rumpuser_cv **cv)
 {
@@ -522,6 +521,8 @@ rumpuser_cv_has_waiters(struct rumpuser_
  * curlwp
  */
 
+static pthread_key_t curlwpkey;
+
 /*
  * the if0'd curlwp implementation is not used by this hypervisor,
  * but serves as test code to check that the intended usage works.
@@ -625,3 +626,10 @@ rumpuser_curlwp(void)
 	return pthread_getspecific(curlwpkey);
 }
 #endif
+
+
+void
+rumpuser__thrinit(void)
+{
+	pthread_key_create(curlwpkey, NULL);
+}



CVS commit: src/bin/ls

2013-05-02 Thread Zafer Aydogan
Module Name:src
Committed By:   zafer
Date:   Thu May  2 22:43:56 UTC 2013

Modified Files:
src/bin/ls: print.c

Log Message:
remove whitespace from end of file.
introduced by erh in 1.49


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/bin/ls/print.c

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

Modified files:

Index: src/bin/ls/print.c
diff -u src/bin/ls/print.c:1.51 src/bin/ls/print.c:1.52
--- src/bin/ls/print.c:1.51	Fri Jun 29 12:51:38 2012
+++ src/bin/ls/print.c	Thu May  2 22:43:55 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.51 2012/06/29 12:51:38 yamt Exp $	*/
+/*	$NetBSD: print.c,v 1.52 2013/05/02 22:43:55 zafer Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)print.c	8.5 (Berkeley) 7/28/94;
 #else
-__RCSID($NetBSD: print.c,v 1.51 2012/06/29 12:51:38 yamt Exp $);
+__RCSID($NetBSD: print.c,v 1.52 2013/05/02 22:43:55 zafer Exp $);
 #endif
 #endif /* not lint */
 
@@ -461,4 +461,3 @@ printlink(FTSENT *p)
 	else
 		(void)printf(%s, path);
 }
-



CVS commit: src/sys/dev/usb

2013-05-02 Thread Radoslaw Kujawa
Module Name:src
Committed By:   rkujawa
Date:   Thu May  2 23:10:53 UTC 2013

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add vendor ID for Mad Catz, Inc.
Add product ID for Mad Catz Cyborg R.A.T. 7.


To generate a diff of this commit:
cvs rdiff -u -r1.645 -r1.646 src/sys/dev/usb/usbdevs

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/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.645 src/sys/dev/usb/usbdevs:1.646
--- src/sys/dev/usb/usbdevs:1.645	Sat Mar 30 03:03:48 2013
+++ src/sys/dev/usb/usbdevs	Thu May  2 23:10:53 2013
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.645 2013/03/30 03:03:48 christos Exp $
+$NetBSD: usbdevs,v 1.646 2013/05/02 23:10:53 rkujawa Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -273,6 +273,7 @@ vendor MCT		0x0711	MCT
 vendor IMATION		0x0718	Imation
 vendor SUSTEEN		0x0731	Susteen
 vendor EICON		0x0734	Eicon Networks
+vendor MADCATZ		0x0738	Mad Catz, Inc.
 vendor DIGITALSTREAM	0x074e	Digital Stream
 vendor AUREAL		0x0755	Aureal Semiconductor
 vendor MIDIMAN		0x0763	Midiman
@@ -1391,6 +1392,9 @@ product EGALAX2 TPANEL		0x0001	Touch Pan
 /* Eicon Networks */
 product EICON DIVA852		0x4905	Diva 852 ISDN TA
 
+/* Mad Catz, Inc. */
+product	MADCATZ CYBORG_RAT7	0x1708	Cyborg R.A.T. 7
+
 /* EIZO products */
 product EIZO HUB		0x	hub
 product EIZO MONITOR		0x0001	monitor



CVS commit: src/sys/dev/usb

2013-05-02 Thread Radoslaw Kujawa
Module Name:src
Committed By:   rkujawa
Date:   Thu May  2 23:13:12 UTC 2013

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Sort Mad Catz.


To generate a diff of this commit:
cvs rdiff -u -r1.646 -r1.647 src/sys/dev/usb/usbdevs

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/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.646 src/sys/dev/usb/usbdevs:1.647
--- src/sys/dev/usb/usbdevs:1.646	Thu May  2 23:10:53 2013
+++ src/sys/dev/usb/usbdevs	Thu May  2 23:13:12 2013
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.646 2013/05/02 23:10:53 rkujawa Exp $
+$NetBSD: usbdevs,v 1.647 2013/05/02 23:13:12 rkujawa Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1392,9 +1392,6 @@ product EGALAX2 TPANEL		0x0001	Touch Pan
 /* Eicon Networks */
 product EICON DIVA852		0x4905	Diva 852 ISDN TA
 
-/* Mad Catz, Inc. */
-product	MADCATZ CYBORG_RAT7	0x1708	Cyborg R.A.T. 7
-
 /* EIZO products */
 product EIZO HUB		0x	hub
 product EIZO MONITOR		0x0001	monitor
@@ -2011,6 +2008,9 @@ product LUWEN EASYDISK		0x0005	EasyDisc
 /* Macally products */
 product MACALLY MOUSE1		0x0101	mouse
 
+/* Mad Catz, Inc. */
+product	MADCATZ CYBORG_RAT7	0x1708	Cyborg R.A.T. 7
+
 /* MCT Corp. products */
 product MCT HUB0100		0x0100	Hub
 product MCT DU_H3SP_USB232	0x0200	D-Link DU-H3SP USB BAY Hub



CVS commit: src/sbin/ccdconfig

2013-05-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May  3 00:01:15 UTC 2013

Modified Files:
src/sbin/ccdconfig: ccdconfig.c

Log Message:
Hi broken vax gcc!


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sbin/ccdconfig/ccdconfig.c

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

Modified files:

Index: src/sbin/ccdconfig/ccdconfig.c
diff -u src/sbin/ccdconfig/ccdconfig.c:1.52 src/sbin/ccdconfig/ccdconfig.c:1.53
--- src/sbin/ccdconfig/ccdconfig.c:1.52	Sat Apr 27 13:12:36 2013
+++ src/sbin/ccdconfig/ccdconfig.c	Thu May  2 20:01:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccdconfig.c,v 1.52 2013/04/27 17:12:36 christos Exp $	*/
+/*	$NetBSD: ccdconfig.c,v 1.53 2013/05/03 00:01:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1996, 1997\
  The NetBSD Foundation, Inc.  All rights reserved.);
-__RCSID($NetBSD: ccdconfig.c,v 1.52 2013/04/27 17:12:36 christos Exp $);
+__RCSID($NetBSD: ccdconfig.c,v 1.53 2013/05/03 00:01:15 christos Exp $);
 #endif
 
 #include sys/param.h
@@ -532,7 +532,7 @@ dump_ccd(int argc, char **argv, int acti
 
 	/* Dump ccd configuration to stdout. */
 	while (argc) {
-		int i;
+		int i = 0;	/* XXX: vax gcc */
 		int error;
 		char *cp = *argv++; --argc;
 		char *ccd;



CVS commit: src/lib/librumpuser

2013-05-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri May  3 00:23:49 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser_pth.c

Log Message:
Support proper rw_downgrade() semantics.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/librumpuser/rumpuser_pth.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.26 src/lib/librumpuser/rumpuser_pth.c:1.27
--- src/lib/librumpuser/rumpuser_pth.c:1.26	Thu May  2 22:07:57 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Fri May  3 00:23:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.26 2013/05/02 22:07:57 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.27 2013/05/03 00:23:49 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.26 2013/05/02 22:07:57 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.27 2013/05/03 00:23:49 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -223,7 +223,12 @@ rumpuser_mutex_owner(struct rumpuser_mtx
 }
 
 /*
- * rwlocks
+ * rwlocks.  these are mostly simple, except that NetBSD wants to
+ * support something called downgrade, which means we need to swap
+ * our exclusive lock for a shared lock.  to accommodate this,
+ * we need to check *after* acquiring a lock in case someone was
+ * downgrading it.  if so, we couldn't actually have it and maybe
+ * need to retry later.
  */
 
 struct rumpuser_rw {
@@ -231,38 +236,77 @@ struct rumpuser_rw {
 	pthread_spinlock_t spin;
 	int readers;
 	struct lwp *writer;
+	int downgrade; /* someone is downgrading (hopefully lock holder ;) */
 };
 
-#define RURW_AMWRITER(rw) (rw-writer == rumpuser_curlwp()		\
- rw-readers == -1)
-#define RURW_HASREAD(rw)  (rw-readers  0)
-
-#define RURW_SETWRITE(rw)		\
-do {	\
-	assert(rw-readers == 0);	\
-	rw-writer = rumpuser_curlwp();	\
-	rw-readers = -1;		\
-} while (/*CONSTCOND*/0)
-#define RURW_CLRWRITE(rw)		\
-do {	\
-	assert(RURW_AMWRITER(rw));	\
-	rw-readers = 0;		\
-	rw-writer = NULL;		\
-} while (/*CONSTCOND*/0)
-#define RURW_INCREAD(rw)		\
-do {	\
-	pthread_spin_lock(rw-spin);	\
-	assert(rw-readers = 0);	\
-	++(rw)-readers;		\
-	pthread_spin_unlock(rw-spin);	\
-} while (/*CONSTCOND*/0)
-#define RURW_DECREAD(rw)		\
-do {	\
-	pthread_spin_lock(rw-spin);	\
-	assert(rw-readers  0);	\
-	--(rw)-readers;		\
-	pthread_spin_unlock(rw-spin);	\
-} while (/*CONSTCOND*/0)
+static int
+rw_amwriter(struct rumpuser_rw *rw)
+{
+
+	return rw-writer == rumpuser_curlwp()  rw-readers == -1;
+}
+
+static int
+rw_nreaders(struct rumpuser_rw *rw)
+{
+
+	return rw-readers  0 ? rw-readers : 0;
+}
+
+static int
+rw_setwriter(struct rumpuser_rw *rw, int retry)
+{
+
+	/*
+	 * Don't need the spinlock here, we already have an
+	 * exclusive lock and downgrade is stable until complete.
+	 */
+	if (rw-downgrade) {
+		pthread_rwlock_unlock(rw-pthrw);
+		if (retry) {
+			struct timespec ts;
+
+			/* portable yield, essentially */
+			ts.tv_sec = 0;
+			ts.tv_nsec = 1;
+			KLOCK_WRAP(nanosleep(ts, NULL));
+		}
+		return EBUSY;
+	}
+	assert(rw-readers == 0);
+	rw-writer = rumpuser_curlwp();
+	rw-readers = -1;
+	return 0;
+}
+
+static void
+rw_clearwriter(struct rumpuser_rw *rw)
+{
+
+	assert(rw_amwriter(rw));
+	rw-readers = 0;
+	rw-writer = NULL;
+}
+
+static void
+rw_readup(struct rumpuser_rw *rw)
+{
+
+	pthread_spin_lock(rw-spin);
+	assert(rw-readers = 0);
+	++rw-readers;
+	pthread_spin_unlock(rw-spin);
+}
+
+static void
+rw_readdown(struct rumpuser_rw *rw)
+{
+
+	pthread_spin_lock(rw-spin);
+	assert(rw-readers  0);
+	--rw-readers;
+	pthread_spin_unlock(rw-spin);
+}
 
 void
 rumpuser_rw_init(struct rumpuser_rw **rw)
@@ -281,16 +325,17 @@ rumpuser_rw_enter(struct rumpuser_rw *rw
 
 	switch (lk) {
 	case RUMPUSER_RW_WRITER:
-		if (pthread_rwlock_trywrlock(rw-pthrw) != 0)
-			KLOCK_WRAP(NOFAIL_ERRNO(
-			pthread_rwlock_wrlock(rw-pthrw)));
-		RURW_SETWRITE(rw);
+		do {
+			if (pthread_rwlock_trywrlock(rw-pthrw) != 0)
+KLOCK_WRAP(NOFAIL_ERRNO(
+pthread_rwlock_wrlock(rw-pthrw)));
+		} while (rw_setwriter(rw, 1) != 0);
 		break;
 	case RUMPUSER_RW_READER:
 		if (pthread_rwlock_tryrdlock(rw-pthrw) != 0)
 			KLOCK_WRAP(NOFAIL_ERRNO(
 			pthread_rwlock_rdlock(rw-pthrw)));
-		RURW_INCREAD(rw);
+		rw_readup(rw);
 		break;
 	}
 }
@@ -304,12 +349,12 @@ rumpuser_rw_tryenter(struct rumpuser_rw 
 	case RUMPUSER_RW_WRITER:
 		rv = pthread_rwlock_trywrlock(rw-pthrw);
 		if (rv == 0)
-			RURW_SETWRITE(rw);
+			rv = rw_setwriter(rw, 0);
 		break;
 	case RUMPUSER_RW_READER:
 		rv = pthread_rwlock_tryrdlock(rw-pthrw);
 		if (rv == 0)
-			RURW_INCREAD(rw);
+			rw_readup(rw);
 		break;
 	default:
 		rv = EINVAL;
@@ -323,33 +368,45 @@ int