MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ntp_update_second

Function ntp_update_second

freebsd/kern/kern_ntptime.c:503–633  ·  view source on GitHub ↗

* second_overflow() - called after ntp_tick_adjust() * * This routine is ordinarily called immediately following the above * routine ntp_tick_adjust(). While these two routines are normally * combined, they are separated here only for the purposes of * simulation. */

Source from the content-addressed store, hash-verified

501 * simulation.
502 */
503void
504ntp_update_second(int64_t *adjustment, time_t *newsec)
505{
506 int tickrate;
507 l_fp ftemp; /* 32/64-bit temporary */
508
509 NTP_LOCK();
510
511 /*
512 * On rollover of the second both the nanosecond and microsecond
513 * clocks are updated and the state machine cranked as
514 * necessary. The phase adjustment to be used for the next
515 * second is calculated and the maximum error is increased by
516 * the tolerance.
517 */
518 time_maxerror += MAXFREQ / 1000;
519
520 /*
521 * Leap second processing. If in leap-insert state at
522 * the end of the day, the system clock is set back one
523 * second; if in leap-delete state, the system clock is
524 * set ahead one second. The nano_time() routine or
525 * external clock driver will insure that reported time
526 * is always monotonic.
527 */
528 switch (time_state) {
529 /*
530 * No warning.
531 */
532 case TIME_OK:
533 if (time_status & STA_INS)
534 time_state = TIME_INS;
535 else if (time_status & STA_DEL)
536 time_state = TIME_DEL;
537 break;
538
539 /*
540 * Insert second 23:59:60 following second
541 * 23:59:59.
542 */
543 case TIME_INS:
544 if (!(time_status & STA_INS))
545 time_state = TIME_OK;
546 else if ((*newsec) % 86400 == 0) {
547 (*newsec)--;
548 time_state = TIME_OOP;
549 time_tai++;
550 }
551 break;
552
553 /*
554 * Delete second 23:59:59.
555 */
556 case TIME_DEL:
557 if (!(time_status & STA_DEL))
558 time_state = TIME_OK;
559 else if (((*newsec) + 1) % 86400 == 0) {
560 (*newsec)++;

Callers 1

kern_tc.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected