diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-30 23:48:01 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-30 23:48:01 +0100 |
commit | 3c13da3dab539eac948de48640d8862857d0c8d0 (patch) | |
tree | 9cf3ae59b79ca89cbcfe08ce6b2b121f37d54a66 /util-linux/hwclock.c | |
parent | 89a55972fd5d7f0ab815c2a62be69a8f34718353 (diff) | |
download | busybox-w32-3c13da3dab539eac948de48640d8862857d0c8d0.tar.gz busybox-w32-3c13da3dab539eac948de48640d8862857d0c8d0.tar.bz2 busybox-w32-3c13da3dab539eac948de48640d8862857d0c8d0.zip |
libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells
function old new delta
xgettimeofday - 11 +11
get_local_var_value 280 281 +1
svlogd_main 1323 1322 -1
change_epoch 67 66 -1
timestamp_and_log 461 458 -3
hwclock_main 301 298 -3
fmt_time_bernstein_25 135 132 -3
step_time 331 326 -5
script_main 1207 1202 -5
machtime 34 28 -6
curtime 61 54 -7
ts_main 423 415 -8
nmeter_main 761 751 -10
gettime1900d 67 46 -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73) Total: -61 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/hwclock.c')
-rw-r--r-- | util-linux/hwclock.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 25db7cdad..723b09589 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c | |||
@@ -79,7 +79,7 @@ static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc) | |||
79 | int before = tm_time.tm_sec; | 79 | int before = tm_time.tm_sec; |
80 | while (1) { | 80 | while (1) { |
81 | rtc_read_tm(&tm_time, fd); | 81 | rtc_read_tm(&tm_time, fd); |
82 | gettimeofday(sys_tv, NULL); | 82 | xgettimeofday(sys_tv); |
83 | if (before != (int)tm_time.tm_sec) | 83 | if (before != (int)tm_time.tm_sec) |
84 | break; | 84 | break; |
85 | } | 85 | } |
@@ -205,7 +205,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) | |||
205 | int rtc; | 205 | int rtc; |
206 | 206 | ||
207 | rtc = rtc_xopen(pp_rtcname, O_WRONLY); | 207 | rtc = rtc_xopen(pp_rtcname, O_WRONLY); |
208 | gettimeofday(&tv, NULL); | 208 | xgettimeofday(&tv); |
209 | /* Prepare tm_time */ | 209 | /* Prepare tm_time */ |
210 | if (sizeof(time_t) == sizeof(tv.tv_sec)) { | 210 | if (sizeof(time_t) == sizeof(tv.tv_sec)) { |
211 | if (utc) | 211 | if (utc) |
@@ -253,7 +253,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) | |||
253 | unsigned rem_usec; | 253 | unsigned rem_usec; |
254 | time_t t; | 254 | time_t t; |
255 | 255 | ||
256 | gettimeofday(&tv, NULL); | 256 | xgettimeofday(&tv); |
257 | 257 | ||
258 | t = tv.tv_sec; | 258 | t = tv.tv_sec; |
259 | rem_usec = 1000000 - tv.tv_usec; | 259 | rem_usec = 1000000 - tv.tv_usec; |
@@ -274,7 +274,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) | |||
274 | } | 274 | } |
275 | 275 | ||
276 | /* gmtime/localtime took some time, re-get cur time */ | 276 | /* gmtime/localtime took some time, re-get cur time */ |
277 | gettimeofday(&tv, NULL); | 277 | xgettimeofday(&tv); |
278 | 278 | ||
279 | if (tv.tv_sec < t /* we are still in old second */ | 279 | if (tv.tv_sec < t /* we are still in old second */ |
280 | || (tv.tv_sec == t && tv.tv_usec < adj) /* not too far into next second */ | 280 | || (tv.tv_sec == t && tv.tv_usec < adj) /* not too far into next second */ |