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

2010-02-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Feb 18 12:32:30 UTC 2010

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
Also, don't try to figure out the size of devices if size matters not.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.48 src/sys/rump/librump/rumpuser/rumpuser.c:1.49
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.48	Thu Feb 18 12:21:28 2010
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Thu Feb 18 12:32:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.48 2010/02/18 12:21:28 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.49 2010/02/18 12:32:30 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.48 2010/02/18 12:21:28 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.49 2010/02/18 12:32:30 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -102,7 +102,7 @@
 
 	if (!needsdev) {
 		size = sb.st_size;
-	} else {
+	} else if (sizep) {
 		/*
 		 * Welcome to the jungle.  Of course querying the kernel
 		 * for a device partition size is supposed to be far from



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

2010-02-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Feb 18 12:21:28 UTC 2010

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
Allow NULL as size and file type pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.47 src/sys/rump/librump/rumpuser/rumpuser.c:1.48
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.47	Tue Dec  8 08:18:24 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Thu Feb 18 12:21:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.47 2009/12/08 08:18:24 stacktic Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.48 2010/02/18 12:21:28 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.47 2009/12/08 08:18:24 stacktic Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.48 2010/02/18 12:21:28 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -69,10 +69,11 @@
 #include "rumpuser_int.h"
 
 int
-rumpuser_getfileinfo(const char *path, uint64_t *size, int *ft, int *error)
+rumpuser_getfileinfo(const char *path, uint64_t *sizep, int *ftp, int *error)
 {
 	struct stat sb;
-	int needsdev = 0;
+	uint64_t size;
+	int needsdev = 0, rv = 0, ft;
 
 	if (stat(path, &sb) == -1) {
 		*error = errno;
@@ -81,26 +82,26 @@
 
 	switch (sb.st_mode & S_IFMT) {
 	case S_IFDIR:
-		*ft = RUMPUSER_FT_DIR;
+		ft = RUMPUSER_FT_DIR;
 		break;
 	case S_IFREG:
-		*ft = RUMPUSER_FT_REG;
+		ft = RUMPUSER_FT_REG;
 		break;
 	case S_IFBLK:
-		*ft = RUMPUSER_FT_BLK;
+		ft = RUMPUSER_FT_BLK;
 		needsdev = 1;
 		break;
 	case S_IFCHR:
-		*ft = RUMPUSER_FT_CHR;
+		ft = RUMPUSER_FT_CHR;
 		needsdev = 1;
 		break;
 	default:
-		*ft = RUMPUSER_FT_OTHER;
+		ft = RUMPUSER_FT_OTHER;
 		break;
 	}
 
 	if (!needsdev) {
-		*size = sb.st_size;
+		size = sb.st_size;
 	} else {
 		/*
 		 * Welcome to the jungle.  Of course querying the kernel
@@ -123,19 +124,21 @@
 		fd = open(path, O_RDONLY);
 		if (fd == -1) {
 			*error = errno;
-			return -1;
+			rv = -1;
+			goto out;
 		}
 
 		off = lseek(fd, 0, SEEK_END);
 		close(fd);
 		if (off != 0) {
-			*size = off;
-			return 0;
+			size = off;
+			goto out;
 		}
 		fprintf(stderr, "error: device size query not implemented on "
 		"this platform\n");
 		*error = EOPNOTSUPP;
-		return -1;
+		rv = -1;
+		goto out;
 #else
 		struct disklabel lab;
 		struct partition *parta;
@@ -144,21 +147,29 @@
 		fd = open(path, O_RDONLY);
 		if (fd == -1) {
 			*error = errno;
-			return -1;
+			rv = -1;
+			goto out;
 		}
 
 		if (ioctl(fd, DIOCGDINFO, &lab) == -1) {
 			*error = errno;
-			return -1;
+			rv = -1;
+			goto out;
 		}
 		close(fd);
 
 		parta = &lab.d_partitions[DISKPART(sb.st_rdev)];
-		*size = (uint64_t)lab.d_secsize * parta->p_size;
+		size = (uint64_t)lab.d_secsize * parta->p_size;
 #endif /* __NetBSD__ */
 	}
 
-	return 0;
+ out:
+	if (rv == 0 && sizep)
+		*sizep = size;
+	if (rv == 0 && ftp)
+		*ftp = ft;
+
+	return rv;
 }
 
 int



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

