aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2001-06-13 10:58:39 +0000
committerPeter Wemm <peter@FreeBSD.org>2001-06-13 10:58:39 +0000
commitf41325db5f16640212574a03b9a34e5ed4a884ca (patch)
tree88aef8097c80f09c2f725d61b6da4d433a595a61 /sys/kern/kern_sysctl.c
parentf3a6406c668744d1692c960352110b9b4c7ea9a6 (diff)
downloadsrc-f41325db5f16640212574a03b9a34e5ed4a884ca.tar.gz
src-f41325db5f16640212574a03b9a34e5ed4a884ca.zip
With this commit, I hereby pronounce gensetdefs past its use-by date.
Replace the a.out emulation of 'struct linker_set' with something a little more flexible. <sys/linker_set.h> now provides macros for accessing elements and completely hides the implementation. The linker_set.h macros have been on the back burner in various forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()), John Polstra (ELF clue) and myself (cleaned up API and the conversion of the rest of the kernel to use it). The macros declare a strongly typed set. They return elements with the type that you declare the set with, rather than a generic void *. For ELF, we use the magic ld symbols (__start_<setname> and __stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the trick about how to force ld to provide them for kld's. For a.out, we use the old linker_set struct. NOTE: the item lists are no longer null terminated. This is why the code impact is high in certain areas. The runtime linker has a new method to find the linker set boundaries depending on which backend format is in use. linker sets are still module/kld unfriendly and should never be used for anything that may be modular one day. Reviewed by: eivind
Notes
Notes: svn path=/head/; revision=78161
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index b3bf555c4665..3256cfdb2357 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -367,34 +367,17 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
}
/*
- * Bulk-register all the oids in a linker_set.
- */
-void sysctl_register_set(struct linker_set *lsp)
-{
- int count = lsp->ls_length;
- int i;
- for (i = 0; i < count; i++)
- sysctl_register_oid((struct sysctl_oid *) lsp->ls_items[i]);
-}
-
-void sysctl_unregister_set(struct linker_set *lsp)
-{
- int count = lsp->ls_length;
- int i;
- for (i = 0; i < count; i++)
- sysctl_unregister_oid((struct sysctl_oid *) lsp->ls_items[i]);
-}
-
-/*
* Register the kernel's oids on startup.
*/
-extern struct linker_set sysctl_set;
+SET_DECLARE(sysctl_set, struct sysctl_oid);
static void sysctl_register_all(void *arg)
{
- sysctl_register_set(&sysctl_set);
-}
+ struct sysctl_oid **oidp;
+ SET_FOREACH(oidp, sysctl_set)
+ sysctl_register_oid(*oidp);
+}
SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0);
/*