CVS commit: src/lib/librumpuser

2021-08-02 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Aug  2 17:45:10 UTC 2021

Modified Files:
src/lib/librumpuser: README.compileopts

Log Message:
fix typo in README.compileopts text.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/README.compileopts

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/README.compileopts
diff -u src/lib/librumpuser/README.compileopts:1.1 src/lib/librumpuser/README.compileopts:1.2
--- src/lib/librumpuser/README.compileopts:1.1	Mon Jan 25 00:24:23 2016
+++ src/lib/librumpuser/README.compileopts	Mon Aug  2 17:45:10 2021
@@ -1,4 +1,4 @@
-$NetBSD: README.compileopts,v 1.1 2016/01/25 00:24:23 pooka Exp $
+$NetBSD: README.compileopts,v 1.2 2021/08/02 17:45:10 andvar Exp $
 
 This file describes compile-time options (make variables) for
 the rumpuser POSIX implementation.
@@ -12,7 +12,7 @@ Global options:
 values: pthread/none/fiber or 
 defval: 
 effect: Define the way threading is implemented in the rumpuser hypercall
-	implmentation.
+	implementation.
 	 - use default implementation (currently "pthread")
 	pthread - use pthreads to implement threading
 	none- do not support kernel threads at all



CVS commit: src/lib/librumpuser

2021-04-03 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Apr  3 07:38:11 UTC 2021

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
For MIPS N32, register_t needs to be uint64_t as "long" isn't
big enough.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.50 src/lib/librumpuser/rumpuser_port.h:1.51
--- src/lib/librumpuser/rumpuser_port.h:1.50	Thu May 11 10:21:55 2017
+++ src/lib/librumpuser/rumpuser_port.h	Sat Apr  3 07:38:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.50 2017/05/11 10:21:55 martin Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.51 2021/04/03 07:38:11 simonb Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -297,6 +297,13 @@ aligned_alloc(size_t alignment, size_t s
 #define MSG_NOSIGNAL 0
 #endif
 
+#if defined(__NetBSD__) && defined(__mips_n32)	/* XXX */
+/* The MIPS N32 ABI has 4 byte longs but uses 8 byte registers */
+#define	HAVE_REGISTER_T	1
+#define	RUMP_REGISTER_T uint64_t
+typedef RUMP_REGISTER_T register_t;
+#define	PRIxREGISTER	PRIx64
+#endif /* __NetBSD__ && __mips_n32 */		/* XXX */
 #if !defined(HAVE_REGISTER_T) && !defined(RUMP_REGISTER_T)
 #define RUMP_REGISTER_T long
 typedef RUMP_REGISTER_T register_t;



CVS commit: src/lib/librumpuser

2020-06-13 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 13 16:51:59 UTC 2020

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

Log Message:
Fix incompatible function pointer casts


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/librumpuser/sp_common.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/sp_common.c
diff -u src/lib/librumpuser/sp_common.c:1.41 src/lib/librumpuser/sp_common.c:1.42
--- src/lib/librumpuser/sp_common.c:1.41	Wed May  6 12:44:36 2020
+++ src/lib/librumpuser/sp_common.c	Sat Jun 13 16:51:59 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: sp_common.c,v 1.41 2020/05/06 12:44:36 christos Exp $	*/
+/*  $NetBSD: sp_common.c,v 1.42 2020/06/13 16:51:59 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -705,15 +705,21 @@ unix_cleanup(struct sockaddr *sa)
 
 /*ARGSUSED*/
 static int
-notsupp(void)
+addrparse_notsupp(const char *addr __unused, struct sockaddr **sa __unused,
+		  int allow_wildcard __unused)
 {
 
 	fprintf(stderr, "rump_sp: support not yet implemented\n");
 	return EOPNOTSUPP;
 }
 
+static void
+cleanup_success(struct sockaddr *sa __unused)
+{
+}
+
 static int
-success(void)
+connecthook_success(int s __unused)
 {
 
 	return 0;
@@ -728,12 +734,12 @@ static struct {
 	cleanup_fn cleanup;
 } parsetab[] = {
 	{ "tcp", PF_INET, sizeof(struct sockaddr_in),
-	tcp_parse, tcp_connecthook, (cleanup_fn)success },
+	tcp_parse, tcp_connecthook, cleanup_success },
 	{ "unix", PF_LOCAL, sizeof(struct sockaddr_un),
-	unix_parse, (connecthook_fn)success, unix_cleanup },
+	unix_parse, connecthook_success, unix_cleanup },
 	{ "tcp6", PF_INET6, sizeof(struct sockaddr_in6),
-	(addrparse_fn)notsupp, (connecthook_fn)success,
-	(cleanup_fn)success },
+	addrparse_notsupp, connecthook_success,
+	cleanup_success },
 };
 #define NPARSE (sizeof(parsetab)/sizeof(parsetab[0]))
 



CVS commit: src/lib/librumpuser

2020-05-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  6 12:44:37 UTC 2020

Modified Files:
src/lib/librumpuser: rumpuser_sp.c sp_common.c

Log Message:
Allocate one more byte so that we are always NUL-terminated, and remove
the extra commented out NUL-terminations. As suggested in:

http://mail-index.netbsd.org/source-changes-d/2020/04/01/msg012470.html


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/lib/librumpuser/rumpuser_sp.c
cvs rdiff -u -r1.40 -r1.41 src/lib/librumpuser/sp_common.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.76 src/lib/librumpuser/rumpuser_sp.c:1.77
--- src/lib/librumpuser/rumpuser_sp.c:1.76	Wed May  6 03:25:26 2020
+++ src/lib/librumpuser/rumpuser_sp.c	Wed May  6 08:44:36 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.76 2020/05/06 07:25:26 kamil Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.77 2020/05/06 12:44:36 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.76 2020/05/06 07:25:26 kamil Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.77 2020/05/06 12:44:36 christos Exp $");
 #endif /* !lint */
 
 #include 
@@ -699,10 +699,8 @@ serv_handlesyscall(struct spclient *spc,
 }
 
 static void
-serv_handleexec(struct spclient *spc, struct rsp_hdr *rhdr, char *comm)
+serv_handleexec(struct spclient *spc, struct rsp_hdr *rhdr, const char *comm)
 {
-	size_t commlen = rhdr->rsp_len - HDRSZ;
-
 	pthread_mutex_lock(>spc_mtx);
 	/* one for the connection and one for us */
 	while (spc->spc_refcnt > 2)
@@ -715,14 +713,6 @@ serv_handleexec(struct spclient *spc, st
 	 * very much).  proceed with exec.
 	 */
 
-#if 0 /* XXX triggers buffer overflow */
-	/* ensure comm is 0-terminated */
-	/* TODO: make sure it contains sensible chars? */
-	comm[commlen] = '\0';
-#else
-	(void)commlen;
-#endif
-
 	lwproc_switch(spc->spc_mainlwp);
 	lwproc_execnotify(comm);
 	lwproc_switch(NULL);
@@ -980,22 +970,11 @@ handlereq(struct spclient *spc)
 		}
 
 		if (spc->spc_hdr.rsp_handshake == HANDSHAKE_GUEST) {
-			char *comm = (char *)spc->spc_buf;
-			size_t commlen = spc->spc_hdr.rsp_len - HDRSZ;
-
-#if 0 /* XXX triggers buffer overflow */
-			/* ensure it's 0-terminated */
-			/* XXX make sure it contains sensible chars? */
-			comm[commlen] = '\0';
-#else
-			(void)commlen;
-#endif
-
 			/* make sure we fork off of proc1 */
 			_DIAGASSERT(lwproc_curlwp() == NULL);
 
-			if ((error = lwproc_rfork(spc,
-			RUMP_RFFD_CLEAR, comm)) != 0) {
+			if ((error = lwproc_rfork(spc, RUMP_RFFD_CLEAR,
+			(const char *)spc->spc_buf)) != 0) {
 shutdown(spc->spc_fd, SHUT_RDWR);
 			}
 

Index: src/lib/librumpuser/sp_common.c
diff -u src/lib/librumpuser/sp_common.c:1.40 src/lib/librumpuser/sp_common.c:1.41
--- src/lib/librumpuser/sp_common.c:1.40	Mon Mar 23 21:13:41 2020
+++ src/lib/librumpuser/sp_common.c	Wed May  6 08:44:36 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: sp_common.c,v 1.40 2020/03/24 01:13:41 kamil Exp $	*/
+/*  $NetBSD: sp_common.c,v 1.41 2020/05/06 12:44:36 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -502,11 +502,12 @@ readframe(struct spclient *spc)
 			return 1;
 		}
 
-		spc->spc_buf = malloc(framelen - HDRSZ);
+		/* Add an extra byte so that we are always NUL-terminated */
+		spc->spc_buf = malloc(framelen - HDRSZ + 1);
 		if (spc->spc_buf == NULL) {
 			return -1;
 		}
-		memset(spc->spc_buf, 0, framelen - HDRSZ);
+		memset(spc->spc_buf, 0, framelen - HDRSZ + 1);
 
 		/* "fallthrough" */
 	} else {



CVS commit: src/lib/librumpuser

2020-05-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  6 07:25:26 UTC 2020

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

Log Message:
Avoid buffer overflow

Disable the offending code.

OK by kre@


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.75 src/lib/librumpuser/rumpuser_sp.c:1.76
--- src/lib/librumpuser/rumpuser_sp.c:1.75	Tue Mar 24 14:56:31 2020
+++ src/lib/librumpuser/rumpuser_sp.c	Wed May  6 07:25:26 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.75 2020/03/24 14:56:31 kre Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.76 2020/05/06 07:25:26 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.75 2020/03/24 14:56:31 kre Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.76 2020/05/06 07:25:26 kamil Exp $");
 #endif /* !lint */
 
 #include 
@@ -715,9 +715,13 @@ serv_handleexec(struct spclient *spc, st
 	 * very much).  proceed with exec.
 	 */
 
+#if 0 /* XXX triggers buffer overflow */
 	/* ensure comm is 0-terminated */
 	/* TODO: make sure it contains sensible chars? */
 	comm[commlen] = '\0';
+#else
+	(void)commlen;
+#endif
 
 	lwproc_switch(spc->spc_mainlwp);
 	lwproc_execnotify(comm);
@@ -979,9 +983,13 @@ handlereq(struct spclient *spc)
 			char *comm = (char *)spc->spc_buf;
 			size_t commlen = spc->spc_hdr.rsp_len - HDRSZ;
 
+#if 0 /* XXX triggers buffer overflow */
 			/* ensure it's 0-terminated */
 			/* XXX make sure it contains sensible chars? */
 			comm[commlen] = '\0';
+#else
+			(void)commlen;
+#endif
 
 			/* make sure we fork off of proc1 */
 			_DIAGASSERT(lwproc_curlwp() == NULL);



CVS commit: src/lib/librumpuser

2020-03-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Mar 24 14:56:32 UTC 2020

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

Log Message:
If we're going to loop, pausing and then retrying malloc() after it
has failed, in the hope that some other thread has free'd some memory,
but we want to bound the number of attempts, it helps if we actually
count them - otherwise we never get nearer to the limit.

In practice, malloc() for a reasonable application on a modern system
almost never fails, so the code containing this bug has probably never
been, and never will be, executed, but just in case, someday.

For this, it isn't clear if the intent was to have 10 retries (ie: 11
attempts) or 10 tries, but as the code said "retries > 10", I am
assuming the former (not that it matters, if the malloc() has failed
10 times in a row, with 10 second pauses between, the chances of an
11th succeeding aren't great).


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.74 src/lib/librumpuser/rumpuser_sp.c:1.75
--- src/lib/librumpuser/rumpuser_sp.c:1.74	Tue Mar 24 14:47:02 2020
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Mar 24 14:56:31 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.75 2020/03/24 14:56:31 kre Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.75 2020/03/24 14:56:31 kre Exp $");
 #endif /* !lint */
 
 #include 
@@ -912,7 +912,7 @@ schedulework(struct spclient *spc, enum 
 
 	reqno = spc->spc_hdr.rsp_reqno;
 	while ((sba = malloc(sizeof(*sba))) == NULL) {
-		if (nworker == 0 || retries > 10) {
+		if (nworker == 0 || retries++ > 10) {
 			send_error_resp(spc, reqno, RUMPSP_ERR_TRYAGAIN);
 			spcfreebuf(spc);
 			return;



CVS commit: src/lib/librumpuser

2020-03-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Mar 24 14:47:02 UTC 2020

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

Log Message:
Revert previous

It will be addressed in a better way.

Requested by 


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.73 src/lib/librumpuser/rumpuser_sp.c:1.74
--- src/lib/librumpuser/rumpuser_sp.c:1.73	Tue Mar 24 01:56:56 2020
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Mar 24 14:47:02 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.73 2020/03/24 01:56:56 kamil Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.73 2020/03/24 01:56:56 kamil Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $");
 #endif /* !lint */
 
 #include 
@@ -717,7 +717,7 @@ serv_handleexec(struct spclient *spc, st
 
 	/* ensure comm is 0-terminated */
 	/* TODO: make sure it contains sensible chars? */
-	comm[commlen - 1] = '\0';
+	comm[commlen] = '\0';
 
 	lwproc_switch(spc->spc_mainlwp);
 	lwproc_execnotify(comm);
@@ -981,7 +981,7 @@ handlereq(struct spclient *spc)
 
 			/* ensure it's 0-terminated */
 			/* XXX make sure it contains sensible chars? */
-			comm[commlen - 1] = '\0';
+			comm[commlen] = '\0';
 
 			/* make sure we fork off of proc1 */
 			_DIAGASSERT(lwproc_curlwp() == NULL);



CVS commit: src/lib/librumpuser

2020-03-23 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Mar 24 01:56:56 UTC 2020

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

Log Message:
Avoid buffer overflow

Detected with ASan + RUMPKERNEL.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.72 src/lib/librumpuser/rumpuser_sp.c:1.73
--- src/lib/librumpuser/rumpuser_sp.c:1.72	Tue Sep  6 07:45:41 2016
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Mar 24 01:56:56 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.72 2016/09/06 07:45:41 martin Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.73 2020/03/24 01:56:56 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.72 2016/09/06 07:45:41 martin Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.73 2020/03/24 01:56:56 kamil Exp $");
 #endif /* !lint */
 
 #include 
@@ -717,7 +717,7 @@ serv_handleexec(struct spclient *spc, st
 
 	/* ensure comm is 0-terminated */
 	/* TODO: make sure it contains sensible chars? */
-	comm[commlen] = '\0';
+	comm[commlen - 1] = '\0';
 
 	lwproc_switch(spc->spc_mainlwp);
 	lwproc_execnotify(comm);
@@ -981,7 +981,7 @@ handlereq(struct spclient *spc)
 
 			/* ensure it's 0-terminated */
 			/* XXX make sure it contains sensible chars? */
-			comm[commlen] = '\0';
+			comm[commlen - 1] = '\0';
 
 			/* make sure we fork off of proc1 */
 			_DIAGASSERT(lwproc_curlwp() == NULL);



CVS commit: src/lib/librumpuser

2020-03-23 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Mar 24 01:13:41 UTC 2020

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

Log Message:
Fix off-by-one

Before accessing array member, check whether it is not out of valid range.

Detected with ASan + RUMPKERNEL.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/librumpuser/sp_common.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/sp_common.c
diff -u src/lib/librumpuser/sp_common.c:1.39 src/lib/librumpuser/sp_common.c:1.40
--- src/lib/librumpuser/sp_common.c:1.39	Mon Sep  5 20:41:59 2016
+++ src/lib/librumpuser/sp_common.c	Tue Mar 24 01:13:41 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: sp_common.c,v 1.39 2016/09/05 20:41:59 dholland Exp $	*/
+/*  $NetBSD: sp_common.c,v 1.40 2020/03/24 01:13:41 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -342,7 +342,7 @@ dosend(struct spclient *spc, struct iove
 		}
 
 		/* ok, need to adjust iovec for potential next round */
-		while (n >= (ssize_t)iov[0].iov_len && iovlen) {
+		while (iovlen && n >= (ssize_t)iov[0].iov_len) {
 			n -= iov[0].iov_len;
 			iov++;
 			iovlen--;



CVS commit: src/lib/librumpuser

2017-05-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May 11 10:21:56 UTC 2017

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Evil hack to fix the build: provide PRIxREGISTER here.
Sevan, please check and fix correctly ;-)


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.49 src/lib/librumpuser/rumpuser_port.h:1.50
--- src/lib/librumpuser/rumpuser_port.h:1.49	Thu May 11 04:27:27 2017
+++ src/lib/librumpuser/rumpuser_port.h	Thu May 11 10:21:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.49 2017/05/11 04:27:27 sevan Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.50 2017/05/11 10:21:55 martin Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -300,6 +300,7 @@ aligned_alloc(size_t alignment, size_t s
 #if !defined(HAVE_REGISTER_T) && !defined(RUMP_REGISTER_T)
 #define RUMP_REGISTER_T long
 typedef RUMP_REGISTER_T register_t;
+#define	PRIxREGISTER	"lx"
 #endif
 
 #include 



CVS commit: src/lib/librumpuser

2017-05-10 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu May 11 04:27:27 UTC 2017

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Update NetBSD values obtained from running configure as instructed in comment.
This paves the way to resolve rump build process using buildrump.sh, where the 
definition of
HAVE_REGISTER_T caused conflicting definitions of register_t.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.48 src/lib/librumpuser/rumpuser_port.h:1.49
--- src/lib/librumpuser/rumpuser_port.h:1.48	Thu Jan 12 18:23:04 2017
+++ src/lib/librumpuser/rumpuser_port.h	Thu May 11 04:27:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.48 2017/01/12 18:23:04 christos Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.49 2017/05/11 04:27:27 sevan Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -29,7 +29,6 @@
 #define HAVE_PATHS_H 1
 #define HAVE_POSIX_MEMALIGN 1
 #define HAVE_PTHREAD_SETNAME3 1
-#define HAVE_REGISTER_T 1
 #define HAVE_SETPROGNAME 1
 #define HAVE_STDINT_H 1
 #define HAVE_STDLIB_H 1
@@ -47,8 +46,8 @@
 #define HAVE_SYS_SYSCTL_H 1
 #define HAVE_SYS_TYPES_H 1
 #define HAVE_UNISTD_H 1
-#define HAVE___QUOTACTL 1
 #define HAVE_UTIMENSAT 1
+#define HAVE___QUOTACTL 1
 #define PACKAGE_BUGREPORT "http://rumpkernel.org/;
 #define PACKAGE_NAME "rumpuser-posix"
 #define PACKAGE_STRING "rumpuser-posix 999"



CVS commit: src/lib/librumpuser

2017-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 12 18:23:04 UTC 2017

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Don't go redefining system constants, without checking if the system provides
them.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.47 src/lib/librumpuser/rumpuser_port.h:1.48
--- src/lib/librumpuser/rumpuser_port.h:1.47	Sat Nov  7 11:21:42 2015
+++ src/lib/librumpuser/rumpuser_port.h	Thu Jan 12 13:23:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.47 2015/11/07 16:21:42 nros Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.48 2017/01/12 18:23:04 christos Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -217,6 +217,8 @@ aligned_alloc(size_t alignment, size_t s
 #define __RCSID(a)
 #endif
 
+#include 
+
 #ifndef INFTIM
 #define INFTIM (-1)
 #endif



CVS commit: src/lib/librumpuser/build-aux

2016-10-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Oct 19 09:51:38 UTC 2016

Modified Files:
src/lib/librumpuser/build-aux: install-sh

Log Message:
Revert previous. it shouldn't have an effect.
$$ should make it sufficiently unique.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/build-aux/install-sh

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/build-aux/install-sh
diff -u src/lib/librumpuser/build-aux/install-sh:1.2 src/lib/librumpuser/build-aux/install-sh:1.3
--- src/lib/librumpuser/build-aux/install-sh:1.2	Mon Oct 17 18:24:42 2016
+++ src/lib/librumpuser/build-aux/install-sh	Wed Oct 19 09:51:38 2016
@@ -345,7 +345,7 @@ do
 	# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
 	;;
 	  *)
-	tmpdir=$(mktemp -d -p ${TMPDIR:-/tmp})
+	tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
 	trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
 	if (umask $mkdir_umask &&



CVS commit: src/lib/librumpuser/build-aux

2016-10-17 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Oct 17 18:24:42 UTC 2016

Modified Files:
src/lib/librumpuser/build-aux: install-sh

Log Message:
use mktemp instead of $RANDOM for tmpdir

..$RANDOM won't work with our /bin/sh.

unsure if this script is used, but it is wrong.
might help the spurious build failures that occasionally
show up on autobuilds.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/build-aux/install-sh

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/build-aux/install-sh
diff -u src/lib/librumpuser/build-aux/install-sh:1.1 src/lib/librumpuser/build-aux/install-sh:1.2
--- src/lib/librumpuser/build-aux/install-sh:1.1	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/build-aux/install-sh	Mon Oct 17 18:24:42 2016
@@ -345,7 +345,7 @@ do
 	# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
 	;;
 	  *)
-	tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	tmpdir=$(mktemp -d -p ${TMPDIR:-/tmp})
 	trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
 	if (umask $mkdir_umask &&



CVS commit: src/lib/librumpuser

2016-09-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep  6 07:32:39 UTC 2016

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

Log Message:
Can not print register_t with %d, cast to long and use %ld instead.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.70 src/lib/librumpuser/rumpuser_sp.c:1.71
--- src/lib/librumpuser/rumpuser_sp.c:1.70	Sun Aug 16 11:37:39 2015
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Sep  6 07:32:39 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.70 2015/08/16 11:37:39 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.71 2016/09/06 07:32:39 martin Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.70 2015/08/16 11:37:39 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.71 2016/09/06 07:32:39 martin Exp $");
 #endif /* !lint */
 
 #include 
@@ -691,8 +691,8 @@ serv_handlesyscall(struct spclient *spc,
 	spc->spc_syscallreq = 0;
 	lwproc_release();
 
-	DPRINTF(("rump_sp: got return value %d & %d/%d\n",
-	rv, retval[0], retval[1]));
+	DPRINTF(("rump_sp: got return value %d & %ld/%ld\n",
+	rv, (long)retval[0], (long)retval[1]));
 
 	send_syscall_resp(spc, rhdr->rsp_reqno, rv, retval);
 }



CVS commit: src/lib/librumpuser

2016-09-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Sep  5 20:41:59 UTC 2016

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

Log Message:
printf functions should be tagged as printf functions. Noticed by
martin, whose build broke for some reason yet to be determined.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/librumpuser/sp_common.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/sp_common.c
diff -u src/lib/librumpuser/sp_common.c:1.38 src/lib/librumpuser/sp_common.c:1.39
--- src/lib/librumpuser/sp_common.c:1.38	Wed Jan  8 01:45:29 2014
+++ src/lib/librumpuser/sp_common.c	Mon Sep  5 20:41:59 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: sp_common.c,v 1.38 2014/01/08 01:45:29 pooka Exp $	*/
+/*  $NetBSD: sp_common.c,v 1.39 2016/09/05 20:41:59 dholland Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -60,14 +60,17 @@
  * XXX: NetBSD's __unused collides with Linux headers, so we cannot
  * define it before we've included everything.
  */
-#if !defined(__unused) && defined(__GNUC__)
+#if !defined(__unused) && (defined(__clang__) || defined(__GNUC__))
 #define __unused __attribute__((__unused__))
 #endif
+#if !defined(__printflike) && (defined(__clang__) || defined(__GNUC__))
+#define __printflike(a,b) __attribute__((__format__(__printf__, a, b
+#endif
 
 //#define DEBUG
 #ifdef DEBUG
 #define DPRINTF(x) mydprintf x
-static void
+static __printflike(1, 2) void
 mydprintf(const char *fmt, ...)
 {
 	va_list ap;



CVS commit: src/lib/librumpuser

2015-09-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Sep 18 10:56:26 UTC 2015

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

Log Message:
Fix typos to match values from rumpuser_config.h

from Hajime Tazaki via rumpkernel-users


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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.44 src/lib/librumpuser/rumpuser_pth.c:1.45
--- src/lib/librumpuser/rumpuser_pth.c:1.44	Tue Dec 16 17:00:17 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Fri Sep 18 10:56:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.44 2014/12/16 17:00:17 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.45 2015/09/18 10:56:25 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.44 2014/12/16 17:00:17 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.45 2015/09/18 10:56:25 pooka Exp $");
 #endif /* !lint */
 
 #include 
@@ -80,11 +80,11 @@ rumpuser_thread_create(void *(*f)(void *
 		nanosleep(, NULL);
 	}
 
-#if defined(HAVE_PTHREAD_SETNAME_3)
+#if defined(HAVE_PTHREAD_SETNAME3)
 	if (rv == 0 && thrname) {
 		pthread_setname_np(*ptidp, thrname, NULL);
 	}
-#elif defined(HAVE_PTHREAD_SETNAME_2)
+#elif defined(HAVE_PTHREAD_SETNAME2)
 	if (rv == 0 && thrname) {
 		pthread_setname_np(*ptidp, thrname);
 	}



CVS commit: src/lib/librumpuser

2015-08-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Aug 16 11:37:39 UTC 2015

Modified Files:
src/lib/librumpuser: rumpuser_port.h rumpuser_sp.c

Log Message:
Hurd support, part 1

from Robert Millan r...@gnu.org via rumpkernel-users


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/librumpuser/rumpuser_port.h
cvs rdiff -u -r1.69 -r1.70 src/lib/librumpuser/rumpuser_sp.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_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.44 src/lib/librumpuser/rumpuser_port.h:1.45
--- src/lib/librumpuser/rumpuser_port.h:1.44	Thu Mar  5 00:25:39 2015
+++ src/lib/librumpuser/rumpuser_port.h	Sun Aug 16 11:37:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.44 2015/03/05 00:25:39 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.45 2015/08/16 11:37:39 pooka Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -63,7 +63,7 @@
 #include rumpuser_config.h
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
 #define _GNU_SOURCE
 #endif
 

Index: src/lib/librumpuser/rumpuser_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.69 src/lib/librumpuser/rumpuser_sp.c:1.70
--- src/lib/librumpuser/rumpuser_sp.c:1.69	Wed Feb  4 12:55:47 2015
+++ src/lib/librumpuser/rumpuser_sp.c	Sun Aug 16 11:37:39 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.69 2015/02/04 12:55:47 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.70 2015/08/16 11:37:39 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.69 2015/02/04 12:55:47 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.70 2015/08/16 11:37:39 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -89,8 +89,8 @@ static char banner[MAXBANNER];
 #define PROTOMINOR 4
 
 
-/* how to use atomic ops on Linux? */
-#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__OpenBSD__)
+/* either no atomic ops, or we haven't figured out how to use them */
+#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__OpenBSD__) || defined(__GNU__) || defined(__GLIBC__)
 static pthread_mutex_t discomtx = PTHREAD_MUTEX_INITIALIZER;
 
 static void



CVS commit: src/lib/librumpuser

2015-08-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Aug 16 11:05:06 UTC 2015

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

Log Message:
Fix return value inspection for clock_nanosleep() (not displayed in the
diff, need to look at the entire file for context).

from Robert Millan r...@freebsd.org via rumpkernel-users


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/lib/librumpuser/rumpuser.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.66 src/lib/librumpuser/rumpuser.c:1.67
--- src/lib/librumpuser/rumpuser.c:1.66	Mon Jul 27 07:31:00 2015
+++ src/lib/librumpuser/rumpuser.c	Sun Aug 16 11:05:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.66 2015/07/27 07:31:00 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.67 2015/08/16 11:05:06 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.66 2015/07/27 07:31:00 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.67 2015/08/16 11:05:06 pooka Exp $);
 #endif /* !lint */
 
 #include sys/stat.h
@@ -156,12 +156,11 @@ rumpuser_clock_sleep(int enum_rumpclock,
 	tsr.tv_nsec += 1000*1000*1000;
 }
 rv = nanosleep(tsr, NULL);
+if (rv == -1)
+	rv = errno;
 			}
 #endif
-		} while (rv == -1  errno == EINTR);
-		if (rv == -1) {
-			rv = errno;
-		}
+		} while (rv == EINTR);
 		break;
 	default:
 		abort();



CVS commit: src/lib/librumpuser

2015-07-27 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jul 27 07:31:00 UTC 2015

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

Log Message:
Print the halted\n from previous commit to stdout, not stderr.

The putchar hypercall writes to stdout, so this change restores
the original functionality (which was not intended to change).

from gson, via tests


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/lib/librumpuser/rumpuser.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.65 src/lib/librumpuser/rumpuser.c:1.66
--- src/lib/librumpuser/rumpuser.c:1.65	Fri Jul 24 14:11:11 2015
+++ src/lib/librumpuser/rumpuser.c	Mon Jul 27 07:31:00 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.65 2015/07/24 14:11:11 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.66 2015/07/27 07:31:00 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.65 2015/07/24 14:11:11 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.66 2015/07/27 07:31:00 pooka Exp $);
 #endif /* !lint */
 
 #include sys/stat.h
@@ -232,7 +232,7 @@ __dead void
 rumpuser_exit(int rv)
 {
 
-	fprintf(stderr, halted\n);
+	printf(halted\n);
 	if (rv == RUMPUSER_PANIC)
 		abort();
 	else



CVS commit: src/lib/librumpuser

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar  5 00:25:39 UTC 2015

Modified Files:
src/lib/librumpuser: configure configure.ac rumpuser_config.h.in
rumpuser_port.h

Log Message:
check for utimensat


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/librumpuser/configure \
src/lib/librumpuser/configure.ac
cvs rdiff -u -r1.3 -r1.4 src/lib/librumpuser/rumpuser_config.h.in
cvs rdiff -u -r1.43 -r1.44 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/configure
diff -u src/lib/librumpuser/configure:1.4 src/lib/librumpuser/configure:1.5
--- src/lib/librumpuser/configure:1.4	Sat Jan  3 13:16:41 2015
+++ src/lib/librumpuser/configure	Thu Mar  5 00:25:39 2015
@@ -3794,7 +3794,7 @@ fi
 
 for ac_func in kqueue chflags strsuftoll setprogname getprogname	\
 	getenv_r posix_memalign memalign aligned_alloc	\
-	arc4random_buf getsubopt fsync_range __quotactl
+	arc4random_buf getsubopt fsync_range __quotactl utimensat
 do :
   as_ac_var=`$as_echo ac_cv_func_$ac_func | $as_tr_sh`
 ac_fn_c_check_func $LINENO $ac_func $as_ac_var
Index: src/lib/librumpuser/configure.ac
diff -u src/lib/librumpuser/configure.ac:1.4 src/lib/librumpuser/configure.ac:1.5
--- src/lib/librumpuser/configure.ac:1.4	Sat Jan  3 13:16:41 2015
+++ src/lib/librumpuser/configure.ac	Thu Mar  5 00:25:39 2015
@@ -28,7 +28,7 @@ AC_CHECK_TYPES([clockid_t, register_t])
 
 AC_CHECK_FUNCS([kqueue chflags strsuftoll setprogname getprogname	\
 	getenv_r posix_memalign memalign aligned_alloc	\
-	arc4random_buf getsubopt fsync_range __quotactl])
+	arc4random_buf getsubopt fsync_range __quotactl utimensat])
 
 AC_TRY_LINK_FUNC([clock_nanosleep],,
 AC_CHECK_LIB([rt], [clock_nanosleep])

Index: src/lib/librumpuser/rumpuser_config.h.in
diff -u src/lib/librumpuser/rumpuser_config.h.in:1.3 src/lib/librumpuser/rumpuser_config.h.in:1.4
--- src/lib/librumpuser/rumpuser_config.h.in:1.3	Wed Nov  5 01:40:30 2014
+++ src/lib/librumpuser/rumpuser_config.h.in	Thu Mar  5 00:25:39 2015
@@ -117,6 +117,9 @@
 /* Define to 1 if you have the unistd.h header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the `utimensat' function. */
+#undef HAVE_UTIMENSAT
+
 /* Define to 1 if you have the `__quotactl' function. */
 #undef HAVE___QUOTACTL
 

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.43 src/lib/librumpuser/rumpuser_port.h:1.44
--- src/lib/librumpuser/rumpuser_port.h:1.43	Sat Jan 17 23:49:40 2015
+++ src/lib/librumpuser/rumpuser_port.h	Thu Mar  5 00:25:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.43 2015/01/17 23:49:40 justin Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.44 2015/03/05 00:25:39 pooka Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -47,6 +47,7 @@
 #define HAVE_SYS_TYPES_H 1
 #define HAVE_UNISTD_H 1
 #define HAVE___QUOTACTL 1
+#define HAVE_UTIMENSAT 1
 #define PACKAGE_BUGREPORT http://rumpkernel.org/;
 #define PACKAGE_NAME rumpuser-posix
 #define PACKAGE_STRING rumpuser-posix 999



CVS commit: src/lib/librumpuser

2015-02-14 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sun Feb 15 00:54:32 UTC 2015

Modified Files:
src/lib/librumpuser: rumpfiber.c rumpfiber.h rumpfiber_sp.c

Log Message:
Minor fixes to types and includes


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/librumpuser/rumpfiber.c
cvs rdiff -u -r1.3 -r1.4 src/lib/librumpuser/rumpfiber.h \
src/lib/librumpuser/rumpfiber_sp.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.11 src/lib/librumpuser/rumpfiber.c:1.12
--- src/lib/librumpuser/rumpfiber.c:1.11	Fri Feb 13 22:00:53 2015
+++ src/lib/librumpuser/rumpfiber.c	Sun Feb 15 00:54:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.11 2015/02/13 22:00:53 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.12 2015/02/15 00:54:32 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,10 +68,9 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.11 2015/02/13 22:00:53 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.12 2015/02/15 00:54:32 justin Exp $);
 #endif /* !lint */
 
-#include sys/ioctl.h
 #include sys/mman.h
 #include sys/time.h
 
@@ -486,7 +485,7 @@ int
 rumpuser_clock_sleep(int enum_rumpclock, int64_t sec, long nsec)
 {
 	enum rumpclock rclk = enum_rumpclock;
-	uint32_t msec;
+	uint64_t msec;
 	int nlocks;
 
 	rumpkern_unsched(nlocks, NULL);

Index: src/lib/librumpuser/rumpfiber.h
diff -u src/lib/librumpuser/rumpfiber.h:1.3 src/lib/librumpuser/rumpfiber.h:1.4
--- src/lib/librumpuser/rumpfiber.h:1.3	Mon Dec 29 21:50:09 2014
+++ src/lib/librumpuser/rumpfiber.h	Sun Feb 15 00:54:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.h,v 1.3 2014/12/29 21:50:09 justin Exp $	*/
+/*	$NetBSD: rumpfiber.h,v 1.4 2015/02/15 00:54:32 justin Exp $	*/
 
 /*
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
@@ -40,7 +40,7 @@ struct thread {
 int64_t wakeup_time;
 TAILQ_ENTRY(thread) thread_list;
 ucontext_t ctx;
-uint32_t flags;
+int flags;
 int threrrno;
 };
 
Index: src/lib/librumpuser/rumpfiber_sp.c
diff -u src/lib/librumpuser/rumpfiber_sp.c:1.3 src/lib/librumpuser/rumpfiber_sp.c:1.4
--- src/lib/librumpuser/rumpfiber_sp.c:1.3	Mon Dec 29 21:50:09 2014
+++ src/lib/librumpuser/rumpfiber_sp.c	Sun Feb 15 00:54:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber_sp.c,v 1.3 2014/12/29 21:50:09 justin Exp $	*/
+/*	$NetBSD: rumpfiber_sp.c,v 1.4 2015/02/15 00:54:32 justin Exp $	*/
 
 /*
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
@@ -30,9 +30,10 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber_sp.c,v 1.3 2014/12/29 21:50:09 justin Exp $);
+__RCSID($NetBSD: rumpfiber_sp.c,v 1.4 2015/02/15 00:54:32 justin Exp $);
 #endif /* !lint */
 
+#include stdint.h
 #include stdlib.h
 
 #include rump/rumpuser.h



CVS commit: src/lib/librumpuser

2015-02-13 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Fri Feb 13 22:00:53 UTC 2015

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

Log Message:
Whitespace fixes, no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/librumpuser/rumpfiber.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.10 src/lib/librumpuser/rumpfiber.c:1.11
--- src/lib/librumpuser/rumpfiber.c:1.10	Fri Feb 13 21:31:18 2015
+++ src/lib/librumpuser/rumpfiber.c	Fri Feb 13 22:00:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.10 2015/02/13 21:31:18 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.11 2015/02/13 22:00:53 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.10 2015/02/13 21:31:18 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.11 2015/02/13 22:00:53 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -445,11 +445,11 @@ rumpuser_init(int version, const struct 
 		ET(rv);
 	}
 
-rumpuser__hyp = *hyp;
+	rumpuser__hyp = *hyp;
 
 	init_sched();
 
-return 0;
+	return 0;
 }
 
 int
@@ -639,7 +639,7 @@ wakeup_all(struct waithead *wh)
 
 int
 rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname,
-int joinable, int pri, int cpuidx, void **tptr)
+	int joinable, int pri, int cpuidx, void **tptr)
 {
 	struct thread *thr;
 
@@ -648,31 +648,31 @@ rumpuser_thread_create(void *(*f)(void *
 	if (!thr)
 		return EINVAL;
 
-/*
- * XXX: should be supplied as a flag to create_thread() so as to
- * _ensure_ it's set before the thread runs (and could exit).
- * now we're trusting unclear semantics of create_thread()
- */
-if (thr  joinable)
-thr-flags |= THREAD_MUSTJOIN;
+	/*
+	 * XXX: should be supplied as a flag to create_thread() so as to
+	 * _ensure_ it's set before the thread runs (and could exit).
+	 * now we're trusting unclear semantics of create_thread()
+	 */
+	if (thr  joinable)
+		thr-flags |= THREAD_MUSTJOIN;
 
-*tptr = thr;
-return 0;
+	*tptr = thr;
+	return 0;
 }
 
 void
 rumpuser_thread_exit(void)
 {
 
-exit_thread();
+	exit_thread();
 }
 
 int
 rumpuser_thread_join(void *p)
 {
 
-join_thread(p);
-return 0;
+	join_thread(p);
+	return 0;
 }
 
 struct rumpuser_mtx {



CVS commit: src/lib/librumpuser

2015-02-13 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Fri Feb 13 21:31:18 UTC 2015

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

Log Message:
Fix some return value checks


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/librumpuser/rumpfiber.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.9 src/lib/librumpuser/rumpfiber.c:1.10
--- src/lib/librumpuser/rumpfiber.c:1.9	Mon Dec 29 21:50:09 2014
+++ src/lib/librumpuser/rumpfiber.c	Fri Feb 13 21:31:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.9 2014/12/29 21:50:09 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.10 2015/02/13 21:31:18 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.9 2014/12/29 21:50:09 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.10 2015/02/13 21:31:18 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -398,6 +398,10 @@ init_sched(void)
 {
 	struct thread *thread = calloc(1, sizeof(struct thread));
 
+	if (!thread) {
+		abort();
+	}
+
 	thread-name = strdup(init);
 	thread-flags = 0;
 	thread-wakeup_time = -1;
@@ -637,9 +641,13 @@ int
 rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname,
 int joinable, int pri, int cpuidx, void **tptr)
 {
-struct thread *thr;
+	struct thread *thr;
+
+	thr = create_thread(thrname, NULL, (void (*)(void *))f, arg, NULL, 0);
+
+	if (!thr)
+		return EINVAL;
 
-thr = create_thread(thrname, NULL, (void (*)(void *))f, arg, NULL, 0);
 /*
  * XXX: should be supplied as a flag to create_thread() so as to
  * _ensure_ it's set before the thread runs (and could exit).
@@ -648,9 +656,6 @@ rumpuser_thread_create(void *(*f)(void *
 if (thr  joinable)
 thr-flags |= THREAD_MUSTJOIN;
 
-if (!thr)
-return EINVAL;
-
 *tptr = thr;
 return 0;
 }



CVS commit: src/lib/librumpuser

2015-02-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Feb  4 12:55:47 UTC 2015

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

Log Message:
If binding fails, print URL with which it failed.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.68 src/lib/librumpuser/rumpuser_sp.c:1.69
--- src/lib/librumpuser/rumpuser_sp.c:1.68	Mon Dec  8 00:12:03 2014
+++ src/lib/librumpuser/rumpuser_sp.c	Wed Feb  4 12:55:47 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.68 2014/12/08 00:12:03 justin Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.69 2015/02/04 12:55:47 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.68 2014/12/08 00:12:03 justin Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.69 2015/02/04 12:55:47 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -1362,7 +1362,7 @@ rumpuser_sp_init(const char *url,
 	/*LINTED*/
 	if (bind(s, sap, parsetab[idx].slen) == -1) {
 		error = errno;
-		fprintf(stderr, rump_sp: server bind failed\n);
+		fprintf(stderr, rump_sp: failed to bind to URL %s\n, url);
 		goto out;
 	}
 	if (listen(s, MAXCLI) == -1) {



CVS commit: src/lib/librumpuser

2015-01-17 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sat Jan 17 23:49:40 UTC 2015

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Remove no longer required definitions


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.42 src/lib/librumpuser/rumpuser_port.h:1.43
--- src/lib/librumpuser/rumpuser_port.h:1.42	Mon Nov 10 22:43:46 2014
+++ src/lib/librumpuser/rumpuser_port.h	Sat Jan 17 23:49:40 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.42 2014/11/10 22:43:46 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.43 2015/01/17 23:49:40 justin Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -112,10 +112,6 @@ typedef uint16_t in_port_t;
 #include sys/select.h
 #define atomic_inc_uint(x)  __sync_fetch_and_add(x, 1)
 #define atomic_dec_uint(x)  __sync_fetch_and_sub(x, 1)
-#include time.h
-int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
-#include stdlib.h
-void arc4random_buf(void*, size_t);
 #endif
 
 /* sunny magic */



CVS commit: src/lib/librumpuser

2015-01-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sat Jan  3 13:16:41 UTC 2015

Modified Files:
src/lib/librumpuser: configure configure.ac

Log Message:
check that sys/cdefs.h builds with -Werror (not the case on alpine linux
where it contains an unconditional #warning)


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

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/configure
diff -u src/lib/librumpuser/configure:1.3 src/lib/librumpuser/configure:1.4
--- src/lib/librumpuser/configure:1.3	Wed Nov  5 01:40:30 2014
+++ src/lib/librumpuser/configure	Sat Jan  3 13:16:41 2015
@@ -3646,7 +3646,7 @@ fi
 done
 
 
-for ac_header in sys/cdefs.h sys/param.h sys/sysctl.h sys/disk.h \
+for ac_header in sys/param.h sys/sysctl.h sys/disk.h \
 	sys/disklabel.h sys/dkio.h sys/atomic.h paths.h
 do :
   as_ac_Header=`$as_echo ac_cv_header_$ac_header | $as_tr_sh`
@@ -4096,6 +4096,21 @@ fi
 
 SAVE_CFLAGS=${CFLAGS}
 CFLAGS=${SAVE_CFLAGS} -Werror
+
+for ac_header in sys/cdefs.h
+do :
+  ac_fn_c_check_header_compile $LINENO sys/cdefs.h ac_cv_header_sys_cdefs_h #include sys/cdefs.h
+
+if test x$ac_cv_header_sys_cdefs_h = xyes; then :
+  cat confdefs.h _ACEOF
+#define HAVE_SYS_CDEFS_H 1
+_ACEOF
+
+fi
+
+done
+
+
 SAVE_LIBS=${LIBS}
 LIBS=${LIBS} -lpthread
 { $as_echo $as_me:${as_lineno-$LINENO}: checking for two-argument pthread_setname_np() 5
Index: src/lib/librumpuser/configure.ac
diff -u src/lib/librumpuser/configure.ac:1.3 src/lib/librumpuser/configure.ac:1.4
--- src/lib/librumpuser/configure.ac:1.3	Wed Nov  5 01:40:30 2014
+++ src/lib/librumpuser/configure.ac	Sat Jan  3 13:16:41 2015
@@ -19,7 +19,7 @@ AC_LANG([C])
 
 AC_SYS_LARGEFILE
 
-AC_CHECK_HEADERS([sys/cdefs.h sys/param.h sys/sysctl.h sys/disk.h \
+AC_CHECK_HEADERS([sys/param.h sys/sysctl.h sys/disk.h \
 	sys/disklabel.h sys/dkio.h sys/atomic.h paths.h])
 
 AC_CANONICAL_TARGET
@@ -52,6 +52,11 @@ dnl pthread_setname() sillyness is a bit
 dnl
 SAVE_CFLAGS=${CFLAGS}
 CFLAGS=${SAVE_CFLAGS} -Werror
+
+dnl check sys/cdefs.h creatively to process only with cc, not cpp
+dnl (sys/cdefs.h in at least in musl contains a #warning)
+AC_CHECK_HEADERS([sys/cdefs.h], [], [], [#include sys/cdefs.h])
+
 SAVE_LIBS=${LIBS}
 LIBS=${LIBS} -lpthread
 AC_MSG_CHECKING([for two-argument pthread_setname_np()])



CVS commit: src/lib/librumpuser

2014-12-29 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Mon Dec 29 21:50:09 UTC 2014

Modified Files:
src/lib/librumpuser: rumpfiber.c rumpfiber.h rumpfiber_sp.c

Log Message:
Just abort on currently unsupported functions.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/librumpuser/rumpfiber.c
cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/rumpfiber.h \
src/lib/librumpuser/rumpfiber_sp.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.8 src/lib/librumpuser/rumpfiber.c:1.9
--- src/lib/librumpuser/rumpfiber.c:1.8	Sat Nov  8 23:47:15 2014
+++ src/lib/librumpuser/rumpfiber.c	Mon Dec 29 21:50:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.8 2014/11/08 23:47:15 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.9 2014/12/29 21:50:09 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.8 2014/11/08 23:47:15 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.9 2014/12/29 21:50:09 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -108,6 +108,16 @@ static struct thread *current_thread = N
 
 static void (*scheduler_hook)(void *, void *);
 
+static void printk(const char *s);
+
+static void
+printk(const char *msg)
+{
+	int ret __attribute__((unused));
+
+	ret = write(2, msg, strlen(msg));
+}
+
 static struct thread *
 get_current(void)
 {

Index: src/lib/librumpuser/rumpfiber.h
diff -u src/lib/librumpuser/rumpfiber.h:1.2 src/lib/librumpuser/rumpfiber.h:1.3
--- src/lib/librumpuser/rumpfiber.h:1.2	Sun Aug 24 14:37:31 2014
+++ src/lib/librumpuser/rumpfiber.h	Mon Dec 29 21:50:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.h,v 1.2 2014/08/24 14:37:31 pooka Exp $	*/
+/*	$NetBSD: rumpfiber.h,v 1.3 2014/12/29 21:50:09 justin Exp $	*/
 
 /*
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
@@ -33,16 +33,6 @@
 #include ucontext.h
 #include unistd.h
 
-static void printk(const char *s);
-
-static void
-printk(const char *msg)
-{
-	int ret __attribute__((unused));
-
-	ret = write(2, msg, strlen(msg));
-}
-
 struct thread {
 char *name;
 void *lwp;
Index: src/lib/librumpuser/rumpfiber_sp.c
diff -u src/lib/librumpuser/rumpfiber_sp.c:1.2 src/lib/librumpuser/rumpfiber_sp.c:1.3
--- src/lib/librumpuser/rumpfiber_sp.c:1.2	Sun Aug 24 14:37:31 2014
+++ src/lib/librumpuser/rumpfiber_sp.c	Mon Dec 29 21:50:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber_sp.c,v 1.2 2014/08/24 14:37:31 pooka Exp $	*/
+/*	$NetBSD: rumpfiber_sp.c,v 1.3 2014/12/29 21:50:09 justin Exp $	*/
 
 /*
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
@@ -30,7 +30,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber_sp.c,v 1.2 2014/08/24 14:37:31 pooka Exp $);
+__RCSID($NetBSD: rumpfiber_sp.c,v 1.3 2014/12/29 21:50:09 justin Exp $);
 #endif /* !lint */
 
 #include stdlib.h
@@ -60,8 +60,7 @@ int
 rumpuser_sp_raise(void *arg, int signo)
 {
 
-	printk(rumphyper: unimplemented rumpuser_sp_raise\n);
-	exit(1);
+	abort();
 }
 
 /*ARGSUSED*/
@@ -69,8 +68,7 @@ int
 rumpuser_sp_copyin(void *arg, const void *raddr, void *laddr, size_t len)
 {
 
-	printk(rumphyper: unimplemented rumpuser_sp_copyin\n);
-	exit(1);
+	abort();
 }
 
 /*ARGSUSED*/
@@ -78,8 +76,7 @@ int
 rumpuser_sp_copyinstr(void *arg, const void *raddr, void *laddr, size_t *len)
 {
 
-	printk(rumphyper: unimplemented rumpuser_sp_copyinstr\n);
-	exit(1);
+	abort();
 }
 
 /*ARGSUSED*/
@@ -87,8 +84,7 @@ int
 rumpuser_sp_copyout(void *arg, const void *laddr, void *raddr, size_t dlen)
 {
 
-	printk(rumphyper: unimplemented rumpuser_sp_copyout\n);
-	exit(1);
+	abort();
 }
 
 /*ARGSUSED*/
@@ -96,8 +92,7 @@ int
 rumpuser_sp_copyoutstr(void *arg, const void *laddr, void *raddr, size_t *dlen)
 {
 
-	printk(rumphyper: unimplemented rumpuser_sp_copyoutstr\n);
-	exit(1);
+	abort();
 }
 
 /*ARGSUSED*/
@@ -105,6 +100,5 @@ int
 rumpuser_sp_anonmmap(void *arg, size_t howmuch, void **addr)
 {
 
-	printk(rumphyper: unimplemented rumpuser_sp_anonmmap\n);
-	exit(1);
+	abort();
 }



CVS commit: src/lib/librumpuser

2014-12-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Dec 16 17:00:17 UTC 2014

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

Log Message:
With glibc on ARM kthread_exit() aborts because pthread_exit() fails
to unwind the stack.  Add a temporary workaround where we simply don't
allow the thread to exit (a kernel thread exit is a relatively uncommon
event in a rump kernel anyway).


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 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.43 src/lib/librumpuser/rumpuser_pth.c:1.44
--- src/lib/librumpuser/rumpuser_pth.c:1.43	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Tue Dec 16 17:00:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.43 2014/11/04 19:05:17 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.44 2014/12/16 17:00:17 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.43 2014/11/04 19:05:17 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.44 2014/12/16 17:00:17 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -104,6 +104,17 @@ __dead void
 rumpuser_thread_exit(void)
 {
 
+	/*
+	 * FIXXXME: with glibc on ARM pthread_exit() aborts because
+	 * it fails to unwind the stack.  In the typical case, only
+	 * the mountroothook thread will exit and even that's
+	 * conditional on vfs being present.
+	 */
+#if (defined(__ARMEL__) || defined(__ARMEB__))  defined(__GLIBC__)
+	for (;;)
+		pause();
+#endif
+
 	pthread_exit(NULL);
 }
 



CVS commit: src/lib/librumpuser

2014-12-07 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Mon Dec  8 00:12:03 UTC 2014

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

Log Message:
Avoid uninitialised variable warning when gcc is feeling lazy


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.67 src/lib/librumpuser/rumpuser_sp.c:1.68
--- src/lib/librumpuser/rumpuser_sp.c:1.67	Mon Aug 25 14:58:48 2014
+++ src/lib/librumpuser/rumpuser_sp.c	Mon Dec  8 00:12:03 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.67 2014/08/25 14:58:48 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.68 2014/12/08 00:12:03 justin Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.67 2014/08/25 14:58:48 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.68 2014/12/08 00:12:03 justin Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -862,7 +862,7 @@ int
 rumpuser_sp_anonmmap(void *arg, size_t howmuch, void **addr)
 {
 	struct spclient *spc = arg;
-	void *resp, *rdata;
+	void *resp, *rdata = NULL; /* XXXuninit */
 	int nlocks, rv;
 
 	rumpkern_unsched(nlocks, NULL);



CVS commit: src/lib/librumpuser

2014-11-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov 10 22:29:06 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Just _GNU_SOURCE should be enough to expose everything necessary on Linux


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.40 src/lib/librumpuser/rumpuser_port.h:1.41
--- src/lib/librumpuser/rumpuser_port.h:1.40	Wed Nov  5 12:28:46 2014
+++ src/lib/librumpuser/rumpuser_port.h	Mon Nov 10 22:29:06 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.40 2014/11/05 12:28:46 justin Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.41 2014/11/10 22:29:06 pooka Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -63,8 +63,6 @@
 #endif
 
 #ifdef __linux__
-#define _XOPEN_SOURCE 600
-#define _BSD_SOURCE
 #define _GNU_SOURCE
 #endif
 



CVS commit: src/lib/librumpuser

2014-11-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov 10 22:43:46 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
work around c11 visibility problems on some version(s) of FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.41 src/lib/librumpuser/rumpuser_port.h:1.42
--- src/lib/librumpuser/rumpuser_port.h:1.41	Mon Nov 10 22:29:06 2014
+++ src/lib/librumpuser/rumpuser_port.h	Mon Nov 10 22:43:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.41 2014/11/10 22:29:06 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.42 2014/11/10 22:43:46 pooka Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -69,6 +69,18 @@
 #if defined(HAVE_SYS_CDEFS_H)
 #include sys/cdefs.h
 #endif
+
+/*
+ * Some versions of FreeBSD (e.g. 9.2) contain C11 stuff without
+ * any obvious way to expose the protos.  Kludge around it.
+ */
+#ifdef __FreeBSD__
+#if __ISO_C_VISIBLE  2011
+#undef __ISO_C_VISIBLE
+#define __ISO_C_VISIBLE 2011
+#endif
+#endif
+
 #if defined(HAVE_SYS_PARAM_H)
 #include sys/param.h
 #endif



CVS commit: src/lib/librumpuser

2014-11-08 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sat Nov  8 21:27:04 UTC 2014

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

Log Message:
Fix some error handling cases.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/librumpuser/rumpfiber.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.5 src/lib/librumpuser/rumpfiber.c:1.6
--- src/lib/librumpuser/rumpfiber.c:1.5	Wed Nov  5 01:39:40 2014
+++ src/lib/librumpuser/rumpfiber.c	Sat Nov  8 21:27:04 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.5 2014/11/05 01:39:40 pooka Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.6 2014/11/08 21:27:04 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.5 2014/11/05 01:39:40 pooka Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.6 2014/11/08 21:27:04 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -199,11 +199,16 @@ create_thread(const char *name, void *co
 {
 	struct thread *thread = calloc(1, sizeof(struct thread));
 
+	if (!thread) {
+		return NULL;
+	}
+
 	if (!stack) {
 		assert(stack_size == 0);
 		stack = mmap(NULL, STACKSIZE, PROT_READ | PROT_WRITE,
 		MAP_SHARED | MAP_ANON, -1, 0);
 		if (stack == MAP_FAILED) {
+			free(thread);
 			return NULL;
 		}
 		stack_size = STACKSIZE;



CVS commit: src/lib/librumpuser

2014-11-08 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sat Nov  8 23:20:24 UTC 2014

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

Log Message:
Move makecontext into function with getcontext for consistency


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/librumpuser/rumpfiber.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.6 src/lib/librumpuser/rumpfiber.c:1.7
--- src/lib/librumpuser/rumpfiber.c:1.6	Sat Nov  8 21:27:04 2014
+++ src/lib/librumpuser/rumpfiber.c	Sat Nov  8 23:20:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.6 2014/11/08 21:27:04 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.7 2014/11/08 23:20:23 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.6 2014/11/08 21:27:04 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.7 2014/11/08 23:20:23 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -181,7 +181,8 @@ schedule(void)
 }
 
 static void
-create_ctx(ucontext_t *ctx, void *stack, size_t stack_size)
+create_ctx(ucontext_t *ctx, void *stack, size_t stack_size,
+	void (*f)(void *), void *data)
 {
 
 	getcontext(ctx);
@@ -189,9 +190,10 @@ create_ctx(ucontext_t *ctx, void *stack,
 	ctx-uc_stack.ss_size = stack_size;
 	ctx-uc_stack.ss_flags = 0;
 	ctx-uc_link = NULL; /* TODO may link to main thread */
+	/* may have to do bounce function to call, if args to makecontext are ints */
+	makecontext(ctx, (void (*)(void))f, 1, data);
 }
 
-/* may have to do bounce function to call, if args to makecontext are ints */
 /* TODO see notes in rumpuser_thread_create, have flags here */
 struct thread *
 create_thread(const char *name, void *cookie, void (*f)(void *), void *data,
@@ -215,8 +217,7 @@ create_thread(const char *name, void *co
 	} else {
 		thread-flags = THREAD_EXTSTACK;
 	}
-	create_ctx(thread-ctx, stack, stack_size);
-	makecontext(thread-ctx, (void (*)(void))f, 1, data);
+	create_ctx(thread-ctx, stack, stack_size, f, data);
 	
 	thread-name = strdup(name);
 	thread-cookie = cookie;



CVS commit: src/lib/librumpuser

2014-11-08 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sat Nov  8 23:47:15 UTC 2014

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

Log Message:
Remove superfluous getcontext()


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/librumpuser/rumpfiber.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.7 src/lib/librumpuser/rumpfiber.c:1.8
--- src/lib/librumpuser/rumpfiber.c:1.7	Sat Nov  8 23:20:23 2014
+++ src/lib/librumpuser/rumpfiber.c	Sat Nov  8 23:47:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.7 2014/11/08 23:20:23 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.8 2014/11/08 23:47:15 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.7 2014/11/08 23:20:23 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.8 2014/11/08 23:47:15 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -388,7 +388,6 @@ init_sched(void)
 {
 	struct thread *thread = calloc(1, sizeof(struct thread));
 
-	getcontext(thread-ctx);
 	thread-name = strdup(init);
 	thread-flags = 0;
 	thread-wakeup_time = -1;



CVS commit: src/lib/librumpuser

2014-11-05 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Wed Nov  5 12:28:47 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Add some prototypes for Android rump kernel builds

See buildrump.sh #70, some Android versins are missing prototypes for
these libc functions


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.39 src/lib/librumpuser/rumpuser_port.h:1.40
--- src/lib/librumpuser/rumpuser_port.h:1.39	Wed Nov  5 01:37:27 2014
+++ src/lib/librumpuser/rumpuser_port.h	Wed Nov  5 12:28:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.39 2014/11/05 01:37:27 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.40 2014/11/05 12:28:46 justin Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -92,12 +92,20 @@ getsubopt(char **optionp, char * const *
 }
 #endif
 
+#if !defined(HAVE_CLOCKID_T)
+typedef int clockid_t;
+#endif
+
 #ifdef __ANDROID__
 #include stdint.h
 typedef uint16_t in_port_t;
 #include sys/select.h
 #define atomic_inc_uint(x)  __sync_fetch_and_add(x, 1)
 #define atomic_dec_uint(x)  __sync_fetch_and_sub(x, 1)
+#include time.h
+int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
+#include stdlib.h
+void arc4random_buf(void*, size_t);
 #endif
 
 /* sunny magic */
@@ -108,10 +116,6 @@ typedef uint16_t in_port_t;
 #  endif
 #endif
 
-#if !defined(HAVE_CLOCKID_T)
-typedef int clockid_t;
-#endif
-
 #if !defined(HAVE_CLOCK_GETTIME)
 #include sys/time.h
 #define	CLOCK_REALTIME	0



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Nov  4 21:08:12 UTC 2014

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

Log Message:
More finegrained disklabel macro checks, for FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librumpuser/rumpuser_file.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_file.c
diff -u src/lib/librumpuser/rumpuser_file.c:1.3 src/lib/librumpuser/rumpuser_file.c:1.4
--- src/lib/librumpuser/rumpuser_file.c:1.3	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/rumpuser_file.c	Tue Nov  4 21:08:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_file.c,v 1.3 2014/11/04 19:05:17 pooka Exp $	*/
+/*	$NetBSD: rumpuser_file.c,v 1.4 2014/11/04 21:08:12 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_file.c,v 1.3 2014/11/04 19:05:17 pooka Exp $);
+__RCSID($NetBSD: rumpuser_file.c,v 1.4 2014/11/04 21:08:12 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -126,7 +126,7 @@ rumpuser_getfileinfo(const char *path, u
 			goto out;
 		}
 
-#if !defined(DIOCGDINFO)  !defined(DIOCGWEDGEINFO)
+#if (!defined(DIOCGDINFO) || !defined(DISKPART))  !defined(DIOCGWEDGEINFO)
 		{
 		off_t off = lseek(fd, 0, SEEK_END);
 		if (off != 0) {
@@ -140,7 +140,7 @@ rumpuser_getfileinfo(const char *path, u
 		}
 #else
 
-#if defined(DIOCGDINFO)
+#if defined(DIOCGDINFO)  defined(DISKPART)
 		{
 		struct disklabel lab;
 		struct partition *parta;



CVS commit: src/lib/librumpuser/build-aux

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Nov  4 23:25:00 UTC 2014

Modified Files:
src/lib/librumpuser/build-aux: config.sub

Log Message:
be happy with netbsd*-* to recognize arm--netbsdelf-eabi

from pkg/48126, simplified


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/build-aux/config.sub

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/build-aux/config.sub
diff -u src/lib/librumpuser/build-aux/config.sub:1.1 src/lib/librumpuser/build-aux/config.sub:1.2
--- src/lib/librumpuser/build-aux/config.sub:1.1	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/build-aux/config.sub	Tue Nov  4 23:25:00 2014
@@ -117,7 +117,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
 os=-$maybe_os



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov  5 00:43:55 UTC 2014

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

Log Message:
check clock_gettime() rv


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/librumpuser/rumpuser.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.63 src/lib/librumpuser/rumpuser.c:1.64
--- src/lib/librumpuser/rumpuser.c:1.63	Fri Jul 25 14:00:31 2014
+++ src/lib/librumpuser/rumpuser.c	Wed Nov  5 00:43:55 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.63 2014/07/25 14:00:31 justin Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.64 2014/11/05 00:43:55 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.63 2014/07/25 14:00:31 justin Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.64 2014/11/05 00:43:55 pooka Exp $);
 #endif /* !lint */
 
 #include sys/stat.h
@@ -143,7 +143,8 @@ rumpuser_clock_sleep(int enum_rumpclock,
 #else
 			/* le/la/der/die/das sigh. timevalspec tailspin */
 			struct timespec ts, tsr;
-			clock_gettime(CLOCK_REALTIME, ts);
+			if ((rv = clock_gettime(CLOCK_REALTIME, ts)) == -1)
+continue;
 			if (ts.tv_sec == rqt.tv_sec ?
 			ts.tv_nsec  rqt.tv_nsec : ts.tv_sec  rqt.tv_sec) {
 rv = 0;



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov  5 00:50:17 UTC 2014

Modified Files:
src/lib/librumpuser: configure configure.ac rumpuser_config.h.in

Log Message:
actually check for clock_nanosleep()


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/configure \
src/lib/librumpuser/configure.ac src/lib/librumpuser/rumpuser_config.h.in

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/configure
diff -u src/lib/librumpuser/configure:1.1 src/lib/librumpuser/configure:1.2
--- src/lib/librumpuser/configure:1.1	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/configure	Wed Nov  5 00:50:17 2014
@@ -3877,6 +3877,13 @@ fi
 fi
 rm -f core conftest.err conftest.$ac_objext \
 conftest$ac_exeext conftest.$ac_ext
+{ $as_echo $as_me:${as_lineno-$LINENO}: checking for clock_nanosleep in -lrt 5
+$as_echo_n checking for clock_nanosleep in -lrt...  6; }
+if ${ac_cv_lib_rt_clock_nanosleep+:} false; then :
+  $as_echo_n (cached)  6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS=-lrt  $LIBS
 cat confdefs.h - _ACEOF conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -3886,26 +3893,32 @@ cat confdefs.h - _ACEOF conftest.$ac_
 #ifdef __cplusplus
 extern C
 #endif
-char clock_gettime ();
+char clock_nanosleep ();
 int
 main ()
 {
-return clock_gettime ();
+return clock_nanosleep ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link $LINENO; then :
-
+  ac_cv_lib_rt_clock_nanosleep=yes
 else
-  { $as_echo $as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt 5
-$as_echo_n checking for clock_gettime in -lrt...  6; }
-if ${ac_cv_lib_rt_clock_gettime+:} false; then :
-  $as_echo_n (cached)  6
+  ac_cv_lib_rt_clock_nanosleep=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo $as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_nanosleep 5
+$as_echo $ac_cv_lib_rt_clock_nanosleep 6; }
+if test x$ac_cv_lib_rt_clock_nanosleep = xyes; then :
+
+$as_echo #define HAVE_CLOCK_NANOSLEEP 1 confdefs.h
+
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS=-lrt  $LIBS
-cat confdefs.h - _ACEOF conftest.$ac_ext
+  cat confdefs.h - _ACEOF conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3914,39 +3927,24 @@ cat confdefs.h - _ACEOF conftest.$ac_
 #ifdef __cplusplus
 extern C
 #endif
-char clock_gettime ();
+char clock_nanosleep ();
 int
 main ()
 {
-return clock_gettime ();
+return clock_nanosleep ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link $LINENO; then :
-  ac_cv_lib_rt_clock_gettime=yes
-else
-  ac_cv_lib_rt_clock_gettime=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo $as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime 5
-$as_echo $ac_cv_lib_rt_clock_gettime 6; }
-if test x$ac_cv_lib_rt_clock_gettime = xyes; then :
-  cat confdefs.h _ACEOF
-#define HAVE_LIBRT 1
-_ACEOF
-
-  LIBS=-lrt $LIBS
-
-fi
 
+$as_echo #define HAVE_CLOCK_NANOSLEEP 1 confdefs.h
 
 fi
 rm -f core conftest.err conftest.$ac_objext \
 conftest$ac_exeext conftest.$ac_ext
+fi
+
 { $as_echo $as_me:${as_lineno-$LINENO}: checking for dlinfo in -ldl 5
 $as_echo_n checking for dlinfo in -ldl...  6; }
 if ${ac_cv_lib_dl_dlinfo+:} false; then :
Index: src/lib/librumpuser/configure.ac
diff -u src/lib/librumpuser/configure.ac:1.1 src/lib/librumpuser/configure.ac:1.2
--- src/lib/librumpuser/configure.ac:1.1	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/configure.ac	Wed Nov  5 00:50:17 2014
@@ -33,9 +33,10 @@ AC_CHECK_FUNCS([kqueue chflags strsuftol
 AC_TRY_LINK_FUNC([clock_nanosleep],,
 AC_CHECK_LIB([rt], [clock_nanosleep])
 )
-AC_TRY_LINK_FUNC([clock_gettime],,
-AC_CHECK_LIB([rt], [clock_gettime])
-)
+AC_CHECK_LIB([rt], [clock_nanosleep],
+	AC_DEFINE([HAVE_CLOCK_NANOSLEEP], 1, [clock_nanosleep]),
+	AC_TRY_LINK_FUNC([clock_nanosleep],
+	AC_DEFINE([HAVE_CLOCK_NANOSLEEP], 1, [clock_nanosleep])))
 AC_CHECK_LIB([dl], [dlinfo],
 	AC_DEFINE([HAVE_DLINFO], 1, [dlinfo]),
 	AC_TRY_LINK_FUNC([dlinfo], AC_DEFINE([HAVE_DLINFO], 1, [dlinfo])))
Index: src/lib/librumpuser/rumpuser_config.h.in
diff -u src/lib/librumpuser/rumpuser_config.h.in:1.1 src/lib/librumpuser/rumpuser_config.h.in:1.2
--- src/lib/librumpuser/rumpuser_config.h.in:1.1	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/rumpuser_config.h.in	Wed Nov  5 00:50:17 2014
@@ -15,6 +15,9 @@
 /* Define to 1 if you have the `clock_gettime' function. */
 #undef HAVE_CLOCK_GETTIME
 
+/* clock_nanosleep */
+#undef HAVE_CLOCK_NANOSLEEP
+
 /* dlinfo */
 #undef HAVE_DLINFO
 



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov  5 01:15:58 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
update for NetBSD-current having clock_nanosleep


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.37 src/lib/librumpuser/rumpuser_port.h:1.38
--- src/lib/librumpuser/rumpuser_port.h:1.37	Tue Nov  4 19:05:17 2014
+++ src/lib/librumpuser/rumpuser_port.h	Wed Nov  5 01:15:58 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.37 2014/11/04 19:05:17 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.38 2014/11/05 01:15:58 pooka Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -16,6 +16,7 @@
 #define HAVE_CHFLAGS 1
 #define HAVE_CLOCKID_T 1
 #define HAVE_CLOCK_GETTIME 1
+#define HAVE_CLOCK_NANOSLEEP 1
 #define HAVE_DLINFO 1
 #define HAVE_FSYNC_RANGE 1
 #define HAVE_GETENV_R 1



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov  5 01:37:27 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
fix clock_gettime emulation


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.38 src/lib/librumpuser/rumpuser_port.h:1.39
--- src/lib/librumpuser/rumpuser_port.h:1.38	Wed Nov  5 01:15:58 2014
+++ src/lib/librumpuser/rumpuser_port.h	Wed Nov  5 01:37:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.38 2014/11/05 01:15:58 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.39 2014/11/05 01:37:27 pooka Exp $	*/
 
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
@@ -123,6 +123,7 @@ clock_gettime(clockid_t clk, struct time
 	if (gettimeofday(tv, 0) == 0) {
 		ts-tv_sec = tv.tv_sec;
 		ts-tv_nsec = tv.tv_usec * 1000;
+		return 0;
 	}
 	return -1;
 }



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov  5 01:39:40 UTC 2014

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

Log Message:
assert that clock_gettime() does not fail


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/librumpuser/rumpfiber.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.4 src/lib/librumpuser/rumpfiber.c:1.5
--- src/lib/librumpuser/rumpfiber.c:1.4	Sun Aug 24 14:37:31 2014
+++ src/lib/librumpuser/rumpfiber.c	Wed Nov  5 01:39:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.4 2014/08/24 14:37:31 pooka Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.5 2014/11/05 01:39:40 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.4 2014/08/24 14:37:31 pooka Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.5 2014/11/05 01:39:40 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -119,8 +119,10 @@ static int64_t
 now(void)
 {
 	struct timespec ts;
+	int rv;
 
-	clock_gettime(CLOCK_MONOTONIC, ts);
+	rv = clock_gettime(CLOCK_MONOTONIC, ts);
+	assert(rv == 0);
 	return (ts.tv_sec * 1000LL) + (ts.tv_nsec / 100LL);
 }
 



CVS commit: src/lib/librumpuser

2014-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov  5 01:40:30 UTC 2014

Modified Files:
src/lib/librumpuser: configure configure.ac rumpuser_config.h.in

Log Message:
check for clock_gettime from librt too


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/configure \
src/lib/librumpuser/configure.ac src/lib/librumpuser/rumpuser_config.h.in

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/configure
diff -u src/lib/librumpuser/configure:1.2 src/lib/librumpuser/configure:1.3
--- src/lib/librumpuser/configure:1.2	Wed Nov  5 00:50:17 2014
+++ src/lib/librumpuser/configure	Wed Nov  5 01:40:30 2014
@@ -3793,7 +3793,7 @@ fi
 
 
 for ac_func in kqueue chflags strsuftoll setprogname getprogname	\
-	clock_gettime getenv_r posix_memalign memalign aligned_alloc	\
+	getenv_r posix_memalign memalign aligned_alloc	\
 	arc4random_buf getsubopt fsync_range __quotactl
 do :
   as_ac_var=`$as_echo ac_cv_func_$ac_func | $as_tr_sh`
@@ -3877,6 +3877,74 @@ fi
 fi
 rm -f core conftest.err conftest.$ac_objext \
 conftest$ac_exeext conftest.$ac_ext
+{ $as_echo $as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt 5
+$as_echo_n checking for clock_gettime in -lrt...  6; }
+if ${ac_cv_lib_rt_clock_gettime+:} false; then :
+  $as_echo_n (cached)  6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS=-lrt  $LIBS
+cat confdefs.h - _ACEOF conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern C
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link $LINENO; then :
+  ac_cv_lib_rt_clock_gettime=yes
+else
+  ac_cv_lib_rt_clock_gettime=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo $as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime 5
+$as_echo $ac_cv_lib_rt_clock_gettime 6; }
+if test x$ac_cv_lib_rt_clock_gettime = xyes; then :
+
+$as_echo #define HAVE_CLOCK_GETTIME 1 confdefs.h
+
+else
+  cat confdefs.h - _ACEOF conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern C
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link $LINENO; then :
+
+$as_echo #define HAVE_CLOCK_GETTIME 1 confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+conftest$ac_exeext conftest.$ac_ext
+fi
+
 { $as_echo $as_me:${as_lineno-$LINENO}: checking for clock_nanosleep in -lrt 5
 $as_echo_n checking for clock_nanosleep in -lrt...  6; }
 if ${ac_cv_lib_rt_clock_nanosleep+:} false; then :
Index: src/lib/librumpuser/configure.ac
diff -u src/lib/librumpuser/configure.ac:1.2 src/lib/librumpuser/configure.ac:1.3
--- src/lib/librumpuser/configure.ac:1.2	Wed Nov  5 00:50:17 2014
+++ src/lib/librumpuser/configure.ac	Wed Nov  5 01:40:30 2014
@@ -27,12 +27,16 @@ AC_CANONICAL_TARGET
 AC_CHECK_TYPES([clockid_t, register_t])
 
 AC_CHECK_FUNCS([kqueue chflags strsuftoll setprogname getprogname	\
-	clock_gettime getenv_r posix_memalign memalign aligned_alloc	\
+	getenv_r posix_memalign memalign aligned_alloc	\
 	arc4random_buf getsubopt fsync_range __quotactl])
 
 AC_TRY_LINK_FUNC([clock_nanosleep],,
 AC_CHECK_LIB([rt], [clock_nanosleep])
 )
+AC_CHECK_LIB([rt], [clock_gettime],
+	AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [clock_gettime]),
+	AC_TRY_LINK_FUNC([clock_gettime],
+	AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [clock_gettime])))
 AC_CHECK_LIB([rt], [clock_nanosleep],
 	AC_DEFINE([HAVE_CLOCK_NANOSLEEP], 1, [clock_nanosleep]),
 	AC_TRY_LINK_FUNC([clock_nanosleep],
Index: src/lib/librumpuser/rumpuser_config.h.in
diff -u src/lib/librumpuser/rumpuser_config.h.in:1.2 src/lib/librumpuser/rumpuser_config.h.in:1.3
--- src/lib/librumpuser/rumpuser_config.h.in:1.2	Wed Nov  5 00:50:17 2014
+++ src/lib/librumpuser/rumpuser_config.h.in	Wed Nov  5 01:40:30 2014
@@ -12,7 +12,7 @@
 /* Define to 1 if the system has the type `clockid_t'. */
 #undef HAVE_CLOCKID_T
 
-/* Define to 1 if you have the `clock_gettime' function. */
+/* clock_gettime */
 #undef HAVE_CLOCK_GETTIME
 
 /* clock_nanosleep */



CVS commit: src/lib/librumpuser

2014-10-28 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Oct 28 23:48:04 UTC 2014

Modified Files:
src/lib/librumpuser: Makefile

Log Message:
Don't install rumpuser.h here.

It's already installed by the rump kernel build (sys/rump/include/rump)


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

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/Makefile
diff -u src/lib/librumpuser/Makefile:1.21 src/lib/librumpuser/Makefile:1.22
--- src/lib/librumpuser/Makefile:1.21	Tue Jul 22 22:41:58 2014
+++ src/lib/librumpuser/Makefile	Tue Oct 28 23:48:03 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.21 2014/07/22 22:41:58 justin Exp $
+#	$NetBSD: Makefile,v 1.22 2014/10/28 23:48:03 pooka Exp $
 #
 
 .include bsd.own.mk
@@ -50,7 +50,7 @@ SRCS+=		rumpuser_errtrans.c rumpuser_sig
 SRCS+=		rumpuser_dl.c rumpuser_daemonize.c
 
 INCSDIR=	/usr/include/rump
-INCS=		rumpuser.h rumpuser_component.h rumpuser_port.h
+INCS=		rumpuser_component.h rumpuser_port.h
 
 MAN=		rumpuser.3
 



Re: CVS commit: src/lib/librumpuser

2014-10-07 Thread Marc Balmer

Am 29.09.2014 um 17:54 schrieb Justin Cormack jus...@netbsd.org:

 Module Name:  src
 Committed By: justin
 Date: Mon Sep 29 15:54:28 UTC 2014
 
 Modified Files:
   src/lib/librumpuser: rumpuser_port.h
 
 Log Message:
 Minix also has getenv_r support
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.34 -r1.35 src/lib/librumpuser/rumpuser_port.h
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 
 Modified files:
 
 Index: src/lib/librumpuser/rumpuser_port.h
 diff -u src/lib/librumpuser/rumpuser_port.h:1.34 
 src/lib/librumpuser/rumpuser_port.h:1.35
 --- src/lib/librumpuser/rumpuser_port.h:1.34  Tue Jul 22 22:41:58 2014
 +++ src/lib/librumpuser/rumpuser_port.h   Mon Sep 29 15:54:28 2014
 @@ -1,4 +1,4 @@
 -/*   $NetBSD: rumpuser_port.h,v 1.34 2014/07/22 22:41:58 justin Exp $
 */
 +/*   $NetBSD: rumpuser_port.h,v 1.35 2014/09/29 15:54:28 justin Exp $
 */
 
 /*
  * Portability header for non-NetBSD platforms.
 @@ -112,8 +112,8 @@ clock_gettime(clockid_t clk, struct time
 #include sys/types.h
 #include sys/param.h
 
 -/* NetBSD is the only(?) platform with getenv_r() */
 -#if !defined(__NetBSD__)
 +/* NetBSD is almost the only platform with getenv_r() */
 +#if !(defined(__NetBSD__) || defined(__minix__))

Minix defines __minix, not __minix__, though.

 #include errno.h
 #include stdlib.h
 #include string.h
 


CVS commit: src/lib/librumpuser

2014-10-07 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Tue Oct  7 12:48:02 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Canonical Minix check as pointed out by Marc


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.35 src/lib/librumpuser/rumpuser_port.h:1.36
--- src/lib/librumpuser/rumpuser_port.h:1.35	Mon Sep 29 15:54:28 2014
+++ src/lib/librumpuser/rumpuser_port.h	Tue Oct  7 12:48:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.35 2014/09/29 15:54:28 justin Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.36 2014/10/07 12:48:02 justin Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -113,7 +113,7 @@ clock_gettime(clockid_t clk, struct time
 #include sys/param.h
 
 /* NetBSD is almost the only platform with getenv_r() */
-#if !(defined(__NetBSD__) || defined(__minix__))
+#if !(defined(__NetBSD__) || defined(__minix))
 #include errno.h
 #include stdlib.h
 #include string.h



CVS commit: src/lib/librumpuser

2014-09-29 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Mon Sep 29 15:54:28 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Minix also has getenv_r support


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.34 src/lib/librumpuser/rumpuser_port.h:1.35
--- src/lib/librumpuser/rumpuser_port.h:1.34	Tue Jul 22 22:41:58 2014
+++ src/lib/librumpuser/rumpuser_port.h	Mon Sep 29 15:54:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.34 2014/07/22 22:41:58 justin Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.35 2014/09/29 15:54:28 justin Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -112,8 +112,8 @@ clock_gettime(clockid_t clk, struct time
 #include sys/types.h
 #include sys/param.h
 
-/* NetBSD is the only(?) platform with getenv_r() */
-#if !defined(__NetBSD__)
+/* NetBSD is almost the only platform with getenv_r() */
+#if !(defined(__NetBSD__) || defined(__minix__))
 #include errno.h
 #include stdlib.h
 #include string.h



CVS commit: src/lib/librumpuser

2014-08-25 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Mon Aug 25 10:21:39 UTC 2014

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

Log Message:
Add errno translation for bio operations


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/librumpuser/rumpuser_bio.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_bio.c
diff -u src/lib/librumpuser/rumpuser_bio.c:1.8 src/lib/librumpuser/rumpuser_bio.c:1.9
--- src/lib/librumpuser/rumpuser_bio.c:1.8	Mon Jun 16 21:07:28 2014
+++ src/lib/librumpuser/rumpuser_bio.c	Mon Aug 25 10:21:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_bio.c,v 1.8 2014/06/16 21:07:28 alnsn Exp $	*/
+/*	$NetBSD: rumpuser_bio.c,v 1.9 2014/08/25 10:21:39 justin Exp $	*/
 
 /*-
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_bio.c,v 1.8 2014/06/16 21:07:28 alnsn Exp $);
+__RCSID($NetBSD: rumpuser_bio.c,v 1.9 2014/08/25 10:21:39 justin Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -75,7 +75,7 @@ dobio(struct rumpuser_bio *biop)
 		biop-bio_dlen, biop-bio_off);
 		if (rv  0) {
 			rv = 0;
-			error = errno;
+			error = rumpuser__errtrans(errno);
 		}
 	} else {
 		error = 0;
@@ -83,7 +83,7 @@ dobio(struct rumpuser_bio *biop)
 		biop-bio_dlen, biop-bio_off);
 		if (rv  0) {
 			rv = 0;
-			error = errno;
+			error = rumpuser__errtrans(errno);
 		} else if (biop-bio_op  RUMPUSER_BIO_SYNC) {
 #ifdef __NetBSD__
 			fsync_range(biop-bio_fd, FDATASYNC,



CVS commit: src/lib/librumpuser

2014-08-25 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Mon Aug 25 10:33:32 UTC 2014

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

Log Message:
lso translate errno in the rumpfiber version


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librumpuser/rumpfiber_bio.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/rumpfiber_bio.c
diff -u src/lib/librumpuser/rumpfiber_bio.c:1.3 src/lib/librumpuser/rumpfiber_bio.c:1.4
--- src/lib/librumpuser/rumpfiber_bio.c:1.3	Sun Aug 24 14:37:31 2014
+++ src/lib/librumpuser/rumpfiber_bio.c	Mon Aug 25 10:33:32 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber_bio.c,v 1.3 2014/08/24 14:37:31 pooka Exp $	*/
+/*	$NetBSD: rumpfiber_bio.c,v 1.4 2014/08/25 10:33:32 justin Exp $	*/
 
 /*-
  * Copyright (c) 2014 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber_bio.c,v 1.3 2014/08/24 14:37:31 pooka Exp $);
+__RCSID($NetBSD: rumpfiber_bio.c,v 1.4 2014/08/25 10:33:32 justin Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -50,10 +50,10 @@ rumpuser_bio(int fd, int op, void *data,
 
 	if (op  RUMPUSER_BIO_READ) {
 		if ((rv = pread(fd, data, dlen, doff)) == -1)
-			error = errno;
+			error = rumpuser__errtrans(errno);
 	} else {
 		if ((rv = pwrite(fd, data, dlen, doff)) == -1)
-			error = errno;
+			error = rumpuser__errtrans(errno);
 		if (error == 0  (op  RUMPUSER_BIO_SYNC)) {
 #ifdef __NetBSD__
 			fsync_range(fd, FDATASYNC, doff, dlen);



CVS commit: src/lib/librumpuser

2014-08-24 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Aug 24 14:35:27 UTC 2014

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

Log Message:
* attempt to clarify what POSIX means
* link to Platforms page on wiki for a list of known implementation


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.18 src/lib/librumpuser/rumpuser.3:1.19
--- src/lib/librumpuser/rumpuser.3:1.18	Thu Feb 20 00:43:26 2014
+++ src/lib/librumpuser/rumpuser.3	Sun Aug 24 14:35:27 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.18 2014/02/20 00:43:26 pooka Exp $
+.\ $NetBSD: rumpuser.3,v 1.19 2014/08/24 14:35:27 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -23,7 +23,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd February 19, 2014
+.Dd August 24, 2014
 .Dt RUMPUSER 3
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@ A hypervisor implementation must impleme
 this document to allow a rump kernel to run on the host.
 The implementation included in
 .Nx
-is for POSIX hosts.
+is for POSIX-like hosts (*BSD, Linux, etc.).
 This document is divided into sections based on the functionality
 group of each hypercall.
 .Pp
@@ -770,6 +770,11 @@ Routines which do not return an integer 
 .%T Flexible Operating System Internals: The Design and Implementation of the Anykernel and Rump Kernels
 .%O Section 2.3.2: The Hypercall Interface
 .Re
+.Pp
+For a list of all known implementations of the
+.Nm
+interface, see
+.Lk http://wiki.rumpkernel.org/Platforms .
 .Sh HISTORY
 The rump kernel hypercall API was first introduced in
 .Nx 5.0 .



CVS commit: src/lib/librumpuser

2014-08-24 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Aug 24 14:37:31 UTC 2014

Modified Files:
src/lib/librumpuser: rumpfiber.c rumpfiber.h rumpfiber_bio.c
rumpfiber_sp.c rumpuser_file.c rumpuser_mem.c rumpuser_random.c

Log Message:
RCS Id police (because we can. or have you heard of git id police?)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librumpuser/rumpfiber.c
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/rumpfiber.h \
src/lib/librumpuser/rumpfiber_sp.c src/lib/librumpuser/rumpuser_file.c \
src/lib/librumpuser/rumpuser_mem.c
cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/rumpfiber_bio.c \
src/lib/librumpuser/rumpuser_random.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.3 src/lib/librumpuser/rumpfiber.c:1.4
--- src/lib/librumpuser/rumpfiber.c:1.3	Fri Jul 25 14:00:31 2014
+++ src/lib/librumpuser/rumpfiber.c	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpfiber.c,v 1.4 2014/08/24 14:37:31 pooka Exp $	*/
+
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
@@ -66,7 +68,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.3 2014/07/25 14:00:31 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.4 2014/08/24 14:37:31 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h

Index: src/lib/librumpuser/rumpfiber.h
diff -u src/lib/librumpuser/rumpfiber.h:1.1 src/lib/librumpuser/rumpfiber.h:1.2
--- src/lib/librumpuser/rumpfiber.h:1.1	Fri Jul 11 20:26:31 2014
+++ src/lib/librumpuser/rumpfiber.h	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpfiber.h,v 1.2 2014/08/24 14:37:31 pooka Exp $	*/
+
 /*
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
  *
Index: src/lib/librumpuser/rumpfiber_sp.c
diff -u src/lib/librumpuser/rumpfiber_sp.c:1.1 src/lib/librumpuser/rumpfiber_sp.c:1.2
--- src/lib/librumpuser/rumpfiber_sp.c:1.1	Fri Jul 11 20:26:31 2014
+++ src/lib/librumpuser/rumpfiber_sp.c	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpfiber_sp.c,v 1.2 2014/08/24 14:37:31 pooka Exp $	*/
+
 /*
  * Copyright (c) 2014 Justin Cormack.  All Rights Reserved.
  *
@@ -28,7 +30,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber_sp.c,v 1.1 2014/07/11 20:26:31 justin Exp $);
+__RCSID($NetBSD: rumpfiber_sp.c,v 1.2 2014/08/24 14:37:31 pooka Exp $);
 #endif /* !lint */
 
 #include stdlib.h
Index: src/lib/librumpuser/rumpuser_file.c
diff -u src/lib/librumpuser/rumpuser_file.c:1.1 src/lib/librumpuser/rumpuser_file.c:1.2
--- src/lib/librumpuser/rumpuser_file.c:1.1	Wed Jul  9 23:41:40 2014
+++ src/lib/librumpuser/rumpuser_file.c	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpuser_file.c,v 1.2 2014/08/24 14:37:31 pooka Exp $	*/
+
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
  *
@@ -28,7 +30,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_file.c,v 1.1 2014/07/09 23:41:40 justin Exp $);
+__RCSID($NetBSD: rumpuser_file.c,v 1.2 2014/08/24 14:37:31 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
Index: src/lib/librumpuser/rumpuser_mem.c
diff -u src/lib/librumpuser/rumpuser_mem.c:1.1 src/lib/librumpuser/rumpuser_mem.c:1.2
--- src/lib/librumpuser/rumpuser_mem.c:1.1	Wed Jul  9 23:41:40 2014
+++ src/lib/librumpuser/rumpuser_mem.c	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpuser_mem.c,v 1.2 2014/08/24 14:37:31 pooka Exp $	*/
+
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
  *
@@ -26,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_mem.c,v 1.1 2014/07/09 23:41:40 justin Exp $);
+__RCSID($NetBSD: rumpuser_mem.c,v 1.2 2014/08/24 14:37:31 pooka Exp $);
 #endif /* !lint */
 
 #include sys/mman.h

Index: src/lib/librumpuser/rumpfiber_bio.c
diff -u src/lib/librumpuser/rumpfiber_bio.c:1.2 src/lib/librumpuser/rumpfiber_bio.c:1.3
--- src/lib/librumpuser/rumpfiber_bio.c:1.2	Wed Aug 20 12:09:15 2014
+++ src/lib/librumpuser/rumpfiber_bio.c	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpfiber_bio.c,v 1.3 2014/08/24 14:37:31 pooka Exp $	*/
+
 /*-
  * Copyright (c) 2014 Antti Kantee.  All Rights Reserved.
  *
@@ -26,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber_bio.c,v 1.2 2014/08/20 12:09:15 justin Exp $);
+__RCSID($NetBSD: rumpfiber_bio.c,v 1.3 2014/08/24 14:37:31 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
Index: src/lib/librumpuser/rumpuser_random.c
diff -u src/lib/librumpuser/rumpuser_random.c:1.2 src/lib/librumpuser/rumpuser_random.c:1.3
--- src/lib/librumpuser/rumpuser_random.c:1.2	Fri Jul 25 14:00:31 2014
+++ src/lib/librumpuser/rumpuser_random.c	Sun Aug 24 14:37:31 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: rumpuser_random.c,v 1.3 2014/08/24 

CVS commit: src/lib/librumpuser

2014-08-20 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Wed Aug 20 12:09:15 UTC 2014

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

Log Message:
Add missing include


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/rumpfiber_bio.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/rumpfiber_bio.c
diff -u src/lib/librumpuser/rumpfiber_bio.c:1.1 src/lib/librumpuser/rumpfiber_bio.c:1.2
--- src/lib/librumpuser/rumpfiber_bio.c:1.1	Fri Jul 11 20:26:31 2014
+++ src/lib/librumpuser/rumpfiber_bio.c	Wed Aug 20 12:09:15 2014
@@ -26,11 +26,12 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber_bio.c,v 1.1 2014/07/11 20:26:31 justin Exp $);
+__RCSID($NetBSD: rumpfiber_bio.c,v 1.2 2014/08/20 12:09:15 justin Exp $);
 #endif /* !lint */
 
 #include sys/types.h
 
+#include errno.h
 #include stdint.h
 #include unistd.h
 



CVS commit: src/lib/librumpuser

2014-07-25 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Fri Jul 25 14:00:31 UTC 2014

Modified Files:
src/lib/librumpuser: rumpfiber.c rumpuser.c rumpuser_random.c

Log Message:
Clean up error handling in rumpuser_init()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/rumpfiber.c
cvs rdiff -u -r1.62 -r1.63 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/rumpuser_random.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/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.2 src/lib/librumpuser/rumpfiber.c:1.3
--- src/lib/librumpuser/rumpfiber.c:1.2	Tue Jul 22 22:41:58 2014
+++ src/lib/librumpuser/rumpfiber.c	Fri Jul 25 14:00:31 2014
@@ -66,7 +66,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.2 2014/07/22 22:41:58 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.3 2014/07/25 14:00:31 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -410,14 +410,16 @@ struct rumpuser_hyperup rumpuser__hyp;
 int
 rumpuser_init(int version, const struct rumpuser_hyperup *hyp)
 {
+	int rv;
 
 	if (version != RUMPUSER_VERSION) {
 		printk(rumpuser version mismatch\n);
-		return 1;
+		abort();
 	}
 
-	if (rumpuser__random_init() != 0) {
-		return 1;
+	rv = rumpuser__random_init();
+	if (rv != 0) {
+		ET(rv);
 	}
 
 rumpuser__hyp = *hyp;

Index: src/lib/librumpuser/rumpuser.c
diff -u src/lib/librumpuser/rumpuser.c:1.62 src/lib/librumpuser/rumpuser.c:1.63
--- src/lib/librumpuser/rumpuser.c:1.62	Tue Jul 22 22:41:58 2014
+++ src/lib/librumpuser/rumpuser.c	Fri Jul 25 14:00:31 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.62 2014/07/22 22:41:58 justin Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.63 2014/07/25 14:00:31 justin 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.62 2014/07/22 22:41:58 justin Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.63 2014/07/25 14:00:31 justin Exp $);
 #endif /* !lint */
 
 #include sys/stat.h
@@ -57,15 +57,17 @@ struct rumpuser_hyperup rumpuser__hyp;
 int
 rumpuser_init(int version, const struct rumpuser_hyperup *hyp)
 {
+	int rv;
 
 	if (version != RUMPUSER_VERSION) {
 		fprintf(stderr, rumpuser mismatch, kern: %d, hypervisor %d\n,
 		version, RUMPUSER_VERSION);
-		return 1;
+		abort();
 	}
 
-	if (rumpuser__random_init() != 0) {
-		return 1;
+	rv = rumpuser__random_init();
+	if (rv != 0) {
+		ET(rv);
 	}
 
 	rumpuser__thrinit();

Index: src/lib/librumpuser/rumpuser_random.c
diff -u src/lib/librumpuser/rumpuser_random.c:1.1 src/lib/librumpuser/rumpuser_random.c:1.2
--- src/lib/librumpuser/rumpuser_random.c:1.1	Tue Jul 22 22:41:58 2014
+++ src/lib/librumpuser/rumpuser_random.c	Fri Jul 25 14:00:31 2014
@@ -26,7 +26,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_random.c,v 1.1 2014/07/22 22:41:58 justin Exp $);
+__RCSID($NetBSD: rumpuser_random.c,v 1.2 2014/07/25 14:00:31 justin Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -64,7 +64,7 @@ rumpuser__random_init(void)
 	random_fd = open(random_device, O_RDONLY);
 	if (random_fd  0) {
 		fprintf(stderr, random init open failed\n);
-		return 1;
+		return errno;
 	}
 	return 0;
 }
@@ -87,5 +87,5 @@ rumpuser_getrandom(void *buf, size_t buf
 	*retp = buflen;
 #endif
 
-	ET(0);
+	return 0;
 }



CVS commit: src/lib/librumpuser

2014-07-22 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Tue Jul 22 22:41:58 UTC 2014

Modified Files:
src/lib/librumpuser: Makefile rumpfiber.c rumpuser.c rumpuser_int.h
rumpuser_port.h
Added Files:
src/lib/librumpuser: rumpuser_random.c

Log Message:
Clean up random implementation for librumpuser

Use /dev/urandom for platforms without arc4random, not srandom(),
deduplicate code, do not read excessive random bytes

Reviewed by pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/librumpuser/Makefile
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/rumpfiber.c
cvs rdiff -u -r1.61 -r1.62 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r1.9 -r1.10 src/lib/librumpuser/rumpuser_int.h
cvs rdiff -u -r1.33 -r1.34 src/lib/librumpuser/rumpuser_port.h
cvs rdiff -u -r0 -r1.1 src/lib/librumpuser/rumpuser_random.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/Makefile
diff -u src/lib/librumpuser/Makefile:1.20 src/lib/librumpuser/Makefile:1.21
--- src/lib/librumpuser/Makefile:1.20	Fri Jul 11 20:26:31 2014
+++ src/lib/librumpuser/Makefile	Tue Jul 22 22:41:58 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2014/07/11 20:26:31 justin Exp $
+#	$NetBSD: Makefile,v 1.21 2014/07/22 22:41:58 justin Exp $
 #
 
 .include bsd.own.mk
@@ -41,7 +41,7 @@ SRCS+=		rumpfiber_sp.c
 .error Unsupported rumpuser threading type: ${RUMPUSER_THREADS}
 .endif
 
-SRCS+=		rumpuser_component.c
+SRCS+=		rumpuser_component.c rumpuser_random.c
 SRCS+=		rumpuser_file.c rumpuser_mem.c
 
 SRCS+=		rumpuser_errtrans.c rumpuser_sigtrans.c

Index: src/lib/librumpuser/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.1 src/lib/librumpuser/rumpfiber.c:1.2
--- src/lib/librumpuser/rumpfiber.c:1.1	Fri Jul 11 20:26:31 2014
+++ src/lib/librumpuser/rumpfiber.c	Tue Jul 22 22:41:58 2014
@@ -66,7 +66,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpfiber.c,v 1.1 2014/07/11 20:26:31 justin Exp $);
+__RCSID($NetBSD: rumpfiber.c,v 1.2 2014/07/22 22:41:58 justin Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -416,20 +416,9 @@ rumpuser_init(int version, const struct 
 		return 1;
 	}
 
-#ifdef RUMPUSER_USE_DEVRANDOM
-	uint32_t rv;
-	int fd;
-
-	if ((fd = open(/dev/urandom, O_RDONLY)) == -1) {
-		srandom(time(NULL));
-	} else {
-		if (read(fd, rv, sizeof(rv)) != sizeof(rv))
-			srandom(time(NULL));
-		else
-			srandom(rv);
-		close(fd);
+	if (rumpuser__random_init() != 0) {
+		return 1;
 	}
-#endif
 
 rumpuser__hyp = *hyp;
 
@@ -570,26 +559,6 @@ rumpuser_kill(int64_t pid, int rumpsig)
 	return 0;
 }
 
-int
-rumpuser_getrandom(void *buf, size_t buflen, int flags, size_t *retp)
-{
-	size_t origlen = buflen;
-	uint32_t *p = buf;
-	uint32_t tmp;
-	int chunk;
-
-	do {
-		chunk = buflen  4 ? buflen : 4; /* portable MIN ... */
-		tmp = RUMPUSER_RANDOM();
-		memcpy(p, tmp, chunk);
-		p++;
-		buflen -= chunk;
-	} while (chunk);
-
-	*retp = origlen;
-	ET(0);
-}
-
 /* thread functions */
 
 TAILQ_HEAD(waithead, waiter);

Index: src/lib/librumpuser/rumpuser.c
diff -u src/lib/librumpuser/rumpuser.c:1.61 src/lib/librumpuser/rumpuser.c:1.62
--- src/lib/librumpuser/rumpuser.c:1.61	Thu Jul 10 08:17:43 2014
+++ src/lib/librumpuser/rumpuser.c	Tue Jul 22 22:41:58 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.61 2014/07/10 08:17:43 justin Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.62 2014/07/22 22:41:58 justin 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.61 2014/07/10 08:17:43 justin Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.62 2014/07/22 22:41:58 justin Exp $);
 #endif /* !lint */
 
 #include sys/stat.h
@@ -64,20 +64,9 @@ rumpuser_init(int version, const struct 
 		return 1;
 	}
 
-#ifdef RUMPUSER_USE_DEVRANDOM
-	uint32_t rv;
-	int fd;
-
-	if ((fd = open(/dev/urandom, O_RDONLY)) == -1) {
-		srandom(time(NULL));
-	} else {
-		if (read(fd, rv, sizeof(rv)) != sizeof(rv))
-			srandom(time(NULL));
-		else
-			srandom(rv);
-		close(fd);
+	if (rumpuser__random_init() != 0) {
+		return 1;
 	}
-#endif
 
 	rumpuser__thrinit();
 	rumpuser__hyp = *hyp;
@@ -276,23 +265,3 @@ rumpuser_kill(int64_t pid, int rumpsig)
 		raise(sig);
 	return 0;
 }
-
-int
-rumpuser_getrandom(void *buf, size_t buflen, int flags, size_t *retp)
-{
-	size_t origlen = buflen;
-	uint32_t *p = buf;
-	uint32_t tmp;
-	int chunk;
-
-	do {
-		chunk = buflen  4 ? buflen : 4; /* portable MIN ... */
-		tmp = RUMPUSER_RANDOM();
-		memcpy(p, tmp, chunk);
-		p++;
-		buflen -= chunk;
-	} while (chunk);
-
-	*retp = origlen;
-	ET(0);
-}

Index: src/lib/librumpuser/rumpuser_int.h
diff -u src/lib/librumpuser/rumpuser_int.h:1.9 src/lib/librumpuser/rumpuser_int.h:1.10
--- src/lib/librumpuser/rumpuser_int.h:1.9	Thu Feb 20 01:24:49 2014
+++ src/lib/librumpuser/rumpuser_int.h	Tue Jul 22 22:41:58 2014
@@ -1,4 +1,4 @@
-/*	

CVS commit: src/lib/librumpuser

2014-07-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jul 14 10:36:33 UTC 2014

Removed Files:
src/lib/librumpuser: rumpuser_cache.c

Log Message:
Remove unused file.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 src/lib/librumpuser/rumpuser_cache.c

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



CVS commit: src/lib/librumpuser

2014-07-10 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Thu Jul 10 08:17:43 UTC 2014

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

Log Message:
Reinstate include of netdb.h, needed on some cross builds


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/librumpuser/rumpuser.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.60 src/lib/librumpuser/rumpuser.c:1.61
--- src/lib/librumpuser/rumpuser.c:1.60	Wed Jul  9 23:41:40 2014
+++ src/lib/librumpuser/rumpuser.c	Thu Jul 10 08:17:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.60 2014/07/09 23:41:40 justin Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.61 2014/07/10 08:17:43 justin 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.60 2014/07/09 23:41:40 justin Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.61 2014/07/10 08:17:43 justin Exp $);
 #endif /* !lint */
 
 #include sys/stat.h
@@ -38,6 +38,7 @@ __RCSID($NetBSD: rumpuser.c,v 1.60 2014
 #include assert.h
 #include errno.h
 #include fcntl.h
+#include netdb.h
 #include signal.h
 #include stdarg.h
 #include stdint.h



CVS commit: src/lib/librumpuser

2014-07-09 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Wed Jul  9 23:41:40 UTC 2014

Modified Files:
src/lib/librumpuser: Makefile rumpuser.c
Added Files:
src/lib/librumpuser: rumpuser_file.c rumpuser_mem.c

Log Message:
Split out file and memory access in librumpuser

This allows alternate implementations to reuse these parts, and the file
parts will at the next hypercall revision be moved to their own driver.

Discussed with pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/librumpuser/Makefile
cvs rdiff -u -r1.59 -r1.60 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r0 -r1.1 src/lib/librumpuser/rumpuser_file.c \
src/lib/librumpuser/rumpuser_mem.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/Makefile
diff -u src/lib/librumpuser/Makefile:1.18 src/lib/librumpuser/Makefile:1.19
--- src/lib/librumpuser/Makefile:1.18	Tue Jun 17 08:42:35 2014
+++ src/lib/librumpuser/Makefile	Wed Jul  9 23:41:40 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.18 2014/06/17 08:42:35 alnsn Exp $
+#	$NetBSD: Makefile,v 1.19 2014/07/09 23:41:40 justin Exp $
 #
 
 .include bsd.own.mk
@@ -20,6 +20,7 @@ CPPFLAGS+=	-DLIBRUMPUSER
 SRCS=		rumpuser.c
 SRCS+=		rumpuser_pth.c
 SRCS+=		rumpuser_component.c rumpuser_bio.c
+SRCS+=		rumpuser_file.c rumpuser_mem.c
 
 SRCS+=		rumpuser_errtrans.c rumpuser_sigtrans.c
 

Index: src/lib/librumpuser/rumpuser.c
diff -u src/lib/librumpuser/rumpuser.c:1.59 src/lib/librumpuser/rumpuser.c:1.60
--- src/lib/librumpuser/rumpuser.c:1.59	Wed Apr  2 13:54:42 2014
+++ src/lib/librumpuser/rumpuser.c	Wed Jul  9 23:41:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.59 2014/04/02 13:54:42 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.60 2014/07/09 23:41:40 justin Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,34 +28,16 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser.c,v 1.59 2014/04/02 13:54:42 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.60 2014/07/09 23:41:40 justin Exp $);
 #endif /* !lint */
 
-#include sys/ioctl.h
-#include sys/mman.h
-#include sys/uio.h
 #include sys/stat.h
 #include sys/time.h
-
-#ifdef __NetBSD__
-#include sys/disk.h
-#include sys/disklabel.h
-#include sys/dkio.h
-#endif
-
-#if defined(__NetBSD__) || defined(__FreeBSD__) || \
-defined(__DragonFly__) || defined(__APPLE__)
-#define	__BSD__
-#endif
-
-#if defined(__BSD__)
-#include sys/sysctl.h
-#endif
+#include sys/types.h
 
 #include assert.h
 #include errno.h
 #include fcntl.h
-#include netdb.h
 #include signal.h
 #include stdarg.h
 #include stdint.h
@@ -103,342 +85,6 @@ rumpuser_init(int version, const struct 
 }
 
 int
-rumpuser_getfileinfo(const char *path, uint64_t *sizep, int *ftp)
-{
-	struct stat sb;
-	uint64_t size = 0;
-	int needsdev = 0, rv = 0, ft = 0;
-	int fd = -1;
-
-	if (stat(path, sb) == -1) {
-		rv = errno;
-		goto out;
-	}
-
-	switch (sb.st_mode  S_IFMT) {
-	case S_IFDIR:
-		ft = RUMPUSER_FT_DIR;
-		break;
-	case S_IFREG:
-		ft = RUMPUSER_FT_REG;
-		break;
-	case S_IFBLK:
-		ft = RUMPUSER_FT_BLK;
-		needsdev = 1;
-		break;
-	case S_IFCHR:
-		ft = RUMPUSER_FT_CHR;
-		needsdev = 1;
-		break;
-	default:
-		ft = RUMPUSER_FT_OTHER;
-		break;
-	}
-
-	if (!needsdev) {
-		size = sb.st_size;
-	} else if (sizep) {
-		/*
-		 * Welcome to the jungle.  Of course querying the kernel
-		 * for a device partition size is supposed to be far from
-		 * trivial.  On NetBSD we use ioctl.  On $other platform
-		 * we have a problem.  We try the lseek trick and just
-		 * fail if that fails.  Platform specific code can later
-		 * be written here if appropriate.
-		 *
-		 * On NetBSD we hope and pray that for block devices nobody
-		 * else is holding them open, because otherwise the kernel
-		 * will not permit us to open it.  Thankfully, this is
-		 * usually called only in bootstrap and then we can
-		 * forget about it.
-		 */
-#ifndef __NetBSD__
-		off_t off;
-
-		fd = open(path, O_RDONLY);
-		if (fd == -1) {
-			rv = errno;
-			goto out;
-		}
-
-		off = lseek(fd, 0, SEEK_END);
-		if (off != 0) {
-			size = off;
-			goto out;
-		}
-		fprintf(stderr, error: device size query not implemented on 
-		this platform\n);
-		rv = EOPNOTSUPP;
-		goto out;
-#else
-		struct disklabel lab;
-		struct partition *parta;
-		struct dkwedge_info dkw;
-
-		fd = open(path, O_RDONLY);
-		if (fd == -1) {
-			rv = errno;
-			goto out;
-		}
-
-		if (ioctl(fd, DIOCGDINFO, lab) == 0) {
-			parta = lab.d_partitions[DISKPART(sb.st_rdev)];
-			size = (uint64_t)lab.d_secsize * parta-p_size;
-			goto out;
-		}
-
-		if (ioctl(fd, DIOCGWEDGEINFO, dkw) == 0) {
-			/*
-			 * XXX: should use DIOCGDISKINFO to query
-			 * sector size, but that requires proplib,
-			 * so just don't bother for now.  it's nice
-			 * that something as difficult as figuring out
-			 * a partition's size has been made so easy.
-			 */
-			size = dkw.dkw_size  

CVS commit: src/lib/librumpuser

2014-06-23 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jun 23 12:38:18 UTC 2014

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

Log Message:
Hrmph, revert previous pending another fix.  I tested it yesterday with
a slightly older tree, and of course it doesn't work anymore ...


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/lib/librumpuser/rumpuser_pth.c:1.42
--- src/lib/librumpuser/rumpuser_pth.c:1.41	Sun Jun 22 20:17:23 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Mon Jun 23 12:38:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.41 2014/06/22 20:17:23 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.42 2014/06/23 12:38:18 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.41 2014/06/22 20:17:23 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.42 2014/06/23 12:38:18 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -87,7 +87,7 @@ rumpuser_thread_create(void *(*f)(void *
 	for (i = 0; i  10; i++) {
 		const struct timespec ts = {0, 10*1000*1000};
 
-		KLOCK_WRAP(rv = pthread_create(ptidp, pattr, f, arg));
+		rv = pthread_create(ptidp, pattr, f, arg);
 		if (rv != EAGAIN)
 			break;
 		nanosleep(ts, NULL);



CVS commit: src/lib/librumpuser

2014-06-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Jun 22 20:17:23 UTC 2014

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

Log Message:
Wrap pthread_create().  Shouldn't really have a functional effect,
apart from testing that rumpuser_thread_create() can actually survive
an unschedule/schedule cycle (which may or may not be necessary with
other hypercall implementations).


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/lib/librumpuser/rumpuser_pth.c:1.41
--- src/lib/librumpuser/rumpuser_pth.c:1.40	Wed Apr  2 17:09:23 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Sun Jun 22 20:17:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.40 2014/04/02 17:09:23 justin Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.41 2014/06/22 20:17:23 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.40 2014/04/02 17:09:23 justin Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.41 2014/06/22 20:17:23 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -87,7 +87,7 @@ rumpuser_thread_create(void *(*f)(void *
 	for (i = 0; i  10; i++) {
 		const struct timespec ts = {0, 10*1000*1000};
 
-		rv = pthread_create(ptidp, pattr, f, arg);
+		KLOCK_WRAP(rv = pthread_create(ptidp, pattr, f, arg));
 		if (rv != EAGAIN)
 			break;
 		nanosleep(ts, NULL);



CVS commit: src/lib/librumpuser

2014-06-17 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Jun 17 06:43:21 UTC 2014

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

Log Message:
For consistency with other files in the same directory
don't include sys/cdefs.h before __RCSID.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/librumpuser/rumpuser_pth_dummy.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_dummy.c
diff -u src/lib/librumpuser/rumpuser_pth_dummy.c:1.16 src/lib/librumpuser/rumpuser_pth_dummy.c:1.17
--- src/lib/librumpuser/rumpuser_pth_dummy.c:1.16	Wed May 15 14:52:49 2013
+++ src/lib/librumpuser/rumpuser_pth_dummy.c	Tue Jun 17 06:43:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth_dummy.c,v 1.16 2013/05/15 14:52:49 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth_dummy.c,v 1.17 2014/06/17 06:43:21 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -27,9 +27,8 @@
 
 #include rumpuser_port.h
 
-#include sys/cdefs.h
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth_dummy.c,v 1.16 2013/05/15 14:52:49 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth_dummy.c,v 1.17 2014/06/17 06:43:21 alnsn Exp $);
 #endif /* !lint */
 
 #include sys/time.h



CVS commit: src/lib/librumpuser

2014-06-17 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Jun 17 08:42:35 UTC 2014

Modified Files:
src/lib/librumpuser: Makefile

Log Message:
Antti objected to including rumpuser_sync_icache. Exclude it from the build.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/librumpuser/Makefile

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/Makefile
diff -u src/lib/librumpuser/Makefile:1.17 src/lib/librumpuser/Makefile:1.18
--- src/lib/librumpuser/Makefile:1.17	Tue Jun 17 06:31:47 2014
+++ src/lib/librumpuser/Makefile	Tue Jun 17 08:42:35 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2014/06/17 06:31:47 alnsn Exp $
+#	$NetBSD: Makefile,v 1.18 2014/06/17 08:42:35 alnsn Exp $
 #
 
 .include bsd.own.mk
@@ -20,7 +20,6 @@ CPPFLAGS+=	-DLIBRUMPUSER
 SRCS=		rumpuser.c
 SRCS+=		rumpuser_pth.c
 SRCS+=		rumpuser_component.c rumpuser_bio.c
-SRCS+=		rumpuser_cache.c
 
 SRCS+=		rumpuser_errtrans.c rumpuser_sigtrans.c
 



CVS commit: src/lib/librumpuser

2014-06-17 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Tue Jun 17 09:53:59 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Applications are not supposed to and do not need to include features.h 
explicitly


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.32 src/lib/librumpuser/rumpuser_port.h:1.33
--- src/lib/librumpuser/rumpuser_port.h:1.32	Wed Apr  2 17:09:23 2014
+++ src/lib/librumpuser/rumpuser_port.h	Tue Jun 17 09:53:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.32 2014/04/02 17:09:23 justin Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.33 2014/06/17 09:53:59 justin Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -58,7 +58,6 @@
 #define _XOPEN_SOURCE 600
 #define _BSD_SOURCE
 #define _GNU_SOURCE
-#include features.h
 #endif
 
 #ifdef __ANDROID__



CVS commit: src/lib/librumpuser

2014-06-16 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jun 16 21:07:28 UTC 2014

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

Log Message:
Add __RCSID.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/librumpuser/rumpuser_bio.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_bio.c
diff -u src/lib/librumpuser/rumpuser_bio.c:1.7 src/lib/librumpuser/rumpuser_bio.c:1.8
--- src/lib/librumpuser/rumpuser_bio.c:1.7	Wed May 15 14:58:24 2013
+++ src/lib/librumpuser/rumpuser_bio.c	Mon Jun 16 21:07:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_bio.c,v 1.7 2013/05/15 14:58:24 pooka Exp $	*/
+/*	$NetBSD: rumpuser_bio.c,v 1.8 2014/06/16 21:07:28 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -27,6 +27,10 @@
 
 #include rumpuser_port.h
 
+#if !defined(lint)
+__RCSID($NetBSD: rumpuser_bio.c,v 1.8 2014/06/16 21:07:28 alnsn Exp $);
+#endif /* !lint */
+
 #include sys/types.h
 
 #include assert.h



CVS commit: src/lib/librumpuser

2014-06-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sat Jun 14 11:52:43 UTC 2014

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

Log Message:
Remove one more symbol reference to librump (missed in previous commit
to this file)


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.65 src/lib/librumpuser/rumpuser_sp.c:1.66
--- src/lib/librumpuser/rumpuser_sp.c:1.65	Fri May 23 16:57:42 2014
+++ src/lib/librumpuser/rumpuser_sp.c	Sat Jun 14 11:52:42 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.65 2014/05/23 16:57:42 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.66 2014/06/14 11:52:42 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.65 2014/05/23 16:57:42 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.66 2014/06/14 11:52:42 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -1194,7 +1194,7 @@ spserver(void *arg)
 	int rv;
 	unsigned int nfds, maxidx;
 
-	rump_pub_lwproc_switch(sarg-sps_l);
+	lwproc_switch(sarg-sps_l);
 
 	for (idx = 0; idx  MAXCLI; idx++) {
 		pfdlist[idx].fd = -1;



CVS commit: src/lib/librumpuser

2014-05-23 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri May 23 11:04:03 UTC 2014

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

Log Message:
Create remote clients with standard file descriptors open.  Fixes at
least editing a new file with ed in rumpremote (because ed calls
isatty(0) in case a file does not exist).


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.63 src/lib/librumpuser/rumpuser_sp.c:1.64
--- src/lib/librumpuser/rumpuser_sp.c:1.63	Fri Feb 28 13:55:36 2014
+++ src/lib/librumpuser/rumpuser_sp.c	Fri May 23 11:04:03 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.63 2014/02/28 13:55:36 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.64 2014/05/23 11:04:03 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.63 2014/02/28 13:55:36 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.64 2014/05/23 11:04:03 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -957,6 +957,7 @@ schedulework(struct spclient *spc, enum 
 struct spservarg {
 	int sps_sock;
 	connecthook_fn sps_connhook;
+	struct lwp *sps_l;
 };
 
 static void
@@ -983,7 +984,7 @@ handlereq(struct spclient *spc)
 			comm[commlen] = '\0';
 
 			if ((error = lwproc_rfork(spc,
-			RUMP_RFCFDG, comm)) != 0) {
+			RUMP_RFFDG, comm)) != 0) {
 shutdown(spc-spc_fd, SHUT_RDWR);
 			}
 
@@ -1193,6 +1194,8 @@ spserver(void *arg)
 	int rv;
 	unsigned int nfds, maxidx;
 
+	rump_pub_lwproc_switch(sarg-sps_l);
+
 	for (idx = 0; idx  MAXCLI; idx++) {
 		pfdlist[idx].fd = -1;
 		pfdlist[idx].events = POLLIN;
@@ -1317,6 +1320,7 @@ rumpuser_sp_init(const char *url,
 	pthread_t pt;
 	struct spservarg *sarg;
 	struct sockaddr *sap;
+	struct lwp *calllwp;
 	char *p;
 	unsigned idx = 0; /* XXXgcc */
 	int error, s;
@@ -1361,13 +1365,28 @@ rumpuser_sp_init(const char *url,
 		fprintf(stderr, rump_sp: server bind failed\n);
 		goto out;
 	}
-
 	if (listen(s, MAXCLI) == -1) {
 		error = errno;
 		fprintf(stderr, rump_sp: server listen failed\n);
 		goto out;
 	}
 
+	/*
+	 * Create a context that the client threads run off of.
+	 * We fork a dedicated context so as to ensure that all
+	 * client threads get the same set of fd's.  We fork off
+	 * of whatever context the caller is running in (most likely
+	 * an implicit thread, i.e. proc 1) and do not
+	 * close fd's.  The assumption is that people who
+	 * write servers (i.e. kernels) know what they're doing.
+	 */
+	calllwp = rump_pub_lwproc_curlwp();
+	if ((error = rump_pub_lwproc_rfork(RUMP_RFFDG)) != 0) {
+		fprintf(stderr, rump_sp: rfork failed);
+		goto out;
+	}
+	sarg-sps_l = rump_pub_lwproc_curlwp();
+	rump_pub_lwproc_switch(calllwp);
 	if ((error = pthread_create(pt, NULL, spserver, sarg)) != 0) {
 		fprintf(stderr, rump_sp: cannot create wrkr thread\n);
 		goto out;
@@ -1389,8 +1408,8 @@ rumpuser_sp_fini(void *arg)
 	}
 
 	/*
-	 * stuff response into the socket, since this process is just
-	 * about to exit
+	 * stuff response into the socket, since the rump kernel container
+	 * is just about to exit
 	 */
 	if (spc  spc-spc_syscallreq)
 		send_syscall_resp(spc, spc-spc_syscallreq, 0, retval);
@@ -1399,4 +1418,9 @@ rumpuser_sp_fini(void *arg)
 		shutdown(spclist[0].spc_fd, SHUT_RDWR);
 		spfini = 1;
 	}
+
+	/*
+	 * could release thread, but don't bother, since the container
+	 * will be stone dead in a moment.
+	 */
 }



CVS commit: src/lib/librumpuser

2014-05-23 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri May 23 16:57:42 UTC 2014

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

Log Message:
do previous the right way to avoid rumpuser linkage dependency on librump


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.64 src/lib/librumpuser/rumpuser_sp.c:1.65
--- src/lib/librumpuser/rumpuser_sp.c:1.64	Fri May 23 11:04:03 2014
+++ src/lib/librumpuser/rumpuser_sp.c	Fri May 23 16:57:42 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.64 2014/05/23 11:04:03 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.65 2014/05/23 16:57:42 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.64 2014/05/23 11:04:03 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.65 2014/05/23 16:57:42 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -1380,13 +1380,13 @@ rumpuser_sp_init(const char *url,
 	 * close fd's.  The assumption is that people who
 	 * write servers (i.e. kernels) know what they're doing.
 	 */
-	calllwp = rump_pub_lwproc_curlwp();
-	if ((error = rump_pub_lwproc_rfork(RUMP_RFFDG)) != 0) {
+	calllwp = lwproc_curlwp();
+	if ((error = lwproc_rfork(NULL, RUMP_RFFDG, spserver)) != 0) {
 		fprintf(stderr, rump_sp: rfork failed);
 		goto out;
 	}
-	sarg-sps_l = rump_pub_lwproc_curlwp();
-	rump_pub_lwproc_switch(calllwp);
+	sarg-sps_l = lwproc_curlwp();
+	lwproc_switch(calllwp);
 	if ((error = pthread_create(pt, NULL, spserver, sarg)) != 0) {
 		fprintf(stderr, rump_sp: cannot create wrkr thread\n);
 		goto out;



CVS commit: src/lib/librumpuser

2014-04-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr  2 13:54:42 UTC 2014

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

Log Message:
Always use sysconf() to query host processor count instead of separate
tricks for each platform.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/lib/librumpuser/rumpuser.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.58 src/lib/librumpuser/rumpuser.c:1.59
--- src/lib/librumpuser/rumpuser.c:1.58	Sun Mar 16 10:23:59 2014
+++ src/lib/librumpuser/rumpuser.c	Wed Apr  2 13:54:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.58 2014/03/16 10:23:59 njoly Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.59 2014/04/02 13:54:42 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.58 2014/03/16 10:23:59 njoly Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.59 2014/04/02 13:54:42 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -536,32 +536,9 @@ rumpuser_clock_sleep(int enum_rumpclock,
 static int
 gethostncpu(void)
 {
-	int ncpu = 1;
+	int ncpu = 1; /* unknown, really */
 
-#if defined(__BSD__)
-	size_t sz = sizeof(ncpu);
-
-	sysctlbyname(hw.ncpu, ncpu, sz, NULL, 0);
-#elif defined(__linux__) || defined(__CYGWIN__)
-	FILE *fp;
-	char *line = NULL;
-	size_t n = 0;
-
-	/* If anyone knows a better way, I'm all ears */
-	if ((fp = fopen(/proc/cpuinfo, r)) != NULL) {
-		ncpu = 0;
-		while (getline(line, n, fp) != -1) {
-			if (strncmp(line,
-			processor, sizeof(processor)-1) == 0)
-				ncpu++;
-		}
-		if (ncpu == 0)
-			ncpu = 1;
-		free(line);
-		fclose(fp);
-	}
-#elif __sun__
-	/* XXX: this is just a rough estimate ... */
+#ifdef _SC_NPROCESSORS_ONLN
 	ncpu = sysconf(_SC_NPROCESSORS_ONLN);
 #endif
 	



CVS commit: src/lib/librumpuser

2014-03-21 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 21 12:07:10 UTC 2014

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

Log Message:
set threadname for correct pthread_t


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/lib/librumpuser/rumpuser_pth.c:1.37
--- src/lib/librumpuser/rumpuser_pth.c:1.36	Mon Mar 10 22:37:51 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Fri Mar 21 12:07:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.36 2014/03/10 22:37:51 justin Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.37 2014/03/21 12:07:10 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.36 2014/03/10 22:37:51 justin Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.37 2014/03/21 12:07:10 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -95,7 +95,7 @@ rumpuser_thread_create(void *(*f)(void *
 
 #if defined(__NetBSD__)
 	if (rv == 0  thrname)
-		pthread_setname_np(ptid, thrname, NULL);
+		pthread_setname_np(*ptidp, thrname, NULL);
 #elif defined(__linux__)
 	/*
 	 * The pthread_setname_np() call varies from one Linux distro to
@@ -103,7 +103,7 @@ rumpuser_thread_create(void *(*f)(void *
 	 */
 #if 0
 	if (rv == 0  thrname)
-		pthread_setname_np(ptid, thrname);
+		pthread_setname_np(*ptidp, thrname);
 #endif
 #endif
 



CVS commit: src/lib/librumpuser

2014-03-21 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 21 12:28:54 UTC 2014

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

Log Message:
use a probe result to decide which pthread_setname_np() to use


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/librumpuser/rumpuser_port.h
cvs rdiff -u -r1.37 -r1.38 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_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.29 src/lib/librumpuser/rumpuser_port.h:1.30
--- src/lib/librumpuser/rumpuser_port.h:1.29	Tue Feb 25 20:58:18 2014
+++ src/lib/librumpuser/rumpuser_port.h	Fri Mar 21 12:28:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.29 2014/02/25 20:58:18 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.30 2014/03/21 12:28:54 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -20,6 +20,9 @@
 #define PLATFORM_HAS_FSYNC_RANGE
 #define PLATFORM_HAS_NBSYSCTL
 #define PLATFORM_HAS_NBFILEHANDLE
+#ifndef HAVE_PTHREAD_SETNAME3
+#define HAVE_PTHREAD_SETNAME3
+#endif
 
 #define PLATFORM_HAS_STRSUFTOLL
 #define PLATFORM_HAS_SETGETPROGNAME

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.37 src/lib/librumpuser/rumpuser_pth.c:1.38
--- src/lib/librumpuser/rumpuser_pth.c:1.37	Fri Mar 21 12:07:10 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Fri Mar 21 12:28:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.37 2014/03/21 12:07:10 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.38 2014/03/21 12:28: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.37 2014/03/21 12:07:10 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.38 2014/03/21 12:28:54 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -93,19 +93,13 @@ rumpuser_thread_create(void *(*f)(void *
 		nanosleep(ts, NULL);
 	}
 
-#if defined(__NetBSD__)
-	if (rv == 0  thrname)
+#if defined(HAVE_PTHREAD_SETNAME_3)
+	if (rv == 0  thrname) {
 		pthread_setname_np(*ptidp, thrname, NULL);
-#elif defined(__linux__)
-	/*
-	 * The pthread_setname_np() call varies from one Linux distro to
-	 * another.  Comment out the call pending autoconf support.
-	 */
-#if 0
+#elif defined(HAVE_PTHREAD_SETNAME_2)
 	if (rv == 0  thrname)
 		pthread_setname_np(*ptidp, thrname);
 #endif
-#endif
 
 	if (joinable) {
 		assert(ptcookie);



CVS commit: src/lib/librumpuser

2014-03-21 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 21 16:03:07 UTC 2014

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

Log Message:
fix braces


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/lib/librumpuser/rumpuser_pth.c:1.39
--- src/lib/librumpuser/rumpuser_pth.c:1.38	Fri Mar 21 12:28:54 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Fri Mar 21 16:03:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.38 2014/03/21 12:28:54 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.39 2014/03/21 16:03:07 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.38 2014/03/21 12:28:54 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.39 2014/03/21 16:03:07 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -96,9 +96,11 @@ rumpuser_thread_create(void *(*f)(void *
 #if defined(HAVE_PTHREAD_SETNAME_3)
 	if (rv == 0  thrname) {
 		pthread_setname_np(*ptidp, thrname, NULL);
+	}
 #elif defined(HAVE_PTHREAD_SETNAME_2)
-	if (rv == 0  thrname)
+	if (rv == 0  thrname) {
 		pthread_setname_np(*ptidp, thrname);
+	}
 #endif
 
 	if (joinable) {



CVS commit: src/lib/librumpuser

2014-03-21 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Mar 21 16:03:35 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
fix name of HAVE_PTHREAD_SETNAME_3


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.30 src/lib/librumpuser/rumpuser_port.h:1.31
--- src/lib/librumpuser/rumpuser_port.h:1.30	Fri Mar 21 12:28:54 2014
+++ src/lib/librumpuser/rumpuser_port.h	Fri Mar 21 16:03:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.30 2014/03/21 12:28:54 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.31 2014/03/21 16:03:35 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -20,8 +20,8 @@
 #define PLATFORM_HAS_FSYNC_RANGE
 #define PLATFORM_HAS_NBSYSCTL
 #define PLATFORM_HAS_NBFILEHANDLE
-#ifndef HAVE_PTHREAD_SETNAME3
-#define HAVE_PTHREAD_SETNAME3
+#ifndef HAVE_PTHREAD_SETNAME_3
+#define HAVE_PTHREAD_SETNAME_3
 #endif
 
 #define PLATFORM_HAS_STRSUFTOLL



CVS commit: src/lib/librumpuser

2014-03-16 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sun Mar 16 10:23:59 UTC 2014

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

Log Message:
Do not use uninitialized pointer if posix_memalign() fails.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/lib/librumpuser/rumpuser.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.57 src/lib/librumpuser/rumpuser.c:1.58
--- src/lib/librumpuser/rumpuser.c:1.57	Thu Feb 20 00:44:20 2014
+++ src/lib/librumpuser/rumpuser.c	Sun Mar 16 10:23:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.57 2014/02/20 00:44:20 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.58 2014/03/16 10:23:59 njoly 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.57 2014/02/20 00:44:20 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.58 2014/03/16 10:23:59 njoly Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -217,7 +217,7 @@ rumpuser_getfileinfo(const char *path, u
 int
 rumpuser_malloc(size_t howmuch, int alignment, void **memp)
 {
-	void *mem;
+	void *mem = NULL;
 	int rv;
 
 	if (alignment == 0)



CVS commit: src/lib/librumpuser

2014-03-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 13 11:21:54 UTC 2014

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

Log Message:
Do not process linkmaps if there is exactly one link map present
(i.e. there is no ld.so).  Makes statically linked rump kernels work on
glibc (at least for me).

based on some discussion with Justin Cormack


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/librumpuser/rumpuser_dl.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_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.25 src/lib/librumpuser/rumpuser_dl.c:1.26
--- src/lib/librumpuser/rumpuser_dl.c:1.25	Wed Oct 30 13:08:14 2013
+++ src/lib/librumpuser/rumpuser_dl.c	Thu Mar 13 11:21:54 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.25 2013/10/30 13:08:14 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.26 2014/03/13 11:21:54 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.25 2013/10/30 13:08:14 pooka Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.26 2014/03/13 11:21:54 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -390,6 +390,22 @@ rumpuser_dl_bootstrap(rump_modinit_fn do
 	origmap = mainmap;
 
 	/*
+	 * Use a heuristic to determine if we are static linked.
+	 * A dynamically linked binary should always have at least
+	 * two objects: itself and ld.so.
+	 *
+	 * In a statically linked binary with glibc the linkmap
+	 * contains some info that leads to a segfault.  Since we
+	 * can't really do anything useful in here without ld.so, just
+	 * simply bail and let the symbol references in librump do the
+	 * right things.
+	 */
+	if (origmap-l_next == NULL  origmap-l_prev == NULL) {
+		dlclose(mainhandle);
+		return;
+	}
+
+	/*
 	 * Process last-first because that's the most probable
 	 * order for dependencies
 	 */



CVS commit: src/lib/librumpuser

2014-03-13 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Fri Mar 14 01:18:39 UTC 2014

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

Log Message:
If dlopen returns NULL assume we are statically linked and return,
rather than getting a warning when dlinfo fails.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/librumpuser/rumpuser_dl.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_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.26 src/lib/librumpuser/rumpuser_dl.c:1.27
--- src/lib/librumpuser/rumpuser_dl.c:1.26	Thu Mar 13 11:21:54 2014
+++ src/lib/librumpuser/rumpuser_dl.c	Fri Mar 14 01:18:39 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.26 2014/03/13 11:21:54 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.27 2014/03/14 01:18:39 justin Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.26 2014/03/13 11:21:54 pooka Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.27 2014/03/14 01:18:39 justin Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -382,6 +382,9 @@ rumpuser_dl_bootstrap(rump_modinit_fn do
 	int error;
 
 	mainhandle = dlopen(NULL, RTLD_NOW);
+	/* Will be null if statically linked so just return */
+	if (mainhandle == NULL)
+		return;
 	if (dlinfo(mainhandle, RTLD_DI_LINKMAP, mainmap) == -1) {
 		fprintf(stderr, warning: rumpuser module bootstrap 
 		failed: %s\n, dlerror());



CVS commit: src/lib/librumpuser

2014-03-10 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Mon Mar 10 22:37:51 UTC 2014

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

Log Message:
Revert conversion to __thread as breaks on archs without TLS support


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/lib/librumpuser/rumpuser_pth.c:1.36
--- src/lib/librumpuser/rumpuser_pth.c:1.35	Sun Mar  9 23:01:11 2014
+++ src/lib/librumpuser/rumpuser_pth.c	Mon Mar 10 22:37:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.35 2014/03/09 23:01:11 justin Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.36 2014/03/10 22:37:51 justin 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.35 2014/03/09 23:01:11 justin Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.36 2014/03/10 22:37:51 justin Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -622,15 +622,13 @@ rumpuser_cv_has_waiters(struct rumpuser_
  * curlwp
  */
 
-static __thread struct lwp *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.
  */
 #if 0
-static pthread_key_t curlwpkey;
-
 struct rumpuser_lwp {
 	struct lwp *l;
 	LIST_ENTRY(rumpuser_lwp) l_entries;
@@ -718,12 +716,12 @@ rumpuser_curlwpop(int enum_rumplwpop, st
 	case RUMPUSER_LWP_DESTROY:
 		break;
 	case RUMPUSER_LWP_SET:
-		assert(curlwp == NULL);
-		curlwp = l;
+		assert(pthread_getspecific(curlwpkey) == NULL);
+		pthread_setspecific(curlwpkey, l);
 		break;
 	case RUMPUSER_LWP_CLEAR:
-		assert(curlwp == l);
-		curlwp = NULL;
+		assert(pthread_getspecific(curlwpkey) == l);
+		pthread_setspecific(curlwpkey, NULL);
 		break;
 	}
 }
@@ -732,7 +730,7 @@ struct lwp *
 rumpuser_curlwp(void)
 {
 
-	return curlwp;
+	return pthread_getspecific(curlwpkey);
 }
 #endif
 
@@ -740,5 +738,5 @@ rumpuser_curlwp(void)
 void
 rumpuser__thrinit(void)
 {
-
+	pthread_key_create(curlwpkey, NULL);
 }



CVS commit: src/lib/librumpuser

2014-03-09 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sun Mar  9 23:01:11 UTC 2014

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

Log Message:
Use __thread rather than pthread_getspecific for rumpuser curlwp.
This has better performance and curlwp is a performance bottleneck
in rump kernel code.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/lib/librumpuser/rumpuser_pth.c:1.35
--- src/lib/librumpuser/rumpuser_pth.c:1.34	Sun Oct 27 16:39:46 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Sun Mar  9 23:01:11 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.34 2013/10/27 16:39:46 rmind Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.35 2014/03/09 23:01:11 justin 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.34 2013/10/27 16:39:46 rmind Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.35 2014/03/09 23:01:11 justin Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -622,13 +622,15 @@ rumpuser_cv_has_waiters(struct rumpuser_
  * curlwp
  */
 
-static pthread_key_t curlwpkey;
+static __thread struct lwp *curlwp;
 
 /*
  * the if0'd curlwp implementation is not used by this hypervisor,
  * but serves as test code to check that the intended usage works.
  */
 #if 0
+static pthread_key_t curlwpkey;
+
 struct rumpuser_lwp {
 	struct lwp *l;
 	LIST_ENTRY(rumpuser_lwp) l_entries;
@@ -716,12 +718,12 @@ rumpuser_curlwpop(int enum_rumplwpop, st
 	case RUMPUSER_LWP_DESTROY:
 		break;
 	case RUMPUSER_LWP_SET:
-		assert(pthread_getspecific(curlwpkey) == NULL);
-		pthread_setspecific(curlwpkey, l);
+		assert(curlwp == NULL);
+		curlwp = l;
 		break;
 	case RUMPUSER_LWP_CLEAR:
-		assert(pthread_getspecific(curlwpkey) == l);
-		pthread_setspecific(curlwpkey, NULL);
+		assert(curlwp == l);
+		curlwp = NULL;
 		break;
 	}
 }
@@ -730,7 +732,7 @@ struct lwp *
 rumpuser_curlwp(void)
 {
 
-	return pthread_getspecific(curlwpkey);
+	return curlwp;
 }
 #endif
 
@@ -738,5 +740,5 @@ rumpuser_curlwp(void)
 void
 rumpuser__thrinit(void)
 {
-	pthread_key_create(curlwpkey, NULL);
+
 }



CVS commit: src/lib/librumpuser

2014-02-28 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Feb 28 13:55:36 UTC 2014

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

Log Message:
Fix locking SNAFU.

Is someone can explain why the code worked for 3+ years with multiple
different pthread implementations, I'll buy you a banana.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.62 src/lib/librumpuser/rumpuser_sp.c:1.63
--- src/lib/librumpuser/rumpuser_sp.c:1.62	Wed Jan  8 01:45:29 2014
+++ src/lib/librumpuser/rumpuser_sp.c	Fri Feb 28 13:55:36 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.62 2014/01/08 01:45:29 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.63 2014/02/28 13:55:36 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.62 2014/01/08 01:45:29 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.63 2014/02/28 13:55:36 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -1021,7 +1021,7 @@ handlereq(struct spclient *spc)
 	break;
 }
 			}
-			pthread_mutex_lock(pfmtx);
+			pthread_mutex_unlock(pfmtx);
 			spcfreebuf(spc);
 
 			if (!pf) {



CVS commit: src/lib/librumpuser

2014-02-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Feb 25 20:58:18 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
emulate printflike properly to avoid fatal error on clang


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

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.28 src/lib/librumpuser/rumpuser_port.h:1.29
--- src/lib/librumpuser/rumpuser_port.h:1.28	Thu Jan 16 16:03:33 2014
+++ src/lib/librumpuser/rumpuser_port.h	Tue Feb 25 20:58:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.28 2014/01/16 16:03:33 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.29 2014/02/25 20:58:18 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -161,8 +161,12 @@ posix_memalign(void **ptr, size_t align,
 #endif
 
 #ifndef __printflike
+#ifdef __GNUC__
+#define __printflike(a,b) __attribute__((__format__ (__printf__,a,b)))
+#else
 #define __printflike(a,b)
 #endif
+#endif
 
 #ifndef __noinline
 #ifdef __GNUC__



CVS commit: src/lib/librumpuser

2014-02-19 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Feb 20 00:43:26 UTC 2014

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

Log Message:
document rumpuser_kill()


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.17 src/lib/librumpuser/rumpuser.3:1.18
--- src/lib/librumpuser/rumpuser.3:1.17	Fri Feb 14 00:33:51 2014
+++ src/lib/librumpuser/rumpuser.3	Thu Feb 20 00:43:26 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.17 2014/02/14 00:33:51 pooka Exp $
+.\ $NetBSD: rumpuser.3,v 1.18 2014/02/20 00:43:26 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -23,7 +23,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd February 13, 2013
+.Dd February 19, 2014
 .Dt RUMPUSER 3
 .Os
 .Sh NAME
@@ -428,6 +428,51 @@ on the console.
 .Fn rumpuser_dprintf const char *fmt ...
 .Pp
 Do output based on printf-like parameters.
+.Ss Signals
+.Pp
+A rump kernel should be able to send signals to client programs
+due to some standard interfaces including signal delivery in their
+specifications.
+Examples of these interfaces include
+.Xr setitimer 2
+and
+.Xr write 2 .
+The
+.Fn rumpuser_kill
+function advises the hypercall implementation to raise a signal for the
+process containing the rump kernel.
+.Pp
+.Ft int
+.Fn rumpuser_kill int64_t pid int sig
+.Pp
+.Bl -tag -width xenum_rumpclock
+.It Fa pid
+The pid of the rump kernel process that the signal is directed to.
+This value may be used as the hypervisor as a hint on how to deliver
+the signal.
+The value
+.Dv RUMPUSER_PID_SELF
+may also be specified to indicate no hint.
+This value will be removed in a future version of the hypercall interface.
+.It Fa sig
+Number of signal to raise.
+The value is in NetBSD signal number namespace.
+In case the host has a native representation for signals, the
+value should be translated before the signal is raised.
+In case there is no mapping between
+.Fa sig
+and native signals (if any), the behavior is implementation-defined.
+.El
+.Pp
+A rump kernel will ignore the return value of this hypercall.
+The only implication of not implementing
+.Fn rumpuser_kill
+is that some application programs may not experience expected behavior
+for standard interfaces.
+.Pp
+As an aside,the
+.Xr rump_sp 7
+protocol provides equivalent functionality for remote clients.
 .Ss Random pool
 .Ft int
 .Fn rumpuser_getrandom void *buf size_t buflen int flags size_t *retp



CVS commit: src/lib/librumpuser

2014-02-19 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Feb 20 00:44:20 UTC 2014

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

Log Message:
make implementation of rumpuser_kill() match the documentation


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/lib/librumpuser/rumpuser.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.56 src/lib/librumpuser/rumpuser.c:1.57
--- src/lib/librumpuser/rumpuser.c:1.56	Thu Feb 20 00:42:27 2014
+++ src/lib/librumpuser/rumpuser.c	Thu Feb 20 00:44:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.56 2014/02/20 00:42:27 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.57 2014/02/20 00:44:20 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.56 2014/02/20 00:42:27 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.57 2014/02/20 00:44:20 pooka Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -645,21 +645,12 @@ rumpuser_dprintf(const char *format, ...
 int
 rumpuser_kill(int64_t pid, int rumpsig)
 {
-	int rv, sig;
-	int error;
+	int sig;
 
 	sig = rumpuser__sig_rump2host(rumpsig);
-	if (pid == RUMPUSER_PID_SELF) {
-		error = raise(sig);
-	} else {
-		error = kill((pid_t)pid, sig);
-	}
-	if (error == -1)
-		rv = errno;
-	else
-		rv = 0;
-
-	ET(rv);
+	if (sig  0)
+		raise(sig);
+	return 0;
 }
 
 int



CVS commit: src/lib/librumpuser

2014-02-19 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Feb 20 01:24:49 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_int.h

Log Message:
remember to commit this file too


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/librumpuser/rumpuser_int.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_int.h
diff -u src/lib/librumpuser/rumpuser_int.h:1.8 src/lib/librumpuser/rumpuser_int.h:1.9
--- src/lib/librumpuser/rumpuser_int.h:1.8	Tue Apr 30 12:39:20 2013
+++ src/lib/librumpuser/rumpuser_int.h	Thu Feb 20 01:24:49 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_int.h,v 1.8 2013/04/30 12:39:20 pooka Exp $	*/
+/*	$NetBSD: rumpuser_int.h,v 1.9 2014/02/20 01:24:49 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -94,6 +94,7 @@ do {	\
 	}\
 } while (/*CONSTCOND*/0)
 
+int  rumpuser__sig_rump2host(int);
 int  rumpuser__errtrans(int);
 #ifdef __NetBSD__
 #define ET(_v_) return (_v_);



CVS commit: src/lib/librumpuser

2014-02-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Feb 14 00:33:51 UTC 2014

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

Log Message:
minor clarification: rumpuser_thread_create() is used to create the host
thread context for kernel threads, never for application threads.

per discussion with justin


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/lib/librumpuser/rumpuser.3:1.17
--- src/lib/librumpuser/rumpuser.3:1.16	Mon Jul 22 12:36:56 2013
+++ src/lib/librumpuser/rumpuser.3	Fri Feb 14 00:33:51 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumpuser.3,v 1.16 2013/07/22 12:36:56 njoly Exp $
+.\ $NetBSD: rumpuser.3,v 1.17 2014/02/14 00:33:51 pooka Exp $
 .\
 .\ Copyright (c) 2013 Antti Kantee.  All rights reserved.
 .\
@@ -23,7 +23,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd May 15, 2013
+.Dd February 13, 2013
 .Dt RUMPUSER 3
 .Os
 .Sh NAME
@@ -455,7 +455,9 @@ The number of random bytes written into
 .Fa int priority int cpuidx void **cookie
 .Fc
 .Pp
-Create a thread.
+Create a schedulable host thread context.
+The rump kernel will call this interface when it creates a kernel thread.
+The scheduling policy for the new thread is defined by the hypervisor.
 In case the hypervisor wants to optimize the scheduling of the
 threads, it can perform heuristics on the
 .Fa thrname ,
@@ -465,7 +467,8 @@ and
 parameters.
 .Bl -tag -width xenum_rumpclock
 .It Fa fun
-function that the new thread must call
+function that the new thread must call.
+This call will never return.
 .It Fa arg
 argument to be passed to
 .Fa fun



CVS commit: src/lib/librumpuser

2014-01-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jan 16 16:03:33 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Do not force _FILE_OFFSET_BITS=64 here.  It's no longer strictly speaking
required (rumpuser interface no longer uses off_t) and force-defining
it causes foo() to magically become foo64() on glibc (even on 64bit
platforms).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.27 src/lib/librumpuser/rumpuser_port.h:1.28
--- src/lib/librumpuser/rumpuser_port.h:1.27	Wed Jan 15 16:53:15 2014
+++ src/lib/librumpuser/rumpuser_port.h	Thu Jan 16 16:03:33 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.27 2014/01/15 16:53:15 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.28 2014/01/16 16:03:33 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -47,7 +47,6 @@
 #ifdef __linux__
 #define _XOPEN_SOURCE 600
 #define _BSD_SOURCE
-#define _FILE_OFFSET_BITS 64
 #define _GNU_SOURCE
 #include features.h
 #endif
@@ -55,8 +54,6 @@
 #if defined(__sun__)
 #  if defined(RUMPUSER_NO_FILE_OFFSET_BITS)
 #undef _FILE_OFFSET_BITS
-#  else
-#define _FILE_OFFSET_BITS 64
 #  endif
 #endif
 



CVS commit: src/lib/librumpuser

2014-01-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jan 15 16:53:16 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
Make setprogname() a nop where it's not supported.


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

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.26 src/lib/librumpuser/rumpuser_port.h:1.27
--- src/lib/librumpuser/rumpuser_port.h:1.26	Wed Jan  8 11:04:47 2014
+++ src/lib/librumpuser/rumpuser_port.h	Wed Jan 15 16:53:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.26 2014/01/08 11:04:47 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.27 2014/01/15 16:53:15 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -237,4 +237,8 @@ do {		\
 } while (/*CONSTCOND*/0)
 #endif
 
+#ifndef PLATFORM_HAS_SETGETPROGNAME
+#define setprogname(a)
+#endif
+
 #endif /* _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_ */



CVS commit: src/lib/librumpuser

2014-01-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jan  8 11:04:47 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
remove obsolete definitions


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

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.25 src/lib/librumpuser/rumpuser_port.h:1.26
--- src/lib/librumpuser/rumpuser_port.h:1.25	Wed Jan  8 01:47:31 2014
+++ src/lib/librumpuser/rumpuser_port.h	Wed Jan  8 11:04:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.25 2014/01/08 01:47:31 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.26 2014/01/08 11:04:47 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -21,8 +21,6 @@
 #define PLATFORM_HAS_NBSYSCTL
 #define PLATFORM_HAS_NBFILEHANDLE
 
-#define PLATFORM_HAS_DISKLABEL
-#define PLATFORM_HAS_NBMODULES
 #define PLATFORM_HAS_STRSUFTOLL
 #define PLATFORM_HAS_SETGETPROGNAME
 



CVS commit: src/lib/librumpuser

2014-01-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jan  8 01:45:29 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h rumpuser_sp.c sp_common.c

Log Message:
OpenBSD support

from Justin Cormack via github


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/librumpuser/rumpuser_port.h
cvs rdiff -u -r1.61 -r1.62 src/lib/librumpuser/rumpuser_sp.c
cvs rdiff -u -r1.37 -r1.38 src/lib/librumpuser/sp_common.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_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.23 src/lib/librumpuser/rumpuser_port.h:1.24
--- src/lib/librumpuser/rumpuser_port.h:1.23	Wed Dec 18 20:24:04 2013
+++ src/lib/librumpuser/rumpuser_port.h	Wed Jan  8 01:45:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.23 2013/12/18 20:24:04 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.24 2014/01/08 01:45:29 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -94,7 +94,7 @@ clock_gettime(clockid_t clk, struct time
 
 /* maybe this should be !__NetBSD__ ? */
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)	\
-|| defined(__DragonFly__) || defined(__APPLE__) || defined(__CYGWIN__)
+|| defined(__DragonFly__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__CYGWIN__)
 #include errno.h
 #include stdlib.h
 #include string.h

Index: src/lib/librumpuser/rumpuser_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.61 src/lib/librumpuser/rumpuser_sp.c:1.62
--- src/lib/librumpuser/rumpuser_sp.c:1.61	Fri Nov  1 23:22:13 2013
+++ src/lib/librumpuser/rumpuser_sp.c	Wed Jan  8 01:45:29 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.61 2013/11/01 23:22:13 pooka Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.62 2014/01/08 01:45:29 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.61 2013/11/01 23:22:13 pooka Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.62 2014/01/08 01:45:29 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -90,7 +90,7 @@ static char banner[MAXBANNER];
 
 
 /* how to use atomic ops on Linux? */
-#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__OpenBSD__)
 static pthread_mutex_t discomtx = PTHREAD_MUTEX_INITIALIZER;
 
 static void

Index: src/lib/librumpuser/sp_common.c
diff -u src/lib/librumpuser/sp_common.c:1.37 src/lib/librumpuser/sp_common.c:1.38
--- src/lib/librumpuser/sp_common.c:1.37	Tue Dec 31 00:25:17 2013
+++ src/lib/librumpuser/sp_common.c	Wed Jan  8 01:45:29 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: sp_common.c,v 1.37 2013/12/31 00:25:17 pooka Exp $	*/
+/*  $NetBSD: sp_common.c,v 1.38 2014/01/08 01:45:29 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -36,6 +36,7 @@
 #include sys/queue.h
 #include sys/socket.h
 #include sys/un.h
+#include sys/uio.h
 
 #include arpa/inet.h
 #include netinet/in.h



CVS commit: src/lib/librumpuser

2014-01-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jan  8 01:47:31 UTC 2014

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
do as the comment says and #if defined(every_other) || defined(platform) || ...
=== #if !defined(__NetBSD__)


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.24 src/lib/librumpuser/rumpuser_port.h:1.25
--- src/lib/librumpuser/rumpuser_port.h:1.24	Wed Jan  8 01:45:29 2014
+++ src/lib/librumpuser/rumpuser_port.h	Wed Jan  8 01:47:31 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.24 2014/01/08 01:45:29 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.25 2014/01/08 01:47:31 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -92,9 +92,8 @@ clock_gettime(clockid_t clk, struct time
 #include sys/types.h
 #include sys/param.h
 
-/* maybe this should be !__NetBSD__ ? */
-#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)	\
-|| defined(__DragonFly__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__CYGWIN__)
+/* NetBSD is the only(?) platform with getenv_r() */
+#if !defined(__NetBSD__)
 #include errno.h
 #include stdlib.h
 #include string.h



CVS commit: src/lib/librumpuser

2013-12-30 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Dec 31 00:25:17 UTC 2013

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

Log Message:
Do not export symbols which don't need to be exported.

via Justin Cormack


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/librumpuser/sp_common.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/sp_common.c
diff -u src/lib/librumpuser/sp_common.c:1.36 src/lib/librumpuser/sp_common.c:1.37
--- src/lib/librumpuser/sp_common.c:1.36	Mon Jan 14 21:00:16 2013
+++ src/lib/librumpuser/sp_common.c	Tue Dec 31 00:25:17 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: sp_common.c,v 1.36 2013/01/14 21:00:16 pooka Exp $	*/
+/*  $NetBSD: sp_common.c,v 1.37 2013/12/31 00:25:17 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -714,7 +714,7 @@ success(void)
 	return 0;
 }
 
-struct {
+static struct {
 	const char *id;
 	int domain;
 	socklen_t slen;



CVS commit: src/lib/librumpuser

2013-12-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Dec 18 20:24:04 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
remove outdated comment (since quite a few months ago)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.22 src/lib/librumpuser/rumpuser_port.h:1.23
--- src/lib/librumpuser/rumpuser_port.h:1.22	Sun Oct 27 16:39:46 2013
+++ src/lib/librumpuser/rumpuser_port.h	Wed Dec 18 20:24:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.22 2013/10/27 16:39:46 rmind Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.23 2013/12/18 20:24:04 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -6,12 +6,6 @@
  * Maybe should try to use the infrastructure in tools/compat instead?
  */
 
-/*
- * XXX:
- * There is currently no errno translation for the error values reported
- * by the hypercall layer.
- */
-
 #ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 #define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
 



CVS commit: src/lib/librumpuser

2013-11-01 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Nov  1 23:22:13 UTC 2013

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

Log Message:
Workaround a gcc -Wuninitilized whine

github/buildrump.sh issue #44


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/librumpuser/rumpuser_sp.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_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.60 src/lib/librumpuser/rumpuser_sp.c:1.61
--- src/lib/librumpuser/rumpuser_sp.c:1.60	Sun Oct 27 16:39:46 2013
+++ src/lib/librumpuser/rumpuser_sp.c	Fri Nov  1 23:22:13 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.60 2013/10/27 16:39:46 rmind Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.61 2013/11/01 23:22:13 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_sp.c,v 1.60 2013/10/27 16:39:46 rmind Exp $);
+__RCSID($NetBSD: rumpuser_sp.c,v 1.61 2013/11/01 23:22:13 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -1318,7 +1318,7 @@ rumpuser_sp_init(const char *url,
 	struct spservarg *sarg;
 	struct sockaddr *sap;
 	char *p;
-	unsigned idx;
+	unsigned idx = 0; /* XXXgcc */
 	int error, s;
 
 	p = strdup(url);



CVS commit: src/lib/librumpuser

2013-10-30 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Oct 30 12:30:32 UTC 2013

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

Log Message:
glibc on MIPS uses the same DYN d_ptr variant as NetBSD and musl.

from Justin Cormack


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/librumpuser/rumpuser_dl.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_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.22 src/lib/librumpuser/rumpuser_dl.c:1.23
--- src/lib/librumpuser/rumpuser_dl.c:1.22	Sun Oct 27 16:39:46 2013
+++ src/lib/librumpuser/rumpuser_dl.c	Wed Oct 30 12:30:32 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.22 2013/10/27 16:39:46 rmind Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.23 2013/10/30 12:30:32 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.22 2013/10/27 16:39:46 rmind Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.23 2013/10/30 12:30:32 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -150,8 +150,7 @@ do {	\
  * On Solaris and DragonFly / FreeBSD, the main object works differently
  * ... h.
  */
-#if defined(__GLIBC__)
-/* XXX: not true for e.g. MIPS, but we'll cross that hurdle later */
+#if defined(__GLIBC__)  !defined(__mips__)
 #define adjptr(_map_, _ptr_) ((void *)(_ptr_))
 #elif defined(__sun__) || defined(__DragonFly__) || defined(__FreeBSD__)
 #define adjptr(_map_, _ptr_) \



CVS commit: src/lib/librumpuser

2013-10-30 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Oct 30 12:55:53 UTC 2013

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

Log Message:
need to include stdint.h before rump/rumpuser.h


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/librumpuser/rumpuser_dl.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_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.23 src/lib/librumpuser/rumpuser_dl.c:1.24
--- src/lib/librumpuser/rumpuser_dl.c:1.23	Wed Oct 30 12:30:32 2013
+++ src/lib/librumpuser/rumpuser_dl.c	Wed Oct 30 12:55:53 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.23 2013/10/30 12:30:32 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.24 2013/10/30 12:55:53 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.23 2013/10/30 12:30:32 pooka Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.24 2013/10/30 12:55:53 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -50,6 +50,7 @@ __RCSID($NetBSD: rumpuser_dl.c,v 1.23 2
 #include dlfcn.h
 #include errno.h
 #include fcntl.h
+#include stdint,h
 #include stdio.h
 #include stdlib.h
 #include string.h



CVS commit: src/lib/librumpuser

2013-10-30 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Oct 30 13:08:14 UTC 2013

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

Log Message:
Oh, stdint.h isn't written with a comma ...


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/librumpuser/rumpuser_dl.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_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.24 src/lib/librumpuser/rumpuser_dl.c:1.25
--- src/lib/librumpuser/rumpuser_dl.c:1.24	Wed Oct 30 12:55:53 2013
+++ src/lib/librumpuser/rumpuser_dl.c	Wed Oct 30 13:08:14 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.24 2013/10/30 12:55:53 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.25 2013/10/30 13:08:14 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.24 2013/10/30 12:55:53 pooka Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.25 2013/10/30 13:08:14 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -50,7 +50,7 @@ __RCSID($NetBSD: rumpuser_dl.c,v 1.24 2
 #include dlfcn.h
 #include errno.h
 #include fcntl.h
-#include stdint,h
+#include stdint.h
 #include stdio.h
 #include stdlib.h
 #include string.h



CVS commit: src/lib/librumpuser

2013-10-27 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Oct 27 16:39:47 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser.c rumpuser_dl.c rumpuser_port.h
rumpuser_pth.c rumpuser_sp.c

Log Message:
librumpuser: add some #ifdef __APPLE__ and missing bits to build it on OS X.
OK pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r1.21 -r1.22 src/lib/librumpuser/rumpuser_dl.c \
src/lib/librumpuser/rumpuser_port.h
cvs rdiff -u -r1.33 -r1.34 src/lib/librumpuser/rumpuser_pth.c
cvs rdiff -u -r1.59 -r1.60 src/lib/librumpuser/rumpuser_sp.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.54 src/lib/librumpuser/rumpuser.c:1.55
--- src/lib/librumpuser/rumpuser.c:1.54	Wed Aug 14 08:29:25 2013
+++ src/lib/librumpuser/rumpuser.c	Sun Oct 27 16:39:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.54 2013/08/14 08:29:25 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.55 2013/10/27 16:39:46 rmind 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.54 2013/08/14 08:29:25 pooka Exp $);
+__RCSID($NetBSD: rumpuser.c,v 1.55 2013/10/27 16:39:46 rmind Exp $);
 #endif /* !lint */
 
 #include sys/ioctl.h
@@ -43,7 +43,12 @@ __RCSID($NetBSD: rumpuser.c,v 1.54 2013
 #include sys/dkio.h
 #endif
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || \
+defined(__DragonFly__) || defined(__APPLE__)
+#define	__BSD__
+#endif
+
+#if defined(__BSD__)
 #include sys/sysctl.h
 #endif
 
@@ -533,7 +538,7 @@ gethostncpu(void)
 {
 	int ncpu = 1;
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#if defined(__BSD__)
 	size_t sz = sizeof(ncpu);
 
 	sysctlbyname(hw.ncpu, ncpu, sz, NULL, 0);
@@ -607,7 +612,7 @@ rumpuser_putchar(int c)
 	putchar(c);
 }
 
-void
+__dead void
 rumpuser_exit(int rv)
 {
 

Index: src/lib/librumpuser/rumpuser_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.21 src/lib/librumpuser/rumpuser_dl.c:1.22
--- src/lib/librumpuser/rumpuser_dl.c:1.21	Tue Jul 30 18:56:03 2013
+++ src/lib/librumpuser/rumpuser_dl.c	Sun Oct 27 16:39:46 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.21 2013/07/30 18:56:03 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.22 2013/10/27 16:39:46 rmind Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.21 2013/07/30 18:56:03 pooka Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.22 2013/10/27 16:39:46 rmind Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -48,7 +48,6 @@ __RCSID($NetBSD: rumpuser_dl.c,v 1.21 2
 #include assert.h
 
 #include dlfcn.h
-#include elf.h
 #include errno.h
 #include fcntl.h
 #include stdio.h
@@ -61,6 +60,7 @@ __RCSID($NetBSD: rumpuser_dl.c,v 1.21 2
 #if defined(__ELF__)  (defined(__NetBSD__) || defined(__FreeBSD__)	\
 || (defined(__sun__)  defined(__svr4__))) || defined(__linux__)	\
 || defined(__DragonFly__)
+#include elf.h
 #include link.h
 
 static size_t symtabsize = 0, strtabsize = 0;
Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.21 src/lib/librumpuser/rumpuser_port.h:1.22
--- src/lib/librumpuser/rumpuser_port.h:1.21	Tue Sep 10 17:58:39 2013
+++ src/lib/librumpuser/rumpuser_port.h	Sun Oct 27 16:39:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.21 2013/09/10 17:58:39 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.22 2013/10/27 16:39:46 rmind Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -68,15 +68,43 @@
 #  endif
 #endif
 
+#if defined(__APPLE__)
+#define	__dead		__attribute__((noreturn))
+#include sys/cdefs.h
+
+#include libkern/OSAtomic.h
+#define	atomic_inc_uint(x)	OSAtomicIncrement32((volatile int32_t *)(x))
+#define	atomic_dec_uint(x)	OSAtomicDecrement32((volatile int32_t *)(x))
+
+#include sys/time.h
+
+#define	CLOCK_REALTIME	0
+typedef int clockid_t;
+
+static inline int
+clock_gettime(clockid_t clk, struct timespec *ts)
+{
+	struct timeval tv;
+
+	if (gettimeofday(tv, 0) == 0) {
+		ts-tv_sec = tv.tv_sec;
+		ts-tv_nsec = tv.tv_usec * 1000;
+	}
+	return -1;
+}
+
+#endif
+
 #include sys/types.h
 #include sys/param.h
 
 /* maybe this should be !__NetBSD__ ? */
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)	\
-|| defined(__DragonFly__) || defined(__CYGWIN__)
+|| defined(__DragonFly__) || defined(__APPLE__) || defined(__CYGWIN__)
 #include errno.h
 #include stdlib.h
 #include string.h
+#include inttypes.h
 
 /* this is inline simply to make this header self-contained */
 static inline int 

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u 

CVS commit: src/lib/librumpuser

2013-09-25 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Sep 26 00:41:51 UTC 2013

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

Log Message:
Give RUMP mutex and rwlock their own cache-line.  Also give a separate
cache-line for the rwlock's reader counter.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.32 src/lib/librumpuser/rumpuser_pth.c:1.33
--- src/lib/librumpuser/rumpuser_pth.c:1.32	Tue Sep 24 23:45:16 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Thu Sep 26 00:41:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.32 2013/09/24 23:45:16 rmind Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.33 2013/09/26 00:41:51 rmind Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,11 +28,12 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.32 2013/09/24 23:45:16 rmind Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.33 2013/09/26 00:41:51 rmind Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
 #if defined(__NetBSD__)
+#include sys/param.h
 #include sys/atomic.h
 #endif
 
@@ -50,6 +51,19 @@ __RCSID($NetBSD: rumpuser_pth.c,v 1.32 
 
 #include rumpuser_int.h
 
+#if defined(__NetBSD__)
+static void *
+aligned_alloc(size_t size)
+{
+	void *ptr;
+
+	size = roundup2(size, COHERENCY_UNIT);
+	return posix_memalign(ptr, COHERENCY_UNIT, size) ? NULL : ptr;
+}
+#else
+#define	aligned_alloc(sz)	malloc(sz)
+#endif
+
 int
 rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname,
 	int joinable, int priority, int cpuidx, void **ptcookie)
@@ -134,7 +148,7 @@ rumpuser_mutex_init(struct rumpuser_mtx 
 {
 	pthread_mutexattr_t att;
 
-	NOFAIL(*mtx = malloc(sizeof(struct rumpuser_mtx)));
+	NOFAIL(*mtx = aligned_alloc(sizeof(struct rumpuser_mtx)));
 
 	pthread_mutexattr_init(att);
 	pthread_mutexattr_settype(att, PTHREAD_MUTEX_ERRORCHECK);
@@ -244,6 +258,7 @@ rumpuser_mutex_owner(struct rumpuser_mtx
 
 struct rumpuser_rw {
 	pthread_rwlock_t pthrw;
+	char pad[64 - sizeof(pthread_rwlock_t)];
 	pthread_spinlock_t spin;
 	unsigned int readers;
 	struct lwp *writer;
@@ -300,7 +315,7 @@ rw_clearwriter(struct rumpuser_rw *rw)
 	rw-writer = NULL;
 }
 
-static void
+static inline void
 rw_readup(struct rumpuser_rw *rw)
 {
 
@@ -313,7 +328,7 @@ rw_readup(struct rumpuser_rw *rw)
 #endif
 }
 
-static void
+static inline void
 rw_readdown(struct rumpuser_rw *rw)
 {
 
@@ -331,7 +346,7 @@ void
 rumpuser_rw_init(struct rumpuser_rw **rw)
 {
 
-	NOFAIL(*rw = malloc(sizeof(struct rumpuser_rw)));
+	NOFAIL(*rw = aligned_alloc(sizeof(struct rumpuser_rw)));
 	NOFAIL_ERRNO(pthread_rwlock_init(((*rw)-pthrw), NULL));
 	NOFAIL_ERRNO(pthread_spin_init(((*rw)-spin),PTHREAD_PROCESS_PRIVATE));
 	(*rw)-readers = 0;



CVS commit: src/lib/librumpuser

2013-09-24 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Tue Sep 24 23:45:16 UTC 2013

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

Log Message:
rumpuser_rwlock: replace internal pthread_spin_lock (for protecting reader
count) with atomic operations.  As pthread_spin_lock is not adaptive lock, it
can have hugely negative impact if contended here, especially with priority
inversions.  Now contended rwlock(9) no longer falls flat in RUMP kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/lib/librumpuser/rumpuser_pth.c:1.32
--- src/lib/librumpuser/rumpuser_pth.c:1.31	Mon Sep 23 10:35:20 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Tue Sep 24 23:45:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.31 2013/09/23 10:35:20 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.32 2013/09/24 23:45:16 rmind Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,10 +28,13 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_pth.c,v 1.31 2013/09/23 10:35:20 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.32 2013/09/24 23:45:16 rmind Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
+#if defined(__NetBSD__)
+#include sys/atomic.h
+#endif
 
 #include assert.h
 #include errno.h
@@ -242,7 +245,7 @@ rumpuser_mutex_owner(struct rumpuser_mtx
 struct rumpuser_rw {
 	pthread_rwlock_t pthrw;
 	pthread_spinlock_t spin;
-	int readers;
+	unsigned int readers;
 	struct lwp *writer;
 	int downgrade; /* someone is downgrading (hopefully lock holder ;) */
 };
@@ -251,14 +254,15 @@ static int
 rw_amwriter(struct rumpuser_rw *rw)
 {
 
-	return rw-writer == rumpuser_curlwp()  rw-readers == -1;
+	return rw-writer == rumpuser_curlwp()  rw-readers == (unsigned)-1;
 }
 
 static int
 rw_nreaders(struct rumpuser_rw *rw)
 {
+	unsigned nreaders = rw-readers;
 
-	return rw-readers  0 ? rw-readers : 0;
+	return nreaders != (unsigned)-1 ? nreaders : 0;
 }
 
 static int
@@ -283,7 +287,7 @@ rw_setwriter(struct rumpuser_rw *rw, int
 	}
 	assert(rw-readers == 0);
 	rw-writer = rumpuser_curlwp();
-	rw-readers = -1;
+	rw-readers = (unsigned)-1;
 	return 0;
 }
 
@@ -300,20 +304,27 @@ static void
 rw_readup(struct rumpuser_rw *rw)
 {
 
+#if defined(__NetBSD__)
+	atomic_inc_uint(rw-readers);
+#else
 	pthread_spin_lock(rw-spin);
-	assert(rw-readers = 0);
 	++rw-readers;
 	pthread_spin_unlock(rw-spin);
+#endif
 }
 
 static void
 rw_readdown(struct rumpuser_rw *rw)
 {
 
+#if defined(__NetBSD__)
+	atomic_dec_uint(rw-readers);
+#else
 	pthread_spin_lock(rw-spin);
 	assert(rw-readers  0);
 	--rw-readers;
 	pthread_spin_unlock(rw-spin);
+#endif
 }
 
 void



CVS commit: src/lib/librumpuser

2013-09-23 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Sep 23 10:35:20 UTC 2013

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

Log Message:
If pthread_create() fails with EAGAIN, try a few more times with short
sleeps in between.  If it helps, good.  If it doesn't, oh well, at
least we tried.  pthread_create() returning EAGAIN has been observed in
real life at least on Linux (buildrump.sh issue #40)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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.30 src/lib/librumpuser/rumpuser_pth.c:1.31
--- src/lib/librumpuser/rumpuser_pth.c:1.30	Wed May 15 14:52:49 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Mon Sep 23 10:35:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.30 2013/05/15 14:52:49 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.31 2013/09/23 10:35:20 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.30 2013/05/15 14:52:49 pooka Exp $);
+__RCSID($NetBSD: rumpuser_pth.c,v 1.31 2013/09/23 10:35:20 pooka Exp $);
 #endif /* !lint */
 
 #include sys/queue.h
@@ -54,7 +54,7 @@ rumpuser_thread_create(void *(*f)(void *
 	pthread_t ptid;
 	pthread_t *ptidp;
 	pthread_attr_t pattr;
-	int rv;
+	int rv, i;
 
 	if ((rv = pthread_attr_init(pattr)) != 0)
 		return rv;
@@ -67,7 +67,15 @@ rumpuser_thread_create(void *(*f)(void *
 		pthread_attr_setdetachstate(pattr, PTHREAD_CREATE_DETACHED);
 	}
 
-	rv = pthread_create(ptidp, pattr, f, arg);
+	for (i = 0; i  10; i++) {
+		const struct timespec ts = {0, 10*1000*1000};
+
+		rv = pthread_create(ptidp, pattr, f, arg);
+		if (rv != EAGAIN)
+			break;
+		nanosleep(ts, NULL);
+	}
+
 #if defined(__NetBSD__)
 	if (rv == 0  thrname)
 		pthread_setname_np(ptid, thrname, NULL);



CVS commit: src/lib/librumpuser

2013-09-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Sep 10 17:58:39 UTC 2013

Modified Files:
src/lib/librumpuser: rumpuser_port.h

Log Message:
more platform-specific qualifiers


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/librumpuser/rumpuser_port.h

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

Modified files:

Index: src/lib/librumpuser/rumpuser_port.h
diff -u src/lib/librumpuser/rumpuser_port.h:1.20 src/lib/librumpuser/rumpuser_port.h:1.21
--- src/lib/librumpuser/rumpuser_port.h:1.20	Mon Jul 22 08:58:31 2013
+++ src/lib/librumpuser/rumpuser_port.h	Tue Sep 10 17:58:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_port.h,v 1.20 2013/07/22 08:58:31 pooka Exp $	*/
+/*	$NetBSD: rumpuser_port.h,v 1.21 2013/09/10 17:58:39 pooka Exp $	*/
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -27,6 +27,11 @@
 #define PLATFORM_HAS_NBSYSCTL
 #define PLATFORM_HAS_NBFILEHANDLE
 
+#define PLATFORM_HAS_DISKLABEL
+#define PLATFORM_HAS_NBMODULES
+#define PLATFORM_HAS_STRSUFTOLL
+#define PLATFORM_HAS_SETGETPROGNAME
+
 #if __NetBSD_Prereq__(5,99,48)
 #define PLATFORM_HAS_NBQUOTA
 #endif



CVS commit: src/lib/librumpuser

2013-07-30 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jul 30 18:48:51 UTC 2013

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

Log Message:
Decide ET_DYN behavior based on __GLIBC__ instead of __linux__,
e.g. musl libc doesn't follow glibc behavior.

per discussions with a number of people


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/librumpuser/rumpuser_dl.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_dl.c
diff -u src/lib/librumpuser/rumpuser_dl.c:1.19 src/lib/librumpuser/rumpuser_dl.c:1.20
--- src/lib/librumpuser/rumpuser_dl.c:1.19	Tue Jun  4 15:17:28 2013
+++ src/lib/librumpuser/rumpuser_dl.c	Tue Jul 30 18:48:51 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.19 2013/06/04 15:17:28 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.20 2013/07/30 18:48:51 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: rumpuser_dl.c,v 1.19 2013/06/04 15:17:28 pooka Exp $);
+__RCSID($NetBSD: rumpuser_dl.c,v 1.20 2013/07/30 18:48:51 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -144,17 +144,20 @@ do {	\
 
 /*
  * On NetBSD, the dynamic section pointer values seem to be relative to
- * the address the dso is mapped at.  On Linux, they seem to contain
+ * the address the dso is mapped at.  On glibc, they seem to contain
  * the absolute address.  I couldn't find anything definite from a quick
  * read of the standard and therefore I will not go and figure beyond ifdef.
- * On Solaris and DragonFly, the main object works differently ... h.
+ * On Solaris and DragonFly / FreeBSD, the main object works differently
+ * ... h.
  */
-#if defined(__linux__)
+#if defined(__GLIBC__)
+/* XXX: not true for e.g. MIPS, but we'll cross that hurdle later */
 #define adjptr(_map_, _ptr_) ((void *)(_ptr_))
 #elif defined(__sun__) || defined(__DragonFly__) || defined(__FreeBSD__)
 #define adjptr(_map_, _ptr_) \
 (ismainobj ? (void *)(_ptr_) : (void *)(_map_-l_addr + (_ptr_)))
 #else
+/* NetBSD and some others, e.g. Linux + musl-libc */
 #define adjptr(_map_, _ptr_) ((void *)(_map_-l_addr + (_ptr_)))
 #endif
 



  1   2   3   >