summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/kern_ntptime.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* pps: Simplify the nsec calculation in pps_event()Sebastian Huber2023-03-071-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let A be the current calculation of the frequency accumulator (pps_fcount) update in pps_event() scale = (uint64_t)1 << 63; scale /= captc->tc_frequency; scale *= 2; bt.sec = 0; bt.frac = 0; bintime_addx(&bt, scale * tcount); bintime2timespec(&bt, &ts); hardpps(tsp, ts.tv_nsec + 1000000000 * ts.tv_sec); and hardpps(..., delta_nsec): u_nsec = delta_nsec; if (u_nsec > (NANOSECOND >> 1)) u_nsec -= NANOSECOND; else if (u_nsec < -(NANOSECOND >> 1)) u_nsec += NANOSECOND; pps_fcount += u_nsec; This change introduces a new calculation which is slightly simpler and more straight forward. Name it B. Consider the following sample values with a tcount of 2000000100 and a tc_frequency of 2000000000 (2GHz). For A, the scale is 9223372036. Then scale * tcount is 18446744994337203600 which is larger than UINT64_MAX (= 18446744073709551615). The result is 920627651984 == 18446744994337203600 % UINT64_MAX. Since all operands are unsigned the result is well defined through modulo arithmetic. The result of bintime2timespec(&bt, &ts) is 49. This is equal to the correct result 1000000049 % NANOSECOND. In hardpps(), both conditional statements are not executed and pps_fcount is incremented by 49. For the new calculation B, we have 1000000000 * tcount is 2000000100000000000 which is less than UINT64_MAX. This yields after the division with tc_frequency the correct result of 1000000050 for delta_nsec. In hardpps(), the first conditional statement is executed and pps_fcount is incremented by 50. This shows that both methods yield roughly the same results. However, method B is easier to understand and requires fewer conditional statements. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/604
* ntptime: ansifyMateusz Guzik2023-03-071-2/+1
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* Clarify hardpps() parameter name and commentSebastian Huber2023-03-071-8/+5
| | | | | | | | | | | | Since 32c203577a5e by phk in 1999 (Make even more of the PPSAPI implementations generic), the "nsec" parameter of hardpps() is a time difference and no longer a time point. Change the name to "delta_nsec" and adjust the comment. Remove comment about a clock tick adjustment which is no longer in the code. Pull Request: https://github.com/freebsd/freebsd-src/pull/640 Reviewed by: imp
* score: Reformat for code coverageSebastian Huber2022-05-231-2/+18
| | | | Close #2349.
* timepps.h: PPS_SYNC defined by defaultGabriel Moyano2022-05-231-10/+0
| | | | Update #2349.
* kern_ntptime.c: Add define in order to remove warningGabriel Moyano2022-05-231-0/+3
| | | | Update #2349.
* kern_ntptime.c: Add lmax() qmin() definitionsGabriel Moyano2022-05-231-0/+2
| | | | Update #2349.
* kern_ntptime.c: Disable freebsd featuresGabriel Moyano2022-05-231-1/+3
| | | | Update #2349.
* kern_ntptime.c: Port to RTEMSSebastian Huber2022-02-211-0/+138
| | | | | | Remove previous adjtime() implementation. Update #2348.
* kern_ntptime.c: Import from FreeBSDSebastian Huber2022-02-211-0/+1053
The file was imported from this repository: https://github.com/freebsd/freebsd.git This commit was used: commit 3ec0dc367bff27c345ad83240625b2057af391b9 Author: Sebastian Huber <sebastian.huber@embedded-brains.de> Date: Mon Feb 7 14:16:16 2022 -0700 kern_ntptime.c: Remove ntp_init() The ntp_init() function did set a couple of global objects to zero. These objects are in the .bss section and already initialized to zero during kernel or module loading. Update #2348.