[libbsd 04/22] Move setfib() back to route.c

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 24 06:33:32 UTC 2022


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

Update #4475.
---
 freebsd/sys/net/route.c                        | 18 ++++++++++++++++++
 freebsd/sys/sys/sysproto.h                     |  2 --
 .../machine/rtems-bsd-kernel-namespace.h       |  1 -
 rtemsbsd/rtems/rtems-bsd-syscall-api.c         | 14 --------------
 4 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/freebsd/sys/net/route.c b/freebsd/sys/net/route.c
index 2e9883a1..adbf91bd 100644
--- a/freebsd/sys/net/route.c
+++ b/freebsd/sys/net/route.c
@@ -407,6 +407,9 @@ struct setfib_args {
 	int     fibnum;
 };
 #endif
+#ifdef __rtems__
+static
+#endif /* __rtems__ */
 int
 sys_setfib(struct thread *td, struct setfib_args *uap)
 {
@@ -420,6 +423,20 @@ sys_setfib(struct thread *td, struct setfib_args *uap)
 #endif /* __rtems__ */
 	return (0);
 }
+#ifdef __rtems__
+int
+setfib(int fibnum)
+{
+	struct setfib_args ua = {
+		.fibnum = fibnum
+	};
+	int error;
+
+	error = sys_setfib(NULL, &ua);
+
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+#endif /* __rtems__ */
 
 /*
  * Packet routing routines.
@@ -2285,3 +2302,4 @@ rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
 		rt_addrmsg(cmd, ifa, fibnum);
 	}
 }
+
diff --git a/freebsd/sys/sys/sysproto.h b/freebsd/sys/sys/sysproto.h
index a1ab7e44..1c1891de 100644
--- a/freebsd/sys/sys/sysproto.h
+++ b/freebsd/sys/sys/sysproto.h
@@ -2027,9 +2027,7 @@ int	sys_rtprio(struct thread *, struct rtprio_args *);
 int	sys_semsys(struct thread *, struct semsys_args *);
 int	sys_msgsys(struct thread *, struct msgsys_args *);
 int	sys_shmsys(struct thread *, struct shmsys_args *);
-#endif /* __rtems__ */
 int	sys_setfib(struct thread *, struct setfib_args *);
-#ifndef __rtems__
 int	sys_ntp_adjtime(struct thread *, struct ntp_adjtime_args *);
 int	sys_setgid(struct thread *, struct setgid_args *);
 int	sys_setegid(struct thread *, struct setegid_args *);
diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
index 85f66912..a83334b5 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
@@ -5872,7 +5872,6 @@
 #define	sys_select _bsd_sys_select
 #define	sys_sendmsg _bsd_sys_sendmsg
 #define	sys_sendto _bsd_sys_sendto
-#define	sys_setfib _bsd_sys_setfib
 #define	sys_setsockopt _bsd_sys_setsockopt
 #define	sys_shutdown _bsd_sys_shutdown
 #define	sys_socket _bsd_sys_socket
diff --git a/rtemsbsd/rtems/rtems-bsd-syscall-api.c b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
index 76fc8ad7..1f659112 100644
--- a/rtemsbsd/rtems/rtems-bsd-syscall-api.c
+++ b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
@@ -644,20 +644,6 @@ sendmsg(int socket, const struct msghdr *message, int flags)
 	return rtems_bsd_error_to_status_and_errno(error);
 }
 
-int
-setfib(int fibnum)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	int error;
-	if (td != NULL) {
-		struct setfib_args ua = { .fibnum = fibnum };
-		error = sys_setfib(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-
 int
 setsockopt(int socket, int level, int option_name, const void *option_value,
     socklen_t option_len)
-- 
2.35.3



More information about the devel mailing list