Changeset 5382f61 in rtems


Ignore:
Timestamp:
Oct 28, 2021, 9:14:57 AM (3 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5
Children:
18bbfc7
Parents:
780b468
git-author:
Sebastian Huber <sebastian.huber@…> (10/28/21 09:14:57)
git-committer:
Moyano, Gabriel <gabriel.moyano@…> (11/16/21 09:13:03)
Message:

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.

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/timecounter.h

    r780b468 r5382f61  
    88
    99/*
    10  * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2015, 2021 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    248248extern struct timecounter *_Timecounter;
    249249
     250/**
     251 * @brief Handler doing the NTP update second processing shall have this type.
     252 *
     253 * @param[in, out] adjustment is the NTP time adjustment.
     254 *
     255 * @param[in, out] newsec is the number of seconds since Unix epoch.
     256 */
     257typedef void ( *Timecounter_NTP_update_second )(
     258  int64_t *adjustment,
     259  time_t  *newsec
     260);
     261
     262/**
     263 * @brief Sets the NTP update second handler.
     264 *
     265 * @param handler is the new NTP update second handler used to carry out the
     266 *   NTP update second processing.
     267 */
     268void _Timecounter_Set_NTP_update_second(
     269  Timecounter_NTP_update_second handler
     270);
     271
    250272/** @} */
    251273
  • cpukit/score/src/kern_tc.c

    r780b468 r5382f61  
    8181#define printf(...)
    8282#define log(...)
    83 /* FIXME: https://devel.rtems.org/ticket/2348 */
    84 #define ntp_update_second(a, b) do { (void) a; (void) b; } while (0)
    8583
    8684static inline void
     
    118116        return ((void *)_Atomic_Load_uintptr(ptr, ATOMIC_ORDER_RELAXED));
    119117}
     118
     119static Timecounter_NTP_update_second _Timecounter_NTP_update_second;
     120
     121void
     122_Timecounter_Set_NTP_update_second(Timecounter_NTP_update_second handler)
     123{
     124
     125        _Timecounter_NTP_update_second = handler;
     126}
     127
     128#define ntp_update_second(a, b) (*ntp_update_second_handler)(a, b)
    120129#endif /* __rtems__ */
    121130
     
    16061615        int i;
    16071616        time_t t;
     1617#ifdef __rtems__
     1618        Timecounter_NTP_update_second ntp_update_second_handler;
     1619#endif
    16081620
    16091621        /*
     
    16811693        bt = th->th_offset;
    16821694        bintime_add(&bt, &th->th_boottime);
     1695#ifdef __rtems__
     1696        ntp_update_second_handler = _Timecounter_NTP_update_second;
     1697        if (ntp_update_second_handler != NULL) {
     1698#endif /* __rtems__ */
    16831699        i = bt.sec - tho->th_microtime.tv_sec;
    16841700        if (i > 0) {
     
    16961712                recalculate_scaling_factor_and_large_delta(th);
    16971713        }
     1714#ifdef __rtems__
     1715        }
     1716#endif /* __rtems__ */
    16981717
    16991718        /* Update the UTC timestamps used by the get*() functions. */
Note: See TracChangeset for help on using the changeset viewer.