tor  0.4.2.0-alpha-dev
approx_time.c
Go to the documentation of this file.
1 /* Copyright (c) 2003, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #include "orconfig.h"
12 #include "lib/subsys/subsys.h"
15 
16 /* =====
17  * Cached time
18  * ===== */
19 
20 #ifndef TIME_IS_FAST
21 
25 static time_t cached_approx_time = 0;
26 
31 time_t
33 {
34  return cached_approx_time;
35 }
36 
40 void
41 update_approx_time(time_t now)
42 {
43  cached_approx_time = now;
44 }
45 #endif /* !defined(TIME_IS_FAST) */
46 
47 static int
48 subsys_wallclock_initialize(void)
49 {
50  update_approx_time(time(NULL));
51  return 0;
52 }
53 
54 const subsys_fns_t sys_wallclock = {
55  .name = "wallclock",
56  .supported = true,
57  .level = -99,
58  .initialize = subsys_wallclock_initialize,
59 };
Header for approx_time.c.
time_t approx_time(void)
Definition: approx_time.c:32
const char * name
Definition: subsys.h:28
Declare subsystem object for the wallclock module.
static time_t cached_approx_time
Definition: approx_time.c:25
void update_approx_time(time_t now)
Definition: approx_time.c:41