[PATCH 2/4] kern_ntptime: Port to rtems

Moyano, Gabriel gabriel.moyano at dlr.de
Thu Feb 3 15:19:21 UTC 2022


From: Chris Johns <chrisj at rtems.org>

---
 freebsd/sys/kern/kern_ntptime.c | 17 +++++++++++++++++
 libbsd.py                       |  1 +
 2 files changed, 18 insertions(+)

diff --git a/freebsd/sys/kern/kern_ntptime.c b/freebsd/sys/kern/kern_ntptime.c
index 116fb584..518adab5 100644
--- a/freebsd/sys/kern/kern_ntptime.c
+++ b/freebsd/sys/kern/kern_ntptime.c
@@ -276,6 +276,10 @@ ntp_gettime1(struct ntptimeval *ntvp)
  * See the timex.h header file for synopsis and API description.  Note that
  * the TAI offset is returned in the ntvtimeval.tai structure member.
  */
+#ifdef __rtems__
+#undef _SYS_SYSPROTO_H_
+#endif /* __rtems__ */
+
 #ifndef _SYS_SYSPROTO_H_
 struct ntp_gettime_args {
 	struct ntptimeval *ntvp;
@@ -311,7 +315,11 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS)
 	return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req));
 }
 
+#ifndef __rtems__
 SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW, 0, "");
+#else /* __rtems__ */
+SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "");
+#endif /* __rtems__ */
 SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE | CTLFLAG_RD |
     CTLFLAG_MPSAFE, 0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval",
     "");
@@ -367,8 +375,10 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
 	 * status words are reset to the initial values at boot.
 	 */
 	modes = ntv.modes;
+#ifndef __rtems__
 	if (modes)
 		error = priv_check(td, PRIV_NTP_ADJTIME);
+#endif /* __rtems__ */
 	if (error != 0)
 		return (error);
 	NTP_LOCK();
@@ -477,7 +487,11 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
 
 	error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv));
 	if (error == 0)
+#ifdef __rtems__
+        error = retval;
+#else /* __rtems__ */
 		td->td_retval[0] = retval;
+#endif /* __rtems__ */
 	return (error);
 }
 
@@ -1056,6 +1070,7 @@ done:
 	return (0);
 }
 
+#ifndef __rtems__
 SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT | CTLFLAG_RWTUN |
     CTLFLAG_MPSAFE, &resettodr_period, 1800, sysctl_resettodr_period, "I",
     "Save system time to RTC with this period (in seconds)");
@@ -1075,3 +1090,5 @@ start_periodic_resettodr(void *arg __unused)
 
 SYSINIT(periodic_resettodr, SI_SUB_LAST, SI_ORDER_MIDDLE,
 	start_periodic_resettodr, NULL);
+
+#endif /* __rtems__ */
diff --git a/libbsd.py b/libbsd.py
index c9151901..a3003344 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -505,6 +505,7 @@ class base(builder.Module):
                 'sys/kern/kern_mib.c',
                 'sys/kern/kern_module.c',
                 'sys/kern/kern_mtxpool.c',
+                'sys/kern/kern_ntptime.c',
                 'sys/kern/kern_osd.c',
                 'sys/kern/kern_synch.c',
                 'sys/kern/kern_sysctl.c',
-- 
2.17.1



More information about the devel mailing list