Tor  0.4.7.0-alpha-dev
torerr.h
Go to the documentation of this file.
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);
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) */
Utility macros to handle different features and behavior in different compilers.
void tor_log_flush_sigsafe_err_fds(void)
Definition: torerr.c:161
int format_dec_number_sigsafe(unsigned long x, char *buf, int max_len)
Definition: torerr.c:305
void tor_raw_abort_(void) ATTR_NORETURN
Definition: torerr.c:222
void tor_log_sigsafe_err_set_granularity(int ms)
Definition: torerr.c:182
void tor_log_reset_sigsafe_err_fds(void)
Definition: torerr.c:147
void tor_log_set_sigsafe_err_fds(const int *fds, int n)
Definition: torerr.c:123
void tor_raw_assertion_failed_msg_(const char *file, int line, const char *expr, const char *msg)
Definition: torerr.c:194
void tor_log_err_sigsafe(const char *m,...)
Definition: torerr.c:70
int format_hex_number_sigsafe(unsigned long x, char *buf, int max_len)
Definition: torerr.c:298
int tor_log_get_sigsafe_err_fds(const int **out)
Definition: torerr.c:103