aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2018-12-07 16:35:23 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2019-01-02 15:25:55 +0200
commit926fc93be5b6afab1a604ecd7c79aa6e8ae8a676 (patch)
treead9b0bd2298f8035734d777f42b1333fb5cf990d /src/lib
parentdd04917851c23f16a11c0d2b0c62ea76c93c4c7d (diff)
downloadtor-926fc93be5b6afab1a604ecd7c79aa6e8ae8a676.tar.gz
tor-926fc93be5b6afab1a604ecd7c79aa6e8ae8a676.zip
Concentrate all TOR_USEC_PER_SEC definitions in a single header file.
Co-authored-by: Mike Perry <mikeperry-git@torproject.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/defs/include.am1
-rw-r--r--src/lib/defs/time.h23
-rw-r--r--src/lib/time/.may_include1
-rw-r--r--src/lib/time/tvdiff.c3
4 files changed, 26 insertions, 2 deletions
diff --git a/src/lib/defs/include.am b/src/lib/defs/include.am
index 48ee7f29fc..6a7f9114ea 100644
--- a/src/lib/defs/include.am
+++ b/src/lib/defs/include.am
@@ -2,4 +2,5 @@
noinst_HEADERS += \
src/lib/defs/dh_sizes.h \
src/lib/defs/digest_sizes.h \
+ src/lib/defs/time.h \
src/lib/defs/x25519_sizes.h
diff --git a/src/lib/defs/time.h b/src/lib/defs/time.h
new file mode 100644
index 0000000000..762b23feab
--- /dev/null
+++ b/src/lib/defs/time.h
@@ -0,0 +1,23 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_TIME_DEFS_H
+#define TOR_TIME_DEFS_H
+
+/**
+ * \file time.h
+ *
+ * \brief Definitions for timing-related constants.
+ **/
+
+/** How many microseconds per second */
+#define TOR_USEC_PER_SEC (1000000)
+/** How many nanoseconds per microsecond */
+#define TOR_NSEC_PER_USEC (1000)
+/* How many nanoseconds per millisecond */
+#define TOR_NSEC_PER_MSEC (1000*1000)
+
+#endif
diff --git a/src/lib/time/.may_include b/src/lib/time/.may_include
index 40a18805ac..ae01431b60 100644
--- a/src/lib/time/.may_include
+++ b/src/lib/time/.may_include
@@ -7,6 +7,7 @@ lib/log/*.h
lib/subsys/*.h
lib/time/*.h
lib/wallclock/*.h
+lib/defs/time.h
# For load_windows_system_lib.
lib/fs/winlib.h \ No newline at end of file
diff --git a/src/lib/time/tvdiff.c b/src/lib/time/tvdiff.c
index bc8a1166e7..9dfb63c26f 100644
--- a/src/lib/time/tvdiff.c
+++ b/src/lib/time/tvdiff.c
@@ -11,6 +11,7 @@
#include "lib/time/tvdiff.h"
#include "lib/cc/compat_compiler.h"
+#include "lib/defs/time.h"
#include "lib/log/log.h"
#ifdef _WIN32
@@ -20,8 +21,6 @@
#include <sys/time.h>
#endif
-#define TOR_USEC_PER_SEC 1000000
-
/** Return the difference between start->tv_sec and end->tv_sec.
* Returns INT64_MAX on overflow and underflow.
*/