aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-05-28 14:59:07 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-05-28 14:59:07 -0400
commitff9aa32143849c69097000290b939f14c9bbcb36 (patch)
tree378b8968346301e4a6cf5442dadcc3a14eed1777 /src/lib
parent0a86f14addd031ac69647f4ab6fc66c1835cd31e (diff)
parent6d9e47702fe52b0817a593117a7f4a3eecf06ad7 (diff)
downloadtor-ff9aa32143849c69097000290b939f14c9bbcb36.tar.gz
tor-ff9aa32143849c69097000290b939f14c9bbcb36.zip
Merge branch 'tor-github/pr/1047'
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/log/log.h6
-rw-r--r--src/lib/wallclock/timeval.h21
2 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/log/log.h b/src/lib/log/log.h
index a381220af0..4a3ea0ad55 100644
--- a/src/lib/log/log.h
+++ b/src/lib/log/log.h
@@ -194,6 +194,11 @@ void tor_log_get_logfile_names(struct smartlist_t *out);
extern int log_global_min_severity_;
+#ifdef TOR_COVERAGE
+/* For coverage builds, we try to avoid our log_debug optimization, since it
+ * can have weird effects on internal macro coverage. */
+#define debug_logging_enabled() (1)
+#else
static inline bool debug_logging_enabled(void);
/**
* Return true iff debug logging is enabled for at least one domain.
@@ -202,6 +207,7 @@ static inline bool debug_logging_enabled(void)
{
return PREDICT_UNLIKELY(log_global_min_severity_ == LOG_DEBUG);
}
+#endif
void log_fn_(int severity, log_domain_mask_t domain,
const char *funcname, const char *format, ...)
diff --git a/src/lib/wallclock/timeval.h b/src/lib/wallclock/timeval.h
index 4967e939bf..33076adc8b 100644
--- a/src/lib/wallclock/timeval.h
+++ b/src/lib/wallclock/timeval.h
@@ -20,6 +20,27 @@
#include <sys/time.h>
#endif
+#ifdef TOR_COVERAGE
+/* For coverage builds, we use a slower definition of these macros without
+ * branches, to make coverage consistent. */
+#undef timeradd
+#undef timersub
+#define timeradd(tv1,tv2,tvout) \
+ do { \
+ (tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec; \
+ (tvout)->tv_usec = (tv1)->tv_usec + (tv2)->tv_usec; \
+ (tvout)->tv_sec += (tvout)->tv_usec / 1000000; \
+ (tvout)->tv_usec %= 1000000; \
+ } while (0)
+#define timersub(tv1,tv2,tvout) \
+ do { \
+ (tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec - 1; \
+ (tvout)->tv_usec = (tv1)->tv_usec - (tv2)->tv_usec + 1000000; \
+ (tvout)->tv_sec += (tvout)->tv_usec / 1000000; \
+ (tvout)->tv_usec %= 1000000; \
+ } while (0)
+#endif
+
#ifndef timeradd
/** Replacement for timeradd on platforms that do not have it: sets tvout to
* the sum of tv1 and tv2. */