aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common.c')
-rw-r--r--common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common.c b/common.c
index a92bae4..7880dee 100644
--- a/common.c
+++ b/common.c
@@ -52,6 +52,21 @@ str_vector_find (const struct str_vector *v, const char *s)
return -1;
}
+static time_t
+unixtime_msec (long *msec)
+{
+#ifdef _POSIX_TIMERS
+ struct timespec tp;
+ hard_assert (clock_gettime (CLOCK_REALTIME, &tp) != -1);
+ *msec = tp.tv_nsec / 1000000;
+#else // ! _POSIX_TIMERS
+ struct timeval tp;
+ hard_assert (gettimeofday (&tp, NULL) != -1);
+ *msec = tp.tv_usec / 1000;
+#endif // ! _POSIX_TIMERS
+ return tp.tv_sec;
+}
+
/// This differs from the non-unique version in that we expect the filename
/// to be something like a pattern for mkstemp(), so the resulting path can
/// reside in a system-wide directory with no risk of a conflict.