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 Include LIST_ENTRY() in "struct ru...
details: https://anonhg.NetBSD.org/src/rev/aa45f3ffb33c
branches: trunk
changeset: 328902:aa45f3ffb33c
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Apr 23 16:17:55 2014 +0000
description:
Include LIST_ENTRY() in "struct rump_component".
Main benefit: rump_component_load() can now be called from an
early-running constructor since the routine doesn't need to allocate
memory.
diffstat:
sys/rump/librump/rumpkern/rump.c | 36 ++++++++++++++++----------------
sys/rump/librump/rumpkern/rump_private.h | 5 ++-
2 files changed, 21 insertions(+), 20 deletions(-)
diffs (105 lines):
diff -r e71e4efb3823 -r aa45f3ffb33c sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Wed Apr 23 09:06:57 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Wed Apr 23 16:17:55 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.294 2014/04/09 23:53:36 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.295 2014/04/23 16:17:55 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.294 2014/04/09 23:53:36 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.295 2014/04/23 16:17:55 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -691,13 +691,8 @@
/*
* Yea, this is O(n^2), but we're only looking at a handful of components.
* Components are always initialized from the thread that called rump_init().
- * Could also free these when done with them, but prolly not worth it.
*/
-struct compstore {
- const struct rump_component *cs_rc;
- LIST_ENTRY(compstore) cs_entries;
-};
-static LIST_HEAD(, compstore) cshead = LIST_HEAD_INITIALIZER(cshead);
+static LIST_HEAD(, rump_component) rchead = LIST_HEAD_INITIALIZER(rchead);
/*
* add components which are visible from the current object.
@@ -714,20 +709,27 @@
}
static void
-rump_component_load(const struct rump_component *rc)
+rump_component_load(const struct rump_component *rc_const)
{
- struct compstore *cs;
+ struct rump_component *rc, *rc_iter;
+
+ /*
+ * XXX: this is ok since the "const" was removed from the
+ * definition of RUMP_COMPONENT().
+ *
+ * However, to preserve the hypercall interface, the const
+ * remains here. This can be fixed in the next hypercall revision.
+ */
+ rc = __UNCONST(rc_const);
KASSERT(curlwp == bootlwp);
- LIST_FOREACH(cs, &cshead, cs_entries) {
- if (rc == cs->cs_rc)
+ LIST_FOREACH(rc_iter, &rchead, rc_entries) {
+ if (rc_iter == rc)
return;
}
- cs = kmem_alloc(sizeof(*cs), KM_SLEEP);
- cs->cs_rc = rc;
- LIST_INSERT_HEAD(&cshead, cs, cs_entries);
+ LIST_INSERT_HEAD(&rchead, rc, rc_entries);
KASSERT(rc->rc_type < RUMP_COMPONENT_MAX);
compcounter[rc->rc_type]++;
}
@@ -744,13 +746,11 @@
void
rump_component_init(enum rump_component_type type)
{
- struct compstore *cs;
const struct rump_component *rc;
KASSERT(curlwp == bootlwp);
KASSERT(!compinited[type]);
- LIST_FOREACH(cs, &cshead, cs_entries) {
- rc = cs->cs_rc;
+ LIST_FOREACH(rc, &rchead, rc_entries) {
if (rc->rc_type == type)
rc->rc_init();
}
diff -r e71e4efb3823 -r aa45f3ffb33c sys/rump/librump/rumpkern/rump_private.h
--- a/sys/rump/librump/rumpkern/rump_private.h Wed Apr 23 09:06:57 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump_private.h Wed Apr 23 16:17:55 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_private.h,v 1.81 2014/04/09 23:53:36 pooka Exp $ */
+/* $NetBSD: rump_private.h,v 1.82 2014/04/23 16:17:55 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -73,10 +73,11 @@
struct rump_component {
enum rump_component_type rc_type;
void (*rc_init)(void);
+ LIST_ENTRY(rump_component) rc_entries;
};
#define RUMP_COMPONENT(type) \
static void rumpcompinit##type(void); \
-static const struct rump_component rumpcomp##type = { \
+static struct rump_component rumpcomp##type = { \
.rc_type = type, \
.rc_init = rumpcompinit##type, \
}; \
Home |
Main Index |
Thread Index |
Old Index