diff options
Diffstat (limited to 'libbb/time.c')
-rw-r--r-- | libbb/time.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libbb/time.c b/libbb/time.c index f2a7415..3e35542 100644 --- a/libbb/time.c +++ b/libbb/time.c @@ -21,12 +21,23 @@ unsigned long long monotonic_us(void) bb_error_msg_and_die("clock_gettime(MONOTONIC) failed"); return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000; } +unsigned monotonic_sec(void) +{ + struct timespec ts; + if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts)) + bb_error_msg_and_die("clock_gettime(MONOTONIC) failed"); + return ts.tv_sec; +} #else unsigned long long monotonic_us(void) { struct timeval tv; - if (gettimeofday(&tv, NULL)) - bb_error_msg_and_die("gettimeofday failed"); + gettimeofday(&tv, NULL); return tv.tv_sec * 1000000ULL + tv_usec; } + +unsigned monotonic_sec(void) +{ + return time(NULL); +} #endif |