Commit c92b4966 authored by Rusty Russell's avatar Rusty Russell

time: split absolute and relative times.

As suggested by David Gibson.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent cff3316c
......@@ -5,7 +5,8 @@
* time - routines for dealing with time
*
* This code provides convenient functions for working with time, in the
* form of 'struct timespec'.
* form of 'struct timerel' for durations and 'struct timeabs' for timestamps
* which are light wrappers around struct timespec.
*
* Author: Rusty Russell <rusty@rustcorp.com.au>
* License: BSD-MIT
......@@ -18,19 +19,19 @@
*
* int main(int argc, char *argv[])
* {
* struct timespec t;
* struct timeabs t;
*
* if (argc != 2)
* errx(1, "Usage: %s <diff in millisec>", argv[0]);
*
* t = time_now();
* if (argv[1][0] == '-')
* t = time_sub(t, time_from_msec(atol(argv[1]+1)));
* t = timeabs_sub(t, time_from_msec(atol(argv[1]+1)));
* else
* t = time_add(t, time_from_msec(atol(argv[1])));
* t = timeabs_add(t, time_from_msec(atol(argv[1])));
*
* printf("%lu.%09u\n",
* (unsigned long)t.tv_sec, (unsigned)t.tv_nsec);
* (unsigned long)t.ts.tv_sec, (unsigned)t.ts.tv_nsec);
* return 0;
* }
*/
......
......@@ -16,140 +16,145 @@ void abort(void)
int main(void)
{
struct timespec t1, t2, t3, zero = { 0, 0 };
struct timeabs t1, t2, epoch = { { 0, 0 } };
struct timerel t3, t4, zero = { { 0, 0 } };
int fds[2];
plan_tests(62);
plan_tests(64);
/* Test time_now */
t1 = time_now();
t2 = time_now();
/* Test time_sub. */
t3 = time_sub(t2, t1);
ok1(t3.tv_sec > 0 || t3.tv_nsec >= 0);
t3 = time_sub(t2, t2);
ok1(t3.tv_sec == 0 && t3.tv_nsec == 0);
t3 = time_sub(t1, t1);
ok1(t3.tv_sec == 0 && t3.tv_nsec == 0);
/* Test time_eq */
ok1(time_eq(t1, t1));
ok1(time_eq(t2, t2));
ok1(!time_eq(t1, t3));
ok1(!time_eq(t2, t3));
/* Test time_between. */
t3 = time_between(t2, t1);
ok1(t3.ts.tv_sec > 0 || t3.ts.tv_nsec >= 0);
t3 = time_between(t2, t2);
ok1(t3.ts.tv_sec == 0 && t3.ts.tv_nsec == 0);
t3 = time_between(t1, t1);
ok1(t3.ts.tv_sec == 0 && t3.ts.tv_nsec == 0);
/* Test timeabs_eq / timerel_eq */
ok1(timeabs_eq(t1, t1));
ok1(timeabs_eq(t2, t2));
ok1(!timeabs_eq(t1, epoch));
ok1(!timeabs_eq(t2, epoch));
t3.ts.tv_sec = 1;
ok1(timerel_eq(t3, t3));
ok1(!timerel_eq(t3, zero));
/* Make sure t2 > t1. */
t3.tv_sec = 0;
t3.tv_nsec = 1;
t2 = time_add(t2, t3);
/* Test time_less and time_greater. */
ok1(!time_eq(t1, t2));
ok1(!time_greater(t1, t2));
ok1(time_less(t1, t2));
ok1(time_greater(t2, t1));
ok1(!time_less(t2, t1));
t3.tv_sec = 0;
t3.tv_nsec = 999999999;
t2 = time_add(t2, t3);
ok1(!time_eq(t1, t2));
ok1(!time_greater(t1, t2));
ok1(time_less(t1, t2));
ok1(time_greater(t2, t1));
ok1(!time_less(t2, t1));
t3 = time_sub(t2, zero);
ok1(time_eq(t3, t2));
t3 = time_sub(t2, t2);
ok1(time_eq(t3, zero));
t3.ts.tv_sec = 0;
t3.ts.tv_nsec = 1;
t2 = timeabs_add(t2, t3);
/* Test time_before and time_after. */
ok1(!timeabs_eq(t1, t2));
ok1(!time_after(t1, t2));
ok1(time_before(t1, t2));
ok1(time_after(t2, t1));
ok1(!time_before(t2, t1));
t3.ts.tv_sec = 0;
t3.ts.tv_nsec = 999999999;
t2 = timeabs_add(t2, t3);
ok1(!timeabs_eq(t1, t2));
ok1(!time_after(t1, t2));
ok1(time_before(t1, t2));
ok1(time_after(t2, t1));
ok1(!time_before(t2, t1));
t3 = time_between(t2, epoch);
ok1(t2.ts.tv_sec == t3.ts.tv_sec && t2.ts.tv_nsec == t3.ts.tv_nsec);
t3 = time_between(t2, t2);
ok1(timerel_eq(t3, zero));
/* time_from_msec / time_to_msec */
t3 = time_from_msec(500);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_msec(t3) == 500);
t3 = time_from_msec(1000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_msec(t3) == 1000);
t3 = time_from_msec(1500);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_msec(t3) == 1500);
/* time_from_usec */
t3 = time_from_usec(500000);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_usec(t3) == 500000);
t3 = time_from_usec(1000000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_usec(t3) == 1000000);
t3 = time_from_usec(1500000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_usec(t3) == 1500000);
/* time_from_nsec */
t3 = time_from_nsec(500000000);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_nsec(t3) == 500000000);
t3 = time_from_nsec(1000000000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_nsec(t3) == 1000000000);
t3 = time_from_nsec(1500000000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_nsec(t3) == 1500000000);
/* Test wrapunder */
t3 = time_sub(time_sub(t2, time_from_msec(500)), time_from_msec(500));
ok1(t3.tv_sec == t2.tv_sec - 1);
ok1(t3.tv_nsec == t2.tv_nsec);
t1 = timeabs_sub(timeabs_sub(t2, time_from_msec(500)),
time_from_msec(500));
ok1(t1.ts.tv_sec == t2.ts.tv_sec - 1);
ok1(t1.ts.tv_nsec == t2.ts.tv_nsec);
/* time_divide and time_multiply */
t1.tv_nsec = 100;
t1.tv_sec = 100;
t4.ts.tv_nsec = 100;
t4.ts.tv_sec = 100;
t3 = time_divide(t1, 2);
ok1(t3.tv_sec == 50);
ok1(t3.tv_nsec == 50);
t3 = time_divide(t4, 2);
ok1(t3.ts.tv_sec == 50);
ok1(t3.ts.tv_nsec == 50);
t3 = time_divide(t1, 100);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 1);
t3 = time_divide(t4, 100);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 1);
t3 = time_multiply(t3, 100);
ok1(time_eq(t3, t1));
ok1(timerel_eq(t3, t4));
t3 = time_divide(t1, 200);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
t3 = time_divide(t4, 200);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
/* Divide by huge number. */
t1.tv_sec = (1U << 31) - 1;
t1.tv_nsec = 999999999;
t2 = time_divide(t1, 1 << 30);
t4.ts.tv_sec = (1U << 31) - 1;
t4.ts.tv_nsec = 999999999;
t3 = time_divide(t4, 1 << 30);
/* Allow us to round either way. */
ok1((t2.tv_sec == 2 && t2.tv_nsec == 0)
|| (t2.tv_sec == 1 && t2.tv_nsec == 999999999));
ok1((t3.ts.tv_sec == 2 && t3.ts.tv_nsec == 0)
|| (t3.ts.tv_sec == 1 && t3.ts.tv_nsec == 999999999));
/* Multiply by huge number. */
t1.tv_sec = 0;
t1.tv_nsec = 1;
t2 = time_multiply(t1, 1UL << 31);
ok1(t2.tv_sec == 2);
ok1(t2.tv_nsec == 147483648);
t4.ts.tv_sec = 0;
t4.ts.tv_nsec = 1;
t3 = time_multiply(t4, 1UL << 31);
ok1(t3.ts.tv_sec == 2);
ok1(t3.ts.tv_nsec == 147483648);
pipe(fds);
......@@ -159,20 +164,20 @@ int main(void)
close(fds[0]);
dup2(fds[1], 1);
dup2(fds[1], 2);
t1.tv_sec = 7;
t1.tv_nsec = 1000000001;
t2 = time_check(t1, NULL);
if (t2.tv_sec != 8 || t2.tv_nsec != 1)
t1.ts.tv_sec = 7;
t1.ts.tv_nsec = 1000000001;
t2 = timeabs_check(t1, NULL);
if (t2.ts.tv_sec != 8 || t2.ts.tv_nsec != 1)
exit(1);
t1.tv_sec = -1;
t1.tv_nsec = 5;
t2 = time_check(t1, NULL);
if (t2.tv_sec != 0 || t2.tv_nsec != 5)
t1.ts.tv_sec = -1;
t1.ts.tv_nsec = 5;
t2 = timeabs_check(t1, NULL);
if (t2.ts.tv_sec != 0 || t2.ts.tv_nsec != 5)
exit(1);
t1.tv_sec = 8;
t1.tv_nsec = 1000000002;
t1.ts.tv_sec = 8;
t1.ts.tv_nsec = 1000000002;
/* We expect this to abort! */
t2 = time_check(t1, "abortstr");
t2 = timeabs_check(t1, "abortstr");
exit(1);
default: {
......
......@@ -4,145 +4,160 @@
int main(void)
{
struct timespec t1, t2, t3, zero = { 0, 0 };
struct timeabs t1, t2;
struct timerel t3, t4, zero = { { 0, 0 } };
plan_tests(61);
plan_tests(66);
/* Test time_now */
t1 = time_now();
t2 = time_now();
/* Test time_sub. */
t3 = time_sub(t2, t1);
ok1(t3.tv_sec > 0 || t3.tv_nsec >= 0);
t3 = time_sub(t2, t2);
ok1(t3.tv_sec == 0 && t3.tv_nsec == 0);
t3 = time_sub(t1, t1);
ok1(t3.tv_sec == 0 && t3.tv_nsec == 0);
/* Test time_eq */
ok1(time_eq(t1, t1));
ok1(time_eq(t2, t2));
ok1(!time_eq(t1, t3));
ok1(!time_eq(t2, t3));
/* Test time_between. */
t3 = time_between(t2, t1);
ok1(t3.ts.tv_sec > 0 || t3.ts.tv_nsec >= 0);
t3 = time_between(t2, t2);
ok1(t3.ts.tv_sec == 0 && t3.ts.tv_nsec == 0);
t3 = time_between(t1, t1);
ok1(t3.ts.tv_sec == 0 && t3.ts.tv_nsec == 0);
/* Test timeabs_eq / timerel_eq */
ok1(timeabs_eq(t1, t1));
ok1(timeabs_eq(t2, t2));
t3.ts.tv_sec = 0;
t3.ts.tv_nsec = 1;
ok1(!timerel_eq(t3, zero));
ok1(!timerel_eq(t3, zero));
/* Make sure t2 > t1. */
t3.tv_sec = 0;
t3.tv_nsec = 1;
t2 = time_add(t2, t3);
t2 = timeabs_add(t2, t3);
/* Test time_after and time_before. */
ok1(!timeabs_eq(t1, t2));
ok1(!time_after(t1, t2));
ok1(time_before(t1, t2));
ok1(time_after(t2, t1));
ok1(!time_before(t2, t1));
t3.ts.tv_sec = 0;
t3.ts.tv_nsec = 999999999;
t2 = timeabs_add(t2, t3);
ok1(!timeabs_eq(t1, t2));
ok1(!time_after(t1, t2));
ok1(time_before(t1, t2));
ok1(time_after(t2, t1));
ok1(!time_before(t2, t1));
/* Test time_less and time_greater. */
ok1(!time_eq(t1, t2));
ok1(!time_greater(t1, t2));
ok1(time_less(t1, t2));
ok1(time_greater(t2, t1));
ok1(!time_less(t2, t1));
t3.tv_sec = 0;
t3.tv_nsec = 999999999;
t2 = time_add(t2, t3);
ok1(!time_eq(t1, t2));
ok1(!time_greater(t1, t2));
ok1(time_less(t1, t2));
ok1(time_greater(t2, t1));
ok1(!time_less(t2, t1));
t3 = time_sub(t2, zero);
ok1(time_eq(t3, t2));
t3 = time_sub(t2, t2);
ok1(time_eq(t3, zero));
ok1(time_less(zero, t3));
ok1(!time_greater(zero, t3));
ok1(!time_less(t3, zero));
ok1(time_greater(t3, zero));
/* Test time_sub */
t3 = time_sub(t3, t3);
ok1(timerel_eq(t3, zero));
/* Test time_between */
t3 = time_between(t2, t2);
ok1(timerel_eq(t3, zero));
t3.ts.tv_sec = 0;
t3.ts.tv_nsec = 999999999;
t1 = timeabs_add(t2, t3);
t3 = time_between(t1, t2);
ok1(t3.ts.tv_sec == 0 && t3.ts.tv_nsec == 999999999);
/* time_from_sec / time_to_sec */
t3 = time_from_sec(500);
ok1(t3.tv_sec == 500);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 500);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_sec(t3) == 500);
/* time_from_msec / time_to_msec */
t3 = time_from_msec(500);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_msec(t3) == 500);
t3 = time_from_msec(1000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_msec(t3) == 1000);
t3 = time_from_msec(1500);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_msec(t3) == 1500);
/* time_from_usec */
t3 = time_from_usec(500000);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_usec(t3) == 500000);
t3 = time_from_usec(1000000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_usec(t3) == 1000000);
t3 = time_from_usec(1500000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_usec(t3) == 1500000);
/* time_from_nsec */
t3 = time_from_nsec(500000000);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_nsec(t3) == 500000000);
t3 = time_from_nsec(1000000000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 0);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 0);
ok1(time_to_nsec(t3) == 1000000000);
t3 = time_from_nsec(1500000000);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 500000000);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 500000000);
ok1(time_to_nsec(t3) == 1500000000);
/* Test wrapunder */
t3 = time_sub(time_sub(t2, time_from_msec(500)), time_from_msec(500));
ok1(t3.tv_sec == t2.tv_sec - 1);
ok1(t3.tv_nsec == t2.tv_nsec);
t1 = timeabs_sub(timeabs_sub(t2, time_from_msec(500)), time_from_msec(500));
ok1(t1.ts.tv_sec == t2.ts.tv_sec - 1);
ok1(t1.ts.tv_nsec == t2.ts.tv_nsec);
/* time_divide and time_multiply */
t1.tv_nsec = 100;
t1.tv_sec = 100;
t4.ts.tv_nsec = 100;
t4.ts.tv_sec = 100;
t3 = time_divide(t1, 2);
ok1(t3.tv_sec == 50);
ok1(t3.tv_nsec == 50);
t3 = time_divide(t4, 2);
ok1(t3.ts.tv_sec == 50);
ok1(t3.ts.tv_nsec == 50);
t3 = time_divide(t1, 100);
ok1(t3.tv_sec == 1);
ok1(t3.tv_nsec == 1);
t3 = time_divide(t4, 100);
ok1(t3.ts.tv_sec == 1);
ok1(t3.ts.tv_nsec == 1);
t3 = time_multiply(t3, 100);
ok1(time_eq(t3, t1));
ok1(timerel_eq(t3, t4));
t3 = time_divide(t1, 200);
ok1(t3.tv_sec == 0);
ok1(t3.tv_nsec == 500000000);
t3 = time_divide(t4, 200);
ok1(t3.ts.tv_sec == 0);
ok1(t3.ts.tv_nsec == 500000000);
/* Divide by huge number. */
t1.tv_sec = (1U << 31) - 1;
t1.tv_nsec = 999999999;
t2 = time_divide(t1, 1 << 30);
t4.ts.tv_sec = (1U << 31) - 1;
t4.ts.tv_nsec = 999999999;
t3 = time_divide(t4, 1 << 30);
/* Allow us to round either way. */
ok1((t2.tv_sec == 2 && t2.tv_nsec == 0)
|| (t2.tv_sec == 1 && t2.tv_nsec == 999999999));
ok1((t3.ts.tv_sec == 2 && t3.ts.tv_nsec == 0)
|| (t3.ts.tv_sec == 1 && t3.ts.tv_nsec == 999999999));
/* Multiply by huge number. */
t1.tv_sec = 0;
t1.tv_nsec = 1;
t2 = time_multiply(t1, 1UL << 31);
ok1(t2.tv_sec == 2);
ok1(t2.tv_nsec == 147483648);
t4.ts.tv_sec = 0;
t4.ts.tv_nsec = 1;
t3 = time_multiply(t4, 1UL << 31);
ok1(t3.ts.tv_sec == 2);
ok1(t3.ts.tv_nsec == 147483648);
return exit_status();
}
......@@ -6,33 +6,33 @@
#if !HAVE_CLOCK_GETTIME && !HAVE_CLOCK_GETTIME_IN_LIBRT
#include <sys/time.h>
struct timespec time_now(void)
struct timeabs time_now(void)
{
struct timeval now;
struct timespec ret;
struct timeabs ret;
gettimeofday(&now, NULL);
ret.tv_sec = now.tv_sec;
ret.tv_nsec = now.tv_usec * 1000;
return TIME_CHECK(ret);
ret.ts.tv_sec = now.tv_sec;
ret.ts.tv_nsec = now.tv_usec * 1000;
return TIMEABS_CHECK(ret);
}
#else
#include <time.h>
struct timespec time_now(void)
struct timeabs time_now(void)
{
struct timespec ret;
clock_gettime(CLOCK_REALTIME, &ret);
return TIME_CHECK(ret);
struct timeabs ret;
clock_gettime(CLOCK_REALTIME, &ret.ts);
return TIMEABS_CHECK(ret);
}
#endif /* HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_IN_LIBRT */
struct timespec time_divide(struct timespec t, unsigned long div)
struct timerel time_divide(struct timerel t, unsigned long div)
{
struct timespec res;
struct timerel res;
uint64_t rem, ns;
/* Dividing seconds is simple. */
res.tv_sec = TIME_CHECK(t).tv_sec / div;
rem = t.tv_sec % div;
res.ts.tv_sec = TIMEREL_CHECK(t).ts.tv_sec / div;
rem = t.ts.tv_sec % div;
/* If we can't fit remainder * 1,000,000,000 in 64 bits? */
#if 0 /* ilog is great, but we use fp for multiply anyway. */
......@@ -45,37 +45,37 @@ struct timespec time_divide(struct timespec t, unsigned long div)
#endif
if (rem & ~(((uint64_t)1 << 30) - 1)) {
/* FIXME: fp is cheating! */
double nsec = rem * 1000000000.0 + t.tv_nsec;
res.tv_nsec = nsec / div;
double nsec = rem * 1000000000.0 + t.ts.tv_nsec;
res.ts.tv_nsec = nsec / div;
} else {
ns = rem * 1000000000 + t.tv_nsec;
res.tv_nsec = ns / div;
ns = rem * 1000000000 + t.ts.tv_nsec;
res.ts.tv_nsec = ns / div;
}
return TIME_CHECK(res);
return TIMEREL_CHECK(res);
}
struct timespec time_multiply(struct timespec t, unsigned long mult)
struct timerel time_multiply(struct timerel t, unsigned long mult)
{
struct timespec res;
struct timerel res;
/* Are we going to overflow if we multiply nsec? */
if (mult & ~((1UL << 30) - 1)) {
/* FIXME: fp is cheating! */
double nsec = (double)t.tv_nsec * mult;
double nsec = (double)t.ts.tv_nsec * mult;
res.tv_sec = nsec / 1000000000.0;
res.tv_nsec = nsec - (res.tv_sec * 1000000000.0);
res.ts.tv_sec = nsec / 1000000000.0;
res.ts.tv_nsec = nsec - (res.ts.tv_sec * 1000000000.0);
} else {
uint64_t nsec = t.tv_nsec * mult;
uint64_t nsec = t.ts.tv_nsec * mult;
res.tv_nsec = nsec % 1000000000;
res.tv_sec = nsec / 1000000000;
res.ts.tv_nsec = nsec % 1000000000;
res.ts.tv_sec = nsec / 1000000000;
}
res.tv_sec += TIME_CHECK(t).tv_sec * mult;
return TIME_CHECK(res);
res.ts.tv_sec += TIMEREL_CHECK(t).ts.tv_sec * mult;
return TIMEREL_CHECK(res);
}
struct timespec time_check(struct timespec t, const char *abortstr)
struct timespec time_check_(struct timespec t, const char *abortstr)
{
if (t.tv_sec < 0 || t.tv_nsec >= 1000000000) {
if (abortstr) {
......@@ -101,3 +101,19 @@ struct timespec time_check(struct timespec t, const char *abortstr)
}
return t;
}
struct timerel timerel_check(struct timerel t, const char *abortstr)
{
struct timerel ret;
ret.ts = time_check_(t.ts, abortstr);
return ret;
}
struct timeabs timeabs_check(struct timeabs t, const char *abortstr)
{
struct timeabs ret;
ret.ts = time_check_(t.ts, abortstr);
return ret;
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment