summaryrefslogtreecommitdiff
path: root/src/common/compat_time.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-12-13 08:28:04 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-13 08:29:23 -0500
commit4c877ae87483d6e63c9e0309eb8abc009f9b9b87 (patch)
tree0ea831105d14594de5619d5416df145abcfc3314 /src/common/compat_time.h
parent426110dfa2e27f134e7bf44341e5df6f454e49a3 (diff)
downloadtor-4c877ae87483d6e63c9e0309eb8abc009f9b9b87.tar.gz
tor-4c877ae87483d6e63c9e0309eb8abc009f9b9b87.zip
Add monotime functions for clearing monotonic times
We need this to replace some of our "msec" users with monotime users.
Diffstat (limited to 'src/common/compat_time.h')
-rw-r--r--src/common/compat_time.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/compat_time.h b/src/common/compat_time.h
index bcf469e270..68c11fb608 100644
--- a/src/common/compat_time.h
+++ b/src/common/compat_time.h
@@ -105,6 +105,15 @@ uint64_t monotime_absolute_usec(void);
*/
uint64_t monotime_absolute_msec(void);
+/**
+ * Set <b>out</b> to zero.
+ */
+void monotime_zero(monotime_t *out);
+/**
+ * Return true iff <b>out</b> is zero
+ */
+int monotime_is_zero(const monotime_t *out);
+
#if defined(MONOTIME_COARSE_FN_IS_DIFFERENT)
/**
* Set <b>out</b> to the current coarse time.
@@ -144,10 +153,14 @@ int64_t monotime_coarse_diff_usec(const monotime_coarse_t *start,
const monotime_coarse_t *end);
int64_t monotime_coarse_diff_msec(const monotime_coarse_t *start,
const monotime_coarse_t *end);
+void monotime_coarse_zero(monotime_coarse_t *out);
+int monotime_coarse_is_zero(const monotime_coarse_t *val);
#else /* !(defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT)) */
#define monotime_coarse_diff_nsec monotime_diff_nsec
#define monotime_coarse_diff_usec monotime_diff_usec
#define monotime_coarse_diff_msec monotime_diff_msec
+#define monotime_coarse_zero monotime_zero
+#define monotime_coarse_is_zero monotime_is_zero
#endif /* defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT) */
void tor_gettimeofday(struct timeval *timeval);