summaryrefslogtreecommitdiffstats
path: root/src/xtime.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-11-27 20:55:51 -0500
committerTavian Barnes <tavianator@tavianator.com>2024-12-02 16:34:26 -0500
commitbac8214e90488fd562d29f6fea18ae75ecd9029e (patch)
tree0ce8c582da2d00e36c93dea8744e0048820f33c9 /src/xtime.h
parent7855b9ad9164ae7ea99a00641f3eadb56015ffc6 (diff)
downloadbfs-bac8214e90488fd562d29f6fea18ae75ecd9029e.tar.xz
xtime: New timespec utility functions
Diffstat (limited to 'src/xtime.h')
-rw-r--r--src/xtime.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/xtime.h b/src/xtime.h
index 2927a2e..b76fef2 100644
--- a/src/xtime.h
+++ b/src/xtime.h
@@ -47,6 +47,42 @@ int xtimegm(struct tm *tm, time_t *timep);
int xgetdate(const char *str, struct timespec *result);
/**
+ * Add to a timespec.
+ */
+void timespec_add(struct timespec *lhs, const struct timespec *rhs);
+
+/**
+ * Subtract from a timespec.
+ */
+void timespec_sub(struct timespec *lhs, const struct timespec *rhs);
+
+/**
+ * Compare two timespecs.
+ *
+ * @return
+ * An integer with the sign of (*lhs - *rhs).
+ */
+int timespec_cmp(const struct timespec *lhs, const struct timespec *rhs);
+
+/**
+ * Update a minimum timespec.
+ */
+void timespec_min(struct timespec *dest, const struct timespec *src);
+
+/**
+ * Update a maximum timespec.
+ */
+void timespec_max(struct timespec *dest, const struct timespec *src);
+
+/**
+ * Convert a timespec to floating point.
+ *
+ * @return
+ * The value in nanoseconds.
+ */
+double timespec_ns(const struct timespec *ts);
+
+/**
* A timer.
*/
struct timer;