2018-06-20 19:02:05 +02:00
|
|
|
/* Copyright (c) 2001, Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2019-01-16 18:33:22 +01:00
|
|
|
* Copyright (c) 2007-2019, The Tor Project, Inc. */
|
2018-06-20 19:02:05 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file torerr.h
|
|
|
|
*
|
|
|
|
* \brief Headers for torerr.c.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef TOR_TORERR_H
|
|
|
|
#define TOR_TORERR_H
|
|
|
|
|
2018-06-21 18:20:52 +02:00
|
|
|
#include "lib/cc/compat_compiler.h"
|
2018-06-20 19:51:21 +02:00
|
|
|
|
2018-06-20 19:02:05 +02:00
|
|
|
/* The raw_assert...() variants are for use within code that can't call
|
|
|
|
* tor_assertion_failed_() because of call circularity issues. */
|
2018-06-20 19:51:21 +02:00
|
|
|
#define raw_assert(expr) STMT_BEGIN \
|
2018-06-20 19:02:05 +02:00
|
|
|
if (!(expr)) { \
|
|
|
|
tor_raw_assertion_failed_msg_(__FILE__, __LINE__, #expr, NULL); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
2018-06-20 19:51:21 +02:00
|
|
|
STMT_END
|
2018-06-20 19:02:05 +02:00
|
|
|
#define raw_assert_unreached(expr) raw_assert(0)
|
2018-06-20 19:51:21 +02:00
|
|
|
#define raw_assert_unreached_msg(msg) STMT_BEGIN \
|
2018-06-20 19:02:05 +02:00
|
|
|
tor_raw_assertion_failed_msg_(__FILE__, __LINE__, "0", (msg)); \
|
|
|
|
abort(); \
|
2018-06-20 19:51:21 +02:00
|
|
|
STMT_END
|
2018-06-20 19:02:05 +02:00
|
|
|
|
|
|
|
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);
|
2018-11-01 17:40:55 +01:00
|
|
|
void tor_log_reset_sigsafe_err_fds(void);
|
2018-06-20 19:02:05 +02:00
|
|
|
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) */
|