]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Deduplicate time unit conversion factors
authorTony Finch <fanf@isc.org>
Fri, 4 Nov 2022 12:02:33 +0000 (12:02 +0000)
committerTony Finch <dot@dotat.at>
Fri, 25 Nov 2022 13:23:36 +0000 (13:23 +0000)
The various factors like NS_PER_MS are now defined in a single place
and the names are no longer inconsistent. I chose the _PER_SEC names
rather than _PER_S because it is slightly more clear in isolation;
but the smaller units are always NS, US, and MS.

CHANGES
bin/tools/mdig.c
lib/dns/resolver.c
lib/isc/include/isc/time.h
lib/isc/stdtime.c
lib/isc/time.c
tests/isc/ratelimiter_test.c
tests/isc/time_test.c
tests/isc/timer_test.c

diff --git a/CHANGES b/CHANGES
index bd078844bcaa24902b35cfd731d24bfa5e28548d..80f83cb891ab271c8abf8c97208e9303a2debd90 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+6026.  [cleanup]       Deduplicate time unit conversion factors.
+                       [GL !7033]
+
 6025.  [bug]           Copy TLS identifier when setting up primaries for
                        catalog member zones. [GL #3638]
 
index 368730b0e96b9607a914e45ff76f309529e60e97..e0214cd816a596efc36cd547e845fe91354cd3ad 100644 (file)
@@ -36,6 +36,7 @@
 #include <isc/sockaddr.h>
 #include <isc/string.h>
 #include <isc/task.h>
+#include <isc/time.h>
 #include <isc/util.h>
 
 #include <dns/byaddr.h>
 #define UDPTIMEOUT 5
 #define MAXTRIES   0xffffffff
 
-#define NS_PER_US  1000           /*%< Nanoseconds per microsecond. */
-#define US_PER_SEC 1000000 /*%< Microseconds per second. */
-#define US_PER_MS  1000           /*%< Microseconds per millisecond. */
-
 static isc_mem_t *mctx = NULL;
 static isc_task_t *global_task = NULL;
 static isc_loopmgr_t *loopmgr = NULL;
index 5a264de86e2f551448d4183d68cc7030210c5f58..fa57133df3a134bf32babfd7f2bafd5973e6bf39 100644 (file)
@@ -33,6 +33,7 @@
 #include <isc/string.h>
 #include <isc/task.h>
 #include <isc/tid.h>
+#include <isc/time.h>
 #include <isc/timer.h>
 #include <isc/util.h>
 
 #define fctx_addref(f) fctx_attach((f), &(fetchctx_t *){ NULL })
 #define fctx_unref(f)  fctx_detach(&(fetchctx_t *){ (f) })
 
-#define US_PER_SEC  1000000U
-#define US_PER_MSEC 1000U
-#define NS_PER_US   1000U
 /*
  * The maximum time we will wait for a single query.
  */
 #define MAX_SINGLE_QUERY_TIMEOUT    9000U
-#define MAX_SINGLE_QUERY_TIMEOUT_US (MAX_SINGLE_QUERY_TIMEOUT * US_PER_MSEC)
+#define MAX_SINGLE_QUERY_TIMEOUT_US (MAX_SINGLE_QUERY_TIMEOUT * US_PER_MS)
 
 /*
  * We need to allow a individual query time to complete / timeout.
@@ -1358,7 +1356,7 @@ fctx_cancelquery(resquery_t **queryp, isc_time_t *finish, bool no_response,
                                                               &query->start);
                        factor = DNS_ADB_RTTADJDEFAULT;
 
-                       rttms = rtt / US_PER_MSEC;
+                       rttms = rtt / US_PER_MS;
                        if (rttms < DNS_RESOLVER_QRYRTTCLASS0) {
                                inc_stats(fctx->res,
                                          dns_resstatscounter_queryrtt0);
@@ -2011,13 +2009,13 @@ fctx_setretryinterval(fetchctx_t *fctx, unsigned int rtt) {
         */
        isc_time_now(&now);
        limit = isc_time_microdiff(&fctx->expires, &now);
-       if (limit < US_PER_MSEC) {
+       if (limit < US_PER_MS) {
                FCTXTRACE("fetch already expired");
                isc_interval_set(&fctx->interval, 0, 0);
                return;
        }
 
-       us = fctx->res->retryinterval * US_PER_MSEC;
+       us = fctx->res->retryinterval * US_PER_MS;
 
        /*
         * Exponential backoff after the first few tries.
@@ -2056,7 +2054,7 @@ fctx_setretryinterval(fetchctx_t *fctx, unsigned int rtt) {
        if ((fctx->options & DNS_FETCHOPT_TRYSTALE_ONTIMEOUT) != 0) {
                uint64_t stale = isc_time_microdiff(&fctx->expires_try_stale,
                                                    &now);
-               if (stale >= US_PER_MSEC && us > stale) {
+               if (stale >= US_PER_MS && us > stale) {
                        FCTXTRACE("setting stale timeout");
                        us = stale;
                }
@@ -2097,7 +2095,7 @@ resquery_timeout(resquery_t *query) {
         */
        isc_time_now(&now);
        timeleft = isc_time_microdiff(&fctx->expires_try_stale, &now);
-       if (timeleft >= US_PER_MSEC) {
+       if (timeleft >= US_PER_MS) {
                return (ISC_R_SUCCESS);
        }
 
@@ -2126,8 +2124,8 @@ resquery_timeout(resquery_t *query) {
         * resume waiting.
         */
        timeleft = isc_time_microdiff(&fctx->next_timeout, &now);
-       if (timeleft >= US_PER_MSEC) {
-               dns_dispatch_resume(query->dispentry, (timeleft / US_PER_MSEC));
+       if (timeleft >= US_PER_MS) {
+               dns_dispatch_resume(query->dispentry, (timeleft / US_PER_MS));
                return (ISC_R_COMPLETE);
        }
 
@@ -8156,7 +8154,7 @@ rctx_timedout(respctx_t *rctx) {
 
                isc_time_now(&now);
                /* netmgr timeouts are accurate to the millisecond */
-               if (isc_time_microdiff(&fctx->expires, &now) < US_PER_MSEC) {
+               if (isc_time_microdiff(&fctx->expires, &now) < US_PER_MS) {
                        FCTXTRACE("stopped trying to make fetch happen");
                } else {
                        FCTXTRACE("query timed out; no response");
index 5dff7f8b60f55ec2c6c82eb0154273a12df3d172..9470903152fd018eaf612aeaf99a864cf5eedd39 100644 (file)
 #include <isc/lang.h>
 #include <isc/types.h>
 
+enum {
+       MS_PER_SEC = 1000,               /*%< Milliseonds per second. */
+       US_PER_MS = 1000,                /*%< Microseconds per millisecond. */
+       US_PER_SEC = 1000 * 1000,        /*%< Microseconds per second. */
+       NS_PER_US = 1000,                /*%< Nanoseconds per millisecond. */
+       NS_PER_MS = 1000 * 1000,         /*%< Nanoseconds per microsecond. */
+       NS_PER_SEC = 1000 * 1000 * 1000, /*%< Nanoseconds per second. */
+};
+
 /*
  * ISC_FORMATHTTPTIMESTAMP_SIZE needs to be 30 in C locale and potentially
  * more for other locales to handle longer national abbreviations when
index 086c0c775bd448782b052206a392b4229bf30944..6fecebb605bbf3c744b505d63bcfe96f1f8b3082 100644 (file)
 
 #include <isc/stdtime.h>
 #include <isc/strerr.h>
+#include <isc/time.h>
 #include <isc/util.h>
 
-#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
-
 #if defined(CLOCK_REALTIME_COARSE)
 #define CLOCKSOURCE CLOCK_REALTIME_COARSE
 #elif defined(CLOCK_REALTIME_FAST)
@@ -44,7 +43,7 @@ isc_stdtime_get(isc_stdtime_t *t) {
                FATAL_SYSERROR(errno, "clock_gettime()");
        }
 
-       REQUIRE(ts.tv_sec > 0 && ts.tv_nsec >= 0 && ts.tv_nsec < NS_PER_S);
+       REQUIRE(ts.tv_sec > 0 && ts.tv_nsec >= 0 && ts.tv_nsec < NS_PER_SEC);
 
        *t = (isc_stdtime_t)ts.tv_sec;
 }
index 8570a9439a0e683bae9d1604bd936f43c757aa3d..d1b55996ddccdef34e941b0e3230980908fa4352 100644 (file)
 #include <isc/tm.h>
 #include <isc/util.h>
 
-#define NS_PER_S  1000000000 /*%< Nanoseconds per second. */
-#define NS_PER_US 1000      /*%< Nanoseconds per microsecond. */
-#define NS_PER_MS 1000000    /*%< Nanoseconds per millisecond. */
-#define MS_PER_S  1000      /*%< Milliseonds per second. */
-
 #if defined(CLOCK_REALTIME)
 #define CLOCKSOURCE_HIRES CLOCK_REALTIME
 #endif /* #if defined(CLOCK_REALTIME) */
@@ -59,7 +54,7 @@ const isc_time_t *const isc_time_epoch = &epoch;
 void
 isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
        REQUIRE(t != NULL);
-       REQUIRE(nanoseconds < NS_PER_S);
+       REQUIRE(nanoseconds < NS_PER_SEC);
 
        t->seconds = seconds;
        t->nanoseconds = nanoseconds;
@@ -76,7 +71,7 @@ isc_time_settoepoch(isc_time_t *t) {
 bool
 isc_time_isepoch(const isc_time_t *t) {
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
 
        if (t->seconds == 0 && t->nanoseconds == 0) {
                return (true);
@@ -96,7 +91,7 @@ time_now(isc_time_t *t, clockid_t clock) {
                return (ISC_R_UNEXPECTED);
        }
 
-       if (ts.tv_sec < 0 || ts.tv_nsec < 0 || ts.tv_nsec >= NS_PER_S) {
+       if (ts.tv_sec < 0 || ts.tv_nsec < 0 || ts.tv_nsec >= NS_PER_SEC) {
                return (ISC_R_UNEXPECTED);
        }
 
@@ -131,14 +126,14 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
 
        REQUIRE(t != NULL);
        REQUIRE(i != NULL);
-       INSIST(i->nanoseconds < NS_PER_S);
+       INSIST(i->nanoseconds < NS_PER_SEC);
 
        if (clock_gettime(CLOCKSOURCE, &ts) == -1) {
                UNEXPECTED_SYSERROR(errno, "clock_gettime()");
                return (ISC_R_UNEXPECTED);
        }
 
-       if (ts.tv_sec < 0 || ts.tv_nsec < 0 || ts.tv_nsec >= NS_PER_S) {
+       if (ts.tv_sec < 0 || ts.tv_nsec < 0 || ts.tv_nsec >= NS_PER_SEC) {
                return (ISC_R_UNEXPECTED);
        }
 
@@ -156,9 +151,9 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
 
        t->seconds = ts.tv_sec + i->seconds;
        t->nanoseconds = ts.tv_nsec + i->nanoseconds;
-       if (t->nanoseconds >= NS_PER_S) {
+       if (t->nanoseconds >= NS_PER_SEC) {
                t->seconds++;
-               t->nanoseconds -= NS_PER_S;
+               t->nanoseconds -= NS_PER_SEC;
        }
 
        return (ISC_R_SUCCESS);
@@ -167,7 +162,7 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
 int
 isc_time_compare(const isc_time_t *t1, const isc_time_t *t2) {
        REQUIRE(t1 != NULL && t2 != NULL);
-       INSIST(t1->nanoseconds < NS_PER_S && t2->nanoseconds < NS_PER_S);
+       INSIST(t1->nanoseconds < NS_PER_SEC && t2->nanoseconds < NS_PER_SEC);
 
        if (t1->seconds < t2->seconds) {
                return (-1);
@@ -187,7 +182,7 @@ isc_time_compare(const isc_time_t *t1, const isc_time_t *t2) {
 isc_result_t
 isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result) {
        REQUIRE(t != NULL && i != NULL && result != NULL);
-       REQUIRE(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
+       REQUIRE(t->nanoseconds < NS_PER_SEC && i->nanoseconds < NS_PER_SEC);
 
        /* Seconds */
 #if HAVE_BUILTIN_ADD_OVERFLOW
@@ -203,11 +198,11 @@ isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result) {
 
        /* Nanoseconds */
        result->nanoseconds = t->nanoseconds + i->nanoseconds;
-       if (result->nanoseconds >= NS_PER_S) {
+       if (result->nanoseconds >= NS_PER_SEC) {
                if (result->seconds == UINT_MAX) {
                        return (ISC_R_RANGE);
                }
-               result->nanoseconds -= NS_PER_S;
+               result->nanoseconds -= NS_PER_SEC;
                result->seconds++;
        }
 
@@ -218,7 +213,7 @@ isc_result_t
 isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
                  isc_time_t *result) {
        REQUIRE(t != NULL && i != NULL && result != NULL);
-       REQUIRE(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
+       REQUIRE(t->nanoseconds < NS_PER_SEC && i->nanoseconds < NS_PER_SEC);
 
        /* Seconds */
 #if HAVE_BUILTIN_SUB_OVERFLOW
@@ -240,7 +235,7 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
                        return (ISC_R_RANGE);
                }
                result->seconds--;
-               result->nanoseconds = NS_PER_S + t->nanoseconds -
+               result->nanoseconds = NS_PER_SEC + t->nanoseconds -
                                      i->nanoseconds;
        }
 
@@ -252,10 +247,10 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
        uint64_t i1, i2, i3;
 
        REQUIRE(t1 != NULL && t2 != NULL);
-       INSIST(t1->nanoseconds < NS_PER_S && t2->nanoseconds < NS_PER_S);
+       INSIST(t1->nanoseconds < NS_PER_SEC && t2->nanoseconds < NS_PER_SEC);
 
-       i1 = (uint64_t)t1->seconds * NS_PER_S + t1->nanoseconds;
-       i2 = (uint64_t)t2->seconds * NS_PER_S + t2->nanoseconds;
+       i1 = (uint64_t)t1->seconds * NS_PER_SEC + t1->nanoseconds;
+       i2 = (uint64_t)t2->seconds * NS_PER_SEC + t2->nanoseconds;
 
        if (i1 <= i2) {
                return (0);
@@ -274,7 +269,7 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
 uint32_t
 isc_time_seconds(const isc_time_t *t) {
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
 
        return ((uint32_t)t->seconds);
 }
@@ -284,7 +279,7 @@ isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp) {
        time_t seconds;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
 
        /*
         * Ensure that the number of seconds represented by t->seconds
@@ -321,7 +316,7 @@ uint32_t
 isc_time_nanoseconds(const isc_time_t *t) {
        REQUIRE(t != NULL);
 
-       ENSURE(t->nanoseconds < NS_PER_S);
+       ENSURE(t->nanoseconds < NS_PER_SEC);
 
        return ((uint32_t)t->nanoseconds);
 }
@@ -329,9 +324,9 @@ isc_time_nanoseconds(const isc_time_t *t) {
 uint32_t
 isc_time_miliseconds(const isc_time_t *t) {
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
 
-       return ((t->seconds * MS_PER_S) + (t->nanoseconds / NS_PER_MS));
+       return ((t->seconds * MS_PER_SEC) + (t->nanoseconds / NS_PER_MS));
 }
 
 void
@@ -341,7 +336,7 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -363,7 +358,7 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -405,7 +400,7 @@ isc_time_formatISO8601L(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -421,7 +416,7 @@ isc_time_formatISO8601Lms(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -441,7 +436,7 @@ isc_time_formatISO8601Lus(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -461,7 +456,7 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -477,7 +472,7 @@ isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -498,7 +493,7 @@ isc_time_formatISO8601us(const isc_time_t *t, char *buf, unsigned int len) {
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
@@ -520,7 +515,7 @@ isc_time_formatshorttimestamp(const isc_time_t *t, char *buf,
        struct tm tm;
 
        REQUIRE(t != NULL);
-       INSIST(t->nanoseconds < NS_PER_S);
+       INSIST(t->nanoseconds < NS_PER_SEC);
        REQUIRE(buf != NULL);
        REQUIRE(len > 0);
 
index 7f82f3088a7f55786fd11620539932566587c405..81c0a71b02462611c10603ba6c9bde5ded062c0c 100644 (file)
 #include <isc/loop.h>
 #include <isc/ratelimiter.h>
 #include <isc/task.h>
+#include <isc/time.h>
 
 #include "ratelimiter.c"
 
 #include <tests/isc.h>
 
-#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
-
 isc_ratelimiter_t *rl = NULL;
 
 ISC_LOOP_TEST_IMPL(ratelimiter_create) {
@@ -220,7 +219,7 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_pertick_interval) {
        isc_event_t *event = NULL;
        isc_interval_t interval;
 
-       isc_interval_set(&interval, 1, NS_PER_S / 10);
+       isc_interval_set(&interval, 1, NS_PER_SEC / 10);
 
        expect_assert_failure(isc_ratelimiter_setinterval(NULL, &interval));
        expect_assert_failure(isc_ratelimiter_setinterval(rl, NULL));
@@ -263,7 +262,7 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_pushpop) {
        isc_event_t *event = NULL;
        isc_interval_t interval;
 
-       isc_interval_set(&interval, 1, NS_PER_S / 10);
+       isc_interval_set(&interval, 1, NS_PER_SEC / 10);
 
        isc_ratelimiter_setinterval(rl, &interval);
        isc_ratelimiter_setpertic(rl, 2);
index 4b355a700305014b414f3c51ef0bb21b7a14dfe4..70858e90d611935ad709453208d742812c787574 100644 (file)
@@ -30,8 +30,7 @@
 
 #include <tests/isc.h>
 
-#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
-#define MAX_NS  (NS_PER_S - 1)
+#define MAX_NS (NS_PER_SEC - 1)
 
 struct time_vectors {
        isc_time_t a;
@@ -43,13 +42,16 @@ struct time_vectors {
 const struct time_vectors vectors_add[8] = {
        { { 0, 0 }, { 0, 0 }, { 0, 0 }, ISC_R_SUCCESS },
        { { 0, MAX_NS }, { 0, MAX_NS }, { 1, MAX_NS - 1 }, ISC_R_SUCCESS },
-       { { 0, NS_PER_S / 2 }, { 0, NS_PER_S / 2 }, { 1, 0 }, ISC_R_SUCCESS },
+       { { 0, NS_PER_SEC / 2 },
+         { 0, NS_PER_SEC / 2 },
+         { 1, 0 },
+         ISC_R_SUCCESS },
        { { UINT_MAX, MAX_NS }, { 0, 0 }, { UINT_MAX, MAX_NS }, ISC_R_SUCCESS },
        { { UINT_MAX, 0 }, { 0, MAX_NS }, { UINT_MAX, MAX_NS }, ISC_R_SUCCESS },
        { { UINT_MAX, 0 }, { 1, 0 }, { 0, 0 }, ISC_R_RANGE },
        { { UINT_MAX, MAX_NS }, { 0, 1 }, { 0, 0 }, ISC_R_RANGE },
-       { { UINT_MAX / 2 + 1, NS_PER_S / 2 },
-         { UINT_MAX / 2, NS_PER_S / 2 },
+       { { UINT_MAX / 2 + 1, NS_PER_SEC / 2 },
+         { UINT_MAX / 2, NS_PER_SEC / 2 },
          { 0, 0 },
          ISC_R_RANGE },
 };
@@ -57,9 +59,9 @@ const struct time_vectors vectors_add[8] = {
 const struct time_vectors vectors_sub[7] = {
        { { 0, 0 }, { 0, 0 }, { 0, 0 }, ISC_R_SUCCESS },
        { { 1, 0 }, { 0, MAX_NS }, { 0, 1 }, ISC_R_SUCCESS },
-       { { 1, NS_PER_S / 2 },
+       { { 1, NS_PER_SEC / 2 },
          { 0, MAX_NS },
-         { 0, NS_PER_S / 2 + 1 },
+         { 0, NS_PER_SEC / 2 + 1 },
          ISC_R_SUCCESS },
        { { UINT_MAX, MAX_NS }, { UINT_MAX, 0 }, { 0, MAX_NS }, ISC_R_SUCCESS },
        { { 0, 0 }, { 1, 0 }, { 0, 0 }, ISC_R_RANGE },
index f2d9176f52f9b28eb699b75f0c01f677c08b58a4..6a1a420179fd83266e1e5f92f20b9c8f932c44e2 100644 (file)
@@ -422,7 +422,6 @@ uint64_t timer_ticks;
 isc_interval_t timer_interval;
 isc_timertype_t timer_type;
 
-#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
 ISC_LOOP_TEARDOWN_IMPL(timer_expect) {
        uint64_t diff = (timer_stop - timer_start) / 1000000000;
        assert_true(diff == timer_expect);
@@ -491,7 +490,7 @@ ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_from_callback,
                          teardown_loop_timer_expect) {
        isc_timer_create(mainloop, timer_event, NULL, &timer);
 
-       isc_interval_set(&timer_interval, 0, NS_PER_S / 2);
+       isc_interval_set(&timer_interval, 0, NS_PER_SEC / 2);
        isc_timer_start(timer, timer_type, &timer_interval);
 }
 
@@ -526,7 +525,7 @@ ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_ticker, setup_loop_reschedule_ticker,
        isc_timer_start(timer, timer_type, &timer_interval);
 
        /* Then fire every 1/4 second */
-       isc_interval_set(&timer_interval, 0, NS_PER_S / 4);
+       isc_interval_set(&timer_interval, 0, NS_PER_SEC / 4);
 }
 
 ISC_TEST_LIST_START