diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-16 21:11:03 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-16 21:11:03 +0000 |
commit | 22b44ad7e83b0b79d24b2dd8a5fff2693f4d6135 (patch) | |
tree | 6100f1c64975e87e8d6565a5df7718ea491965bd /usr.bin/dig/lib | |
parent | dcf239f715eb536fe337084df88935073f470c48 (diff) |
clock_gettime cannot fail if called correctly; unravel TIME_NOW
indirections.
(I'm not convinced that we always want to read CLOCK_REALTIME, in fact
we probably want to almost always read CLOCK_MONOTONIC.)
OK millert
Diffstat (limited to 'usr.bin/dig/lib')
-rw-r--r-- | usr.bin/dig/lib/isc/include/isc/util.h | 7 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/log.c | 8 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/timer.c | 10 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/app.c | 2 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/include/isc/time.h | 18 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/time.c | 13 |
6 files changed, 13 insertions, 45 deletions
diff --git a/usr.bin/dig/lib/isc/include/isc/util.h b/usr.bin/dig/lib/isc/include/isc/util.h index 56390593db8..9a460785692 100644 --- a/usr.bin/dig/lib/isc/include/isc/util.h +++ b/usr.bin/dig/lib/isc/include/isc/util.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: util.h,v 1.1 2020/02/07 09:58:54 florian Exp $ */ +/* $Id: util.h,v 1.2 2020/02/16 21:11:02 florian Exp $ */ #ifndef ISC_UTIL_H #define ISC_UTIL_H 1 @@ -140,9 +140,4 @@ /*% Runtime Check */ #define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond) -/*% - * Time - */ -#define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS) - #endif /* ISC_UTIL_H */ diff --git a/usr.bin/dig/lib/isc/log.c b/usr.bin/dig/lib/isc/log.c index 0d47ea2bf22..76a01473640 100644 --- a/usr.bin/dig/lib/isc/log.c +++ b/usr.bin/dig/lib/isc/log.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.12 2020/02/16 21:09:32 florian Exp $ */ +/* $Id: log.c,v 1.13 2020/02/16 21:11:02 florian Exp $ */ /*! \file * \author Principal Authors: DCL */ @@ -945,7 +945,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, time_string[0] == '\0') { struct timespec now; - TIME_NOW(&now); + clock_gettime(CLOCK_REALTIME, &now); strftime(time_string, sizeof(time_string), "%d-%b-%Y %X", localtime(&now.tv_sec)); } @@ -987,7 +987,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, * which fall within the duplicate_interval * range. */ - TIME_NOW(&oldest); + clock_gettime(CLOCK_REALTIME, &oldest); timespecsub(&oldest, &interval, &oldest); message = ISC_LIST_HEAD(lctx->messages); @@ -1050,7 +1050,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, strlcpy(message->text, lctx->buffer, size); - TIME_NOW(&message->time); + clock_gettime(CLOCK_REALTIME, &message->time); ISC_LINK_INIT(message, link); ISC_LIST_APPEND(lctx->messages, diff --git a/usr.bin/dig/lib/isc/timer.c b/usr.bin/dig/lib/isc/timer.c index 8c4bf3a04d4..20e472b99f9 100644 --- a/usr.bin/dig/lib/isc/timer.c +++ b/usr.bin/dig/lib/isc/timer.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.17 2020/02/16 21:08:59 florian Exp $ */ +/* $Id: timer.c,v 1.18 2020/02/16 21:11:02 florian Exp $ */ /*! \file */ @@ -218,7 +218,7 @@ isc__timer_create(isc_timermgr_t *manager0, const struct timespec *interval, /* * Get current time. */ - TIME_NOW(&now); + clock_gettime(CLOCK_REALTIME, &now); timer = malloc(sizeof(*timer)); if (timer == NULL) @@ -291,7 +291,7 @@ isc__timer_reset(isc_timer_t *timer0, const struct timespec *interval, /* * Get current time. */ - TIME_NOW(&now); + clock_gettime(CLOCK_REALTIME, &now); if (purge) (void)isc_task_purgerange(timer->task, @@ -322,7 +322,7 @@ isc__timer_touch(isc_timer_t *timer0) { REQUIRE(VALID_TIMER(timer)); - TIME_NOW(&now); + clock_gettime(CLOCK_REALTIME, &now); timespecadd(&now, &timer->interval, &timer->idle); } @@ -565,7 +565,7 @@ isc__timermgr_dispatch(isc_timermgr_t *manager0) { manager = timermgr; if (manager == NULL) return; - TIME_NOW(&now); + clock_gettime(CLOCK_REALTIME, &now); dispatch(manager, &now); } diff --git a/usr.bin/dig/lib/isc/unix/app.c b/usr.bin/dig/lib/isc/unix/app.c index eebe9a39936..6c6d5daf236 100644 --- a/usr.bin/dig/lib/isc/unix/app.c +++ b/usr.bin/dig/lib/isc/unix/app.c @@ -331,7 +331,7 @@ evloop(isc__appctx_t *ctx) { else { uint64_t us; - TIME_NOW(&now); + clock_gettime(CLOCK_REALTIME, &now); us = isc_time_microdiff(&when, &now); if (us == 0) call_timer_dispatch = ISC_TRUE; diff --git a/usr.bin/dig/lib/isc/unix/include/isc/time.h b/usr.bin/dig/lib/isc/unix/include/isc/time.h index 9215c8cc972..e225b7292c4 100644 --- a/usr.bin/dig/lib/isc/unix/include/isc/time.h +++ b/usr.bin/dig/lib/isc/unix/include/isc/time.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.h,v 1.13 2020/02/16 21:10:07 florian Exp $ */ +/* $Id: time.h,v 1.14 2020/02/16 21:11:02 florian Exp $ */ #ifndef ISC_TIME_H #define ISC_TIME_H 1 @@ -30,22 +30,6 @@ *** Absolute Times ***/ -isc_result_t -isc_time_now(struct timespec *t); -/*%< - * Set 't' to the current absolute time. - * - * Requires: - * - *\li 't' is a valid pointer. - * - * Returns: - * - *\li Success - *\li Unexpected error - * Getting the time from the system failed. - */ - uint64_t isc_time_microdiff(const struct timespec *t1, const struct timespec *t2); /*%< diff --git a/usr.bin/dig/lib/isc/unix/time.c b/usr.bin/dig/lib/isc/unix/time.c index 34b3115a9dc..ed4e821cd73 100644 --- a/usr.bin/dig/lib/isc/unix/time.c +++ b/usr.bin/dig/lib/isc/unix/time.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.16 2020/02/16 21:10:07 florian Exp $ */ +/* $Id: time.c,v 1.17 2020/02/16 21:11:02 florian Exp $ */ /*! \file */ @@ -43,17 +43,6 @@ *** Absolute Times ***/ -isc_result_t -isc_time_now(struct timespec *t) { - REQUIRE(t != NULL); - - if (clock_gettime(CLOCK_REALTIME, t) == -1) { - UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strerror(errno)); - return (ISC_R_UNEXPECTED); - } - return (ISC_R_SUCCESS); -} - uint64_t isc_time_microdiff(const struct timespec *t1, const struct timespec *t2) { struct timespec res; |