diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-01-18 17:42:17 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-01-18 17:42:17 +0100 |
commit | 479bd7af0d24d123326c1ceb447e015e9e2955d7 (patch) | |
tree | 7525847e4fc969e31e0c09beba49eb6eb5703cd3 | |
parent | c344ca6c7f5d8468624ae518d2912d1d9612cb91 (diff) | |
download | busybox-w32-479bd7af0d24d123326c1ceb447e015e9e2955d7.tar.gz busybox-w32-479bd7af0d24d123326c1ceb447e015e9e2955d7.tar.bz2 busybox-w32-479bd7af0d24d123326c1ceb447e015e9e2955d7.zip |
ntpd: fold d_to_tv() into its only caller
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ntpd.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index ff49550e9..db04eb272 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -551,13 +551,6 @@ gettime1900d(void) | |||
551 | return G.cur_time; | 551 | return G.cur_time; |
552 | } | 552 | } |
553 | 553 | ||
554 | static void | ||
555 | d_to_tv(struct timeval *tv, double d) | ||
556 | { | ||
557 | tv->tv_sec = (time_t)d; | ||
558 | tv->tv_usec = (d - tv->tv_sec) * 1000000; | ||
559 | } | ||
560 | |||
561 | static NOINLINE double | 554 | static NOINLINE double |
562 | lfp_to_d(l_fixedpt_t lfp) | 555 | lfp_to_d(l_fixedpt_t lfp) |
563 | { | 556 | { |
@@ -1044,8 +1037,17 @@ step_time(double offset) | |||
1044 | time_t tval; | 1037 | time_t tval; |
1045 | 1038 | ||
1046 | xgettimeofday(&tvc); | 1039 | xgettimeofday(&tvc); |
1040 | /* This code adds floating point value on the order of 1.0 | ||
1041 | * to a value of ~4 billion (as of years 203x). | ||
1042 | * With 52-bit mantissa, "only" 20 bits of offset's precision | ||
1043 | * are used (0.01 attosecond), the rest is lost. | ||
1044 | * Some 200 billion years later, when tvc.tv_sec would have | ||
1045 | * 63 significant bits, the precision loss would be catastrophic, | ||
1046 | * a more complex code would be needed. | ||
1047 | */ | ||
1047 | dtime = tvc.tv_sec + (1.0e-6 * tvc.tv_usec) + offset; | 1048 | dtime = tvc.tv_sec + (1.0e-6 * tvc.tv_usec) + offset; |
1048 | d_to_tv(&tvn, dtime); | 1049 | tvn.tv_sec = (time_t)dtime; |
1050 | tvn.tv_usec = (dtime - tvn.tv_sec) * 1000000; | ||
1049 | xsettimeofday(&tvn); | 1051 | xsettimeofday(&tvn); |
1050 | 1052 | ||
1051 | VERB2 { | 1053 | VERB2 { |