aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/time.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libbb/time.c b/libbb/time.c
index f2a741521..3e35542f3 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -21,12 +21,23 @@ unsigned long long monotonic_us(void)
21 bb_error_msg_and_die("clock_gettime(MONOTONIC) failed"); 21 bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
22 return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000; 22 return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000;
23} 23}
24unsigned monotonic_sec(void)
25{
26 struct timespec ts;
27 if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts))
28 bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
29 return ts.tv_sec;
30}
24#else 31#else
25unsigned long long monotonic_us(void) 32unsigned long long monotonic_us(void)
26{ 33{
27 struct timeval tv; 34 struct timeval tv;
28 if (gettimeofday(&tv, NULL)) 35 gettimeofday(&tv, NULL);
29 bb_error_msg_and_die("gettimeofday failed");
30 return tv.tv_sec * 1000000ULL + tv_usec; 36 return tv.tv_sec * 1000000ULL + tv_usec;
31} 37}
38
39unsigned monotonic_sec(void)
40{
41 return time(NULL);
42}
32#endif 43#endif