torerr.h (1962B)
1 /* Copyright (c) 2001, Matej Pfajfar. 2 * Copyright (c) 2001-2004, Roger Dingledine. 3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 * Copyright (c) 2007-2021, The Tor Project, Inc. */ 5 /* See LICENSE for licensing information */ 6 7 /** 8 * \file torerr.h 9 * 10 * \brief Headers for torerr.c. 11 **/ 12 13 #ifndef TOR_TORERR_H 14 #define TOR_TORERR_H 15 16 #include "lib/cc/compat_compiler.h" 17 18 /* The raw_assert...() variants are for use within code that can't call 19 * tor_assertion_failed_() because of call circularity issues. */ 20 #define raw_assert(expr) STMT_BEGIN \ 21 if (!(expr)) { \ 22 tor_raw_assertion_failed_msg_(__FILE__, __LINE__, #expr, NULL); \ 23 tor_raw_abort_(); \ 24 } \ 25 STMT_END 26 #define raw_assert_unreached(expr) raw_assert(0) 27 #define raw_assert_unreached_msg(msg) STMT_BEGIN \ 28 tor_raw_assertion_failed_msg_(__FILE__, __LINE__, "0", (msg)); \ 29 tor_raw_abort_(); \ 30 STMT_END 31 32 void tor_raw_assertion_failed_msg_(const char *file, int line, 33 const char *expr, 34 const char *msg); 35 36 /** Maximum number of fds that will get notifications if we crash */ 37 #define TOR_SIGSAFE_LOG_MAX_FDS 8 38 39 void tor_log_err_sigsafe(const char *m, ...); 40 int tor_log_get_sigsafe_err_fds(const int **out); 41 void tor_log_set_sigsafe_err_fds(const int *fds, int n); 42 void tor_log_reset_sigsafe_err_fds(void); 43 void tor_log_flush_sigsafe_err_fds(void); 44 void tor_log_sigsafe_err_set_granularity(int ms); 45 46 void tor_raw_abort_(void) ATTR_NORETURN; 47 48 int format_hex_number_sigsafe(unsigned long x, char *buf, int max_len); 49 int format_dec_number_sigsafe(unsigned long x, char *buf, int max_len); 50 51 #endif /* !defined(TOR_TORERR_H) */