mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Split some long #if lines to make the #endif annotator happy
This commit is contained in:
parent
40ce9819dd
commit
7a597718bb
7 changed files with 31 additions and 19 deletions
|
@ -212,7 +212,8 @@ tor_rename(const char *path_old, const char *path_new)
|
||||||
#define COMPAT_HAS_MMAN_AND_PAGESIZE
|
#define COMPAT_HAS_MMAN_AND_PAGESIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(COMPAT_HAS_MMAN_AND_PAGESIZE) || defined(RUNNING_DOXYGEN)
|
#if defined(COMPAT_HAS_MMAN_AND_PAGESIZE) || \
|
||||||
|
defined(RUNNING_DOXYGEN)
|
||||||
/** Try to create a memory mapping for <b>filename</b> and return it. On
|
/** Try to create a memory mapping for <b>filename</b> and return it. On
|
||||||
* failure, return NULL. Sets errno properly, using ERANGE to mean
|
* failure, return NULL. Sets errno properly, using ERANGE to mean
|
||||||
* "empty file". */
|
* "empty file". */
|
||||||
|
@ -1316,7 +1317,8 @@ tor_accept_socket_with_extensions(tor_socket_t sockfd, struct sockaddr *addr,
|
||||||
return TOR_INVALID_SOCKET;
|
return TOR_INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
|
#if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) \
|
||||||
|
&& defined(SOCK_NONBLOCK)
|
||||||
int ext_flags = (cloexec ? SOCK_CLOEXEC : 0) |
|
int ext_flags = (cloexec ? SOCK_CLOEXEC : 0) |
|
||||||
(nonblock ? SOCK_NONBLOCK : 0);
|
(nonblock ? SOCK_NONBLOCK : 0);
|
||||||
s = accept4(sockfd, addr, len, ext_flags);
|
s = accept4(sockfd, addr, len, ext_flags);
|
||||||
|
@ -2193,8 +2195,8 @@ switch_id(const char *user, const unsigned flags)
|
||||||
|
|
||||||
have_already_switched_id = 1; /* mark success so we never try again */
|
have_already_switched_id = 1; /* mark success so we never try again */
|
||||||
|
|
||||||
#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL)
|
#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && \
|
||||||
#ifdef PR_SET_DUMPABLE
|
defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
|
||||||
if (pw->pw_uid) {
|
if (pw->pw_uid) {
|
||||||
/* Re-enable core dumps if we're not running as root. */
|
/* Re-enable core dumps if we're not running as root. */
|
||||||
log_info(LD_CONFIG, "Re-enabling coredumps");
|
log_info(LD_CONFIG, "Re-enabling coredumps");
|
||||||
|
@ -2202,7 +2204,6 @@ switch_id(const char *user, const unsigned flags)
|
||||||
log_warn(LD_CONFIG, "Unable to re-enable coredumps: %s",strerror(errno));
|
log_warn(LD_CONFIG, "Unable to re-enable coredumps: %s",strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2241,12 +2242,11 @@ tor_disable_debugger_attach(void)
|
||||||
log_debug(LD_CONFIG,
|
log_debug(LD_CONFIG,
|
||||||
"Attemping to disable debugger attachment to Tor for "
|
"Attemping to disable debugger attachment to Tor for "
|
||||||
"unprivileged users.");
|
"unprivileged users.");
|
||||||
#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL)
|
#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) \
|
||||||
#ifdef PR_SET_DUMPABLE
|
&& defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
|
||||||
attempted = 1;
|
attempted = 1;
|
||||||
r = prctl(PR_SET_DUMPABLE, 0);
|
r = prctl(PR_SET_DUMPABLE, 0);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if defined(__APPLE__) && defined(PT_DENY_ATTACH)
|
#if defined(__APPLE__) && defined(PT_DENY_ATTACH)
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
attempted = 1;
|
attempted = 1;
|
||||||
|
@ -3050,6 +3050,10 @@ tor_gmtime_r(const time_t *timep, struct tm *result)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
|
#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
|
||||||
|
#define HAVE_UNIX_MLOCKALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNIX_MLOCKALL
|
||||||
/** Attempt to raise the current and max rlimit to infinity for our process.
|
/** Attempt to raise the current and max rlimit to infinity for our process.
|
||||||
* This only needs to be done once and can probably only be done when we have
|
* This only needs to be done once and can probably only be done when we have
|
||||||
* not already dropped privileges.
|
* not already dropped privileges.
|
||||||
|
@ -3105,7 +3109,7 @@ tor_mlockall(void)
|
||||||
* http://msdn.microsoft.com/en-us/library/aa366895(VS.85).aspx
|
* http://msdn.microsoft.com/en-us/library/aa366895(VS.85).aspx
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
|
#ifdef HAVE_UNIX_MLOCKALL
|
||||||
if (tor_set_max_memlock() == 0) {
|
if (tor_set_max_memlock() == 0) {
|
||||||
log_debug(LD_GENERAL, "RLIMIT_MEMLOCK is now set to RLIM_INFINITY.");
|
log_debug(LD_GENERAL, "RLIMIT_MEMLOCK is now set to RLIM_INFINITY.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,11 @@ size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
||||||
#define I64_LITERAL(n) (n ## ll)
|
#define I64_LITERAL(n) (n ## ll)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
|
#define MINGW_ANY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(MINGW_ANY)
|
||||||
/** The formatting string used to put a uint64_t value in a printf() or
|
/** The formatting string used to put a uint64_t value in a printf() or
|
||||||
* scanf() function. See also U64_PRINTF_ARG and U64_SCANF_ARG. */
|
* scanf() function. See also U64_PRINTF_ARG and U64_SCANF_ARG. */
|
||||||
#define U64_FORMAT "%I64u"
|
#define U64_FORMAT "%I64u"
|
||||||
|
@ -526,8 +530,8 @@ struct in6_addr
|
||||||
|
|
||||||
/** @{ */
|
/** @{ */
|
||||||
/** Many BSD variants seem not to define these. */
|
/** Many BSD variants seem not to define these. */
|
||||||
#if defined(__APPLE__) || defined(__darwin__) || defined(__FreeBSD__) \
|
#if defined(__APPLE__) || defined(__darwin__) || \
|
||||||
|| defined(__NetBSD__) || defined(__OpenBSD__)
|
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
#ifndef s6_addr16
|
#ifndef s6_addr16
|
||||||
#define s6_addr16 __u6_addr.__u6_addr16
|
#define s6_addr16 __u6_addr.__u6_addr16
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -237,8 +237,9 @@ tor_init_libevent_rng(void)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= V(2,1,1) \
|
#if defined(LIBEVENT_VERSION_NUMBER) && \
|
||||||
&& !defined(TOR_UNIT_TESTS)
|
LIBEVENT_VERSION_NUMBER >= V(2,1,1) && \
|
||||||
|
!defined(TOR_UNIT_TESTS)
|
||||||
void
|
void
|
||||||
tor_gettimeofday_cached(struct timeval *tv)
|
tor_gettimeofday_cached(struct timeval *tv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,7 +201,8 @@ tor_cond_init(tor_cond_t *cond)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_CLOCK_GETTIME)
|
#if defined(HAVE_CLOCK_GETTIME)
|
||||||
#if defined(CLOCK_MONOTONIC) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK)
|
#if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && \
|
||||||
|
defined(CLOCK_MONOTONIC)
|
||||||
/* Use monotonic time so when we timedwait() on it, any clock adjustment
|
/* Use monotonic time so when we timedwait() on it, any clock adjustment
|
||||||
* won't affect the timeout value. */
|
* won't affect the timeout value. */
|
||||||
if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC)) {
|
if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC)) {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
|
#if !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
|
||||||
/** Implementation of timeval for platforms that don't have it. */
|
/** Implementation of timeval for platforms that don't have it. */
|
||||||
struct timeval {
|
struct timeval {
|
||||||
time_t tv_sec;
|
time_t tv_sec;
|
||||||
|
@ -54,7 +54,8 @@ typedef struct monotime_t {
|
||||||
#endif
|
#endif
|
||||||
} monotime_t;
|
} monotime_t;
|
||||||
|
|
||||||
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC_COARSE)
|
#if defined(CLOCK_MONOTONIC_COARSE) && \
|
||||||
|
defined(HAVE_CLOCK_GETTIME)
|
||||||
#define MONOTIME_COARSE_FN_IS_DIFFERENT
|
#define MONOTIME_COARSE_FN_IS_DIFFERENT
|
||||||
#define monotime_coarse_t monotime_t
|
#define monotime_coarse_t monotime_t
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
|
|
|
@ -5623,7 +5623,7 @@ clamp_double_to_int64(double number)
|
||||||
{
|
{
|
||||||
int exponent;
|
int exponent;
|
||||||
|
|
||||||
#if (defined(__MINGW32__) || defined(__MINGW64__)) && GCC_VERSION >= 409
|
#if defined(MINGW_ANY) && GCC_VERSION >= 409
|
||||||
/*
|
/*
|
||||||
Mingw's math.h uses gcc's __builtin_choose_expr() facility to declare
|
Mingw's math.h uses gcc's __builtin_choose_expr() facility to declare
|
||||||
isnan, isfinite, and signbit. But as implemented in at least some
|
isnan, isfinite, and signbit. But as implemented in at least some
|
||||||
|
|
|
@ -2079,7 +2079,8 @@ get_pf_socket(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || defined(TRANS_TPROXY)
|
#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || \
|
||||||
|
defined(TRANS_TPROXY)
|
||||||
/** Try fill in the address of <b>req</b> from the socket configured
|
/** Try fill in the address of <b>req</b> from the socket configured
|
||||||
* with <b>conn</b>. */
|
* with <b>conn</b>. */
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Reference in a new issue