aboutsummaryrefslogtreecommitdiff
path: root/src/lib/err/torerr.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-21 09:53:08 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-21 10:47:11 -0400
commit2cfcb7b364541c27749ae0df73eabd7a56797f93 (patch)
tree1fb03761e4631f1d5edd893fc9164a49ff8981b6 /src/lib/err/torerr.h
parentb2346b12019c45288bbae3bd009fe0bafe80ff58 (diff)
downloadtor-2cfcb7b364541c27749ae0df73eabd7a56797f93.tar.gz
tor-2cfcb7b364541c27749ae0df73eabd7a56797f93.zip
Extract error functionality into a new lowest-level library.
Diffstat (limited to 'src/lib/err/torerr.h')
-rw-r--r--src/lib/err/torerr.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/err/torerr.h b/src/lib/err/torerr.h
new file mode 100644
index 0000000000..10d9f481c0
--- /dev/null
+++ b/src/lib/err/torerr.h
@@ -0,0 +1,47 @@
+/* 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 */
+
+/**
+ * \file torerr.h
+ *
+ * \brief Headers for torerr.c.
+ **/
+
+#ifndef TOR_TORERR_H
+#define TOR_TORERR_H
+
+#include "common/compat_compiler.h"
+
+/* The raw_assert...() variants are for use within code that can't call
+ * tor_assertion_failed_() because of call circularity issues. */
+#define raw_assert(expr) STMT_BEGIN \
+ if (!(expr)) { \
+ tor_raw_assertion_failed_msg_(__FILE__, __LINE__, #expr, NULL); \
+ abort(); \
+ } \
+ STMT_END
+#define raw_assert_unreached(expr) raw_assert(0)
+#define raw_assert_unreached_msg(msg) STMT_BEGIN \
+ tor_raw_assertion_failed_msg_(__FILE__, __LINE__, "0", (msg)); \
+ abort(); \
+ STMT_END
+
+void tor_raw_assertion_failed_msg_(const char *file, int line,
+ const char *expr,
+ const char *msg);
+
+/** Maximum number of fds that will get notifications if we crash */
+#define TOR_SIGSAFE_LOG_MAX_FDS 8
+
+void tor_log_err_sigsafe(const char *m, ...);
+int tor_log_get_sigsafe_err_fds(const int **out);
+void tor_log_set_sigsafe_err_fds(const int *fds, int n);
+void tor_log_sigsafe_err_set_granularity(int ms);
+
+int format_hex_number_sigsafe(unsigned long x, char *buf, int max_len);
+int format_dec_number_sigsafe(unsigned long x, char *buf, int max_len);
+
+#endif /* !defined(TOR_TORLOG_H) */