summaryrefslogtreecommitdiff
path: root/src/lib/cc/compat_compiler.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-03 10:25:31 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-03 10:25:31 -0400
commite2a94dc48147c9bad1f09f8b14df3bec0e3f5e94 (patch)
treeb7badc1868939a516ae1c455699bab513bd03087 /src/lib/cc/compat_compiler.h
parenta01b4d7f87f2217f55f5c5113fe19a2d3081a44c (diff)
downloadtor-e2a94dc48147c9bad1f09f8b14df3bec0e3f5e94.tar.gz
tor-e2a94dc48147c9bad1f09f8b14df3bec0e3f5e94.zip
Require stdint.h and inttypes.h
We've been silently requiring stdint.h for a while now, and nobody has complained. Closes ticket 26626.
Diffstat (limited to 'src/lib/cc/compat_compiler.h')
-rw-r--r--src/lib/cc/compat_compiler.h53
1 files changed, 10 insertions, 43 deletions
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index 084923eb09..c1621724d2 100644
--- a/src/lib/cc/compat_compiler.h
+++ b/src/lib/cc/compat_compiler.h
@@ -7,6 +7,7 @@
#define TOR_COMPAT_COMPILER_H
#include "orconfig.h"
+#include <inttypes.h>
#if defined(__has_feature)
# if __has_feature(address_sanitizer)
@@ -183,53 +184,19 @@
#define OP_EQ ==
#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) || ... */
+#define U64_PRINTF_ARG(a) ((uint64_t)a)
+#define U64_SCANF_ARG(a) (a)
+#define U64_LITERAL(n) UINT64_C(n)
+#define I64_PRINTF_ARG(a) ((int64_t)a)
+#define I64_SCANF_ARG(a) (a)
+#define I64_LITERAL(n) INT64_C(n)
+#define U64_FORMAT "%"PRIu64
+#define I64_FORMAT "%"PRId64
+#define INTPTR_T_FORMAT "%"PRIuPTR
/** Macro: yield a pointer to the field at position <b>off</b> within the
* structure <b>st</b>. Example: