+ * struct timerel - a relative time.
+ * @ts: the actual timespec value.
+ *
+ * For example, 1 second: ts.tv_sec = 1, ts.tv_nsec = 0
+ */
+struct timerel {
+ struct timespec ts;
+};
+
+/**
+ * struct timeabs - an absolue time.
+ * @ts: the actual timespec value.
+ *
+ * For example, Midnight UTC January 1st, 1970: ts.tv_sec = 0, ts.tv_nsec = 0
+ */
+struct timeabs {
+ struct timespec ts;
+};
+
+/**
+ * struct timemono - a monotonic time.
+ * @ts: the actual timespec value.
+ *
+ * This comes from the monotonic clock (if available), so it's useful
+ * for measuring intervals as it won't change even if the system clock
+ * is moved for some reason.
+ */
+struct timemono {
+ struct timespec ts;
+};
+
+/**
+ * TIME_HAVE_MONOTONIC - defined if we really have a monotonic clock.
+ *
+ * Otherwise time_mono() just refers to time_now(). Your code might
+ * test this if you really need a monotonic clock.
+ */
+#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
+#define TIME_HAVE_MONOTONIC 1
+#endif
+
+struct timespec time_check_(struct timespec in, const char *abortstr);
+
+/**
+ * timerel_check - check if a relative time is malformed.
+ * @in: the relative time to check (returned)
+ * @abortstr: the string to print to stderr before aborting (if set).
+ *
+ * This can be used to make sure a time isn't negative and doesn't
+ * have a tv_nsec >= 1000000000. If it is, and @abortstr is non-NULL,
+ * that will be printed and abort() is called. Otherwise, if
+ * @abortstr is NULL then the returned timerel will be normalized and
+ * tv_sec set to 0 if it was negative.
+ *
+ * Note that if ccan/time is compiled with DEBUG, then it will call this
+ * for all passed and returned times.
+ *
+ * Example:
+ * printf("Time to calc this was %lu nanoseconds\n",
+ * (long)timerel_check(time_between(time_now(), time_now()),
+ * "time_now() failed?").ts.tv_nsec);
+ */
+struct timerel timerel_check(struct timerel in, const char *abortstr);
+
+/**
+ * timeabs_check - check if an absolute time is malformed.
+ * @in: the relative time to check (returned)