diff options
Diffstat (limited to 'libbb/time.c')
-rw-r--r-- | libbb/time.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libbb/time.c b/libbb/time.c index e66a9cba8..cf5f2e5c8 100644 --- a/libbb/time.c +++ b/libbb/time.c | |||
@@ -90,7 +90,11 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) | |||
90 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ | 90 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ |
91 | } else | 91 | } else |
92 | if (date_str[0] == '@') { | 92 | if (date_str[0] == '@') { |
93 | time_t t = bb_strtol(date_str + 1, NULL, 10); | 93 | time_t t; |
94 | if (sizeof(t) <= sizeof(long)) | ||
95 | t = bb_strtol(date_str + 1, NULL, 10); | ||
96 | else /* time_t is 64 bits but longs are smaller */ | ||
97 | t = bb_strtoll(date_str + 1, NULL, 10); | ||
94 | if (!errno) { | 98 | if (!errno) { |
95 | struct tm *lt = localtime(&t); | 99 | struct tm *lt = localtime(&t); |
96 | if (lt) { | 100 | if (lt) { |
@@ -246,7 +250,6 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) | |||
246 | 250 | ||
247 | #if ENABLE_MONOTONIC_SYSCALL | 251 | #if ENABLE_MONOTONIC_SYSCALL |
248 | 252 | ||
249 | #include <sys/syscall.h> | ||
250 | /* Old glibc (< 2.3.4) does not provide this constant. We use syscall | 253 | /* Old glibc (< 2.3.4) does not provide this constant. We use syscall |
251 | * directly so this definition is safe. */ | 254 | * directly so this definition is safe. */ |
252 | #ifndef CLOCK_MONOTONIC | 255 | #ifndef CLOCK_MONOTONIC |
@@ -288,19 +291,19 @@ unsigned FAST_FUNC monotonic_sec(void) | |||
288 | unsigned long long FAST_FUNC monotonic_ns(void) | 291 | unsigned long long FAST_FUNC monotonic_ns(void) |
289 | { | 292 | { |
290 | struct timeval tv; | 293 | struct timeval tv; |
291 | gettimeofday(&tv, NULL); | 294 | xgettimeofday(&tv); |
292 | return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000; | 295 | return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000; |
293 | } | 296 | } |
294 | unsigned long long FAST_FUNC monotonic_us(void) | 297 | unsigned long long FAST_FUNC monotonic_us(void) |
295 | { | 298 | { |
296 | struct timeval tv; | 299 | struct timeval tv; |
297 | gettimeofday(&tv, NULL); | 300 | xgettimeofday(&tv); |
298 | return tv.tv_sec * 1000000ULL + tv.tv_usec; | 301 | return tv.tv_sec * 1000000ULL + tv.tv_usec; |
299 | } | 302 | } |
300 | unsigned long long FAST_FUNC monotonic_ms(void) | 303 | unsigned long long FAST_FUNC monotonic_ms(void) |
301 | { | 304 | { |
302 | struct timeval tv; | 305 | struct timeval tv; |
303 | gettimeofday(&tv, NULL); | 306 | xgettimeofday(&tv); |
304 | return tv.tv_sec * 1000ULL + tv.tv_usec / 1000; | 307 | return tv.tv_sec * 1000ULL + tv.tv_usec / 1000; |
305 | } | 308 | } |
306 | unsigned FAST_FUNC monotonic_sec(void) | 309 | unsigned FAST_FUNC monotonic_sec(void) |