summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-10-28 11:14:57 +0200
committerMoyano, Gabriel <gabriel.moyano@dlr.de>2021-11-16 10:13:03 +0100
commit5382f617ff3141c429b52b66e0a9ae5663b21750 (patch)
tree7e7c40a63cbbc2f7b1e93d274f0ffa162788ad45 /cpukit/score
parentscore: Optimize timehand updates for non-SMP (diff)
downloadrtems-5382f617ff3141c429b52b66e0a9ae5663b21750.tar.bz2
score: Add _Timecounter_Set_NTP_update_second()
Allow the installation of an NTP update second handler which may be used by an NTP service. Update #4549.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/src/kern_tc.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 1161463a0e..56ec4751ce 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -80,8 +80,6 @@ ISR_LOCK_DEFINE(, _Timecounter_Lock, "Timecounter")
#define hz rtems_clock_get_ticks_per_second()
#define printf(...)
#define log(...)
-/* FIXME: https://devel.rtems.org/ticket/2348 */
-#define ntp_update_second(a, b) do { (void) a; (void) b; } while (0)
static inline void
atomic_thread_fence_acq(void)
@@ -117,6 +115,17 @@ atomic_load_ptr(void *ptr)
return ((void *)_Atomic_Load_uintptr(ptr, ATOMIC_ORDER_RELAXED));
}
+
+static Timecounter_NTP_update_second _Timecounter_NTP_update_second;
+
+void
+_Timecounter_Set_NTP_update_second(Timecounter_NTP_update_second handler)
+{
+
+ _Timecounter_NTP_update_second = handler;
+}
+
+#define ntp_update_second(a, b) (*ntp_update_second_handler)(a, b)
#endif /* __rtems__ */
/*
@@ -1605,6 +1614,9 @@ _Timecounter_Windup(struct bintime *new_boottimebin,
#endif
int i;
time_t t;
+#ifdef __rtems__
+ Timecounter_NTP_update_second ntp_update_second_handler;
+#endif
/*
* Make the next timehands a copy of the current one, but do
@@ -1680,6 +1692,10 @@ _Timecounter_Windup(struct bintime *new_boottimebin,
*/
bt = th->th_offset;
bintime_add(&bt, &th->th_boottime);
+#ifdef __rtems__
+ ntp_update_second_handler = _Timecounter_NTP_update_second;
+ if (ntp_update_second_handler != NULL) {
+#endif /* __rtems__ */
i = bt.sec - tho->th_microtime.tv_sec;
if (i > 0) {
if (i > LARGE_STEP)
@@ -1695,6 +1711,9 @@ _Timecounter_Windup(struct bintime *new_boottimebin,
recalculate_scaling_factor_and_large_delta(th);
}
+#ifdef __rtems__
+ }
+#endif /* __rtems__ */
/* Update the UTC timestamps used by the get*() functions. */
th->th_bintime = bt;