struct timemono t1, t2;
struct timerel t3;
- plan_tests(7);
+ plan_tests(10);
/* Test time_mono */
t1 = time_mono();
ok1(timemono_sub(timemono_add(t1, t3), t3).ts.tv_sec == t1.ts.tv_sec);
ok1(timemono_sub(timemono_add(t1, t3), t3).ts.tv_nsec == t1.ts.tv_nsec);
-
+
+ ok1(timemono_after(timemono_add(t1, t3), t1));
+ ok1(!timemono_after(t1, timemono_add(t1, t3)));
+ ok1(!timemono_after(t1, t1));
return exit_status();
}
return time_greater_(a.ts, b.ts);
}
+/**
+ * timemono_after - is a after b?
+ * @a: one monotonic time.
+ * @b: another monotonic time.
+ *
+ * Example:
+ * static bool timed_out(const struct timemono *start)
+ * {
+ * #define TIMEOUT time_from_msec(1000)
+ * return timemono_after(time_mono(), timemono_add(*start, TIMEOUT));
+ * }
+ */
+static inline bool timemono_after(struct timemono a, struct timemono b)
+{
+ return time_greater_(a.ts, b.ts);
+}
+
static inline bool time_less_(struct timespec a, struct timespec b)
{
if (TIME_CHECK(a).tv_sec < TIME_CHECK(b).tv_sec)
* @div: number to divide it by.
*
* Example:
+ * #include <sys/wait.h>
+ *
* // How long does it take to do a fork?
* static struct timerel forking_time(void)
* {