mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-23 20:03:31 +01:00
Move more compiler-compatibility stuff into compat_compiler.h
This commit is contained in:
parent
68bbe915d9
commit
49d7c9ce53
@ -78,54 +78,6 @@ size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
|||||||
size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
/** Casts the uint64_t value in <b>a</b> to the right type for an argument
|
|
||||||
* to printf. */
|
|
||||||
#define U64_PRINTF_ARG(a) (a)
|
|
||||||
/** Casts the uint64_t* value in <b>a</b> to the right type for an argument
|
|
||||||
* to scanf. */
|
|
||||||
#define U64_SCANF_ARG(a) (a)
|
|
||||||
/** Expands to a literal uint64_t-typed constant for the value <b>n</b>. */
|
|
||||||
#define U64_LITERAL(n) (n ## ui64)
|
|
||||||
#define I64_PRINTF_ARG(a) (a)
|
|
||||||
#define I64_SCANF_ARG(a) (a)
|
|
||||||
#define I64_LITERAL(n) (n ## i64)
|
|
||||||
#else /* !(defined(_MSC_VER)) */
|
|
||||||
#define U64_PRINTF_ARG(a) ((long long unsigned int)(a))
|
|
||||||
#define U64_SCANF_ARG(a) ((long long unsigned int*)(a))
|
|
||||||
#define U64_LITERAL(n) (n ## llu)
|
|
||||||
#define I64_PRINTF_ARG(a) ((long long signed int)(a))
|
|
||||||
#define I64_SCANF_ARG(a) ((long long signed int*)(a))
|
|
||||||
#define I64_LITERAL(n) (n ## ll)
|
|
||||||
#endif /* defined(_MSC_VER) */
|
|
||||||
|
|
||||||
#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
|
|
||||||
* scanf() function. See also U64_PRINTF_ARG and U64_SCANF_ARG. */
|
|
||||||
#define U64_FORMAT "%I64u"
|
|
||||||
#define I64_FORMAT "%I64d"
|
|
||||||
#else /* !(defined(_MSC_VER) || defined(MINGW_ANY)) */
|
|
||||||
#define U64_FORMAT "%llu"
|
|
||||||
#define I64_FORMAT "%lld"
|
|
||||||
#endif /* defined(_MSC_VER) || defined(MINGW_ANY) */
|
|
||||||
|
|
||||||
#if (SIZEOF_INTPTR_T == SIZEOF_INT)
|
|
||||||
#define INTPTR_T_FORMAT "%d"
|
|
||||||
#define INTPTR_PRINTF_ARG(x) ((int)(x))
|
|
||||||
#elif (SIZEOF_INTPTR_T == SIZEOF_LONG)
|
|
||||||
#define INTPTR_T_FORMAT "%ld"
|
|
||||||
#define INTPTR_PRINTF_ARG(x) ((long)(x))
|
|
||||||
#elif (SIZEOF_INTPTR_T == 8)
|
|
||||||
#define INTPTR_T_FORMAT I64_FORMAT
|
|
||||||
#define INTPTR_PRINTF_ARG(x) I64_PRINTF_ARG(x)
|
|
||||||
#else
|
|
||||||
#error Unknown: SIZEOF_INTPTR_T
|
|
||||||
#endif /* (SIZEOF_INTPTR_T == SIZEOF_INT) || ... */
|
|
||||||
|
|
||||||
/** Represents an mmaped file. Allocated via tor_mmap_file; freed with
|
/** Represents an mmaped file. Allocated via tor_mmap_file; freed with
|
||||||
* tor_munmap_file. */
|
* tor_munmap_file. */
|
||||||
typedef struct tor_mmap_t {
|
typedef struct tor_mmap_t {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
include src/ext/include.am
|
include src/ext/include.am
|
||||||
include src/lib/err/include.am
|
include src/lib/err/include.am
|
||||||
|
include src/lib/cc/include.am
|
||||||
include src/lib/ctime/include.am
|
include src/lib/ctime/include.am
|
||||||
include src/lib/compress/include.am
|
include src/lib/compress/include.am
|
||||||
include src/lib/trace/include.am
|
include src/lib/trace/include.am
|
||||||
|
@ -194,4 +194,52 @@
|
|||||||
#define OP_EQ ==
|
#define OP_EQ ==
|
||||||
#define OP_NE !=
|
#define OP_NE !=
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
/** Casts the uint64_t value in <b>a</b> to the right type for an argument
|
||||||
|
* to printf. */
|
||||||
|
#define U64_PRINTF_ARG(a) (a)
|
||||||
|
/** Casts the uint64_t* value in <b>a</b> to the right type for an argument
|
||||||
|
* to scanf. */
|
||||||
|
#define U64_SCANF_ARG(a) (a)
|
||||||
|
/** Expands to a literal uint64_t-typed constant for the value <b>n</b>. */
|
||||||
|
#define U64_LITERAL(n) (n ## ui64)
|
||||||
|
#define I64_PRINTF_ARG(a) (a)
|
||||||
|
#define I64_SCANF_ARG(a) (a)
|
||||||
|
#define I64_LITERAL(n) (n ## i64)
|
||||||
|
#else /* !(defined(_MSC_VER)) */
|
||||||
|
#define U64_PRINTF_ARG(a) ((long long unsigned int)(a))
|
||||||
|
#define U64_SCANF_ARG(a) ((long long unsigned int*)(a))
|
||||||
|
#define U64_LITERAL(n) (n ## llu)
|
||||||
|
#define I64_PRINTF_ARG(a) ((long long signed int)(a))
|
||||||
|
#define I64_SCANF_ARG(a) ((long long signed int*)(a))
|
||||||
|
#define I64_LITERAL(n) (n ## ll)
|
||||||
|
#endif /* defined(_MSC_VER) */
|
||||||
|
|
||||||
|
#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
|
||||||
|
* scanf() function. See also U64_PRINTF_ARG and U64_SCANF_ARG. */
|
||||||
|
#define U64_FORMAT "%I64u"
|
||||||
|
#define I64_FORMAT "%I64d"
|
||||||
|
#else /* !(defined(_MSC_VER) || defined(MINGW_ANY)) */
|
||||||
|
#define U64_FORMAT "%llu"
|
||||||
|
#define I64_FORMAT "%lld"
|
||||||
|
#endif /* defined(_MSC_VER) || defined(MINGW_ANY) */
|
||||||
|
|
||||||
|
#if (SIZEOF_INTPTR_T == SIZEOF_INT)
|
||||||
|
#define INTPTR_T_FORMAT "%d"
|
||||||
|
#define INTPTR_PRINTF_ARG(x) ((int)(x))
|
||||||
|
#elif (SIZEOF_INTPTR_T == SIZEOF_LONG)
|
||||||
|
#define INTPTR_T_FORMAT "%ld"
|
||||||
|
#define INTPTR_PRINTF_ARG(x) ((long)(x))
|
||||||
|
#elif (SIZEOF_INTPTR_T == 8)
|
||||||
|
#define INTPTR_T_FORMAT I64_FORMAT
|
||||||
|
#define INTPTR_PRINTF_ARG(x) I64_PRINTF_ARG(x)
|
||||||
|
#else
|
||||||
|
#error Unknown: SIZEOF_INTPTR_T
|
||||||
|
#endif /* (SIZEOF_INTPTR_T == SIZEOF_INT) || ... */
|
||||||
|
|
||||||
#endif /* !defined(TOR_COMPAT_H) */
|
#endif /* !defined(TOR_COMPAT_H) */
|
||||||
|
Loading…
Reference in New Issue
Block a user