[tor-commits] [tlsdate/debian-master] fork clock-linux.c for GNU/Hurd

ioerror at torproject.org ioerror at torproject.org
Thu Oct 31 10:25:57 UTC 2013


commit 691d6f0b8712ce24e826bd39e6beddd51e403c71
Author: Jacob Appelbaum <jacob at appelbaum.net>
Date:   Wed Apr 24 22:06:48 2013 -0700

    fork clock-linux.c for GNU/Hurd
---
 src/compat/clock-hurd.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/src/compat/clock-hurd.c b/src/compat/clock-hurd.c
new file mode 100644
index 0000000..3d62068
--- /dev/null
+++ b/src/compat/clock-hurd.c
@@ -0,0 +1,59 @@
+/* Copyright (c) 2012, David Goulet <dgoulet at ev0ke.net>
+ *                     Jacob Appelbaum
+ * Copyright (c) 2012, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+  * \file clock-linux.c
+  * \brief Contains clock primitives for GNU/Linux OS
+  **/
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "src/compat/clock.h"
+
+/**
+ * Get current real time value and store it into time.
+ *
+ * @param time where the current time is stored
+ * @return clock_gettime syscall return value
+ */
+int clock_get_real_time(struct tlsdate_time *time)
+{
+  /* Safety net */
+  assert(time);
+
+  return clock_gettime(CLOCK_REALTIME, &time->tp);
+}
+
+/**
+ * Set current real time clock using time.
+ *
+ * @param time where the current time to set is stored
+ * @return clock_settime syscall return value
+ */
+int clock_set_real_time(const struct tlsdate_time *time)
+{
+  /* Safety net */
+  assert(time);
+
+  return clock_settime(CLOCK_REALTIME, &time->tp);
+}
+
+/**
+ * Init a tlsdate_time structure.
+ *
+ * @param sec is the seconds
+ * @param nsec is the nanoseconds
+ */
+void clock_init_time(struct tlsdate_time *time, time_t sec,
+                           long nsec)
+{
+  /* Safety net */
+  assert(time);
+
+  time->tp.tv_sec = sec;
+  time->tp.tv_nsec = nsec;
+}





More information about the tor-commits mailing list