2009-12-08 Thread Arnaud Ysmal
Module Name:src
Committed By:   stacktic
Date:   Tue Dec  8 08:18:25 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c rumpuser_pth.c
rumpuser_pth_dummy.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/rump/librump/rumpuser/rumpuser.c
cvs rdiff -u -r1.39 -r1.40 src/sys/rump/librump/rumpuser/rumpuser_pth.c
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.46 src/sys/rump/librump/rumpuser/rumpuser.c:1.47
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.46	Thu Nov 19 13:42:29 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Tue Dec  8 08:18:24 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.46 2009/11/19 13:42:29 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.47 2009/12/08 08:18:24 stacktic Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.46 2009/11/19 13:42:29 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.47 2009/12/08 08:18:24 stacktic Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -346,7 +346,7 @@
 	/* check against <0 instead of ==-1 to get typing below right */
 	if (rv < 0)
 		rv = 0;
-		
+
 	/* LINTED: see above */
 	biodone(biodonecookie, rv, error);
 }
@@ -391,7 +391,7 @@
 	biodone(biodonecookie, rv, error);
 }
 
-ssize_t 
+ssize_t
 rumpuser_readv(int fd, const struct rumpuser_iovec *riov, int iovcnt,
 	int *error)
 {
@@ -418,7 +418,7 @@
 	return rv;
 }
 
-ssize_t 
+ssize_t
 rumpuser_writev(int fd, const struct rumpuser_iovec *riov, int iovcnt,
 	int *error)
 {

Index: src/sys/rump/librump/rumpuser/rumpuser_pth.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.39 src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.40
--- src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.39	Thu Nov 19 14:44:58 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth.c	Tue Dec  8 08:18:24 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.39 2009/11/19 14:44:58 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.40 2009/12/08 08:18:24 stacktic Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.39 2009/11/19 14:44:58 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.40 2009/12/08 08:18:24 stacktic Exp $");
 #endif /* !lint */
 
 #ifdef __linux__
@@ -175,7 +175,7 @@
 		rumpuser__klock(0);
 		biodone(rua->rua_bp, (size_t)rv, error);
 		rumpuser__kunlock(0, &dummy);
-			
+
 		rua->rua_bp = NULL;
 
 		NOFAIL_ERRNO(pthread_mutex_lock(&rumpuser_aio_mtx.pthmtx));

Index: src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c:1.7 src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c:1.8
--- src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c:1.7	Thu Nov 19 14:44:58 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c	Tue Dec  8 08:18:24 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth_dummy.c,v 1.7 2009/11/19 14:44:58 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth_dummy.c,v 1.8 2009/12/08 08:18:24 stacktic Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.7 2009/11/19 14:44:58 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.8 2009/12/08 08:18:24 stacktic Exp $");
 #endif /* !lint */
 
 #include 
@@ -230,7 +230,7 @@
 {
 
 }
- 
+
 /*ARGSUSED*/
 void
 rumpuser_cv_wait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx)



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

2009-12-08 Thread Arnaud Ysmal
Module Name:src
Committed By:   stacktic
Date:   Tue Dec  8 08:12:49 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_dl.c

Log Message:
Fixed build without module bootstrap


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_dl.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.10 src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.11
--- src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.10	Mon Dec  7 17:38:16 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_dl.c	Tue Dec  8 08:12:49 2009
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.10 2009/12/07 17:38:16 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.11 2009/12/08 08:12:49 stacktic Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.10 2009/12/07 17:38:16 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.11 2009/12/08 08:12:49 stacktic Exp $");
 
 #include 
 #include 
@@ -404,7 +404,8 @@
 }
 #else
 void
