Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Use SYSCTL_SETUP mechanism to establish ...



details:   https://anonhg.NetBSD.org/src/rev/7926d8cf0513
branches:  trunk
changeset: 745892:7926d8cf0513
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Mar 15 14:15:12 2020 +0000

description:
Use SYSCTL_SETUP mechanism to establish our sysctl tree, rather than
using explicit calls to netbsd32_sysctl_{init,fini}()

diffstat:

 sys/compat/netbsd32/netbsd32_mod.c    |   8 +-----
 sys/compat/netbsd32/netbsd32_sysctl.c |  39 ++++++++++++----------------------
 sys/compat/netbsd32/netbsd32_sysctl.h |  38 ----------------------------------
 3 files changed, 16 insertions(+), 69 deletions(-)

diffs (217 lines):

diff -r fee1296e3f2b -r 7926d8cf0513 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c        Sun Mar 15 14:14:50 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c        Sun Mar 15 14:15:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_mod.c,v 1.20 2020/03/09 21:49:26 pgoyette Exp $       */
+/*     $NetBSD: netbsd32_mod.c,v 1.21 2020/03/15 14:15:12 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.20 2020/03/09 21:49:26 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.21 2020/03/15 14:15:12 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -76,7 +76,6 @@
 #include <sys/module_hook.h>
 #include <sys/compat_stub.h>
 
-#include <compat/netbsd32/netbsd32_sysctl.h>
 #include <compat/netbsd32/netbsd32_kern_proc.h>
 #include <compat/netbsd32/netbsd32_exec.h>
 
@@ -167,7 +166,6 @@
                error = exec_add(netbsd32_execsw,
                    __arraycount(netbsd32_execsw));
                if (error == 0) {
-                       netbsd32_sysctl_init();
                        netbsd32_machdep_md_init();
                        netbsd32_kern_proc_32_init();
 #if defined(__amd64__)
@@ -182,14 +180,12 @@
                MODULE_HOOK_UNSET(amd64_oosyscall_hook);
 #endif /* defined(__amd64__) */
                netbsd32_machdep_md_fini();
-               netbsd32_sysctl_fini();
                netbsd32_kern_proc_32_fini();
 
                error = exec_remove(netbsd32_execsw,
                    __arraycount(netbsd32_execsw));
                if (error) {
                        netbsd32_kern_proc_32_init();
-                       netbsd32_sysctl_init();
                        netbsd32_machdep_md_init();
 #if defined(__amd64__)
                        MODULE_HOOK_SET(amd64_oosyscall_hook,
diff -r fee1296e3f2b -r 7926d8cf0513 sys/compat/netbsd32/netbsd32_sysctl.c
--- a/sys/compat/netbsd32/netbsd32_sysctl.c     Sun Mar 15 14:14:50 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_sysctl.c     Sun Mar 15 14:15:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_sysctl.c,v 1.41 2020/01/02 15:42:26 thorpej Exp $     */
+/*     $NetBSD: netbsd32_sysctl.c,v 1.42 2020/03/15 14:15:12 pgoyette Exp $    */
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.41 2020/01/02 15:42:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.42 2020/03/15 14:15:12 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -57,7 +57,6 @@
 #include <compat/netbsd32/netbsd32_syscall.h>
 #include <compat/netbsd32/netbsd32_syscallargs.h>
 #include <compat/netbsd32/netbsd32_conv.h>
-#include <compat/netbsd32/netbsd32_sysctl.h>
 
 #if defined(DDB)
 #include <ddb/ddbvar.h>
@@ -70,8 +69,6 @@
        .sysctl_size = sizeof(struct sysctlnode),
 };
 
-static struct sysctllog *netbsd32_clog;
-
 /*
  * sysctl helper routine for netbsd32's kern.boottime node
  */
@@ -120,78 +117,70 @@
        return sysctl_lookup(SYSCTLFN_CALL(&node));
 }
 
-void
-netbsd32_sysctl_init(void)
+SYSCTL_SETUP(netbsd32_sysctl_emul_setup, "netbsd32 shadow tree")
 {
        const struct sysctlnode *_root = &netbsd32_sysctl_root;
        extern const char machine32[];
 
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       printf("%s: called\n", __func__); /* XXX PRG */
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "kern", NULL,
                       NULL, 0, NULL, 0,
                       CTL_KERN, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRUCT, "boottime", NULL,
                       netbsd32_sysctl_kern_boottime, 0, NULL,
                       sizeof(struct netbsd32_timeval),
                       CTL_KERN, KERN_BOOTTIME, CTL_EOL);
 
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "vm", NULL,
                       NULL, 0, NULL, 0,
                       CTL_VM, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRUCT, "loadavg", NULL,
                       netbsd32_sysctl_vm_loadavg, 0, NULL,
                       sizeof(struct netbsd32_loadavg),
                       CTL_VM, VM_LOADAVG, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
                       CTLTYPE_INT, "maxaddress",
                       SYSCTL_DESCR("Maximum user address"),
                       NULL, VM_MAXUSER_ADDRESS32, NULL, 0,
                       CTL_VM, VM_MAXADDRESS, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
                       CTLTYPE_INT, "minaddress",
                       SYSCTL_DESCR("Minimum user address"),
                       NULL, VM_MIN_ADDRESS, NULL, 0,
                       CTL_VM, VM_MINADDRESS, CTL_EOL);
 
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "hw", NULL,
                       NULL, 0, NULL, 0,
                       CTL_HW, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
                       CTLTYPE_INT, "alignbytes", NULL,
                       NULL, ALIGNBYTES32, NULL, 0,
                       CTL_HW, HW_ALIGNBYTES, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRING, "machine", NULL,
                       NULL, 0, __UNCONST(&machine32), 0,
                       CTL_HW, HW_MACHINE, CTL_EOL);
-       sysctl_createv(&netbsd32_clog, 0, &_root, NULL,
+       sysctl_createv(clog, 0, &_root, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
                       CTLTYPE_STRING, "machine_arch", NULL,
                       sysctl_hw_machine_arch32, 0, NULL, 0,
                       CTL_HW, HW_MACHINE_ARCH, CTL_EOL);
 }
 
-void
-netbsd32_sysctl_fini(void)
-{
-
-       sysctl_teardown(&netbsd32_clog);
-       sysctl_free(&netbsd32_sysctl_root);
-}
-
 int
 netbsd32___sysctl(struct lwp *l, const struct netbsd32___sysctl_args *uap, register_t *retval)
 {
diff -r fee1296e3f2b -r 7926d8cf0513 sys/compat/netbsd32/netbsd32_sysctl.h
--- a/sys/compat/netbsd32/netbsd32_sysctl.h     Sun Mar 15 14:14:50 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*     $NetBSD: netbsd32_sysctl.h,v 1.1 2008/11/19 18:36:05 ad Exp $   */
-
-/*-
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software developed for The NetBSD Foundation
- * by Andrew Doran.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _NETBSD32_SYSCTL_H
-#define _NETBSD32_SYSCTL_H
-
-void   netbsd32_sysctl_init(void);
-void   netbsd32_sysctl_fini(void);
-
-#endif /* !_NETBSD32_SYSCTL_H */



Home | Main Index | Thread Index | Old Index