Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Extend RUMP_USE_CTOR to SYSCTL_SETUP(), similar to what ...
details: https://anonhg.NetBSD.org/src/rev/33886deee923
branches: trunk
changeset: 335377:33886deee923
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Jan 04 22:11:40 2015 +0000
description:
Extend RUMP_USE_CTOR to SYSCTL_SETUP(), similar to what is already
done in MODULE(). The sysctl tree nodes from all components which
were loaded when rump_init() was called now get created -- mimics the
monolithic kernel.
No change to the monolithic kernel.
diffstat:
sys/rump/librump/rumpkern/rump.c | 30 ++++++++++++++++++++++++++----
sys/sys/sysctl.h | 33 ++++++++++++++++++++++++++++-----
2 files changed, 54 insertions(+), 9 deletions(-)
diffs (134 lines):
diff -r ffc8a48e34dd -r 33886deee923 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Sun Jan 04 22:05:37 2015 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Sun Jan 04 22:11:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.313 2015/01/03 17:23:51 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.314 2015/01/04 22:11:40 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.313 2015/01/03 17:23:51 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.314 2015/01/04 22:11:40 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -182,7 +182,15 @@
return rumpuser_daemonize_done(error);
}
-#ifndef RUMP_USE_CTOR
+#ifdef RUMP_USE_CTOR
+
+/* sysctl bootstrap handling */
+struct sysctl_boot_chain sysctl_boot_chain \
+ = LIST_HEAD_INITIALIZER(sysctl_boot_chain);
+__link_set_add_text(sysctl_funcs,voidop); /* ensure linkset is non-empty */
+
+#else /* RUMP_USE_CTOR */
+
RUMP_COMPONENT(RUMP_COMPONENT_POSTINIT)
{
__link_set_decl(rump_components, struct rump_component);
@@ -194,7 +202,8 @@
asm("" :: "r"(__start_link_set_rump_components));
asm("" :: "r"(__stop_link_set_rump_components));
}
-#endif
+
+#endif /* RUMP_USE_CTOR */
int
rump_init(void)
@@ -284,6 +293,19 @@
secmodel_init();
sysctl_init();
+ /*
+ * The above call to sysctl_init() only initializes sysctl nodes
+ * from link sets. Initialize sysctls in case we used ctors.
+ */
+#ifdef RUMP_USE_CTOR
+ {
+ struct sysctl_setup_chain *ssc;
+
+ LIST_FOREACH(ssc, &sysctl_boot_chain, ssc_entries) {
+ ssc->ssc_func(NULL);
+ }
+ }
+#endif /* RUMP_USE_CTOR */
rnd_init();
cprng_init();
diff -r ffc8a48e34dd -r 33886deee923 sys/sys/sysctl.h
--- a/sys/sys/sysctl.h Sun Jan 04 22:05:37 2015 +0000
+++ b/sys/sys/sysctl.h Sun Jan 04 22:11:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.h,v 1.214 2014/09/05 05:42:50 matt Exp $ */
+/* $NetBSD: sysctl.h,v 1.215 2015/01/04 22:11:40 pooka Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -1087,6 +1087,29 @@
oldlenp, newp, newlen, \
oname, l, node
+#ifdef RUMP_USE_CTOR
+struct sysctl_setup_chain {
+ void (*ssc_func)(struct sysctllog **);
+ LIST_ENTRY(sysctl_setup_chain) ssc_entries;
+};
+LIST_HEAD(sysctl_boot_chain, sysctl_setup_chain);
+#define _SYSCTL_REGISTER(name) \
+static void sysctlctor_##name(void) __attribute__((constructor)); \
+static void sysctlctor_##name(void) \
+{ \
+ static struct sysctl_setup_chain ssc = { \
+ .ssc_func = name, \
+ }; \
+ extern struct sysctl_boot_chain sysctl_boot_chain; \
+ LIST_INSERT_HEAD(&sysctl_boot_chain, &ssc, ssc_entries); \
+}
+
+#else /* RUMP_USE_CTOR */
+
+#define _SYSCTL_REGISTER(name) __link_set_add_text(sysctl_funcs, name);
+
+#endif /* RUMP_USE_CTOR */
+
#ifdef _MODULE
#define SYSCTL_SETUP_PROTO(name) \
@@ -1098,12 +1121,12 @@
void name(struct sysctllog **clog) { \
printf("%s\n", desc); \
__CONCAT(___,name)(clog); } \
- __link_set_add_text(sysctl_funcs, name); \
+ _SYSCTL_REGISTER(name); \
static void __CONCAT(___,name)(struct sysctllog **clog)
#else /* !SYSCTL_DEBUG_SETUP */
#define SYSCTL_SETUP(name, desc) \
SYSCTL_SETUP_PROTO(name); \
- __link_set_add_text(sysctl_funcs, name); \
+ _SYSCTL_REGISTER(name); \
void name(struct sysctllog **clog)
#endif /* !SYSCTL_DEBUG_SETUP */
@@ -1116,12 +1139,12 @@
static void name(struct sysctllog **clog) { \
printf("%s\n", desc); \
__CONCAT(___,name)(clog); } \
- __link_set_add_text(sysctl_funcs, name); \
+ _SYSCTL_REGISTER(name); \
static void __CONCAT(___,name)(struct sysctllog **clog)
#else /* !SYSCTL_DEBUG_SETUP */
#define SYSCTL_SETUP(name, desc) \
static void name(struct sysctllog **); \
- __link_set_add_text(sysctl_funcs, name); \
+ _SYSCTL_REGISTER(name); \
static void name(struct sysctllog **clog)
#endif /* !SYSCTL_DEBUG_SETUP */
Home |
Main Index |
Thread Index |
Old Index