Collecting all system calls in a single translation unit is not good due to the
library initialization through linker sets.

Update #4475.
---
 freebsd/sys/kern/kern_sysctl.c         |  4 ++
 freebsd/sys/sys/sysctl.h               |  8 ++++
 rtemsbsd/rtems/rtems-bsd-syscall-api.c | 64 --------------------------
 3 files changed, 12 insertions(+), 64 deletions(-)

diff --git a/freebsd/sys/kern/kern_sysctl.c b/freebsd/sys/kern/kern_sysctl.c
index 71cbd2d8..f529704a 100644
--- a/freebsd/sys/kern/kern_sysctl.c
+++ b/freebsd/sys/kern/kern_sysctl.c
@@ -1773,7 +1773,11 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, 
size_t l)
 
 int
 kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
+#ifndef __rtems__
     size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags)
+#else /* __rtems__ */
+    size_t *oldlenp, const void *new, size_t newlen, size_t *retval, int flags)
+#endif /* __rtems__ */
 {
        int error = 0;
        struct sysctl_req req;
diff --git a/freebsd/sys/sys/sysctl.h b/freebsd/sys/sys/sysctl.h
index fa9779f3..c21f19d3 100644
--- a/freebsd/sys/sys/sysctl.h
+++ b/freebsd/sys/sys/sysctl.h
@@ -1129,10 +1129,18 @@ int     sysctl_ctx_entry_del(struct sysctl_ctx_list 
*clist,
            struct sysctl_oid *oidp);
 
 int    kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
+#ifndef __rtems__
            size_t *oldlenp, void *new, size_t newlen, size_t *retval,
+#else /* __rtems__ */
+           size_t *oldlenp, const void *newp, size_t newlen, size_t *retval,
+#endif /* __rtems__ */
            int flags);
 int    kernel_sysctlbyname(struct thread *td, char *name, void *old,
+#ifndef __rtems__
            size_t *oldlenp, void *new, size_t newlen, size_t *retval,
+#else /* __rtems__ */
+           size_t *oldlenp, const void *newp, size_t newlen, size_t *retval,
+#endif /* __rtems__ */
            int flags);
 #ifndef __rtems__
 int    userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
diff --git a/rtemsbsd/rtems/rtems-bsd-syscall-api.c 
b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
index 1f659112..5c45d88a 100644
--- a/rtemsbsd/rtems/rtems-bsd-syscall-api.c
+++ b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
@@ -4,8 +4,6 @@
  * @ingroup rtems_bsd_rtems
  *
  * @brief TODO.
- *
- * File origin from FreeBSD 'lib/libc/gen/sysctlnametomib.c'.
  */
 
 /*
@@ -794,68 +792,6 @@ out:
        return rtems_bsd_error_to_status_and_errno(error);
 }
 
-int
-sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,
-    const void *newp, size_t newlen)
-{
-       int error = EINVAL;
-       if (namelen <= CTL_MAXNAME) {
-               int namedup[CTL_MAXNAME];
-               memcpy(namedup, name, namelen * sizeof(*name));
-               error = kernel_sysctl(NULL, namedup, namelen, oldp, oldlenp,
-                   RTEMS_DECONST(void *, newp), newlen, oldlenp, 0);
-       }
-       return rtems_bsd_error_to_status_and_errno(error);
-}
-
-/*
- * File origin from FreeBSD 'lib/libc/gen/sysctlbyname.c'.
- *
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <p...@freebsd.org> wrote this file.  As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- */
-int
-sysctlbyname(const char *name, void *oldp, size_t *oldlenp, const void *newp,
-    size_t newlen)
-{
-       int real_oid[CTL_MAXNAME + 2];
-       int error;
-       size_t oidlen;
-       oidlen = sizeof(real_oid) / sizeof(int);
-       error = sysctlnametomib(name, real_oid, &oidlen);
-       if (error < 0)
-               return (error);
-       error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
-       return rtems_bsd_error_to_status_and_errno(error);
-}
-
-/*
- * File origin from FreeBSD 'lib/libc/gen/sysctlnametomib.c'.
- *
- * This function uses a presently undocumented interface to the kernel
- * to walk the tree and get the type so it can print the value.
- * This interface is under work and consideration, and should probably
- * be killed with a big axe by the first person who can find the time.
- * (be aware though, that the proper interface isn't as obvious as it
- * may seem, there are various conflicting requirements.
- */
-int
-sysctlnametomib(const char *name, int *mibp, size_t *sizep)
-{
-       int oid[2];
-       int error;
-       oid[0] = 0;
-       oid[1] = 3;
-       *sizep *= sizeof(int);
-       error = sysctl(oid, 2, mibp, sizep, name, strlen(name));
-       *sizep /= sizeof(int);
-       return (error);
-}
 
 static int
 rtems_bsd_sysgen_open_error(
-- 
2.35.3

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to