-rumpuser_dl_module_bootstrap(void)
+rumpuser_dl_module_bootstrap(rump_modinit_fn domodinit,
+	rump_symload_fn symload)
 {
 
 	fprintf(stderr, "Warning, dlinfo() unsupported on host?\n");



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

2009-12-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Dec  7 17:38:16 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_dl.c

Log Message:
add comment


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_dl.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.9 src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.10
--- src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.9	Thu Nov 26 15:44:26 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_dl.c	Mon Dec  7 17:38:16 2009
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.9 2009/11/26 15:44:26 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.10 2009/12/07 17:38:16 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.9 2009/11/26 15:44:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.10 2009/12/07 17:38:16 pooka Exp $");
 
 #include 
 #include 
@@ -391,6 +391,9 @@
 	free(symtab);
 	free(strtab);
 
+	/*
+	 * Next, load modules from dynlibs.
+	 */
 	do {
 		couldload = 0;
 		map = origmap;



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

2009-11-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 26 15:44:26 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_dl.c

Log Message:
* load symbols only up to actual size of symbol table instead of size
  we allocated for storing the table
* trimm unused end off of table before passing to the kernel


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_dl.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.8 src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.9
--- src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.8	Thu Nov 26 10:57:26 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_dl.c	Thu Nov 26 15:44:26 2009
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.8 2009/11/26 10:57:26 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.9 2009/11/26 15:44:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.8 2009/11/26 10:57:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.9 2009/11/26 15:44:26 pooka Exp $");
 
 #include 
 #include 
@@ -363,8 +363,33 @@
 		if (strstr(map->l_name, "librump") != NULL)
 			error = getsymbols(map);
 	}
-	if (error == 0)
-		symload(symtab, symtabsize, strtab, strtabsize);
+
+	if (error == 0) {
+		void *trimmedsym, *trimmedstr;
+
+		/*
+		 * Allocate optimum-sized memory for storing tables
+		 * and feed to kernel.  If memory allocation fails,
+		 * just give the ones with extra context (although
+		 * I'm pretty sure we'll die moments later due to
+		 * memory running out).
+		 */
+		if ((trimmedsym = malloc(symtaboff)) != NULL) {
+			memcpy(trimmedsym, symtab, symtaboff);
+		} else {
+			trimmedsym = symtab;
+			symtab = NULL;
+		}
+		if ((trimmedstr = malloc(strtaboff)) != NULL) {
+			memcpy(trimmedstr, strtab, strtaboff);
+		} else {
+			trimmedstr = strtab;
+			strtab = NULL;
+		}
+		symload(trimmedsym, symtaboff, trimmedstr, strtaboff);
+	}
+	free(symtab);
+	free(strtab);
 
 	do {
 		couldload = 0;



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

2009-11-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 26 10:57:26 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_dl.c

Log Message:
Shuffle types around and add some random typecasts to make lint
and LP64 gcc sign comparison shut up.  I'm not sure what benefit
this brings apart from introducing some more bugs for everyone's
debugging pleasure.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_dl.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.7 src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.8
--- src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.7	Thu Nov 26 09:50:38 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_dl.c	Thu Nov 26 10:57:26 2009
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.7 2009/11/26 09:50:38 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.8 2009/11/26 10:57:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.7 2009/11/26 09:50:38 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.8 2009/11/26 10:57:26 pooka Exp $");
 
 #include 
 #include 
@@ -59,7 +59,7 @@
 
 static void *
 reservespace(void *store, size_t *storesize,
-	size_t storeoff, int64_t required)
+	size_t storeoff, size_t required)
 {
 	size_t chunk, newsize;
 
@@ -88,9 +88,11 @@
 do {	\
 	if (eident == ELFCLASS32) {	\
 		Elf32_Ehdr *ehdr = base;\
+		/*LINTED*/		\
 		result = ehdr->thevar;	\
 	} else {			\
 		Elf64_Ehdr *ehdr = base;\
+		/*LINTED*/		\
 		result = ehdr->thevar;	\
 	}\
 } while (/*CONSTCOND*/0)
@@ -99,9 +101,11 @@
 do {	\
 	if (eident == ELFCLASS32) {	\
 		Elf32_Shdr *shdr = base;\
+		/*LINTED*/		\
 		result = shdr[n].thevar;\
 	} else {			\
 		Elf64_Shdr *shdr = base;\
+		/*LINTED*/		\
 		result = shdr[n].thevar;\
 	}\
 } while (/*CONSTCOND*/0)
@@ -154,9 +158,10 @@
 	int i = 0, fd;
 	char *str_base;
 	void *syms_base = NULL; /* XXXgcc */
-	int64_t cursymsize, curstrsize;
+	size_t cursymsize, curstrsize;
 	void *shdr_base;
-	size_t shnum, shsize;
+	size_t shsize;
+	int shnum;
 	uint64_t shoff;
 	void *ed_base;
 	uint64_t ed_tag;
@@ -180,7 +185,8 @@
 	EHDR_GETMEMBER(libbase, e_shentsize, shsize);
 	EHDR_GETMEMBER(libbase, e_shoff, shoff);
 	shdr_base = malloc(shnum * shsize);
-	if (pread(fd, shdr_base, shnum * shsize, (off_t)shoff) != shnum*shsize){
+	if (pread(fd, shdr_base, shnum * shsize, (off_t)shoff)
+	!= (ssize_t)(shnum*shsize)){
 		sverrno = errno;
 		fprintf(stderr, "read section headers for %s failed\n",
 		map->l_name);
@@ -188,7 +194,7 @@
 		close(fd);
 		return sverrno;
 	}
-	cursymsize = -1;
+	cursymsize = (size_t)-1;
 	for (i = 1; i <= shnum; i++) {
 		int shtype;
 
@@ -200,7 +206,7 @@
 	}
 	free(shdr_base);
 	close(fd);
-	if (cursymsize == -1) {
+	if (cursymsize == (size_t)-1) {
 		fprintf(stderr, "could not find dynsym size from %s\n",
 		map->l_name);
 		return ENOEXEC;
@@ -208,13 +214,13 @@
 
 	/* find symtab, strtab and strtab size */
 	str_base = NULL;
-	curstrsize = -1;
+	curstrsize = (size_t)-1;
 	ed_base = map->l_ld;
 	i = 0;
 	DYNn_GETMEMBER(ed_base, i, d_tag, ed_tag);
 	while (ed_tag != DT_NULL) {
 		uintptr_t edptr;
-		uint64_t edval;
+		size_t edval;
 
 		switch (ed_tag) {
 		case DT_SYMTAB:
@@ -236,7 +242,7 @@
 		DYNn_GETMEMBER(ed_base, i, d_tag, ed_tag);
 	} while (ed_tag != DT_NULL);
 
-	if (str_base == NULL || syms_base == NULL || curstrsize == -1) {
+	if (str_base == NULL || syms_base == NULL || curstrsize == (size_t)-1) {
 		fprintf(stderr, "could not find strtab, symtab or strtab size "
 		"in %s\n", map->l_name);
 		return ENOEXEC;



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

2009-11-23 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov 23 14:39:35 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_dl.c

Log Message:
Include link.h instead of the NetBSD-specific link_elf.h.  Use
dlinfo() only if __ELF__ is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_dl.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.5 src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.6
--- src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.5	Thu Nov  5 14:13:03 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_dl.c	Mon Nov 23 14:39:35 2009
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.5 2009/11/05 14:13:03 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.6 2009/11/23 14:39:35 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -30,21 +30,21 @@
  */
 
 #include 
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.5 2009/11/05 14:13:03 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.6 2009/11/23 14:39:35 pooka Exp $");
 
 #include 
 #include 
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
 #include 
 
-#if defined(__NetBSD__) || defined(__FreeBSD__)\
-|| (defined(__sun__) && defined(__svr4__))
+#if defined(__ELF__) && (defined(__NetBSD__) || defined(__FreeBSD__)	\
+|| (defined(__sun__) && defined(__svr4__)))
 static int
 process(const char *soname, rump_modinit_fn domodinit)
 {



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

2009-11-19 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 19 13:42:29 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
.. umm, and use correct device value for previous.
And use 64bit arithmetic.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.45 src/sys/rump/librump/rumpuser/rumpuser.c:1.46
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.45	Thu Nov 19 13:25:48 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Thu Nov 19 13:42:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.45 2009/11/19 13:25:48 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.46 2009/11/19 13:42:29 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.45 2009/11/19 13:25:48 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.46 2009/11/19 13:42:29 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -153,8 +153,8 @@
 		}
 		close(fd);
 
-		parta = &lab.d_partitions[DISKPART(sb.st_dev)];
-		*size = lab.d_secsize * parta->p_size;
+		parta = &lab.d_partitions[DISKPART(sb.st_rdev)];
+		*size = (uint64_t)lab.d_secsize * parta->p_size;
 #endif /* __NetBSD__ */
 	}
 



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

2009-11-19 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 19 13:25:49 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
Improve host file size detection for devices (i.e. make it work).
Use ioctl() on NetBSD since it appears to be the only way to get
the info.  On other platforms, attempt lseek() and if that doesn't
work, punt, and hope someone comes along with a better implementation
later.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.44 src/sys/rump/librump/rumpuser/rumpuser.c:1.45
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.44	Sat Oct 24 11:29:55 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Thu Nov 19 13:25:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.44 2009/10/24 11:29:55 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.45 2009/11/19 13:25:48 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.44 2009/10/24 11:29:55 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.45 2009/11/19 13:25:48 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -47,6 +47,10 @@
 #include 
 #include 
 
+#ifdef __NetBSD__
+#include 
+#endif
+
 #include 
 #include 
 #include 
@@ -68,15 +72,13 @@
 rumpuser_getfileinfo(const char *path, uint64_t *size, int *ft, int *error)
 {
 	struct stat sb;
-	int rv;
+	int needsdev = 0;
 
-	rv = stat(path, &sb);
-	if (rv == -1) {
+	if (stat(path, &sb) == -1) {
 		*error = errno;
-		return rv;
+		return -1;
 	}
 
-	*size = sb.st_size;
 	switch (sb.st_mode & S_IFMT) {
 	case S_IFDIR:
 		*ft = RUMPUSER_FT_DIR;
@@ -86,16 +88,77 @@
 		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;
 	}
 
-	return rv;
+	if (!needsdev) {
+		*size = sb.st_size;
+	} else {
+		/*
+		 * 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;
+		int fd;
+
+		fd = open(path, O_RDONLY);
+		if (fd == -1) {
+			*error = errno;
+			return -1;
+		}
+
+		off = lseek(fd, 0, SEEK_END);
+		close(fd);
+		if (off != 0) {
+			*size = off;
+			return 0;
+		}
+		fprintf(stderr, "error: device size query not implemented on "
+		"this platform\n");
+		*error = EOPNOTSUPP;
+		return -1;
+#else
+		struct disklabel lab;
+		struct partition *parta;
+		int fd;
+
+		fd = open(path, O_RDONLY);
+		if (fd == -1) {
+			*error = errno;
+			return -1;
+		}
+
+		if (ioctl(fd, DIOCGDINFO, &lab) == -1) {
+			*error = errno;
+			return -1;
+		}
+		close(fd);
+
+		parta = &lab.d_partitions[DISKPART(sb.st_dev)];
+		*size = lab.d_secsize * parta->p_size;
+#endif /* __NetBSD__ */
+	}
+
+	return 0;
 }
 
 int



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

2009-11-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov  9 18:00:26 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_pth.c

Log Message:
Add scheduling points around the iothread call to biodone()


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_pth.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.36 src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.37
--- src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.36	Thu Oct 15 00:28:47 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth.c	Mon Nov  9 18:00:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.36 2009/10/15 00:28:47 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.37 2009/11/09 18:00:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.36 2009/10/15 00:28:47 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.37 2009/11/09 18:00:26 pooka Exp $");
 #endif /* !lint */
 
 #ifdef __linux__
@@ -131,7 +131,7 @@
 	struct rumpuser_aio *rua;
 	rump_biodone_fn biodone = arg;
 	ssize_t rv;
-	int error;
+	int error, dummy;
 
 	NOFAIL_ERRNO(pthread_mutex_lock(&rumpuser_aio_mtx.pthmtx));
 	for (;;) {
@@ -168,7 +168,10 @@
 #endif
 			}
 		}
+		rumpuser__klock(0);
 		biodone(rua->rua_bp, rv, error);
+		rumpuser__kunlock(0, &dummy);
+		assert(dummy == 0);
 			
 		rua->rua_bp = NULL;
 



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

2009-10-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Oct  8 00:34:54 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_dl.c

Log Message:
dlclose() in error branch


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_dl.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.1 src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.2
--- src/sys/rump/librump/rumpuser/rumpuser_dl.c:1.1	Thu Sep 24 21:30:42 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_dl.c	Thu Oct  8 00:34:54 2009
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_dl.c,v 1.1 2009/09/24 21:30:42 pooka Exp $	*/
+/*  $NetBSD: rumpuser_dl.c,v 1.2 2009/10/08 00:34:54 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.1 2009/09/24 21:30:42 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.2 2009/10/08 00:34:54 pooka Exp $");
 
 #include 
 #include 
@@ -61,15 +61,16 @@
 
 	mi = dlsym(handle, "__start_link_set_modules");
 	if (!mi)
-		return;
+		goto out;
 	mi_end = dlsym(handle, "__stop_link_set_modules");
 	if (!mi_end)
-		return;
+		goto out;
 
 	for (; mi < mi_end; mi++)
 		rump_module_init(*mi, NULL);
 	assert(mi == mi_end);
 
+ out:
 	dlclose(handle);
 }
 



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

2009-09-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Sep  8 20:04:03 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_pth.c

Log Message:
Use PTHREAD_MUTEX_ERRORCHECK.  This enables rump deadlock detection
once again:
panic: rumpuser fatal failure 11 (Resource deadlock avoided)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_pth.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.34 src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.35
--- src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.34	Tue Jul 14 21:00:53 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth.c	Tue Sep  8 20:04:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.34 2009/07/14 21:00:53 apb Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.35 2009/09/08 20:04:03 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.34 2009/07/14 21:00:53 apb Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.35 2009/09/08 20:04:03 pooka Exp $");
 #endif /* !lint */
 
 #ifdef __linux__
@@ -237,8 +237,15 @@
 void
 rumpuser_mutex_init(struct rumpuser_mtx **mtx)
 {
+	pthread_mutexattr_t att;
+
 	NOFAIL(*mtx = malloc(sizeof(struct rumpuser_mtx)));
-	NOFAIL_ERRNO(pthread_mutex_init(&((*mtx)->pthmtx), NULL));
+
+	pthread_mutexattr_init(&att);
+	pthread_mutexattr_settype(&att, PTHREAD_MUTEX_ERRORCHECK);
+	NOFAIL_ERRNO(pthread_mutex_init(&((*mtx)->pthmtx), &att));
+	pthread_mutexattr_destroy(&att);
+
 	(*mtx)->owner = NULL;
 	(*mtx)->recursion = 0;
 }



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

2009-07-14 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Jul 14 21:00:53 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_pth.c

Log Message:
Mark rumpuser_thread_exit() as __dead, to match its prototype.
Part of PR 41255 from Kurt Lidl.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_pth.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.33 src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.34
--- src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.33	Mon Apr 27 14:28:58 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth.c	Tue Jul 14 21:00:53 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.33 2009/04/27 14:28:58 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.34 2009/07/14 21:00:53 apb Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.33 2009/04/27 14:28:58 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.34 2009/07/14 21:00:53 apb Exp $");
 #endif /* !lint */
 
 #ifdef __linux__
@@ -227,7 +227,7 @@
 	return rv;
 }
 
-void
+__dead void
 rumpuser_thread_exit(void)
 {
 



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

2009-06-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jun 10 18:36:33 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
indicate function of previous in comment


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.41 src/sys/rump/librump/rumpuser/rumpuser.c:1.42
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.41	Wed Jun 10 18:34:49 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Wed Jun 10 18:36:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.41 2009/06/10 18:34:49 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.42 2009/06/10 18:36:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.41 2009/06/10 18:34:49 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.42 2009/06/10 18:36:33 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -496,6 +496,9 @@
 	return rv;
 }
 
+/*
+ * This is meant for safe debugging prints from the kernel.
+ */
 int
 rumpuser_dprintf(const char *format, ...)
 {



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

2009-04-29 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr 29 14:58:50 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_pth_dummy.c

Log Message:
catch locking-against-oneself already when taking the lock


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c:1.5 src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c:1.6
--- src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c:1.5	Wed Mar 18 10:22:45 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c	Wed Apr 29 14:58:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth_dummy.c,v 1.5 2009/03/18 10:22:45 cegger Exp $	*/
+/*	$NetBSD: rumpuser_pth_dummy.c,v 1.6 2009/04/29 14:58:50 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.5 2009/03/18 10:22:45 cegger Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.6 2009/04/29 14:58:50 pooka Exp $");
 #endif /* !lint */
 
 #include 
@@ -161,6 +161,7 @@
 
 	if (write) {
 		rw->v++;
+		assert(rw->v == 1);
 	} else {
 		assert(rw->v <= 0);
 		rw->v--;



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

2009-04-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Apr 26 22:26:59 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser_pth.c

Log Message:
avoid namespace collision.  no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser_pth.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.31 src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.32
--- src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.31	Mon Mar 23 11:48:32 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth.c	Sun Apr 26 22:26:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.31 2009/03/23 11:48:32 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.32 2009/04/26 22:26:59 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.31 2009/03/23 11:48:32 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.32 2009/04/26 22:26:59 pooka Exp $");
 #endif /* !lint */
 
 #ifdef __linux__
@@ -313,10 +313,10 @@
 }
 
 void
-rumpuser_rw_enter(struct rumpuser_rw *rw, int write)
+rumpuser_rw_enter(struct rumpuser_rw *rw, int iswrite)
 {
 
-	if (write) {
+	if (iswrite) {
 		KLOCK_WRAP(NOFAIL_ERRNO(pthread_rwlock_wrlock(&rw->pthrw)));
 		RURW_SETWRITE(rw);
 	} else {
@@ -326,11 +326,11 @@
 }
 
 int
-rumpuser_rw_tryenter(struct rumpuser_rw *rw, int write)
+rumpuser_rw_tryenter(struct rumpuser_rw *rw, int iswrite)
 {
 	int rv;
 
-	if (write) {
+	if (iswrite) {
 		rv = pthread_rwlock_trywrlock(&rw->pthrw);
 		if (rv == 0)
 			RURW_SETWRITE(rw);



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

2009-04-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Apr 26 21:30:43 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
Don't drop kernel lock twice inside same operation.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.39 src/sys/rump/librump/rumpuser/rumpuser.c:1.40
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.39	Fri Apr 17 00:39:26 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Sun Apr 26 21:30:43 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.39 2009/04/17 00:39:26 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.40 2009/04/26 21:30:43 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.39 2009/04/17 00:39:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.40 2009/04/26 21:30:43 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -278,7 +278,7 @@
 	ssize_t rv;
 	int error = 0;
 
-	KLOCK_WRAP(rv = rumpuser_pread(fd, data, size, offset, &error));
+	rv = rumpuser_pread(fd, data, size, offset, &error);
 	/* check against <0 instead of ==-1 to get typing below right */
 	if (rv < 0)
 		rv = 0;
@@ -318,7 +318,7 @@
 	ssize_t rv;
 	int error = 0;
 
-	KLOCK_WRAP(rv = rumpuser_pwrite(fd, data, size, offset, &error));
+	rv = rumpuser_pwrite(fd, data, size, offset, &error);
 	/* check against <0 instead of ==-1 to get typing below right */
 	if (rv < 0)
 		rv = 0;



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

2009-04-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Apr 17 00:39:27 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: rumpuser.c

Log Message:
Don't bzero in rumpuser_malloc, do it in the caller iff necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/rump/librump/rumpuser/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/sys/rump/librump/rumpuser/rumpuser.c
diff -u src/sys/rump/librump/rumpuser/rumpuser.c:1.38 src/sys/rump/librump/rumpuser/rumpuser.c:1.39
--- src/sys/rump/librump/rumpuser/rumpuser.c:1.38	Tue Apr  7 18:35:49 2009
+++ src/sys/rump/librump/rumpuser/rumpuser.c	Fri Apr 17 00:39:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.38 2009/04/07 18:35:49 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.39 2009/04/17 00:39:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.38 2009/04/07 18:35:49 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.39 2009/04/17 00:39:26 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -129,9 +129,6 @@
 		abort();
 	}
 
-	if (rv)
-		memset(rv, 0, howmuch);
-
 	return rv;
 }
 



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

2009-03-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar 25 14:05:03 UTC 2009

Modified Files:
src/sys/rump/librump/rumpuser: Makefile

Log Message:
Need to compile with -D_REENTRANT, otherwise calling putchar() can
cause libc to commit suicide (!!!).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/rump/librump/rumpuser/Makefile

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

Modified files:

Index: src/sys/rump/librump/rumpuser/Makefile
diff -u src/sys/rump/librump/rumpuser/Makefile:1.14 src/sys/rump/librump/rumpuser/Makefile:1.15
--- src/sys/rump/librump/rumpuser/Makefile:1.14	Tue Jan 20 21:43:13 2009
+++ src/sys/rump/librump/rumpuser/Makefile	Wed Mar 25 14:05:03 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.14 2009/01/20 21:43:13 pooka Exp $
+#	$NetBSD: Makefile,v 1.15 2009/03/25 14:05:03 pooka Exp $
 #
 
 LIB=		rumpuser
@@ -7,6 +7,8 @@
 SRCS=		rumpuser.c rumpuser_net.c
 SRCS+=		rumpuser_pth.c
 
+CPPFLAGS+=	-D_REENTRANT
+
 # Using this instead of the above makes it possible to link rump
 # without involving pthreads.  Multithreaded operation will not
 # of course work correctly in case.