aboutsummaryrefslogtreecommitdiff
path: root/src/lib/wallclock
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-01 13:34:07 -0400
committerNick Mathewson <nickm@torproject.org>2018-11-05 09:22:02 -0500
commita0ee54549fec3ae710ab5e3623d707bd08adcafe (patch)
tree36bbaf50040a4fb8e6ae4868d438da6edb6aed31 /src/lib/wallclock
parentd3e4afcc9b835e0f862207ef16d7e706ceea9ce1 (diff)
downloadtor-a0ee54549fec3ae710ab5e3623d707bd08adcafe.tar.gz
tor-a0ee54549fec3ae710ab5e3623d707bd08adcafe.zip
Turn the wallclock module into a subsystem.
(This may be slightly gratuitous.)
Diffstat (limited to 'src/lib/wallclock')
-rw-r--r--src/lib/wallclock/.may_include1
-rw-r--r--src/lib/wallclock/approx_time.c16
-rw-r--r--src/lib/wallclock/include.am3
-rw-r--r--src/lib/wallclock/wallclock_sys.h14
4 files changed, 33 insertions, 1 deletions
diff --git a/src/lib/wallclock/.may_include b/src/lib/wallclock/.may_include
index dc010da063..ce7a26472b 100644
--- a/src/lib/wallclock/.may_include
+++ b/src/lib/wallclock/.may_include
@@ -3,4 +3,5 @@ lib/cc/*.h
lib/err/*.h
lib/wallclock/*.h
lib/string/*.h
+lib/subsys/*.h
lib/testsupport/*.h
diff --git a/src/lib/wallclock/approx_time.c b/src/lib/wallclock/approx_time.c
index bb9a292369..c7a7ae9bd7 100644
--- a/src/lib/wallclock/approx_time.c
+++ b/src/lib/wallclock/approx_time.c
@@ -9,7 +9,9 @@
**/
#include "orconfig.h"
+#include "lib/subsys/subsys.h"
#include "lib/wallclock/approx_time.h"
+#include "lib/wallclock/wallclock_sys.h"
/* =====
* Cached time
@@ -41,3 +43,17 @@ update_approx_time(time_t now)
cached_approx_time = now;
}
#endif /* !defined(TIME_IS_FAST) */
+
+static int
+init_wallclock_subsys(void)
+{
+ update_approx_time(time(NULL));
+ return 0;
+}
+
+const subsys_fns_t sys_wallclock = {
+ .name = "wallclock",
+ .supported = true,
+ .level = -99,
+ .initialize = init_wallclock_subsys,
+};
diff --git a/src/lib/wallclock/include.am b/src/lib/wallclock/include.am
index 1961639bd7..2351252e0c 100644
--- a/src/lib/wallclock/include.am
+++ b/src/lib/wallclock/include.am
@@ -19,4 +19,5 @@ noinst_HEADERS += \
src/lib/wallclock/approx_time.h \
src/lib/wallclock/timeval.h \
src/lib/wallclock/time_to_tm.h \
- src/lib/wallclock/tor_gettimeofday.h
+ src/lib/wallclock/tor_gettimeofday.h \
+ src/lib/wallclock/wallclock_sys.h
diff --git a/src/lib/wallclock/wallclock_sys.h b/src/lib/wallclock/wallclock_sys.h
new file mode 100644
index 0000000000..e009578a83
--- /dev/null
+++ b/src/lib/wallclock/wallclock_sys.h
@@ -0,0 +1,14 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file wallclock_sys.h
+ * \brief Declare subsystem object for the wallclock module.
+ **/
+
+#ifndef TOR_WALLCLOCK_SYS_H
+#define TOR_WALLCLOCK_SYS_H
+
+extern const struct subsys_fns_t sys_wallclock;
+
+#endif /* !defined(TOR_WALLCLOCK_SYS_H) */