Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Use a table to check for kernel th...



details:   https://anonhg.NetBSD.org/src/rev/c7334d80af1d
branches:  trunk
changeset: 782485:c7334d80af1d
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Nov 04 14:40:18 2012 +0000

description:
Use a table to check for kernel threads.

diffstat:

 sys/rump/librump/rumpkern/threads.c |  62 +++++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 29 deletions(-)

diffs (90 lines):

diff -r 129150dadc87 -r c7334d80af1d sys/rump/librump/rumpkern/threads.c
--- a/sys/rump/librump/rumpkern/threads.c       Sun Nov 04 14:27:15 2012 +0000
+++ b/sys/rump/librump/rumpkern/threads.c       Sun Nov 04 14:40:18 2012 +0000
@@ -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 @@
        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 @@
        }
 
        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);
 



Home | Main Index | Thread Index | Old Index