Module Name:    src
Committed By:   pooka
Date:           Sun Nov  4 14:40:18 UTC 2012

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

Log Message:
Use a table to check for kernel threads.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/rump/librump/rumpkern/threads.c

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

Modified files:

Index: src/sys/rump/librump/rumpkern/threads.c
diff -u src/sys/rump/librump/rumpkern/threads.c:1.15 src/sys/rump/librump/rumpkern/threads.c:1.16
--- src/sys/rump/librump/rumpkern/threads.c:1.15	Sun Aug  7 14:03:16 2011
+++ src/sys/rump/librump/rumpkern/threads.c	Sun Nov  4 14:40:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: threads.c,v 1.15 2011/08/07 14:03:16 rmind Exp $	*/
+/*	$NetBSD: threads.c,v 1.16 2012/11/04 14:40:18 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2009 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.15 2011/08/07 14:03:16 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.16 2012/11/04 14:40:18 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -74,6 +74,18 @@ threadbouncer(void *arg)
 	panic("unreachable, should kthread_exit()");
 }
 
+static struct {
+	const char *t_name;
+	bool t_ncmp;
+} nothreads[] = {
+	{ "vrele", false },
+	{ "cachegc", false },
+	{ "nfssilly", false },
+	{ "unpgc", false },
+	{ "pmf", true },
+	{ "xcall", true },
+};
+
 int
 kthread_create(pri_t pri, int flags, struct cpu_info *ci,
 	void (*func)(void *), void *arg, lwp_t **newlp, const char *fmt, ...)
@@ -104,33 +116,25 @@ kthread_create(pri_t pri, int flags, str
 	}
 
 	if (!rump_threads) {
-		/* fake them */
-		if (strcmp(thrstore, "vrele") == 0) {
-			printf("rump warning: threads not enabled, not starting"
-			   " vrele thread\n");
-			return 0;
-		} else if (strcmp(thrstore, "cachegc") == 0) {
-			printf("rump warning: threads not enabled, not starting"
-			   " namecache g/c thread\n");
-			return 0;
-		} else if (strcmp(thrstore, "nfssilly") == 0) {
-			printf("rump warning: threads not enabled, not enabling"
-			   " nfs silly rename\n");
-			return 0;
-		} else if (strcmp(thrstore, "unpgc") == 0) {
-			printf("rump warning: threads not enabled, not enabling"
-			   " UNP garbage collection\n");
-			return 0;
-		} else if (strncmp(thrstore, "pmf", sizeof("pmf")-1) == 0) {
-			printf("rump warning: threads not enabled, not enabling"
-			   " pmf thread\n");
-			return 0;
-		} else if (strncmp(thrstore, "xcall", sizeof("xcall")-1) == 0) {
-			printf("rump warning: threads not enabled, CPU xcall"
-			   " not functional\n");
-			return 0;
-		} else
-			panic("threads not available, setenv RUMP_THREADS 1");
+		bool matched;
+		int i;
+
+		/* do we want to fake it? */
+		for (i = 0; i < __arraycount(nothreads); i++) {
+			if (nothreads[i].t_ncmp) {
+				matched = strncmp(thrstore, nothreads[i].t_name,
+				    strlen(nothreads[i].t_name)) == 0;
+			} else {
+				matched = strcmp(thrstore,
+				    nothreads[i].t_name) == 0;
+			}
+			if (matched) {
+				aprint_error("rump kernel threads not enabled, "
+				    "%s not functional\n", nothreads[i].t_name);
+				return 0;
+			}
+		}
+		panic("threads not available");
 	}
 	KASSERT(fmt != NULL);
 

Reply via email to