torerr.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file torerr.h
  8. *
  9. * \brief Headers for torerr.c.
  10. **/
  11. #ifndef TOR_TORERR_H
  12. #define TOR_TORERR_H
  13. #include "lib/cc/compat_compiler.h"
  14. /* The raw_assert...() variants are for use within code that can't call
  15. * tor_assertion_failed_() because of call circularity issues. */
  16. #define raw_assert(expr) STMT_BEGIN \
  17. if (!(expr)) { \
  18. tor_raw_assertion_failed_msg_(__FILE__, __LINE__, #expr, NULL); \
  19. abort(); \
  20. } \
  21. STMT_END
  22. #define raw_assert_unreached(expr) raw_assert(0)
  23. #define raw_assert_unreached_msg(msg) STMT_BEGIN \
  24. tor_raw_assertion_failed_msg_(__FILE__, __LINE__, "0", (msg)); \
  25. abort(); \
  26. STMT_END
  27. void tor_raw_assertion_failed_msg_(const char *file, int line,
  28. const char *expr,
  29. const char *msg);
  30. /** Maximum number of fds that will get notifications if we crash */
  31. #define TOR_SIGSAFE_LOG_MAX_FDS 8
  32. void tor_log_err_sigsafe(const char *m, ...);
  33. int tor_log_get_sigsafe_err_fds(const int **out);
  34. void tor_log_set_sigsafe_err_fds(const int *fds, int n);
  35. void tor_log_sigsafe_err_set_granularity(int ms);
  36. int format_hex_number_sigsafe(unsigned long x, char *buf, int max_len);
  37. int format_dec_number_sigsafe(unsigned long x, char *buf, int max_len);
  38. #endif /* !defined(TOR_TORLOG_H) */