-/* The clock to use for measuring time intervals. This is CLOCK_MONOTONIC by
- * preference, but on systems that don't have a monotonic clock we fall back
- * to CLOCK_REALTIME. */
-static clockid_t monotonic_clock;
+struct clock {
+ clockid_t id; /* CLOCK_MONOTONIC or CLOCK_REALTIME. */
+
+ /* Features for use by unit tests. Protected by 'mutex'. */
+ struct ovs_mutex mutex;
+ atomic_bool slow_path; /* True if warped or stopped. */
+ struct timespec warp OVS_GUARDED; /* Offset added for unit tests. */
+ bool stopped OVS_GUARDED; /* Disable real-time updates if true. */
+ struct timespec cache OVS_GUARDED; /* Last time read from kernel. */
+};
+
+/* Our clocks. */
+static struct clock monotonic_clock; /* CLOCK_MONOTONIC, if available. */
+static struct clock wall_clock; /* CLOCK_REALTIME. */
+
+/* The monotonic time at which the time module was initialized. */
+static long long int boot_time;
+
+/* True only when timeval_dummy_register() is called. */
+static bool timewarp_enabled;
+/* Reference to the seq struct. Threads other than main thread can
+ * wait on timewarp_seq and be waken up when time is warped. */
+static struct seq *timewarp_seq;
+/* Last value of 'timewarp_seq'. */
+DEFINE_STATIC_PER_THREAD_DATA(uint64_t, last_seq, 0);
+
+/* Monotonic time in milliseconds at which to die with SIGALRM (if not
+ * LLONG_MAX). */
+static long long int deadline = LLONG_MAX;
+
+/* Monotonic time, in milliseconds, at which the last call to time_poll() woke
+ * up. */
+DEFINE_STATIC_PER_THREAD_DATA(long long int, last_wakeup, 0);