Browse Source

Merge remote-tracking branch 'github/ticket26626'

Nick Mathewson 5 years ago
parent
commit
df98582851
57 changed files with 656 additions and 987 deletions
  1. 3 0
      changes/ticket26626
  2. 0 17
      configure.ac
  3. 2 2
      src/common/procmon.c
  4. 1 47
      src/lib/cc/compat_compiler.h
  5. 3 264
      src/lib/cc/torint.h
  6. 8 8
      src/lib/intmath/bits.c
  7. 1 1
      src/lib/net/nettypes.h
  8. 10 10
      src/lib/time/tvdiff.c
  9. 2 2
      src/lib/tls/tortls.c
  10. 2 2
      src/lib/wallclock/tm_cvt.c
  11. 4 4
      src/lib/wallclock/tor_gettimeofday.c
  12. 1 1
      src/or/addressmap.c
  13. 145 145
      src/or/channel.c
  14. 13 13
      src/or/channelpadding.c
  15. 36 36
      src/or/channeltls.c
  16. 8 8
      src/or/circuitbuild.c
  17. 8 8
      src/or/circuitlist.c
  18. 29 29
      src/or/circuitmux.c
  19. 2 2
      src/or/circuitstats.c
  20. 5 6
      src/or/circuituse.c
  21. 2 2
      src/or/command.c
  22. 6 6
      src/or/config.c
  23. 2 2
      src/or/config.h
  24. 12 12
      src/or/confparse.c
  25. 6 6
      src/or/connection.c
  26. 2 2
      src/or/connection_edge.c
  27. 2 2
      src/or/connection_or.c
  28. 20 20
      src/or/control.c
  29. 1 1
      src/or/cpuworker.c
  30. 34 34
      src/or/dirauth/dirvote.c
  31. 6 6
      src/or/directory.c
  32. 4 4
      src/or/geoip.c
  33. 16 16
      src/or/hibernate.c
  34. 26 26
      src/or/main.c
  35. 3 3
      src/or/microdesc.c
  36. 3 3
      src/or/policies.c
  37. 66 66
      src/or/rephist.c
  38. 2 2
      src/or/router.c
  39. 4 4
      src/or/routerlist.c
  40. 85 85
      src/or/routerparse.c
  41. 8 8
      src/or/scheduler_vanilla.c
  42. 11 11
      src/or/status.c
  43. 1 1
      src/or/torcert.c
  44. 2 2
      src/test/test-timers.c
  45. 7 15
      src/test/test.h
  46. 1 1
      src/test/test_bwmgt.c
  47. 1 1
      src/test/test_channel.c
  48. 1 1
      src/test/test_circuitmux.c
  49. 2 2
      src/test/test_config.c
  50. 8 8
      src/test/test_crypto.c
  51. 5 5
      src/test/test_dir.c
  52. 0 1
      src/test/test_geoip.c
  53. 2 2
      src/test/test_mainloop.c
  54. 1 1
      src/test/test_options.c
  55. 1 1
      src/test/test_status.c
  56. 18 18
      src/test/test_util.c
  57. 2 2
      src/test/test_util_format.c

+ 3 - 0
changes/ticket26626

@@ -0,0 +1,3 @@
+  o Code simplification and refactoring:
+    - Tor now assumes that you have standards-conformant stdint.h and
+      inttypes.h headers when compiling.  Closes ticket 26626.

+ 0 - 17
configure.ac

@@ -1393,7 +1393,6 @@ AC_CHECK_HEADERS([errno.h \
                   netinet/in6.h \
                   pwd.h \
                   readpassphrase.h \
-                  stdint.h \
                   stdatomic.h \
                   sys/eventfd.h \
                   sys/file.h \
@@ -1517,22 +1516,6 @@ AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
 #include <sys/time.h>
 #endif])
 
-dnl In case we aren't given a working stdint.h, we'll need to grow our own.
-dnl Watch out.
-
-AC_CHECK_SIZEOF(int8_t)
-AC_CHECK_SIZEOF(int16_t)
-AC_CHECK_SIZEOF(int32_t)
-AC_CHECK_SIZEOF(int64_t)
-AC_CHECK_SIZEOF(uint8_t)
-AC_CHECK_SIZEOF(uint16_t)
-AC_CHECK_SIZEOF(uint32_t)
-AC_CHECK_SIZEOF(uint64_t)
-AC_CHECK_SIZEOF(intptr_t)
-AC_CHECK_SIZEOF(uintptr_t)
-
-dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
-
 AC_CHECK_SIZEOF(char)
 AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)

+ 2 - 2
src/common/procmon.c

@@ -35,8 +35,8 @@ typedef int pid_t;
 #define PID_T_FORMAT "%d"
 #elif (SIZEOF_PID_T == SIZEOF_LONG)
 #define PID_T_FORMAT "%ld"
-#elif (SIZEOF_PID_T == SIZEOF_INT64_T)
-#define PID_T_FORMAT I64_FORMAT
+#elif (SIZEOF_PID_T == 8)
+#define PID_T_FORMAT "%"PRId64
 #else
 #error Unknown: SIZEOF_PID_T
 #endif /* (0 == SIZEOF_PID_T) && defined(_WIN32) || ... */

+ 1 - 47
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)
@@ -105,9 +106,6 @@
 #endif /* !defined(HAVE_MACRO__func__) */
 #endif /* defined(_MSC_VER) */
 
-#define U64_TO_DBL(x) ((double) (x))
-#define DBL_TO_U64(x) ((uint64_t) (x))
-
 #ifdef ENUM_VALS_ARE_SIGNED
 #define ENUM_BF(t) unsigned
 #else
@@ -183,54 +181,10 @@
 #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) || ... */
-
 /** Macro: yield a pointer to the field at position <b>off</b> within the
  * structure <b>st</b>.  Example:
  * <pre>

+ 3 - 264
src/lib/cc/torint.h

@@ -19,189 +19,16 @@
 
 #include "orconfig.h"
 
-#ifdef HAVE_STDINT_H
 #include <stdint.h>
-#endif
+#include <stdbool.h>
+#include <limits.h>
+
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 #ifdef HAVE_SYS_LIMITS_H
 #include <sys/limits.h>
 #endif
-#ifdef HAVE_MACHINE_LIMITS_H
-#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
-  /* FreeBSD has a bug where it complains that this file is obsolete,
-     and I should migrate to using sys/limits. It complains even when
-     I include both.
-     __FreeBSD_kernel__ is defined by Debian GNU/kFreeBSD which
-      does the same thing (but doesn't defined __FreeBSD__).
-     */
-#include <machine/limits.h>
-#endif /* !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) */
-#endif /* defined(HAVE_MACHINE_LIMITS_H) */
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-
-#include <stdbool.h>
-
-#if (SIZEOF_INT8_T != 0)
-#define HAVE_INT8_T
-#endif
-#if (SIZEOF_INT16_T != 0)
-#define HAVE_INT16_T
-#endif
-#if (SIZEOF_INT32_T != 0)
-#define HAVE_INT32_T
-#endif
-#if (SIZEOF_INT64_T != 0)
-#define HAVE_INT64_T
-#endif
-#if (SIZEOF_UINT8_T != 0)
-#define HAVE_UINT8_T
-#endif
-#if (SIZEOF_UINT16_T != 0)
-#define HAVE_UINT16_T
-#endif
-#if (SIZEOF_UINT32_T != 0)
-#define HAVE_UINT32_T
-#endif
-#if (SIZEOF_UINT64_T != 0)
-#define HAVE_UINT64_T
-#endif
-#if (SIZEOF_INTPTR_T != 0)
-#define HAVE_INTPTR_T
-#endif
-#if (SIZEOF_UINTPTR_T != 0)
-#define HAVE_UINTPTR_T
-#endif
-
-#if (SIZEOF_CHAR == 1)
-#ifndef HAVE_INT8_T
-typedef signed char int8_t;
-#define HAVE_INT8_T
-#endif
-#ifndef HAVE_UINT8_T
-typedef unsigned char uint8_t;
-#define HAVE_UINT8_T
-#endif
-#endif /* (SIZEOF_CHAR == 1) */
-
-#if (SIZEOF_SHORT == 2)
-#ifndef HAVE_INT16_T
-typedef signed short int16_t;
-#define HAVE_INT16_T
-#endif
-#ifndef HAVE_UINT16_T
-typedef unsigned short uint16_t;
-#define HAVE_UINT16_T
-#endif
-#endif /* (SIZEOF_SHORT == 2) */
-
-#if (SIZEOF_INT == 2)
-#ifndef HAVE_INT16_T
-typedef signed int int16_t;
-#define HAVE_INT16_T
-#endif
-#ifndef HAVE_UINT16_T
-typedef unsigned int uint16_t;
-#define HAVE_UINT16_T
-#endif
-#elif (SIZEOF_INT == 4)
-#ifndef HAVE_INT32_T
-typedef signed int int32_t;
-#define HAVE_INT32_T
-#endif
-#ifndef HAVE_UINT32_T
-typedef unsigned int uint32_t;
-#define HAVE_UINT32_T
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX 0xffffu
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX 0x7fff
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-INT16_MAX-1)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX 0xffffffffu
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX 0x7fffffff
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#endif /* (SIZEOF_INT == 2) || ... */
-
-#if (SIZEOF_LONG == 4)
-#ifndef HAVE_INT32_T
-typedef signed long int32_t;
-#define HAVE_INT32_T
-#endif
-#ifndef HAVE_UINT32_T
-typedef unsigned long uint32_t;
-#define HAVE_UINT32_T
-#ifndef UINT32_MAX
-#define UINT32_MAX 0xfffffffful
-#endif
-#endif /* !defined(HAVE_UINT32_T) */
-#elif (SIZEOF_LONG == 8)
-#ifndef HAVE_INT64_T
-typedef signed long int64_t;
-#define HAVE_INT64_T
-#endif
-#ifndef HAVE_UINT32_T
-typedef unsigned long uint64_t;
-#define HAVE_UINT32_T
-#endif
-#ifndef UINT64_MAX
-#define UINT64_MAX 0xfffffffffffffffful
-#endif
-#endif /* (SIZEOF_LONG == 4) || ... */
-
-#if (SIZEOF_LONG_LONG == 8)
-#ifndef HAVE_INT64_T
-typedef signed long long int64_t;
-#define HAVE_INT64_T
-#endif
-#ifndef HAVE_UINT64_T
-typedef unsigned long long uint64_t;
-#define HAVE_UINT64_T
-#endif
-#ifndef UINT64_MAX
-#define UINT64_MAX 0xffffffffffffffffull
-#endif
-#ifndef INT64_MAX
-#define INT64_MAX 0x7fffffffffffffffll
-#endif
-#endif /* (SIZEOF_LONG_LONG == 8) */
-
-#if (SIZEOF___INT64 == 8)
-#ifndef HAVE_INT64_T
-typedef signed __int64 int64_t;
-#define HAVE_INT64_T
-#endif
-#ifndef HAVE_UINT64_T
-typedef unsigned __int64 uint64_t;
-#define HAVE_UINT64_T
-#endif
-#ifndef UINT64_MAX
-#define UINT64_MAX 0xffffffffffffffffui64
-#endif
-#ifndef INT64_MAX
-#define INT64_MAX 0x7fffffffffffffffi64
-#endif
-#endif /* (SIZEOF___INT64 == 8) */
-
-#ifndef INT64_MIN
-#define INT64_MIN ((- INT64_MAX) - 1)
-#endif
 
 #ifndef SIZE_MAX
 #if SIZEOF_SIZE_T == 8
@@ -223,100 +50,12 @@ typedef int32_t ssize_t;
 #endif /* SIZEOF_SIZE_T == 8 || ... */
 #endif /* !defined(HAVE_SSIZE_T) */
 
-#if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8)
-#ifndef HAVE_INTPTR_T
-typedef int64_t intptr_t;
-#define SIZEOF_INTPTR_T 8
-#endif
-#ifndef HAVE_UINTPTR_T
-typedef uint64_t uintptr_t;
-#define SIZEOF_UINTPTR_T 8
-#endif
-#elif (SIZEOF_VOID_P > 2 && SIZEOF_VOID_P <= 4)
-#ifndef HAVE_INTPTR_T
-typedef int32_t intptr_t;
-#define SIZEOF_INTPTR_T 4
-#endif
-#ifndef HAVE_UINTPTR_T
-typedef uint32_t uintptr_t;
-#define SIZEOF_UINTPTR_T 4
-#endif
-#else
-#error "void * is either >8 bytes or <= 2.  In either case, I am confused."
-#endif /* (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8) || ... */
-
-#ifndef HAVE_INT8_T
-#error "Missing type int8_t"
-#endif
-#ifndef HAVE_UINT8_T
-#error "Missing type uint8_t"
-#endif
-#ifndef HAVE_INT16_T
-#error "Missing type int16_t"
-#endif
-#ifndef HAVE_UINT16_T
-#error "Missing type uint16_t"
-#endif
-#ifndef HAVE_INT32_T
-#error "Missing type int32_t"
-#endif
-#ifndef HAVE_UINT32_T
-#error "Missing type uint32_t"
-#endif
-#ifndef HAVE_INT64_T
-#error "Missing type int64_t"
-#endif
-#ifndef HAVE_UINT64_T
-#error "Missing type uint64_t"
-#endif
-
 /* This assumes a sane (2's-complement) representation.  But if you
  * aren't 2's complement, and you don't define LONG_MAX, then you're so
  * bizarre that I want nothing to do with you. */
 #ifndef USING_TWOS_COMPLEMENT
 #error "Seems that your platform doesn't use 2's complement arithmetic. Argh."
 #endif
-#ifndef LONG_MAX
-#if (SIZEOF_LONG == 4)
-#define LONG_MAX 0x7fffffffL
-#elif (SIZEOF_LONG == 8)
-#define LONG_MAX 0x7fffffffffffffffL
-#else
-#error "Can't define LONG_MAX"
-#endif /* (SIZEOF_LONG == 4) || ... */
-#endif /* !defined(LONG_MAX) */
-
-#ifndef INT_MAX
-#if (SIZEOF_INT == 4)
-#define INT_MAX 0x7fffffffL
-#elif (SIZEOF_INT == 8)
-#define INT_MAX 0x7fffffffffffffffL
-#else
-#error "Can't define INT_MAX"
-#endif /* (SIZEOF_INT == 4) || ... */
-#endif /* !defined(INT_MAX) */
-
-#ifndef UINT_MAX
-#if (SIZEOF_INT == 2)
-#define UINT_MAX 0xffffu
-#elif (SIZEOF_INT == 4)
-#define UINT_MAX 0xffffffffu
-#elif (SIZEOF_INT == 8)
-#define UINT_MAX 0xffffffffffffffffu
-#else
-#error "Can't define UINT_MAX"
-#endif /* (SIZEOF_INT == 2) || ... */
-#endif /* !defined(UINT_MAX) */
-
-#ifndef SHORT_MAX
-#if (SIZEOF_SHORT == 2)
-#define SHORT_MAX 0x7fff
-#elif (SIZEOF_SHORT == 4)
-#define SHORT_MAX 0x7fffffff
-#else
-#error "Can't define SHORT_MAX"
-#endif /* (SIZEOF_SHORT == 2) || ... */
-#endif /* !defined(SHORT_MAX) */
 
 #ifndef TIME_MAX
 

+ 8 - 8
src/lib/intmath/bits.c

@@ -16,27 +16,27 @@ int
 tor_log2(uint64_t u64)
 {
   int r = 0;
-  if (u64 >= (U64_LITERAL(1)<<32)) {
+  if (u64 >= (UINT64_C(1)<<32)) {
     u64 >>= 32;
     r = 32;
   }
-  if (u64 >= (U64_LITERAL(1)<<16)) {
+  if (u64 >= (UINT64_C(1)<<16)) {
     u64 >>= 16;
     r += 16;
   }
-  if (u64 >= (U64_LITERAL(1)<<8)) {
+  if (u64 >= (UINT64_C(1)<<8)) {
     u64 >>= 8;
     r += 8;
   }
-  if (u64 >= (U64_LITERAL(1)<<4)) {
+  if (u64 >= (UINT64_C(1)<<4)) {
     u64 >>= 4;
     r += 4;
   }
-  if (u64 >= (U64_LITERAL(1)<<2)) {
+  if (u64 >= (UINT64_C(1)<<2)) {
     u64 >>= 2;
     r += 2;
   }
-  if (u64 >= (U64_LITERAL(1)<<1)) {
+  if (u64 >= (UINT64_C(1)<<1)) {
     // u64 >>= 1; // not using this any more.
     r += 1;
   }
@@ -55,12 +55,12 @@ round_to_power_of_2(uint64_t u64)
     return 1;
 
   lg2 = tor_log2(u64);
-  low = U64_LITERAL(1) << lg2;
+  low = UINT64_C(1) << lg2;
 
   if (lg2 == 63)
     return low;
 
-  high = U64_LITERAL(1) << (lg2+1);
+  high = UINT64_C(1) << (lg2+1);
   if (high - u64 < u64 - low)
     return high;
   else

+ 1 - 1
src/lib/net/nettypes.h

@@ -23,7 +23,7 @@ typedef int socklen_t;
  * any inadvertent checks for the socket being <= 0 or > 0 will probably
  * still work. */
 #define tor_socket_t intptr_t
-#define TOR_SOCKET_T_FORMAT INTPTR_T_FORMAT
+#define TOR_SOCKET_T_FORMAT "%"PRIuPTR
 #define SOCKET_OK(s) ((SOCKET)(s) != INVALID_SOCKET)
 #define TOR_INVALID_SOCKET INVALID_SOCKET
 #else /* !(defined(_WIN32)) */

+ 10 - 10
src/lib/time/tvdiff.c

@@ -51,15 +51,15 @@ tv_udiff(const struct timeval *start, const struct timeval *end)
   /* Sanity check tv_usec */
   if (start->tv_usec > TOR_USEC_PER_SEC || start->tv_usec < 0) {
     log_warn(LD_GENERAL, "comparing times on microsecond detail with bad "
-             "start tv_usec: " I64_FORMAT " microseconds",
-             I64_PRINTF_ARG(start->tv_usec));
+             "start tv_usec: %"PRId64 " microseconds",
+             (int64_t)start->tv_usec);
     return LONG_MAX;
   }
 
   if (end->tv_usec > TOR_USEC_PER_SEC || end->tv_usec < 0) {
     log_warn(LD_GENERAL, "comparing times on microsecond detail with bad "
-             "end tv_usec: " I64_FORMAT " microseconds",
-             I64_PRINTF_ARG(end->tv_usec));
+             "end tv_usec: %"PRId64 " microseconds",
+             (int64_t)end->tv_usec);
     return LONG_MAX;
   }
 
@@ -72,7 +72,7 @@ tv_udiff(const struct timeval *start, const struct timeval *end)
   if (secdiff > (int64_t)(LONG_MAX/1000000 - 1) ||
       secdiff < (int64_t)(LONG_MIN/1000000 + 1)) {
     log_warn(LD_GENERAL, "comparing times on microsecond detail too far "
-             "apart: " I64_FORMAT " seconds", I64_PRINTF_ARG(secdiff));
+             "apart: %"PRId64 " seconds", (secdiff));
     return LONG_MAX;
   }
 
@@ -100,15 +100,15 @@ tv_mdiff(const struct timeval *start, const struct timeval *end)
   /* Sanity check tv_usec */
   if (start->tv_usec > TOR_USEC_PER_SEC || start->tv_usec < 0) {
     log_warn(LD_GENERAL, "comparing times on millisecond detail with bad "
-             "start tv_usec: " I64_FORMAT " microseconds",
-             I64_PRINTF_ARG(start->tv_usec));
+             "start tv_usec: %"PRId64 " microseconds",
+             (int64_t)start->tv_usec);
     return LONG_MAX;
   }
 
   if (end->tv_usec > TOR_USEC_PER_SEC || end->tv_usec < 0) {
     log_warn(LD_GENERAL, "comparing times on millisecond detail with bad "
-             "end tv_usec: " I64_FORMAT " microseconds",
-             I64_PRINTF_ARG(end->tv_usec));
+             "end tv_usec: %"PRId64 " microseconds",
+             (int64_t)end->tv_usec);
     return LONG_MAX;
   }
 
@@ -124,7 +124,7 @@ tv_mdiff(const struct timeval *start, const struct timeval *end)
   if (secdiff > (int64_t)(LONG_MAX/1000 - 2) ||
       secdiff < (int64_t)(LONG_MIN/1000 + 1)) {
     log_warn(LD_GENERAL, "comparing times on millisecond detail too far "
-             "apart: " I64_FORMAT " seconds", I64_PRINTF_ARG(secdiff));
+             "apart: %"PRId64 " seconds", (int64_t)secdiff);
     return LONG_MAX;
   }
 

+ 2 - 2
src/lib/tls/tortls.c

@@ -2442,8 +2442,8 @@ tls_get_write_overhead_ratio,(void))
   if (total_bytes_written_over_tls == 0)
     return 1.0;
 
-  return U64_TO_DBL(total_bytes_written_by_tls) /
-    U64_TO_DBL(total_bytes_written_over_tls);
+  return ((double)total_bytes_written_by_tls) /
+    ((double)total_bytes_written_over_tls);
 }
 
 /** Implement check_no_tls_errors: If there are any pending OpenSSL

+ 2 - 2
src/lib/wallclock/tm_cvt.c

@@ -100,9 +100,9 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
   /* LCOV_EXCL_STOP */
  done:
   if (err_out) {
-    tor_asprintf(err_out, "%s("I64_FORMAT") failed with error %s: %s",
+    tor_asprintf(err_out, "%s(%"PRId64") failed with error %s: %s",
                  islocal?"localtime":"gmtime",
-                 timep?I64_PRINTF_ARG(*timep):0,
+                 timep?((int64_t)*timep):0,
                  strerror(errno),
                  outcome);
   }

+ 4 - 4
src/lib/wallclock/tor_gettimeofday.c

@@ -44,10 +44,10 @@ tor_gettimeofday, (struct timeval *timeval))
 #ifdef _WIN32
   /* Epoch bias copied from perl: number of units between windows epoch and
    * Unix epoch. */
-#define EPOCH_BIAS U64_LITERAL(116444736000000000)
-#define UNITS_PER_SEC U64_LITERAL(10000000)
-#define USEC_PER_SEC U64_LITERAL(1000000)
-#define UNITS_PER_USEC U64_LITERAL(10)
+#define EPOCH_BIAS UINT64_C(116444736000000000)
+#define UNITS_PER_SEC UINT64_C(10000000)
+#define USEC_PER_SEC UINT64_C(1000000)
+#define UNITS_PER_USEC UINT64_C(10)
   union {
     uint64_t ft_64;
     FILETIME ft_ft;

+ 1 - 1
src/or/addressmap.c

@@ -643,7 +643,7 @@ client_dns_incr_failures(const char *address)
     ent->expires = time(NULL) + MAX_DNS_ENTRY_AGE;
     strmap_set(addressmap,address,ent);
   }
-  if (ent->num_resolve_failures < SHORT_MAX)
+  if (ent->num_resolve_failures < SHRT_MAX)
     ++ent->num_resolve_failures; /* don't overflow */
   log_info(LD_APP, "Address %s now has %d resolve failures.",
            safe_str_client(address),

+ 145 - 145
src/or/channel.c

@@ -391,9 +391,9 @@ channel_register(channel_t *chan)
   if (chan->registered) return;
 
   log_debug(LD_CHANNEL,
-            "Registering channel %p (ID " U64_FORMAT ") "
+            "Registering channel %p (ID %"PRIu64 ") "
             "in state %s (%d) with digest %s",
-            chan, U64_PRINTF_ARG(chan->global_identifier),
+            chan, (chan->global_identifier),
             channel_state_to_string(chan->state), chan->state,
             hex_str(chan->identity_digest, DIGEST_LEN));
 
@@ -421,9 +421,9 @@ channel_register(channel_t *chan)
         channel_add_to_digest_map(chan);
       } else {
         log_info(LD_CHANNEL,
-                "Channel %p (global ID " U64_FORMAT ") "
+                "Channel %p (global ID %"PRIu64 ") "
                 "in state %s (%d) registered with no identity digest",
-                chan, U64_PRINTF_ARG(chan->global_identifier),
+                chan, (chan->global_identifier),
                 channel_state_to_string(chan->state), chan->state);
       }
     }
@@ -487,9 +487,9 @@ channel_listener_register(channel_listener_t *chan_l)
   if (chan_l->registered) return;
 
   log_debug(LD_CHANNEL,
-            "Registering channel listener %p (ID " U64_FORMAT ") "
+            "Registering channel listener %p (ID %"PRIu64 ") "
             "in state %s (%d)",
-            chan_l, U64_PRINTF_ARG(chan_l->global_identifier),
+            chan_l, (chan_l->global_identifier),
             channel_listener_state_to_string(chan_l->state),
             chan_l->state);
 
@@ -579,9 +579,9 @@ channel_add_to_digest_map(channel_t *chan)
   TOR_LIST_INSERT_HEAD(&ent->channel_list, chan, next_with_same_id);
 
   log_debug(LD_CHANNEL,
-            "Added channel %p (global ID " U64_FORMAT ") "
+            "Added channel %p (global ID %"PRIu64 ") "
             "to identity map in state %s (%d) with digest %s",
-            chan, U64_PRINTF_ARG(chan->global_identifier),
+            chan, (chan->global_identifier),
             channel_state_to_string(chan->state), chan->state,
             hex_str(chan->identity_digest, DIGEST_LEN));
 }
@@ -618,18 +618,18 @@ channel_remove_from_digest_map(channel_t *chan)
     }
 
     log_debug(LD_CHANNEL,
-              "Removed channel %p (global ID " U64_FORMAT ") from "
+              "Removed channel %p (global ID %"PRIu64 ") from "
               "identity map in state %s (%d) with digest %s",
-              chan, U64_PRINTF_ARG(chan->global_identifier),
+              chan, (chan->global_identifier),
               channel_state_to_string(chan->state), chan->state,
               hex_str(chan->identity_digest, DIGEST_LEN));
   } else {
     /* Shouldn't happen */
     log_warn(LD_BUG,
-             "Trying to remove channel %p (global ID " U64_FORMAT ") with "
+             "Trying to remove channel %p (global ID %"PRIu64 ") with "
              "digest %s from identity map, but couldn't find any with "
              "that digest",
-             chan, U64_PRINTF_ARG(chan->global_identifier),
+             chan, (chan->global_identifier),
              hex_str(chan->identity_digest, DIGEST_LEN));
   }
 }
@@ -883,8 +883,8 @@ channel_free_(channel_t *chan)
   tor_assert(!(chan->registered));
 
   log_debug(LD_CHANNEL,
-            "Freeing channel " U64_FORMAT " at %p",
-            U64_PRINTF_ARG(chan->global_identifier), chan);
+            "Freeing channel %"PRIu64 " at %p",
+            (chan->global_identifier), chan);
 
   /* Get this one out of the scheduler */
   scheduler_release_channel(chan);
@@ -929,8 +929,8 @@ channel_listener_free_(channel_listener_t *chan_l)
   if (!chan_l) return;
 
   log_debug(LD_CHANNEL,
-            "Freeing channel_listener_t " U64_FORMAT " at %p",
-            U64_PRINTF_ARG(chan_l->global_identifier),
+            "Freeing channel_listener_t %"PRIu64 " at %p",
+            (chan_l->global_identifier),
             chan_l);
 
   /* It must be closed or errored */
@@ -956,8 +956,8 @@ channel_force_xfree(channel_t *chan)
   tor_assert(chan);
 
   log_debug(LD_CHANNEL,
-            "Force-freeing channel " U64_FORMAT " at %p",
-            U64_PRINTF_ARG(chan->global_identifier), chan);
+            "Force-freeing channel %"PRIu64 " at %p",
+            (chan->global_identifier), chan);
 
   /* Get this one out of the scheduler */
   scheduler_release_channel(chan);
@@ -1000,8 +1000,8 @@ channel_listener_force_xfree(channel_listener_t *chan_l)
   tor_assert(chan_l);
 
   log_debug(LD_CHANNEL,
-            "Force-freeing channel_listener_t " U64_FORMAT " at %p",
-            U64_PRINTF_ARG(chan_l->global_identifier),
+            "Force-freeing channel_listener_t %"PRIu64 " at %p",
+            (chan_l->global_identifier),
             chan_l);
 
   /* Call a free method if there is one */
@@ -1040,8 +1040,8 @@ channel_listener_set_listener_fn(channel_listener_t *chan_l,
 
   log_debug(LD_CHANNEL,
            "Setting listener callback for channel listener %p "
-           "(global ID " U64_FORMAT ") to %p",
-           chan_l, U64_PRINTF_ARG(chan_l->global_identifier),
+           "(global ID %"PRIu64 ") to %p",
+           chan_l, (chan_l->global_identifier),
            listener);
 
   chan_l->listener = listener;
@@ -1140,9 +1140,9 @@ channel_mark_for_close(channel_t *chan)
     return;
 
   log_debug(LD_CHANNEL,
-            "Closing channel %p (global ID " U64_FORMAT ") "
+            "Closing channel %p (global ID %"PRIu64 ") "
             "by request",
-            chan, U64_PRINTF_ARG(chan->global_identifier));
+            chan, (chan->global_identifier));
 
   /* Note closing by request from above */
   chan->reason_for_closing = CHANNEL_CLOSE_REQUESTED;
@@ -1180,9 +1180,9 @@ channel_listener_mark_for_close(channel_listener_t *chan_l)
       chan_l->state == CHANNEL_LISTENER_STATE_ERROR) return;
 
   log_debug(LD_CHANNEL,
-            "Closing channel listener %p (global ID " U64_FORMAT ") "
+            "Closing channel listener %p (global ID %"PRIu64 ") "
             "by request",
-            chan_l, U64_PRINTF_ARG(chan_l->global_identifier));
+            chan_l, (chan_l->global_identifier));
 
   /* Note closing by request from above */
   chan_l->reason_for_closing = CHANNEL_LISTENER_CLOSE_REQUESTED;
@@ -1218,9 +1218,9 @@ channel_close_from_lower_layer(channel_t *chan)
     return;
 
   log_debug(LD_CHANNEL,
-            "Closing channel %p (global ID " U64_FORMAT ") "
+            "Closing channel %p (global ID %"PRIu64 ") "
             "due to lower-layer event",
-            chan, U64_PRINTF_ARG(chan->global_identifier));
+            chan, (chan->global_identifier));
 
   /* Note closing by event from below */
   chan->reason_for_closing = CHANNEL_CLOSE_FROM_BELOW;
@@ -1303,8 +1303,8 @@ channel_clear_identity_digest(channel_t *chan)
 
   log_debug(LD_CHANNEL,
             "Clearing remote endpoint digest on channel %p with "
-            "global ID " U64_FORMAT,
-            chan, U64_PRINTF_ARG(chan->global_identifier));
+            "global ID %"PRIu64,
+            chan, (chan->global_identifier));
 
   state_not_in_map = CHANNEL_CONDEMNED(chan);
 
@@ -1334,8 +1334,8 @@ channel_set_identity_digest(channel_t *chan,
 
   log_debug(LD_CHANNEL,
             "Setting remote endpoint digest on channel %p with "
-            "global ID " U64_FORMAT " to digest %s",
-            chan, U64_PRINTF_ARG(chan->global_identifier),
+            "global ID %"PRIu64 " to digest %s",
+            chan, (chan->global_identifier),
             identity_digest ?
               hex_str(identity_digest, DIGEST_LEN) : "(null)");
 
@@ -1391,8 +1391,8 @@ channel_clear_remote_end(channel_t *chan)
 
   log_debug(LD_CHANNEL,
             "Clearing remote endpoint identity on channel %p with "
-            "global ID " U64_FORMAT,
-            chan, U64_PRINTF_ARG(chan->global_identifier));
+            "global ID %"PRIu64,
+            chan, (chan->global_identifier));
 
   state_not_in_map = CHANNEL_CONDEMNED(chan);
 
@@ -1475,13 +1475,13 @@ channel_write_packed_cell(channel_t *chan, packed_cell_t *cell)
 
   if (CHANNEL_IS_CLOSING(chan)) {
     log_debug(LD_CHANNEL, "Discarding %p on closing channel %p with "
-              "global ID "U64_FORMAT, cell, chan,
-              U64_PRINTF_ARG(chan->global_identifier));
+              "global ID %"PRIu64, cell, chan,
+              (chan->global_identifier));
     goto end;
   }
   log_debug(LD_CHANNEL,
             "Writing %p to channel %p with global ID "
-            U64_FORMAT, cell, chan, U64_PRINTF_ARG(chan->global_identifier));
+            "%"PRIu64, cell, chan, (chan->global_identifier));
 
   ret = write_packed_cell(chan, cell);
 
@@ -1518,9 +1518,9 @@ channel_change_state_(channel_t *chan, channel_state_t to_state)
   if (from_state == to_state) {
     log_debug(LD_CHANNEL,
               "Got no-op transition from \"%s\" to itself on channel %p"
-              "(global ID " U64_FORMAT ")",
+              "(global ID %"PRIu64 ")",
               channel_state_to_string(to_state),
-              chan, U64_PRINTF_ARG(chan->global_identifier));
+              chan, (chan->global_identifier));
     return;
   }
 
@@ -1532,10 +1532,10 @@ channel_change_state_(channel_t *chan, channel_state_t to_state)
   }
 
   log_debug(LD_CHANNEL,
-            "Changing state of channel %p (global ID " U64_FORMAT
+            "Changing state of channel %p (global ID %"PRIu64
             ") from \"%s\" to \"%s\"",
             chan,
-            U64_PRINTF_ARG(chan->global_identifier),
+            (chan->global_identifier),
             channel_state_to_string(chan->state),
             channel_state_to_string(to_state));
 
@@ -1638,9 +1638,9 @@ channel_listener_change_state(channel_listener_t *chan_l,
   if (from_state == to_state) {
     log_debug(LD_CHANNEL,
               "Got no-op transition from \"%s\" to itself on channel "
-              "listener %p (global ID " U64_FORMAT ")",
+              "listener %p (global ID %"PRIu64 ")",
               channel_listener_state_to_string(to_state),
-              chan_l, U64_PRINTF_ARG(chan_l->global_identifier));
+              chan_l, (chan_l->global_identifier));
     return;
   }
 
@@ -1652,9 +1652,9 @@ channel_listener_change_state(channel_listener_t *chan_l,
   }
 
   log_debug(LD_CHANNEL,
-            "Changing state of channel listener %p (global ID " U64_FORMAT
+            "Changing state of channel listener %p (global ID %"PRIu64
             "from \"%s\" to \"%s\"",
-            chan_l, U64_PRINTF_ARG(chan_l->global_identifier),
+            chan_l, (chan_l->global_identifier),
             channel_listener_state_to_string(chan_l->state),
             channel_listener_state_to_string(to_state));
 
@@ -1803,8 +1803,8 @@ channel_listener_process_incoming(channel_listener_t *listener)
 
   log_debug(LD_CHANNEL,
             "Processing queue of incoming connections for channel "
-            "listener %p (global ID " U64_FORMAT ")",
-            listener, U64_PRINTF_ARG(listener->global_identifier));
+            "listener %p (global ID %"PRIu64 ")",
+            listener, (listener->global_identifier));
 
   if (!(listener->incoming_list)) return;
 
@@ -1813,12 +1813,12 @@ channel_listener_process_incoming(channel_listener_t *listener)
     tor_assert(chan);
 
     log_debug(LD_CHANNEL,
-              "Handling incoming channel %p (" U64_FORMAT ") "
-              "for listener %p (" U64_FORMAT ")",
+              "Handling incoming channel %p (%"PRIu64 ") "
+              "for listener %p (%"PRIu64 ")",
               chan,
-              U64_PRINTF_ARG(chan->global_identifier),
+              (chan->global_identifier),
               listener,
-              U64_PRINTF_ARG(listener->global_identifier));
+              (listener->global_identifier));
     /* Make sure this is set correctly */
     channel_mark_incoming(chan);
     listener->listener(listener, chan);
@@ -1924,10 +1924,10 @@ channel_listener_queue_incoming(channel_listener_t *listener,
   tor_assert(incoming);
 
   log_debug(LD_CHANNEL,
-            "Queueing incoming channel %p (global ID " U64_FORMAT ") on "
-            "channel listener %p (global ID " U64_FORMAT ")",
-            incoming, U64_PRINTF_ARG(incoming->global_identifier),
-            listener, U64_PRINTF_ARG(listener->global_identifier));
+            "Queueing incoming channel %p (global ID %"PRIu64 ") on "
+            "channel listener %p (global ID %"PRIu64 ")",
+            incoming, (incoming->global_identifier),
+            listener, (listener->global_identifier));
 
   /* Do we need to queue it, or can we just call the listener right away? */
   if (!(listener->listener)) need_to_queue = 1;
@@ -1984,8 +1984,8 @@ channel_process_cell(channel_t *chan, cell_t *cell)
 
   log_debug(LD_CHANNEL,
             "Processing incoming cell_t %p for channel %p (global ID "
-            U64_FORMAT ")", cell, chan,
-            U64_PRINTF_ARG(chan->global_identifier));
+            "%"PRIu64 ")", cell, chan,
+            (chan->global_identifier));
   chan->cell_handler(chan, cell);
 }
 
@@ -2025,8 +2025,8 @@ channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
   tor_assert(chan);
   if (circ_id == 0) {
     log_warn(LD_BUG, "Attempted to send a destroy cell for circID 0 "
-             "on a channel " U64_FORMAT " at %p in state %s (%d)",
-             U64_PRINTF_ARG(chan->global_identifier),
+             "on a channel %"PRIu64 " at %p in state %s (%d)",
+             (chan->global_identifier),
              chan, channel_state_to_string(chan->state),
              chan->state);
     return 0;
@@ -2038,14 +2038,14 @@ channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
     circuitmux_append_destroy_cell(chan, chan->cmux, circ_id, reason);
     log_debug(LD_OR,
               "Sending destroy (circID %u) on channel %p "
-              "(global ID " U64_FORMAT ")",
+              "(global ID %"PRIu64 ")",
               (unsigned)circ_id, chan,
-              U64_PRINTF_ARG(chan->global_identifier));
+              (chan->global_identifier));
   } else {
     log_warn(LD_BUG,
              "Someone called channel_send_destroy() for circID %u "
-             "on a channel " U64_FORMAT " at %p in state %s (%d)",
-             (unsigned)circ_id, U64_PRINTF_ARG(chan->global_identifier),
+             "on a channel %"PRIu64 " at %p in state %s (%d)",
+             (unsigned)circ_id, (chan->global_identifier),
              chan, channel_state_to_string(chan->state),
              chan->state);
   }
@@ -2179,9 +2179,9 @@ channel_free_list(smartlist_t *channels, int mark_for_close)
     /* Deregister and free it */
     tor_assert(curr);
     log_debug(LD_CHANNEL,
-              "Cleaning up channel %p (global ID " U64_FORMAT ") "
+              "Cleaning up channel %p (global ID %"PRIu64 ") "
               "in state %s (%d)",
-              curr, U64_PRINTF_ARG(curr->global_identifier),
+              curr, (curr->global_identifier),
               channel_state_to_string(curr->state), curr->state);
     /* Detach circuits early so they can find the channel */
     if (curr->cmux) {
@@ -2210,9 +2210,9 @@ channel_listener_free_list(smartlist_t *listeners, int mark_for_close)
     /* Deregister and free it */
     tor_assert(curr);
     log_debug(LD_CHANNEL,
-              "Cleaning up channel listener %p (global ID " U64_FORMAT ") "
+              "Cleaning up channel listener %p (global ID %"PRIu64 ") "
               "in state %s (%d)",
-              curr, U64_PRINTF_ARG(curr->global_identifier),
+              curr, (curr->global_identifier),
               channel_listener_state_to_string(curr->state), curr->state);
     channel_listener_unregister(curr);
     if (mark_for_close) {
@@ -2535,33 +2535,33 @@ channel_dump_statistics, (channel_t *chan, int severity))
   age = (double)(now - chan->timestamp_created);
 
   tor_log(severity, LD_GENERAL,
-      "Channel " U64_FORMAT " (at %p) with transport %s is in state "
+      "Channel %"PRIu64 " (at %p) with transport %s is in state "
       "%s (%d)",
-      U64_PRINTF_ARG(chan->global_identifier), chan,
+      (chan->global_identifier), chan,
       channel_describe_transport(chan),
       channel_state_to_string(chan->state), chan->state);
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " was created at " U64_FORMAT
-      " (" U64_FORMAT " seconds ago) "
-      "and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
-      U64_PRINTF_ARG(chan->global_identifier),
-      U64_PRINTF_ARG(chan->timestamp_created),
-      U64_PRINTF_ARG(now - chan->timestamp_created),
-      U64_PRINTF_ARG(chan->timestamp_active),
-      U64_PRINTF_ARG(now - chan->timestamp_active));
+      " * Channel %"PRIu64 " was created at %"PRIu64
+      " (%"PRIu64 " seconds ago) "
+      "and last active at %"PRIu64 " (%"PRIu64 " seconds ago)",
+      (chan->global_identifier),
+      (uint64_t)(chan->timestamp_created),
+      (uint64_t)(now - chan->timestamp_created),
+      (uint64_t)(chan->timestamp_active),
+      (uint64_t)(now - chan->timestamp_active));
 
   /* Handle digest. */
   if (!tor_digest_is_zero(chan->identity_digest)) {
     tor_log(severity, LD_GENERAL,
-        " * Channel " U64_FORMAT " says it is connected "
+        " * Channel %"PRIu64 " says it is connected "
         "to an OR with digest %s",
-        U64_PRINTF_ARG(chan->global_identifier),
+        (chan->global_identifier),
         hex_str(chan->identity_digest, DIGEST_LEN));
   } else {
     tor_log(severity, LD_GENERAL,
-        " * Channel " U64_FORMAT " does not know the digest"
+        " * Channel %"PRIu64 " does not know the digest"
         " of the OR it is connected to",
-        U64_PRINTF_ARG(chan->global_identifier));
+        (chan->global_identifier));
   }
 
   /* Handle remote address and descriptions */
@@ -2570,10 +2570,10 @@ channel_dump_statistics, (channel_t *chan, int severity))
     char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
     remote_addr_str = tor_addr_to_str_dup(&remote_addr);
     tor_log(severity, LD_GENERAL,
-        " * Channel " U64_FORMAT " says its remote address"
+        " * Channel %"PRIu64 " says its remote address"
         " is %s, and gives a canonical description of \"%s\" and an "
         "actual description of \"%s\"",
-        U64_PRINTF_ARG(chan->global_identifier),
+        (chan->global_identifier),
         safe_str(remote_addr_str),
         safe_str(channel_get_canonical_remote_descr(chan)),
         safe_str(actual));
@@ -2582,10 +2582,10 @@ channel_dump_statistics, (channel_t *chan, int severity))
   } else {
     char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
     tor_log(severity, LD_GENERAL,
-        " * Channel " U64_FORMAT " does not know its remote "
+        " * Channel %"PRIu64 " does not know its remote "
         "address, but gives a canonical description of \"%s\" and an "
         "actual description of \"%s\"",
-        U64_PRINTF_ARG(chan->global_identifier),
+        (chan->global_identifier),
         channel_get_canonical_remote_descr(chan),
         actual);
     tor_free(actual);
@@ -2593,9 +2593,9 @@ channel_dump_statistics, (channel_t *chan, int severity))
 
   /* Handle marks */
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " has these marks: %s %s %s "
+      " * Channel %"PRIu64 " has these marks: %s %s %s "
       "%s %s %s",
-      U64_PRINTF_ARG(chan->global_identifier),
+      (chan->global_identifier),
       channel_is_bad_for_new_circs(chan) ?
         "bad_for_new_circs" : "!bad_for_new_circs",
       channel_is_canonical(chan) ?
@@ -2612,9 +2612,9 @@ channel_dump_statistics, (channel_t *chan, int severity))
 
   /* Describe circuits */
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " has %d active circuits out of"
+      " * Channel %"PRIu64 " has %d active circuits out of"
       " %d in total",
-      U64_PRINTF_ARG(chan->global_identifier),
+      (chan->global_identifier),
       (chan->cmux != NULL) ?
          circuitmux_num_active_circuits(chan->cmux) : 0,
       (chan->cmux != NULL) ?
@@ -2622,78 +2622,78 @@ channel_dump_statistics, (channel_t *chan, int severity))
 
   /* Describe timestamps */
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " was last used by a "
-      "client at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
-      U64_PRINTF_ARG(chan->global_identifier),
-      U64_PRINTF_ARG(chan->timestamp_client),
-      U64_PRINTF_ARG(now - chan->timestamp_client));
+      " * Channel %"PRIu64 " was last used by a "
+      "client at %"PRIu64 " (%"PRIu64 " seconds ago)",
+      (chan->global_identifier),
+      (uint64_t)(chan->timestamp_client),
+      (uint64_t)(now - chan->timestamp_client));
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " last received a cell "
-      "at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
-      U64_PRINTF_ARG(chan->global_identifier),
-      U64_PRINTF_ARG(chan->timestamp_recv),
-      U64_PRINTF_ARG(now - chan->timestamp_recv));
+      " * Channel %"PRIu64 " last received a cell "
+      "at %"PRIu64 " (%"PRIu64 " seconds ago)",
+      (chan->global_identifier),
+      (uint64_t)(chan->timestamp_recv),
+      (uint64_t)(now - chan->timestamp_recv));
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " last transmitted a cell "
-      "at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
-      U64_PRINTF_ARG(chan->global_identifier),
-      U64_PRINTF_ARG(chan->timestamp_xmit),
-      U64_PRINTF_ARG(now - chan->timestamp_xmit));
+      " * Channel %"PRIu64 " last transmitted a cell "
+      "at %"PRIu64 " (%"PRIu64 " seconds ago)",
+      (chan->global_identifier),
+      (uint64_t)(chan->timestamp_xmit),
+      (uint64_t)(now - chan->timestamp_xmit));
 
   /* Describe counters and rates */
   tor_log(severity, LD_GENERAL,
-      " * Channel " U64_FORMAT " has received "
-      U64_FORMAT " bytes in " U64_FORMAT " cells and transmitted "
-      U64_FORMAT " bytes in " U64_FORMAT " cells",
-      U64_PRINTF_ARG(chan->global_identifier),
-      U64_PRINTF_ARG(chan->n_bytes_recved),
-      U64_PRINTF_ARG(chan->n_cells_recved),
-      U64_PRINTF_ARG(chan->n_bytes_xmitted),
-      U64_PRINTF_ARG(chan->n_cells_xmitted));
+      " * Channel %"PRIu64 " has received "
+      "%"PRIu64 " bytes in %"PRIu64 " cells and transmitted "
+      "%"PRIu64 " bytes in %"PRIu64 " cells",
+      (chan->global_identifier),
+      (chan->n_bytes_recved),
+      (chan->n_cells_recved),
+      (chan->n_bytes_xmitted),
+      (chan->n_cells_xmitted));
   if (now > chan->timestamp_created &&
       chan->timestamp_created > 0) {
     if (chan->n_bytes_recved > 0) {
       avg = (double)(chan->n_bytes_recved) / age;
       tor_log(severity, LD_GENERAL,
-          " * Channel " U64_FORMAT " has averaged %f "
+          " * Channel %"PRIu64 " has averaged %f "
           "bytes received per second",
-          U64_PRINTF_ARG(chan->global_identifier), avg);
+          (chan->global_identifier), avg);
     }
     if (chan->n_cells_recved > 0) {
       avg = (double)(chan->n_cells_recved) / age;
       if (avg >= 1.0) {
         tor_log(severity, LD_GENERAL,
-            " * Channel " U64_FORMAT " has averaged %f "
+            " * Channel %"PRIu64 " has averaged %f "
             "cells received per second",
-            U64_PRINTF_ARG(chan->global_identifier), avg);
+            (chan->global_identifier), avg);
       } else if (avg >= 0.0) {
         interval = 1.0 / avg;
         tor_log(severity, LD_GENERAL,
-            " * Channel " U64_FORMAT " has averaged %f "
+            " * Channel %"PRIu64 " has averaged %f "
             "seconds between received cells",
-            U64_PRINTF_ARG(chan->global_identifier), interval);
+            (chan->global_identifier), interval);
       }
     }
     if (chan->n_bytes_xmitted > 0) {
       avg = (double)(chan->n_bytes_xmitted) / age;
       tor_log(severity, LD_GENERAL,
-          " * Channel " U64_FORMAT " has averaged %f "
+          " * Channel %"PRIu64 " has averaged %f "
           "bytes transmitted per second",
-          U64_PRINTF_ARG(chan->global_identifier), avg);
+          (chan->global_identifier), avg);
     }
     if (chan->n_cells_xmitted > 0) {
       avg = (double)(chan->n_cells_xmitted) / age;
       if (avg >= 1.0) {
         tor_log(severity, LD_GENERAL,
-            " * Channel " U64_FORMAT " has averaged %f "
+            " * Channel %"PRIu64 " has averaged %f "
             "cells transmitted per second",
-            U64_PRINTF_ARG(chan->global_identifier), avg);
+            (chan->global_identifier), avg);
       } else if (avg >= 0.0) {
         interval = 1.0 / avg;
         tor_log(severity, LD_GENERAL,
-            " * Channel " U64_FORMAT " has averaged %f "
+            " * Channel %"PRIu64 " has averaged %f "
             "seconds between transmitted cells",
-            U64_PRINTF_ARG(chan->global_identifier), interval);
+            (chan->global_identifier), interval);
       }
     }
   }
@@ -2718,29 +2718,29 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
   age = (double)(now - chan_l->timestamp_created);
 
   tor_log(severity, LD_GENERAL,
-      "Channel listener " U64_FORMAT " (at %p) with transport %s is in "
+      "Channel listener %"PRIu64 " (at %p) with transport %s is in "
       "state %s (%d)",
-      U64_PRINTF_ARG(chan_l->global_identifier), chan_l,
+      (chan_l->global_identifier), chan_l,
       channel_listener_describe_transport(chan_l),
       channel_listener_state_to_string(chan_l->state), chan_l->state);
   tor_log(severity, LD_GENERAL,
-      " * Channel listener " U64_FORMAT " was created at " U64_FORMAT
-      " (" U64_FORMAT " seconds ago) "
-      "and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
-      U64_PRINTF_ARG(chan_l->global_identifier),
-      U64_PRINTF_ARG(chan_l->timestamp_created),
-      U64_PRINTF_ARG(now - chan_l->timestamp_created),
-      U64_PRINTF_ARG(chan_l->timestamp_active),
-      U64_PRINTF_ARG(now - chan_l->timestamp_active));
+      " * Channel listener %"PRIu64 " was created at %"PRIu64
+      " (%"PRIu64 " seconds ago) "
+      "and last active at %"PRIu64 " (%"PRIu64 " seconds ago)",
+      (chan_l->global_identifier),
+      (uint64_t)(chan_l->timestamp_created),
+      (uint64_t)(now - chan_l->timestamp_created),
+      (uint64_t)(chan_l->timestamp_active),
+      (uint64_t)(now - chan_l->timestamp_active));
 
   tor_log(severity, LD_GENERAL,
-      " * Channel listener " U64_FORMAT " last accepted an incoming "
-        "channel at " U64_FORMAT " (" U64_FORMAT " seconds ago) "
-        "and has accepted " U64_FORMAT " channels in total",
-        U64_PRINTF_ARG(chan_l->global_identifier),
-        U64_PRINTF_ARG(chan_l->timestamp_accepted),
-        U64_PRINTF_ARG(now - chan_l->timestamp_accepted),
-        U64_PRINTF_ARG(chan_l->n_accepted));
+      " * Channel listener %"PRIu64 " last accepted an incoming "
+        "channel at %"PRIu64 " (%"PRIu64 " seconds ago) "
+        "and has accepted %"PRIu64 " channels in total",
+        (chan_l->global_identifier),
+        (uint64_t)(chan_l->timestamp_accepted),
+        (uint64_t)(now - chan_l->timestamp_accepted),
+        (uint64_t)(chan_l->n_accepted));
 
   /*
    * If it's sensible to do so, get the rate of incoming channels on this
@@ -2752,15 +2752,15 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
     avg = (double)(chan_l->n_accepted) / age;
     if (avg >= 1.0) {
       tor_log(severity, LD_GENERAL,
-          " * Channel listener " U64_FORMAT " has averaged %f incoming "
+          " * Channel listener %"PRIu64 " has averaged %f incoming "
           "channels per second",
-          U64_PRINTF_ARG(chan_l->global_identifier), avg);
+          (chan_l->global_identifier), avg);
     } else if (avg >= 0.0) {
       interval = 1.0 / avg;
       tor_log(severity, LD_GENERAL,
-          " * Channel listener " U64_FORMAT " has averaged %f seconds "
+          " * Channel listener %"PRIu64 " has averaged %f seconds "
           "between incoming channels",
-          U64_PRINTF_ARG(chan_l->global_identifier), interval);
+          (chan_l->global_identifier), interval);
     }
   }
 

+ 13 - 13
src/or/channelpadding.c

@@ -283,10 +283,10 @@ channelpadding_update_padding_for_channel(channel_t *chan,
                                       pad_vars->ito_high_ms);
 
   log_fn(LOG_INFO,LD_OR,
-         "Negotiated padding=%d, lo=%d, hi=%d on "U64_FORMAT,
+         "Negotiated padding=%d, lo=%d, hi=%d on %"PRIu64,
          chan->padding_enabled, chan->padding_timeout_low_ms,
          chan->padding_timeout_high_ms,
-         U64_PRINTF_ARG(chan->global_identifier));
+         (chan->global_identifier));
 
   return 1;
 }
@@ -394,13 +394,13 @@ channelpadding_send_padding_cell_for_callback(channel_t *chan)
     monotime_coarse_get(&now);
 
     log_fn(LOG_INFO,LD_OR,
-        "Sending netflow keepalive on "U64_FORMAT" to %s (%s) after "
-        I64_FORMAT" ms. Delta "I64_FORMAT"ms",
-        U64_PRINTF_ARG(chan->global_identifier),
+        "Sending netflow keepalive on %"PRIu64" to %s (%s) after "
+        "%"PRId64" ms. Delta %"PRId64"ms",
+        (chan->global_identifier),
         safe_str_client(chan->get_remote_descr(chan, 0)),
         safe_str_client(hex_str(chan->identity_digest, DIGEST_LEN)),
-        I64_PRINTF_ARG(monotime_coarse_diff_msec(&chan->timestamp_xfer,&now)),
-        I64_PRINTF_ARG(
+        (monotime_coarse_diff_msec(&chan->timestamp_xfer,&now)),
+        (
                    monotime_coarse_diff_msec(&chan->next_padding_time,&now)));
   }
 
@@ -540,9 +540,9 @@ channelpadding_compute_time_until_pad_for_netflow(channel_t *chan)
   if (ms_till_pad > DFLT_NETFLOW_INACTIVE_KEEPALIVE_MAX) {
     tor_fragile_assert();
     log_warn(LD_BUG,
-        "Channel padding timeout scheduled "I64_FORMAT"ms in the future. "
+        "Channel padding timeout scheduled %"PRId64"ms in the future. "
         "Did the monotonic clock just jump?",
-        I64_PRINTF_ARG(ms_till_pad));
+        (ms_till_pad));
     return 0; /* Clock jumped: Send padding now */
   }
 
@@ -566,8 +566,8 @@ channelpadding_compute_time_until_pad_for_netflow(channel_t *chan)
       int severity = (ms_till_pad < -NETFLOW_MISSED_WINDOW)
                       ? LOG_NOTICE : LOG_INFO;
       log_fn(severity, LD_OR,
-              "Channel padding timeout scheduled "I64_FORMAT"ms in the past. ",
-             I64_PRINTF_ARG(-ms_till_pad));
+              "Channel padding timeout scheduled %"PRId64"ms in the past. ",
+             (-ms_till_pad));
       return 0; /* Clock jumped: Send padding now */
     }
 
@@ -698,8 +698,8 @@ channelpadding_reduce_padding_on_channel(channel_t *chan)
   chan->padding_timeout_high_ms = consensus_nf_ito_high_reduced;
 
   log_fn(LOG_INFO,LD_OR,
-         "Reduced padding on channel "U64_FORMAT": lo=%d, hi=%d",
-         U64_PRINTF_ARG(chan->global_identifier),
+         "Reduced padding on channel %"PRIu64": lo=%d, hi=%d",
+         (chan->global_identifier),
          chan->padding_timeout_low_ms, chan->padding_timeout_high_ms);
 }
 

+ 36 - 36
src/or/channeltls.c

@@ -194,19 +194,19 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
 
   log_debug(LD_CHANNEL,
             "In channel_tls_connect() for channel %p "
-            "(global id " U64_FORMAT ")",
+            "(global id %"PRIu64 ")",
             tlschan,
-            U64_PRINTF_ARG(chan->global_identifier));
+            (chan->global_identifier));
 
   if (is_local_addr(addr)) {
     log_debug(LD_CHANNEL,
-              "Marking new outgoing channel " U64_FORMAT " at %p as local",
-              U64_PRINTF_ARG(chan->global_identifier), chan);
+              "Marking new outgoing channel %"PRIu64 " at %p as local",
+              (chan->global_identifier), chan);
     channel_mark_local(chan);
   } else {
     log_debug(LD_CHANNEL,
-              "Marking new outgoing channel " U64_FORMAT " at %p as remote",
-              U64_PRINTF_ARG(chan->global_identifier), chan);
+              "Marking new outgoing channel %"PRIu64 " at %p as remote",
+              (chan->global_identifier), chan);
     channel_mark_remote(chan);
   }
 
@@ -222,8 +222,8 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
   }
 
   log_debug(LD_CHANNEL,
-            "Got orconn %p for channel with global id " U64_FORMAT,
-            tlschan->conn, U64_PRINTF_ARG(chan->global_identifier));
+            "Got orconn %p for channel with global id %"PRIu64,
+            tlschan->conn, (chan->global_identifier));
 
   goto done;
 
@@ -273,8 +273,8 @@ channel_tls_start_listener(void)
     channel_tls_listener = listener;
 
     log_debug(LD_CHANNEL,
-              "Starting TLS channel listener %p with global id " U64_FORMAT,
-              listener, U64_PRINTF_ARG(listener->global_identifier));
+              "Starting TLS channel listener %p with global id %"PRIu64,
+              listener, (listener->global_identifier));
 
     channel_listener_register(listener);
   } else listener = channel_tls_listener;
@@ -303,9 +303,9 @@ channel_tls_free_all(void)
      */
     old_listener = channel_tls_listener;
     log_debug(LD_CHANNEL,
-              "Closing channel_tls_listener with ID " U64_FORMAT
+              "Closing channel_tls_listener with ID %"PRIu64
               " at %p.",
-              U64_PRINTF_ARG(old_listener->global_identifier),
+              (old_listener->global_identifier),
               old_listener);
     channel_listener_unregister(old_listener);
     channel_listener_mark_for_close(old_listener);
@@ -337,13 +337,13 @@ channel_tls_handle_incoming(or_connection_t *orconn)
 
   if (is_local_addr(&(TO_CONN(orconn)->addr))) {
     log_debug(LD_CHANNEL,
-              "Marking new incoming channel " U64_FORMAT " at %p as local",
-              U64_PRINTF_ARG(chan->global_identifier), chan);
+              "Marking new incoming channel %"PRIu64 " at %p as local",
+              (chan->global_identifier), chan);
     channel_mark_local(chan);
   } else {
     log_debug(LD_CHANNEL,
-              "Marking new incoming channel " U64_FORMAT " at %p as remote",
-              U64_PRINTF_ARG(chan->global_identifier), chan);
+              "Marking new incoming channel %"PRIu64 " at %p as remote",
+              (chan->global_identifier), chan);
     channel_mark_remote(chan);
   }
 
@@ -433,8 +433,8 @@ channel_tls_describe_transport_method(channel_t *chan)
 
     if (buf) tor_free(buf);
     tor_asprintf(&buf,
-                 "TLS channel (connection " U64_FORMAT ")",
-                 U64_PRINTF_ARG(id));
+                 "TLS channel (connection %"PRIu64 ")",
+                 (id));
 
     rv = buf;
   } else {
@@ -495,8 +495,8 @@ channel_tls_get_overhead_estimate_method(channel_t *chan)
   }
 
   log_debug(LD_CHANNEL,
-            "Estimated overhead ratio for TLS chan " U64_FORMAT " is %f",
-            U64_PRINTF_ARG(chan->global_identifier), overhead);
+            "Estimated overhead ratio for TLS chan %"PRIu64 " is %f",
+            (chan->global_identifier), overhead);
 
   return overhead;
 }
@@ -627,8 +627,8 @@ channel_tls_has_queued_writes_method(channel_t *chan)
   if (!(tlschan->conn)) {
     log_info(LD_CHANNEL,
              "something called has_queued_writes on a tlschan "
-             "(%p with ID " U64_FORMAT " but no conn",
-             chan, U64_PRINTF_ARG(chan->global_identifier));
+             "(%p with ID %"PRIu64 " but no conn",
+             chan, (chan->global_identifier));
   }
 
   outbuf_len = (tlschan->conn != NULL) ?
@@ -695,8 +695,8 @@ channel_tls_matches_extend_info_method(channel_t *chan,
   if (!(tlschan->conn)) {
     log_info(LD_CHANNEL,
              "something called matches_extend_info on a tlschan "
-             "(%p with ID " U64_FORMAT " but no conn",
-             chan, U64_PRINTF_ARG(chan->global_identifier));
+             "(%p with ID %"PRIu64 " but no conn",
+             chan, (chan->global_identifier));
     return 0;
   }
 
@@ -725,8 +725,8 @@ channel_tls_matches_target_method(channel_t *chan,
   if (!(tlschan->conn)) {
     log_info(LD_CHANNEL,
              "something called matches_target on a tlschan "
-             "(%p with ID " U64_FORMAT " but no conn",
-             chan, U64_PRINTF_ARG(chan->global_identifier));
+             "(%p with ID %"PRIu64 " but no conn",
+             chan, (chan->global_identifier));
     return 0;
   }
 
@@ -808,8 +808,8 @@ channel_tls_write_cell_method(channel_t *chan, cell_t *cell)
   } else {
     log_info(LD_CHANNEL,
              "something called write_cell on a tlschan "
-             "(%p with ID " U64_FORMAT " but no conn",
-             chan, U64_PRINTF_ARG(chan->global_identifier));
+             "(%p with ID %"PRIu64 " but no conn",
+             chan, (chan->global_identifier));
   }
 
   return written;
@@ -841,8 +841,8 @@ channel_tls_write_packed_cell_method(channel_t *chan,
   } else {
     log_info(LD_CHANNEL,
              "something called write_packed_cell on a tlschan "
-             "(%p with ID " U64_FORMAT " but no conn",
-             chan, U64_PRINTF_ARG(chan->global_identifier));
+             "(%p with ID %"PRIu64 " but no conn",
+             chan, (chan->global_identifier));
     return -1;
   }
 
@@ -870,8 +870,8 @@ channel_tls_write_var_cell_method(channel_t *chan, var_cell_t *var_cell)
   } else {
     log_info(LD_CHANNEL,
              "something called write_var_cell on a tlschan "
-             "(%p with ID " U64_FORMAT " but no conn",
-             chan, U64_PRINTF_ARG(chan->global_identifier));
+             "(%p with ID %"PRIu64 " but no conn",
+             chan, (chan->global_identifier));
   }
 
   return written;
@@ -1343,15 +1343,15 @@ channel_tls_update_marks(or_connection_t *conn)
   if (is_local_addr(&(TO_CONN(conn)->addr))) {
     if (!channel_is_local(chan)) {
       log_debug(LD_CHANNEL,
-                "Marking channel " U64_FORMAT " at %p as local",
-                U64_PRINTF_ARG(chan->global_identifier), chan);
+                "Marking channel %"PRIu64 " at %p as local",
+                (chan->global_identifier), chan);
       channel_mark_local(chan);
     }
   } else {
     if (channel_is_local(chan)) {
       log_debug(LD_CHANNEL,
-                "Marking channel " U64_FORMAT " at %p as remote",
-                U64_PRINTF_ARG(chan->global_identifier), chan);
+                "Marking channel %"PRIu64 " at %p as remote",
+                (chan->global_identifier), chan);
       channel_mark_remote(chan);
     }
   }

+ 8 - 8
src/or/circuitbuild.c

@@ -202,11 +202,11 @@ get_unique_circ_id_by_chan(channel_t *chan)
                                                               chan->cmux);
 
       log_warn(LD_CIRC, "  Circuitmux on this channel has %u circuits, "
-               "of which %u are active. It says it has "I64_FORMAT
+               "of which %u are active. It says it has %"PRId64
                " destroy cells queued.",
                circuitmux_num_circuits(chan->cmux),
                circuitmux_num_active_circuits(chan->cmux),
-               I64_PRINTF_ARG(queued_destroys));
+               (queued_destroys));
 
       /* Change this into "if (1)" in order to get more information about
        * possible failure modes here.  You'll need to know how to use gdb with
@@ -1150,20 +1150,20 @@ circuit_note_clock_jumped(int64_t seconds_elapsed, bool was_idle)
 {
   int severity = server_mode(get_options()) ? LOG_WARN : LOG_NOTICE;
   if (was_idle) {
-    tor_log(severity, LD_GENERAL, "Tor has been idle for "I64_FORMAT
+    tor_log(severity, LD_GENERAL, "Tor has been idle for %"PRId64
             " seconds; assuming established circuits no longer work.",
-            I64_PRINTF_ARG(seconds_elapsed));
+            (seconds_elapsed));
   } else {
     tor_log(severity, LD_GENERAL,
-            "Your system clock just jumped "I64_FORMAT" seconds %s; "
+            "Your system clock just jumped %"PRId64" seconds %s; "
             "assuming established circuits no longer work.",
-            I64_PRINTF_ARG(
+            (
                  seconds_elapsed >=0 ? seconds_elapsed : -seconds_elapsed),
             seconds_elapsed >=0 ? "forward" : "backward");
   }
-  control_event_general_status(LOG_WARN, "CLOCK_JUMPED TIME="I64_FORMAT
+  control_event_general_status(LOG_WARN, "CLOCK_JUMPED TIME=%"PRId64
                                " IDLE=%d",
-                               I64_PRINTF_ARG(seconds_elapsed), was_idle?1:0);
+                               (seconds_elapsed), was_idle?1:0);
   /* so we log when it works again */
   note_that_we_maybe_cant_complete_circuits();
   control_event_client_status(severity, "CIRCUIT_NOT_ESTABLISHED REASON=%s",

+ 8 - 8
src/or/circuitlist.c

@@ -1003,9 +1003,9 @@ origin_circuit_new(void)
     }
 
     log_info(LD_CIRC,
-              "Circuit " U64_FORMAT " chose an idle timeout of %d based on "
+              "Circuit %"PRIu32" chose an idle timeout of %d based on "
               "%d seconds of predictive building remaining.",
-              U64_PRINTF_ARG(circ->global_identifier),
+              (circ->global_identifier),
               circ->circuit_idle_timeout,
               prediction_time_remaining);
   }
@@ -1392,9 +1392,9 @@ circuit_get_by_circid_channel_impl(circid_t circ_id, channel_t *chan,
   if (found && found->circuit) {
     log_debug(LD_CIRC,
               "circuit_get_by_circid_channel_impl() returning circuit %p for"
-              " circ_id %u, channel ID " U64_FORMAT " (%p)",
+              " circ_id %u, channel ID %"PRIu64 " (%p)",
               found->circuit, (unsigned)circ_id,
-              U64_PRINTF_ARG(chan->global_identifier), chan);
+              (chan->global_identifier), chan);
     if (found_entry_out)
       *found_entry_out = 1;
     return found->circuit;
@@ -1402,10 +1402,10 @@ circuit_get_by_circid_channel_impl(circid_t circ_id, channel_t *chan,
 
   log_debug(LD_CIRC,
             "circuit_get_by_circid_channel_impl() found %s for"
-            " circ_id %u, channel ID " U64_FORMAT " (%p)",
+            " circ_id %u, channel ID %"PRIu64 " (%p)",
             found ? "placeholder" : "nothing",
             (unsigned)circ_id,
-            U64_PRINTF_ARG(chan->global_identifier), chan);
+            (chan->global_identifier), chan);
 
   if (found_entry_out)
     *found_entry_out = found ? 1 : 0;
@@ -2604,10 +2604,10 @@ circuits_handle_oom(size_t current_allocation)
 
  done_recovering_mem:
 
-  log_notice(LD_GENERAL, "Removed "U64_FORMAT" bytes by killing %d circuits; "
+  log_notice(LD_GENERAL, "Removed %"TOR_PRIuSZ" bytes by killing %d circuits; "
              "%d circuits remain alive. Also killed %d non-linked directory "
              "connections.",
-             U64_PRINTF_ARG(mem_recovered),
+             mem_recovered,
              n_circuits_killed,
              smartlist_len(circlist) - n_circuits_killed,
              n_dirconns_killed);

+ 29 - 29
src/or/circuitmux.c

@@ -320,10 +320,10 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out)
           } else {
             /* Complain and move on */
             log_warn(LD_CIRC,
-                     "Circuit %u/channel " U64_FORMAT " had direction == "
+                     "Circuit %u/channel %"PRIu64 " had direction == "
                      "CELL_DIRECTION_IN, but isn't an or_circuit_t",
                      (unsigned)to_remove->circ_id,
-                     U64_PRINTF_ARG(to_remove->chan_id));
+                     (to_remove->chan_id));
           }
 
           /* Free policy-specific data if we have it */
@@ -344,15 +344,15 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out)
         } else {
           /* Complain and move on */
           log_warn(LD_CIRC,
-                   "Couldn't find circuit %u (for channel " U64_FORMAT ")",
+                   "Couldn't find circuit %u (for channel %"PRIu64 ")",
                    (unsigned)to_remove->circ_id,
-                   U64_PRINTF_ARG(to_remove->chan_id));
+                   (to_remove->chan_id));
         }
       } else {
         /* Complain and move on */
         log_warn(LD_CIRC,
-                 "Couldn't find channel " U64_FORMAT " (for circuit id %u)",
-                 U64_PRINTF_ARG(to_remove->chan_id),
+                 "Couldn't find channel %"PRIu64 " (for circuit id %u)",
+                 (to_remove->chan_id),
                  (unsigned)to_remove->circ_id);
       }
 
@@ -428,17 +428,17 @@ circuitmux_free_(circuitmux_t *cmux)
     global_destroy_ctr -= cmux->destroy_cell_queue.n;
     log_debug(LD_CIRC,
               "Freeing cmux at %p with %u queued destroys; the last cmux "
-              "destroy balance was "I64_FORMAT", global is "I64_FORMAT,
+              "destroy balance was %"PRId64", global is %"PRId64,
               cmux, cmux->destroy_cell_queue.n,
-              I64_PRINTF_ARG(cmux->destroy_ctr),
-              I64_PRINTF_ARG(global_destroy_ctr));
+              (cmux->destroy_ctr),
+              (global_destroy_ctr));
   } else {
     log_debug(LD_CIRC,
               "Freeing cmux at %p with no queued destroys, the cmux destroy "
-              "balance was "I64_FORMAT", global is "I64_FORMAT,
+              "balance was %"PRId64", global is %"PRId64,
               cmux,
-              I64_PRINTF_ARG(cmux->destroy_ctr),
-              I64_PRINTF_ARG(global_destroy_ctr));
+              (cmux->destroy_ctr),
+              (global_destroy_ctr));
   }
 
   destroy_cell_queue_clear(&cmux->destroy_cell_queue);
@@ -835,9 +835,9 @@ circuitmux_attach_circuit,(circuitmux_t *cmux, circuit_t *circ,
      * directions match and update the cell count and active circuit count.
      */
     log_info(LD_CIRC,
-             "Circuit %u on channel " U64_FORMAT " was already attached to "
+             "Circuit %u on channel %"PRIu64 " was already attached to "
              "cmux %p (trying to attach to %p)",
-             (unsigned)circ_id, U64_PRINTF_ARG(channel_id),
+             (unsigned)circ_id, (channel_id),
              ((direction == CELL_DIRECTION_OUT) ?
                 circ->n_mux : TO_OR_CIRCUIT(circ)->p_mux),
              cmux);
@@ -869,8 +869,8 @@ circuitmux_attach_circuit,(circuitmux_t *cmux, circuit_t *circ,
      * counts.
      */
     log_debug(LD_CIRC,
-             "Attaching circuit %u on channel " U64_FORMAT " to cmux %p",
-              (unsigned)circ_id, U64_PRINTF_ARG(channel_id), cmux);
+             "Attaching circuit %u on channel %"PRIu64 " to cmux %p",
+              (unsigned)circ_id, (channel_id), cmux);
 
     /*
      * Assert that the circuit doesn't already have a mux for this
@@ -1241,11 +1241,11 @@ circuitmux_notify_xmit_destroy(circuitmux_t *cmux)
   --(cmux->destroy_ctr);
   --(global_destroy_ctr);
   log_debug(LD_CIRC,
-            "Cmux at %p sent a destroy, cmux counter is now "I64_FORMAT", "
-            "global counter is now "I64_FORMAT,
+            "Cmux at %p sent a destroy, cmux counter is now %"PRId64", "
+            "global counter is now %"PRId64,
             cmux,
-            I64_PRINTF_ARG(cmux->destroy_ctr),
-            I64_PRINTF_ARG(global_destroy_ctr));
+            (cmux->destroy_ctr),
+            (global_destroy_ctr));
 }
 
 /*DOCDOC */
@@ -1262,10 +1262,10 @@ circuitmux_append_destroy_cell(channel_t *chan,
   ++global_destroy_ctr;
   log_debug(LD_CIRC,
             "Cmux at %p queued a destroy for circ %u, cmux counter is now "
-            I64_FORMAT", global counter is now "I64_FORMAT,
+            "%"PRId64", global counter is now %"PRId64,
             cmux, circ_id,
-            I64_PRINTF_ARG(cmux->destroy_ctr),
-            I64_PRINTF_ARG(global_destroy_ctr));
+            (cmux->destroy_ctr),
+            (global_destroy_ctr));
 
   /* XXXX Duplicate code from append_cell_to_circuit_queue */
   if (!channel_has_queued_writes(chan)) {
@@ -1303,12 +1303,12 @@ circuitmux_count_queued_destroy_cells(const channel_t *chan,
       n_destroy_cells != manual_total ||
       n_destroy_cells != manual_total_in_map) {
     log_warn(LD_BUG, "  Discrepancy in counts for queued destroy cells on "
-             "circuitmux. n="I64_FORMAT". queue_size="I64_FORMAT". "
-             "manual_total="I64_FORMAT". manual_total_in_map="I64_FORMAT".",
-             I64_PRINTF_ARG(n_destroy_cells),
-             I64_PRINTF_ARG(destroy_queue_size),
-             I64_PRINTF_ARG(manual_total),
-             I64_PRINTF_ARG(manual_total_in_map));
+             "circuitmux. n=%"PRId64". queue_size=%"PRId64". "
+             "manual_total=%"PRId64". manual_total_in_map=%"PRId64".",
+             (n_destroy_cells),
+             (destroy_queue_size),
+             (manual_total),
+             (manual_total_in_map));
   }
 
   return n_destroy_cells;

+ 2 - 2
src/or/circuitstats.c

@@ -713,8 +713,8 @@ circuit_build_times_handle_completed_hop(origin_circuit_t *circ)
      * Switch their purpose and wait. */
     if (circ->base_.purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
       log_info(LD_CIRC,
-               "Deciding to timeout circuit "U64_FORMAT"\n",
-               U64_PRINTF_ARG(circ->global_identifier));
+               "Deciding to timeout circuit %"PRIu32"\n",
+               (circ->global_identifier));
       circuit_build_times_mark_circ_as_measurement_only(circ);
     }
   }

+ 5 - 6
src/or/circuituse.c

@@ -719,9 +719,8 @@ circuit_expire_building(void)
           circuit_build_times_enough_to_compute(get_circuit_build_times())) {
 
         log_info(LD_CIRC,
-                   "Deciding to count the timeout for circuit "U64_FORMAT"\n",
-                   U64_PRINTF_ARG(
-                       TO_ORIGIN_CIRCUIT(victim)->global_identifier));
+                 "Deciding to count the timeout for circuit %"PRIu32"\n",
+                 TO_ORIGIN_CIRCUIT(victim)->global_identifier);
 
         /* Circuits are allowed to last longer for measurement.
          * Switch their purpose and wait. */
@@ -1510,10 +1509,10 @@ circuit_expire_old_circuits_clientside(void)
                 circ->purpose <= CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) ||
                 circ->purpose == CIRCUIT_PURPOSE_S_CONNECT_REND) {
           log_info(LD_CIRC,
-                    "Closing circuit "U64_FORMAT
+                    "Closing circuit %"PRIu32
                     " that has been unused for %ld msec.",
-                    U64_PRINTF_ARG(TO_ORIGIN_CIRCUIT(circ)->global_identifier),
-                    tv_mdiff(&circ->timestamp_began, &now));
+                   TO_ORIGIN_CIRCUIT(circ)->global_identifier,
+                   tv_mdiff(&circ->timestamp_began, &now));
           circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
         } else if (!TO_ORIGIN_CIRCUIT(circ)->is_ancient) {
           /* Server-side rend joined circuits can end up really old, because

+ 2 - 2
src/or/command.c

@@ -249,10 +249,10 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
   tor_assert(chan);
 
   log_debug(LD_OR,
-            "Got a CREATE cell for circ_id %u on channel " U64_FORMAT
+            "Got a CREATE cell for circ_id %u on channel %"PRIu64
             " (%p)",
             (unsigned)cell->circ_id,
-            U64_PRINTF_ARG(chan->global_identifier), chan);
+            (chan->global_identifier), chan);
 
   /* First thing we do, even though the cell might be invalid, is inform the
    * DoS mitigation subsystem layer of this event. Validation is done by this

+ 6 - 6
src/or/config.c

@@ -3061,8 +3061,8 @@ ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
     --*value;
   }
   if (*value > ROUTER_MAX_DECLARED_BANDWIDTH) {
-    tor_asprintf(msg, "%s ("U64_FORMAT") must be at most %d",
-                 desc, U64_PRINTF_ARG(*value),
+    tor_asprintf(msg, "%s (%"PRIu64") must be at most %d",
+                 desc, (*value),
                  ROUTER_MAX_DECLARED_BANDWIDTH);
     return -1;
   }
@@ -4595,8 +4595,8 @@ compute_real_max_mem_in_queues(const uint64_t val, int log_guess)
   uint64_t result;
 
   if (val == 0) {
-#define ONE_GIGABYTE (U64_LITERAL(1) << 30)
-#define ONE_MEGABYTE (U64_LITERAL(1) << 20)
+#define ONE_GIGABYTE (UINT64_C(1) << 30)
+#define ONE_MEGABYTE (UINT64_C(1) << 20)
     /* The user didn't pick a memory limit.  Choose a very large one
      * that is still smaller than the system memory */
     static int notice_sent = 0;
@@ -4650,10 +4650,10 @@ compute_real_max_mem_in_queues(const uint64_t val, int log_guess)
       }
     }
     if (log_guess && ! notice_sent) {
-      log_notice(LD_CONFIG, "%sMaxMemInQueues is set to "U64_FORMAT" MB. "
+      log_notice(LD_CONFIG, "%sMaxMemInQueues is set to %"PRIu64" MB. "
                  "You can override this by setting MaxMemInQueues by hand.",
                  ram ? "Based on detected system memory, " : "",
-                 U64_PRINTF_ARG(result / ONE_MEGABYTE));
+                 (result / ONE_MEGABYTE));
       notice_sent = 1;
     }
     return result;

+ 2 - 2
src/or/config.h

@@ -25,9 +25,9 @@
 
 /** Maximum default value for MaxMemInQueues, in bytes. */
 #if SIZEOF_VOID_P >= 8
-#define MAX_DEFAULT_MEMORY_QUEUE_SIZE (U64_LITERAL(8) << 30)
+#define MAX_DEFAULT_MEMORY_QUEUE_SIZE (UINT64_C(8) << 30)
 #else
-#define MAX_DEFAULT_MEMORY_QUEUE_SIZE (U64_LITERAL(2) << 30)
+#define MAX_DEFAULT_MEMORY_QUEUE_SIZE (UINT64_C(2) << 30)
 #endif
 
 MOCK_DECL(const char*, get_dirportfrontpage, (void));

+ 12 - 12
src/or/confparse.c

@@ -575,8 +575,8 @@ config_get_assigned_option(const config_format_t *fmt, const void *options,
       escape_val = 0; /* Can't need escape. */
       break;
     case CONFIG_TYPE_MEMUNIT:
-      tor_asprintf(&result->value, U64_FORMAT,
-                   U64_PRINTF_ARG(*(uint64_t*)value));
+      tor_asprintf(&result->value, "%"PRIu64,
+                   (*(uint64_t*)value));
       escape_val = 0; /* Can't need escape. */
       break;
     case CONFIG_TYPE_DOUBLE:
@@ -1041,15 +1041,15 @@ static struct unit_table_t memory_units[] = {
   { "gigabit",   1<<27 },
   { "gbits",     1<<27 },
   { "gbit",      1<<27 },
-  { "tb",        U64_LITERAL(1)<<40 },
-  { "tbyte",     U64_LITERAL(1)<<40 },
-  { "tbytes",    U64_LITERAL(1)<<40 },
-  { "terabyte",  U64_LITERAL(1)<<40 },
-  { "terabytes", U64_LITERAL(1)<<40 },
-  { "terabits",  U64_LITERAL(1)<<37 },
-  { "terabit",   U64_LITERAL(1)<<37 },
-  { "tbits",     U64_LITERAL(1)<<37 },
-  { "tbit",      U64_LITERAL(1)<<37 },
+  { "tb",        UINT64_C(1)<<40 },
+  { "tbyte",     UINT64_C(1)<<40 },
+  { "tbytes",    UINT64_C(1)<<40 },
+  { "terabyte",  UINT64_C(1)<<40 },
+  { "terabytes", UINT64_C(1)<<40 },
+  { "terabits",  UINT64_C(1)<<37 },
+  { "terabit",   UINT64_C(1)<<37 },
+  { "tbits",     UINT64_C(1)<<37 },
+  { "tbit",      UINT64_C(1)<<37 },
   { NULL, 0 },
 };
 
@@ -1118,7 +1118,7 @@ config_parse_units(const char *val, struct unit_table_t *u, int *ok)
 
   if (!cp) {
     *ok = 1;
-    v = use_float ? DBL_TO_U64(d) :  v;
+    v = use_float ? ((uint64_t)d) :  v;
     goto done;
   }
 

+ 6 - 6
src/or/connection.c

@@ -624,9 +624,9 @@ connection_free_minimal(connection_t *conn)
       /* Owww, this shouldn't happen, but... */
       log_info(LD_CHANNEL,
                "Freeing orconn at %p, saw channel %p with ID "
-               U64_FORMAT " left un-NULLed",
+               "%"PRIu64 " left un-NULLed",
                or_conn, TLS_CHAN_TO_BASE(or_conn->chan),
-               U64_PRINTF_ARG(
+               (
                  TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier));
       if (!CHANNEL_FINISHED(TLS_CHAN_TO_BASE(or_conn->chan))) {
         channel_close_for_error(TLS_CHAN_TO_BASE(or_conn->chan));
@@ -4996,16 +4996,16 @@ connection_dump_buffer_mem_stats(int severity)
   }
 
   tor_log(severity, LD_GENERAL,
-     "In buffers for %d connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
+     "In buffers for %d connections: %"PRIu64" used/%"PRIu64" allocated",
       smartlist_len(conns),
-      U64_PRINTF_ARG(total_used), U64_PRINTF_ARG(total_alloc));
+      (total_used), (total_alloc));
   for (i=CONN_TYPE_MIN_; i <= CONN_TYPE_MAX_; ++i) {
     if (!n_conns_by_type[i])
       continue;
     tor_log(severity, LD_GENERAL,
-        "  For %d %s connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
+        "  For %d %s connections: %"PRIu64" used/%"PRIu64" allocated",
         n_conns_by_type[i], conn_type_to_string(i),
-        U64_PRINTF_ARG(used_by_type[i]), U64_PRINTF_ARG(alloc_by_type[i]));
+        (used_by_type[i]), (alloc_by_type[i]));
   }
 }
 

+ 2 - 2
src/or/connection_edge.c

@@ -3200,9 +3200,9 @@ connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply,
        !CIRCUIT_IS_ORIGIN(conn->edge_.on_circuit)) {
       if (endreason != END_STREAM_REASON_RESOLVEFAILED) {
         log_info(LD_BUG,
-                 "No origin circuit for successful SOCKS stream "U64_FORMAT
+                 "No origin circuit for successful SOCKS stream %"PRIu64
                  ". Reason: %d",
-                 U64_PRINTF_ARG(ENTRY_TO_CONN(conn)->global_identifier),
+                 (ENTRY_TO_CONN(conn)->global_identifier),
                  endreason);
       }
       /*

+ 2 - 2
src/or/connection_or.c

@@ -855,9 +855,9 @@ connection_or_set_canonical(or_connection_t *or_conn,
           TLS_CHAN_TO_BASE(or_conn->chan), is_canonical);
 
   log_info(LD_CIRC,
-          "Channel " U64_FORMAT " chose an idle timeout of %d.",
+          "Channel %"PRIu64 " chose an idle timeout of %d.",
           or_conn->chan ?
-          U64_PRINTF_ARG(TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier):0,
+          (TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier):0,
           or_conn->idle_timeout);
 }
 

+ 20 - 20
src/or/control.c

@@ -1893,9 +1893,9 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
     }
     *answer = tor_dup_ip(addr);
   } else if (!strcmp(question, "traffic/read")) {
-    tor_asprintf(answer, U64_FORMAT, U64_PRINTF_ARG(get_bytes_read()));
+    tor_asprintf(answer, "%"PRIu64, (get_bytes_read()));
   } else if (!strcmp(question, "traffic/written")) {
-    tor_asprintf(answer, U64_FORMAT, U64_PRINTF_ARG(get_bytes_written()));
+    tor_asprintf(answer, "%"PRIu64, (get_bytes_written()));
   } else if (!strcmp(question, "process/pid")) {
     int myPid = -1;
 
@@ -1930,8 +1930,8 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
     int max_fds = get_max_sockets();
     tor_asprintf(answer, "%d", max_fds);
   } else if (!strcmp(question, "limits/max-mem-in-queues")) {
-    tor_asprintf(answer, U64_FORMAT,
-                 U64_PRINTF_ARG(get_options()->MaxMemInQueues));
+    tor_asprintf(answer, "%"PRIu64,
+                 (get_options()->MaxMemInQueues));
   } else if (!strcmp(question, "fingerprint")) {
     crypto_pk_t *server_key;
     if (!server_mode(get_options())) {
@@ -5891,8 +5891,8 @@ control_event_stream_status(entry_connection_t *conn, stream_status_event_t tp,
   if (circ && CIRCUIT_IS_ORIGIN(circ))
     origin_circ = TO_ORIGIN_CIRCUIT(circ);
   send_control_event(EVENT_STREAM_STATUS,
-                        "650 STREAM "U64_FORMAT" %s %lu %s%s%s%s\r\n",
-                     U64_PRINTF_ARG(ENTRY_TO_CONN(conn)->global_identifier),
+                        "650 STREAM %"PRIu64" %s %lu %s%s%s%s\r\n",
+                     (ENTRY_TO_CONN(conn)->global_identifier),
                      status,
                         origin_circ?
                            (unsigned long)origin_circ->global_identifier : 0ul,
@@ -5963,12 +5963,12 @@ control_event_or_conn_status(or_connection_t *conn, or_conn_status_event_t tp,
 
   orconn_target_get_name(name, sizeof(name), conn);
   send_control_event(EVENT_OR_CONN_STATUS,
-                              "650 ORCONN %s %s%s%s%s ID="U64_FORMAT"\r\n",
+                              "650 ORCONN %s %s%s%s%s ID=%"PRIu64"\r\n",
                               name, status,
                               reason ? " REASON=" : "",
                               orconn_end_reason_to_control_string(reason),
                               ncircs_buf,
-                              U64_PRINTF_ARG(conn->base_.global_identifier));
+                              (conn->base_.global_identifier));
 
   return 0;
 }
@@ -5988,8 +5988,8 @@ control_event_stream_bandwidth(edge_connection_t *edge_conn)
     tor_gettimeofday(&now);
     format_iso_time_nospace_usec(tbuf, &now);
     send_control_event(EVENT_STREAM_BANDWIDTH_USED,
-                       "650 STREAM_BW "U64_FORMAT" %lu %lu %s\r\n",
-                       U64_PRINTF_ARG(edge_conn->base_.global_identifier),
+                       "650 STREAM_BW %"PRIu64" %lu %lu %s\r\n",
+                       (edge_conn->base_.global_identifier),
                        (unsigned long)edge_conn->n_read,
                        (unsigned long)edge_conn->n_written,
                        tbuf);
@@ -6022,8 +6022,8 @@ control_event_stream_bandwidth_used(void)
         tor_gettimeofday(&now);
         format_iso_time_nospace_usec(tbuf, &now);
         send_control_event(EVENT_STREAM_BANDWIDTH_USED,
-                           "650 STREAM_BW "U64_FORMAT" %lu %lu %s\r\n",
-                           U64_PRINTF_ARG(edge_conn->base_.global_identifier),
+                           "650 STREAM_BW %"PRIu64" %lu %lu %s\r\n",
+                           (edge_conn->base_.global_identifier),
                            (unsigned long)edge_conn->n_read,
                            (unsigned long)edge_conn->n_written,
                            tbuf);
@@ -6101,9 +6101,9 @@ control_event_conn_bandwidth(connection_t *conn)
       return 0;
   }
   send_control_event(EVENT_CONN_BW,
-                     "650 CONN_BW ID="U64_FORMAT" TYPE=%s "
+                     "650 CONN_BW ID=%"PRIu64" TYPE=%s "
                      "READ=%lu WRITTEN=%lu\r\n",
-                     U64_PRINTF_ARG(conn->global_identifier),
+                     (conn->global_identifier),
                      conn_type_str,
                      (unsigned long)conn->n_read_conn_bw,
                      (unsigned long)conn->n_written_conn_bw);
@@ -6168,9 +6168,9 @@ append_cell_stats_by_command(smartlist_t *event_parts, const char *key,
   int i;
   for (i = 0; i <= CELL_COMMAND_MAX_; i++) {
     if (include_if_non_zero[i] > 0) {
-      smartlist_add_asprintf(key_value_strings, "%s:"U64_FORMAT,
+      smartlist_add_asprintf(key_value_strings, "%s:%"PRIu64,
                              cell_command_to_string(i),
-                             U64_PRINTF_ARG(number_to_include[i]));
+                             (number_to_include[i]));
     }
   }
   if (smartlist_len(key_value_strings) > 0) {
@@ -6197,8 +6197,8 @@ format_cell_stats(char **event_string, circuit_t *circ,
     or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
     smartlist_add_asprintf(event_parts, "InboundQueue=%lu",
                  (unsigned long)or_circ->p_circ_id);
-    smartlist_add_asprintf(event_parts, "InboundConn="U64_FORMAT,
-                 U64_PRINTF_ARG(or_circ->p_chan->global_identifier));
+    smartlist_add_asprintf(event_parts, "InboundConn=%"PRIu64,
+                 (or_circ->p_chan->global_identifier));
     append_cell_stats_by_command(event_parts, "InboundAdded",
                                  cell_stats->added_cells_appward,
                                  cell_stats->added_cells_appward);
@@ -6212,8 +6212,8 @@ format_cell_stats(char **event_string, circuit_t *circ,
   if (circ->n_chan) {
     smartlist_add_asprintf(event_parts, "OutboundQueue=%lu",
                      (unsigned long)circ->n_circ_id);
-    smartlist_add_asprintf(event_parts, "OutboundConn="U64_FORMAT,
-                 U64_PRINTF_ARG(circ->n_chan->global_identifier));
+    smartlist_add_asprintf(event_parts, "OutboundConn=%"PRIu64,
+                 (circ->n_chan->global_identifier));
     append_cell_stats_by_command(event_parts, "OutboundAdded",
                                  cell_stats->added_cells_exitward,
                                  cell_stats->added_cells_exitward);

+ 1 - 1
src/or/cpuworker.c

@@ -283,7 +283,7 @@ get_overhead_for_onionskins(uint32_t *usec_out, double *frac_out,
     onionskins_usec_internal[onionskin_type];
 
   *usec_out = (uint32_t)(overhead / onionskins_n_processed[onionskin_type]);
-  *frac_out = U64_TO_DBL(overhead) / onionskins_usec_internal[onionskin_type];
+  *frac_out = ((double)overhead) / onionskins_usec_internal[onionskin_type];
 
   return 0;
 }

+ 34 - 34
src/or/dirauth/dirvote.c

@@ -1001,13 +1001,13 @@ networkstatus_check_weights(int64_t Wgg, int64_t Wgd, int64_t Wmg,
  out:
   if (berr) {
     log_info(LD_DIR,
-             "Bw weight mismatch %d. G="I64_FORMAT" M="I64_FORMAT
-             " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT
+             "Bw weight mismatch %d. G=%"PRId64" M=%"PRId64
+             " E=%"PRId64" D=%"PRId64" T=%"PRId64
              " Wmd=%d Wme=%d Wmg=%d Wed=%d Wee=%d"
              " Wgd=%d Wgg=%d Wme=%d Wmg=%d",
              berr,
-             I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-             I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+             (G), (M), (E),
+             (D), (T),
              (int)Wmd, (int)Wme, (int)Wmg, (int)Wed, (int)Wee,
              (int)Wgd, (int)Wgg, (int)Wme, (int)Wmg);
   }
@@ -1033,10 +1033,10 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
 
   if (G <= 0 || M <= 0 || E <= 0 || D <= 0) {
     log_warn(LD_DIR, "Consensus with empty bandwidth: "
-                     "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
-                     " D="I64_FORMAT" T="I64_FORMAT,
-             I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-             I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
+                     "G=%"PRId64" M=%"PRId64" E=%"PRId64
+                     " D=%"PRId64" T=%"PRId64,
+             (G), (M), (E),
+             (D), (T));
     return 0;
   }
 
@@ -1067,13 +1067,13 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
 
     if (berr) {
       log_warn(LD_DIR,
-             "Bw Weights error %d for %s v10. G="I64_FORMAT" M="I64_FORMAT
-             " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT
+             "Bw Weights error %d for %s v10. G=%"PRId64" M=%"PRId64
+             " E=%"PRId64" D=%"PRId64" T=%"PRId64
              " Wmd=%d Wme=%d Wmg=%d Wed=%d Wee=%d"
              " Wgd=%d Wgg=%d Wme=%d Wmg=%d weight_scale=%d",
              berr, casename,
-             I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-             I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+             (G), (M), (E),
+             (D), (T),
              (int)Wmd, (int)Wme, (int)Wmg, (int)Wed, (int)Wee,
              (int)Wgd, (int)Wgg, (int)Wme, (int)Wmg, (int)weight_scale);
       return 0;
@@ -1138,13 +1138,13 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
       if (berr != BW_WEIGHTS_NO_ERROR &&
               berr != BW_WEIGHTS_BALANCE_MID_ERROR) {
         log_warn(LD_DIR,
-             "Bw Weights error %d for %s v10. G="I64_FORMAT" M="I64_FORMAT
-             " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT
+             "Bw Weights error %d for %s v10. G=%"PRId64" M=%"PRId64
+             " E=%"PRId64" D=%"PRId64" T=%"PRId64
              " Wmd=%d Wme=%d Wmg=%d Wed=%d Wee=%d"
              " Wgd=%d Wgg=%d Wme=%d Wmg=%d weight_scale=%d",
              berr, casename,
-             I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-             I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+             (G), (M), (E),
+             (D), (T),
              (int)Wmd, (int)Wme, (int)Wmg, (int)Wed, (int)Wee,
              (int)Wgd, (int)Wgg, (int)Wme, (int)Wmg, (int)weight_scale);
         return 0;
@@ -1155,10 +1155,10 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
     // Case 3: Exactly one of Guard or Exit is scarce
     if (!(3*E < T || 3*G < T) || !(3*G >= T || 3*E >= T)) {
       log_warn(LD_BUG,
-           "Bw-Weights Case 3 v10 but with G="I64_FORMAT" M="
-           I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT,
-               I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-               I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
+           "Bw-Weights Case 3 v10 but with G=%"PRId64" M="
+           "%"PRId64" E=%"PRId64" D=%"PRId64" T=%"PRId64,
+               (G), (M), (E),
+               (D), (T));
     }
 
     if (3*(S+D) < T) { // Subcase a: S+D < T/3
@@ -1210,13 +1210,13 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
       }
       if (berr) {
         log_warn(LD_DIR,
-             "Bw Weights error %d for %s v10. G="I64_FORMAT" M="I64_FORMAT
-             " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT
+             "Bw Weights error %d for %s v10. G=%"PRId64" M=%"PRId64
+             " E=%"PRId64" D=%"PRId64" T=%"PRId64
              " Wmd=%d Wme=%d Wmg=%d Wed=%d Wee=%d"
              " Wgd=%d Wgg=%d Wme=%d Wmg=%d weight_scale=%d",
              berr, casename,
-             I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-             I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+             (G), (M), (E),
+             (D), (T),
              (int)Wmd, (int)Wme, (int)Wmg, (int)Wed, (int)Wee,
              (int)Wgd, (int)Wgg, (int)Wme, (int)Wmg, (int)weight_scale);
         return 0;
@@ -1250,11 +1250,11 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
      (int)weight_scale, (int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale);
 
   log_notice(LD_CIRC, "Computed bandwidth weights for %s with v10: "
-             "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-             " T="I64_FORMAT,
+             "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+             " T=%"PRId64,
              casename,
-             I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-             I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
+             (G), (M), (E),
+             (D), (T));
   return 1;
 }
 
@@ -1758,9 +1758,9 @@ networkstatus_compute_consensus(smartlist_t *votes,
 
     /* Build the flag indexes. Note that no vote can have more than 64 members
      * for known_flags, so no value will be greater than 63, so it's safe to
-     * do U64_LITERAL(1) << index on these values.  But note also that
+     * do UINT64_C(1) << index on these values.  But note also that
      * named_flag and unnamed_flag are initialized to -1, so we need to check
-     * that they're actually set before doing U64_LITERAL(1) << index with
+     * that they're actually set before doing UINT64_C(1) << index with
      * them.*/
     SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
       flag_map[v_sl_idx] = tor_calloc(smartlist_len(v->known_flags),
@@ -1789,7 +1789,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
         uint64_t nf;
         if (named_flag[v_sl_idx]<0)
           continue;
-        nf = U64_LITERAL(1) << named_flag[v_sl_idx];
+        nf = UINT64_C(1) << named_flag[v_sl_idx];
         SMARTLIST_FOREACH_BEGIN(v->routerstatus_list,
                                 vote_routerstatus_t *, rs) {
 
@@ -1814,7 +1814,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
         uint64_t uf;
         if (unnamed_flag[v_sl_idx]<0)
           continue;
-        uf = U64_LITERAL(1) << unnamed_flag[v_sl_idx];
+        uf = UINT64_C(1) << unnamed_flag[v_sl_idx];
         SMARTLIST_FOREACH_BEGIN(v->routerstatus_list,
                                 vote_routerstatus_t *, rs) {
           if ((rs->flags & uf) != 0) {
@@ -1904,11 +1904,11 @@ networkstatus_compute_consensus(smartlist_t *votes,
 
         /* Tally up all the flags. */
         for (int flag = 0; flag < n_voter_flags[voter_idx]; ++flag) {
-          if (rs->flags & (U64_LITERAL(1) << flag))
+          if (rs->flags & (UINT64_C(1) << flag))
             ++flag_counts[flag_map[voter_idx][flag]];
         }
         if (named_flag[voter_idx] >= 0 &&
-            (rs->flags & (U64_LITERAL(1) << named_flag[voter_idx]))) {
+            (rs->flags & (UINT64_C(1) << named_flag[voter_idx]))) {
           if (chosen_name && strcmp(chosen_name, rs->status.nickname)) {
             log_notice(LD_DIR, "Conflict on naming for router: %s vs %s",
                        chosen_name, rs->status.nickname);

+ 6 - 6
src/or/directory.c

@@ -1941,12 +1941,12 @@ directory_send_command(dir_connection_t *conn,
 
   log_debug(LD_DIR,
             "Sent request to directory server '%s:%d': "
-            "(purpose: %d, request size: " U64_FORMAT ", "
-            "payload size: " U64_FORMAT ")",
+            "(purpose: %d, request size: %"TOR_PRIuSZ", "
+            "payload size: %"TOR_PRIuSZ")",
             conn->base_.address, conn->base_.port,
             conn->base_.purpose,
-            U64_PRINTF_ARG(total_request_len),
-            U64_PRINTF_ARG(payload ? payload_len : 0));
+            (total_request_len),
+            (payload ? payload_len : 0));
 }
 
 /** Parse an HTTP request string <b>headers</b> of the form
@@ -2432,14 +2432,14 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
 
   tor_log(LOG_DEBUG, LD_DIR,
             "Received response from directory server '%s:%d': %d %s "
-            "(purpose: %d, response size: " U64_FORMAT
+            "(purpose: %d, response size: %"TOR_PRIuSZ
 #ifdef MEASUREMENTS_21206
             ", data cells received: %d, data cells sent: %d"
 #endif
             ", compression: %d)",
             conn->base_.address, conn->base_.port, status_code,
             escaped(reason), conn->base_.purpose,
-            U64_PRINTF_ARG(received_bytes),
+            (received_bytes),
 #ifdef MEASUREMENTS_21206
             conn->data_cells_received, conn->data_cells_sent,
 #endif

+ 4 - 4
src/or/geoip.c

@@ -1040,12 +1040,12 @@ geoip_get_transport_history(void)
     void *transport_count_ptr = strmap_get(transport_counts, transport_name);
     uintptr_t transport_count = (uintptr_t) transport_count_ptr;
 
-    log_debug(LD_GENERAL, "We got "U64_FORMAT" clients with transport '%s'.",
-              U64_PRINTF_ARG((uint64_t)transport_count), transport_name);
+    log_debug(LD_GENERAL, "We got %"PRIu64" clients with transport '%s'.",
+              ((uint64_t)transport_count), transport_name);
 
-    smartlist_add_asprintf(string_chunks, "%s="U64_FORMAT,
+    smartlist_add_asprintf(string_chunks, "%s=%"PRIu64,
                            transport_name,
-                           U64_PRINTF_ARG(round_uint64_to_next_multiple_of(
+                           (round_uint64_to_next_multiple_of(
                                                (uint64_t)transport_count,
                                                granularity)));
   } SMARTLIST_FOREACH_END(transport_name);

+ 16 - 16
src/or/hibernate.c

@@ -767,13 +767,13 @@ read_bandwidth_usage(void)
        "Successfully read bandwidth accounting info from state written at %s "
        "for interval starting at %s.  We have been active for %lu seconds in "
        "this interval.  At the start of the interval, we expected to use "
-       "about %lu KB per second. ("U64_FORMAT" bytes read so far, "
-       U64_FORMAT" bytes written so far)",
+       "about %lu KB per second. (%"PRIu64" bytes read so far, "
+       "%"PRIu64" bytes written so far)",
        tbuf1, tbuf2,
        (unsigned long)n_seconds_active_in_interval,
        (unsigned long)(expected_bandwidth_usage*1024/60),
-       U64_PRINTF_ARG(n_bytes_read_in_interval),
-       U64_PRINTF_ARG(n_bytes_written_in_interval));
+       (n_bytes_read_in_interval),
+       (n_bytes_written_in_interval));
   }
 
   return 0;
@@ -805,7 +805,7 @@ hibernate_soft_limit_reached(void)
    *   - We have used up 95% of our bytes.
    *   - We have less than 500MB of bytes left.
    */
-  uint64_t soft_limit = DBL_TO_U64(U64_TO_DBL(acct_max) * SOFT_LIM_PCT);
+  uint64_t soft_limit = (uint64_t) (acct_max * SOFT_LIM_PCT);
   if (acct_max > SOFT_LIM_BYTES && acct_max - SOFT_LIM_BYTES > soft_limit) {
     soft_limit = acct_max - SOFT_LIM_BYTES;
   }
@@ -1140,9 +1140,9 @@ getinfo_helper_accounting(control_connection_t *conn,
     *answer = tor_strdup(hibernate_state_to_string(hibernate_state));
     tor_strlower(*answer);
   } else if (!strcmp(question, "accounting/bytes")) {
-      tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
-                 U64_PRINTF_ARG(n_bytes_read_in_interval),
-                 U64_PRINTF_ARG(n_bytes_written_in_interval));
+      tor_asprintf(answer, "%"PRIu64" %"PRIu64,
+                 (n_bytes_read_in_interval),
+                 (n_bytes_written_in_interval));
   } else if (!strcmp(question, "accounting/bytes-left")) {
     uint64_t limit = get_options()->AccountingMax;
     if (get_options()->AccountingRule == ACCT_SUM) {
@@ -1150,28 +1150,28 @@ getinfo_helper_accounting(control_connection_t *conn,
       uint64_t total_bytes = get_accounting_bytes();
       if (total_bytes < limit)
         total_left = limit - total_bytes;
-      tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
-                   U64_PRINTF_ARG(total_left), U64_PRINTF_ARG(total_left));
+      tor_asprintf(answer, "%"PRIu64" %"PRIu64,
+                   (total_left), (total_left));
     } else if (get_options()->AccountingRule == ACCT_IN) {
       uint64_t read_left = 0;
       if (n_bytes_read_in_interval < limit)
         read_left = limit - n_bytes_read_in_interval;
-      tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
-                   U64_PRINTF_ARG(read_left), U64_PRINTF_ARG(limit));
+      tor_asprintf(answer, "%"PRIu64" %"PRIu64,
+                   (read_left), (limit));
     } else if (get_options()->AccountingRule == ACCT_OUT) {
       uint64_t write_left = 0;
       if (n_bytes_written_in_interval < limit)
         write_left = limit - n_bytes_written_in_interval;
-      tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
-                   U64_PRINTF_ARG(limit), U64_PRINTF_ARG(write_left));
+      tor_asprintf(answer, "%"PRIu64" %"PRIu64,
+                   (limit), (write_left));
     } else {
       uint64_t read_left = 0, write_left = 0;
       if (n_bytes_read_in_interval < limit)
         read_left = limit - n_bytes_read_in_interval;
       if (n_bytes_written_in_interval < limit)
         write_left = limit - n_bytes_written_in_interval;
-      tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
-                   U64_PRINTF_ARG(read_left), U64_PRINTF_ARG(write_left));
+      tor_asprintf(answer, "%"PRIu64" %"PRIu64,
+                   (read_left), (write_left));
     }
   } else if (!strcmp(question, "accounting/interval-start")) {
     *answer = tor_malloc(ISO_TIME_LEN+1);

+ 26 - 26
src/or/main.c

@@ -1280,9 +1280,9 @@ run_connection_housekeeping(int i, time_t now)
   } else if (!have_any_circuits &&
              now - or_conn->idle_timeout >=
                                          chan->timestamp_last_had_circuits) {
-    log_info(LD_OR,"Expiring non-used OR connection "U64_FORMAT" to fd %d "
+    log_info(LD_OR,"Expiring non-used OR connection %"PRIu64" to fd %d "
              "(%s:%d) [no circuits for %d; timeout %d; %scanonical].",
-             U64_PRINTF_ARG(chan->global_identifier),
+             (chan->global_identifier),
              (int)conn->s, conn->address, conn->port,
              (int)(now - chan->timestamp_last_had_circuits),
              or_conn->idle_timeout,
@@ -3208,8 +3208,8 @@ static void
 dumpmemusage(int severity)
 {
   connection_dump_buffer_mem_stats(severity);
-  tor_log(severity, LD_GENERAL, "In rephist: "U64_FORMAT" used by %d Tors.",
-      U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
+  tor_log(severity, LD_GENERAL, "In rephist: %"PRIu64" used by %d Tors.",
+      (rephist_total_alloc), rephist_total_num);
   dump_routerlist_mem_usage(severity);
   dump_cell_pool_usage(severity);
   dump_dns_mem_usage(severity);
@@ -3272,28 +3272,28 @@ dumpstats(int severity)
   channel_listener_dumpstats(severity);
 
   tor_log(severity, LD_NET,
-      "Cells processed: "U64_FORMAT" padding\n"
-      "                 "U64_FORMAT" create\n"
-      "                 "U64_FORMAT" created\n"
-      "                 "U64_FORMAT" relay\n"
-      "                        ("U64_FORMAT" relayed)\n"
-      "                        ("U64_FORMAT" delivered)\n"
-      "                 "U64_FORMAT" destroy",
-      U64_PRINTF_ARG(stats_n_padding_cells_processed),
-      U64_PRINTF_ARG(stats_n_create_cells_processed),
-      U64_PRINTF_ARG(stats_n_created_cells_processed),
-      U64_PRINTF_ARG(stats_n_relay_cells_processed),
-      U64_PRINTF_ARG(stats_n_relay_cells_relayed),
-      U64_PRINTF_ARG(stats_n_relay_cells_delivered),
-      U64_PRINTF_ARG(stats_n_destroy_cells_processed));
+      "Cells processed: %"PRIu64" padding\n"
+      "                 %"PRIu64" create\n"
+      "                 %"PRIu64" created\n"
+      "                 %"PRIu64" relay\n"
+      "                        (%"PRIu64" relayed)\n"
+      "                        (%"PRIu64" delivered)\n"
+      "                 %"PRIu64" destroy",
+      (stats_n_padding_cells_processed),
+      (stats_n_create_cells_processed),
+      (stats_n_created_cells_processed),
+      (stats_n_relay_cells_processed),
+      (stats_n_relay_cells_relayed),
+      (stats_n_relay_cells_delivered),
+      (stats_n_destroy_cells_processed));
   if (stats_n_data_cells_packaged)
     tor_log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
-        100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
-             U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
+        100*(((double)stats_n_data_bytes_packaged) /
+             ((double)stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
   if (stats_n_data_cells_received)
     tor_log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
-        100*(U64_TO_DBL(stats_n_data_bytes_received) /
-             U64_TO_DBL(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
+        100*(((double)stats_n_data_bytes_received) /
+             ((double)stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
 
   cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_TAP, "TAP");
   cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_NTOR,"ntor");
@@ -3305,13 +3305,13 @@ dumpstats(int severity)
 
   if (elapsed) {
     tor_log(severity, LD_NET,
-        "Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec reading",
-        U64_PRINTF_ARG(stats_n_bytes_read),
+        "Average bandwidth: %"PRIu64"/%d = %d bytes/sec reading",
+        (stats_n_bytes_read),
         (int)elapsed,
         (int) (stats_n_bytes_read/elapsed));
     tor_log(severity, LD_NET,
-        "Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec writing",
-        U64_PRINTF_ARG(stats_n_bytes_written),
+        "Average bandwidth: %"PRIu64"/%d = %d bytes/sec writing",
+        (stats_n_bytes_written),
         (int)elapsed,
         (int) (stats_n_bytes_written/elapsed));
   }

+ 3 - 3
src/or/microdesc.c

@@ -721,9 +721,9 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
     off_real = tor_fd_getpos(fd);
     if (off_real != off) {
       log_warn(LD_BUG, "Discontinuity in position in microdescriptor cache."
-               "By my count, I'm at "I64_FORMAT
-               ", but I should be at "I64_FORMAT,
-               I64_PRINTF_ARG(off), I64_PRINTF_ARG(off_real));
+               "By my count, I'm at %"PRId64
+               ", but I should be at %"PRId64,
+               (off), (off_real));
       if (off_real >= 0)
         off = off_real;
     }

+ 3 - 3
src/or/policies.c

@@ -2410,7 +2410,7 @@ policy_summary_item_split(policy_summary_item_t* old, uint16_t new_starts)
 #define REJECT_CUTOFF_SCALE_IPV4 (0)
 /* Ports are rejected in an IPv4 summary if they are rejected in more than two
  * IPv4 /8 address blocks */
-#define REJECT_CUTOFF_COUNT_IPV4 (U64_LITERAL(1) << \
+#define REJECT_CUTOFF_COUNT_IPV4 (UINT64_C(1) << \
                                   (IPV4_BITS - REJECT_CUTOFF_SCALE_IPV4 - 7))
 
 #define IPV6_BITS                (128)
@@ -2422,7 +2422,7 @@ policy_summary_item_split(policy_summary_item_t* old, uint16_t new_starts)
  * some scattered smaller blocks) have been allocated to the RIRs.
  * Network providers are typically allocated one or more IPv6 /32s.
  */
-#define REJECT_CUTOFF_COUNT_IPV6 (U64_LITERAL(1) << \
+#define REJECT_CUTOFF_COUNT_IPV6 (UINT64_C(1) << \
                                   (IPV6_BITS - REJECT_CUTOFF_SCALE_IPV6 - 16))
 
 /** Split an exit policy summary so that prt_min and prt_max
@@ -2517,7 +2517,7 @@ policy_summary_reject(smartlist_t *summary,
      * in the range. */
     count = UINT64_MAX;
   } else {
-    count = (U64_LITERAL(1) << (addrbits - scale - maskbits));
+    count = (UINT64_C(1) << (addrbits - scale - maskbits));
   }
   tor_assert_nonfatal_once(count > 0);
   while (i < smartlist_len(summary) &&

+ 66 - 66
src/or/rephist.c

@@ -1223,9 +1223,9 @@ rep_hist_bandwidth_assess(void)
   r = find_largest_max(read_array);
   w = find_largest_max(write_array);
   if (r>w)
-    return (int)(U64_TO_DBL(w)/NUM_SECS_ROLLING_MEASURE);
+    return (int)(((double)w)/NUM_SECS_ROLLING_MEASURE);
   else
-    return (int)(U64_TO_DBL(r)/NUM_SECS_ROLLING_MEASURE);
+    return (int)(((double)r)/NUM_SECS_ROLLING_MEASURE);
 }
 
 /** Print the bandwidth history of b (either [dir-]read_array or
@@ -1271,9 +1271,9 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
       total = cutoff;
 
     if (n==(b->num_maxes_set-1))
-      tor_snprintf(cp, len-(cp-buf), U64_FORMAT, U64_PRINTF_ARG(total));
+      tor_snprintf(cp, len-(cp-buf), "%"PRIu64, (total));
     else
-      tor_snprintf(cp, len-(cp-buf), U64_FORMAT",", U64_PRINTF_ARG(total));
+      tor_snprintf(cp, len-(cp-buf), "%"PRIu64",", (total));
     cp += strlen(cp);
   }
   return cp-buf;
@@ -1385,17 +1385,17 @@ rep_hist_update_bwhist_state_section(or_state_t *state,
   for (j=0; j < b->num_maxes_set; ++j,++i) {
     if (i >= NUM_TOTALS)
       i = 0;
-    smartlist_add_asprintf(*s_values, U64_FORMAT,
-                           U64_PRINTF_ARG(b->totals[i] & ~0x3ff));
+    smartlist_add_asprintf(*s_values, "%"PRIu64,
+                           (b->totals[i] & ~0x3ff));
     maxval = b->maxima[i] / NUM_SECS_ROLLING_MEASURE;
-    smartlist_add_asprintf(*s_maxima, U64_FORMAT,
-                           U64_PRINTF_ARG(maxval & ~0x3ff));
+    smartlist_add_asprintf(*s_maxima, "%"PRIu64,
+                           (maxval & ~0x3ff));
   }
-  smartlist_add_asprintf(*s_values, U64_FORMAT,
-                         U64_PRINTF_ARG(b->total_in_period & ~0x3ff));
+  smartlist_add_asprintf(*s_values, "%"PRIu64,
+                         (b->total_in_period & ~0x3ff));
   maxval = b->max_total / NUM_SECS_ROLLING_MEASURE;
-  smartlist_add_asprintf(*s_maxima, U64_FORMAT,
-                         U64_PRINTF_ARG(maxval & ~0x3ff));
+  smartlist_add_asprintf(*s_maxima, "%"PRIu64,
+                         (maxval & ~0x3ff));
 }
 
 /** Update <b>state</b> with the newest bandwidth history. Done before
@@ -1969,8 +1969,8 @@ rep_hist_format_exit_stats(time_t now)
                      exit_bytes_written[cur_port],
                      EXIT_STATS_ROUND_UP_BYTES);
       num /= 1024;
-      smartlist_add_asprintf(written_strings, "%d="U64_FORMAT,
-                             cur_port, U64_PRINTF_ARG(num));
+      smartlist_add_asprintf(written_strings, "%d=%"PRIu64,
+                             cur_port, (num));
       other_written -= exit_bytes_written[cur_port];
     }
     if (exit_bytes_read[cur_port] > 0) {
@@ -1978,8 +1978,8 @@ rep_hist_format_exit_stats(time_t now)
                      exit_bytes_read[cur_port],
                      EXIT_STATS_ROUND_UP_BYTES);
       num /= 1024;
-      smartlist_add_asprintf(read_strings, "%d="U64_FORMAT,
-                             cur_port, U64_PRINTF_ARG(num));
+      smartlist_add_asprintf(read_strings, "%d=%"PRIu64,
+                             cur_port, (num));
       other_read -= exit_bytes_read[cur_port];
     }
     if (exit_streams[cur_port] > 0) {
@@ -1995,13 +1995,13 @@ rep_hist_format_exit_stats(time_t now)
   other_written = round_uint64_to_next_multiple_of(other_written,
                   EXIT_STATS_ROUND_UP_BYTES);
   other_written /= 1024;
-  smartlist_add_asprintf(written_strings, "other="U64_FORMAT,
-                         U64_PRINTF_ARG(other_written));
+  smartlist_add_asprintf(written_strings, "other=%"PRIu64,
+                         (other_written));
   other_read = round_uint64_to_next_multiple_of(other_read,
                EXIT_STATS_ROUND_UP_BYTES);
   other_read /= 1024;
-  smartlist_add_asprintf(read_strings, "other="U64_FORMAT,
-                         U64_PRINTF_ARG(other_read));
+  smartlist_add_asprintf(read_strings, "other=%"PRIu64,
+                         (other_read));
   other_streams = round_uint32_to_next_multiple_of(other_streams,
                   EXIT_STATS_ROUND_UP_STREAMS);
   smartlist_add_asprintf(streams_strings, "other=%u", other_streams);
@@ -2261,8 +2261,8 @@ rep_hist_format_buffer_stats(time_t now)
   time_in_queue_strings = smartlist_new();
   for (i = 0; i < SHARES; i++) {
     smartlist_add_asprintf(processed_cells_strings,
-                           U64_FORMAT, !circs_in_share[i] ? 0 :
-                           U64_PRINTF_ARG(processed_cells[i] /
+                           "%"PRIu64, !circs_in_share[i] ? 0 :
+                           (processed_cells[i] /
                            circs_in_share[i]));
   }
   for (i = 0; i < SHARES; i++) {
@@ -2929,14 +2929,14 @@ rep_hist_format_hs_stats(time_t now)
 
   format_iso_time(t, now);
   tor_asprintf(&hs_stats_string, "hidserv-stats-end %s (%d s)\n"
-               "hidserv-rend-relayed-cells "I64_FORMAT" delta_f=%d "
+               "hidserv-rend-relayed-cells %"PRId64" delta_f=%d "
                                            "epsilon=%.2f bin_size=%d\n"
-               "hidserv-dir-onions-seen "I64_FORMAT" delta_f=%d "
+               "hidserv-dir-onions-seen %"PRId64" delta_f=%d "
                                         "epsilon=%.2f bin_size=%d\n",
                t, (unsigned) (now - start_of_hs_stats_interval),
-               I64_PRINTF_ARG(obfuscated_cells_seen), REND_CELLS_DELTA_F,
+               (obfuscated_cells_seen), REND_CELLS_DELTA_F,
                REND_CELLS_EPSILON, REND_CELLS_BIN_SIZE,
-               I64_PRINTF_ARG(obfuscated_onions_seen),
+               (obfuscated_onions_seen),
                ONIONS_SEEN_DELTA_F,
                ONIONS_SEEN_EPSILON, ONIONS_SEEN_BIN_SIZE);
 
@@ -3122,33 +3122,33 @@ rep_hist_get_padding_count_lines(void)
   }
 
   tor_asprintf(&result, "padding-counts %s (%d s)"
-                        " bin-size="U64_FORMAT
-                        " write-drop="U64_FORMAT
-                        " write-pad="U64_FORMAT
-                        " write-total="U64_FORMAT
-                        " read-drop="U64_FORMAT
-                        " read-pad="U64_FORMAT
-                        " read-total="U64_FORMAT
-                        " enabled-read-pad="U64_FORMAT
-                        " enabled-read-total="U64_FORMAT
-                        " enabled-write-pad="U64_FORMAT
-                        " enabled-write-total="U64_FORMAT
-                        " max-chanpad-timers="U64_FORMAT
+                        " bin-size=%"PRIu64
+                        " write-drop=%"PRIu64
+                        " write-pad=%"PRIu64
+                        " write-total=%"PRIu64
+                        " read-drop=%"PRIu64
+                        " read-pad=%"PRIu64
+                        " read-total=%"PRIu64
+                        " enabled-read-pad=%"PRIu64
+                        " enabled-read-total=%"PRIu64
+                        " enabled-write-pad=%"PRIu64
+                        " enabled-write-total=%"PRIu64
+                        " max-chanpad-timers=%"PRIu64
                         "\n",
                padding_published.first_published_at,
                REPHIST_CELL_PADDING_COUNTS_INTERVAL,
-               U64_PRINTF_ARG(ROUND_CELL_COUNTS_TO),
-               U64_PRINTF_ARG(padding_published.write_drop_cell_count),
-               U64_PRINTF_ARG(padding_published.write_pad_cell_count),
-               U64_PRINTF_ARG(padding_published.write_cell_count),
-               U64_PRINTF_ARG(padding_published.read_drop_cell_count),
-               U64_PRINTF_ARG(padding_published.read_pad_cell_count),
-               U64_PRINTF_ARG(padding_published.read_cell_count),
-               U64_PRINTF_ARG(padding_published.enabled_read_pad_cell_count),
-               U64_PRINTF_ARG(padding_published.enabled_read_cell_count),
-               U64_PRINTF_ARG(padding_published.enabled_write_pad_cell_count),
-               U64_PRINTF_ARG(padding_published.enabled_write_cell_count),
-               U64_PRINTF_ARG(padding_published.maximum_chanpad_timers)
+               (uint64_t)ROUND_CELL_COUNTS_TO,
+               (padding_published.write_drop_cell_count),
+               (padding_published.write_pad_cell_count),
+               (padding_published.write_cell_count),
+               (padding_published.read_drop_cell_count),
+               (padding_published.read_pad_cell_count),
+               (padding_published.read_cell_count),
+               (padding_published.enabled_read_pad_cell_count),
+               (padding_published.enabled_read_cell_count),
+               (padding_published.enabled_write_pad_cell_count),
+               (padding_published.enabled_write_cell_count),
+               (padding_published.maximum_chanpad_timers)
                );
 
   return result;
@@ -3162,22 +3162,22 @@ rep_hist_log_link_protocol_counts(void)
 {
   log_notice(LD_HEARTBEAT,
              "Since startup, we have initiated "
-             U64_FORMAT" v1 connections, "
-             U64_FORMAT" v2 connections, "
-             U64_FORMAT" v3 connections, and "
-             U64_FORMAT" v4 connections; and received "
-             U64_FORMAT" v1 connections, "
-             U64_FORMAT" v2 connections, "
-             U64_FORMAT" v3 connections, and "
-             U64_FORMAT" v4 connections.",
-             U64_PRINTF_ARG(link_proto_count[1][1]),
-             U64_PRINTF_ARG(link_proto_count[2][1]),
-             U64_PRINTF_ARG(link_proto_count[3][1]),
-             U64_PRINTF_ARG(link_proto_count[4][1]),
-             U64_PRINTF_ARG(link_proto_count[1][0]),
-             U64_PRINTF_ARG(link_proto_count[2][0]),
-             U64_PRINTF_ARG(link_proto_count[3][0]),
-             U64_PRINTF_ARG(link_proto_count[4][0]));
+             "%"PRIu64" v1 connections, "
+             "%"PRIu64" v2 connections, "
+             "%"PRIu64" v3 connections, and "
+             "%"PRIu64" v4 connections; and received "
+             "%"PRIu64" v1 connections, "
+             "%"PRIu64" v2 connections, "
+             "%"PRIu64" v3 connections, and "
+             "%"PRIu64" v4 connections.",
+             (link_proto_count[1][1]),
+             (link_proto_count[2][1]),
+             (link_proto_count[3][1]),
+             (link_proto_count[4][1]),
+             (link_proto_count[1][0]),
+             (link_proto_count[2][0]),
+             (link_proto_count[3][0]),
+             (link_proto_count[4][0]));
 }
 
 /** Free all storage held by the OR/link history caches, by the

+ 2 - 2
src/or/router.c

@@ -1359,10 +1359,10 @@ router_should_be_dirserver(const or_options_t *options, int dir_port)
       interval_length = 1;
     }
     log_info(LD_GENERAL, "Calculating whether to advertise %s: effective "
-                         "bwrate: %u, AccountingMax: "U64_FORMAT", "
+                         "bwrate: %u, AccountingMax: %"PRIu64", "
                          "accounting interval length %d",
                          dir_port ? "dirport" : "begindir",
-                         effective_bw, U64_PRINTF_ARG(options->AccountingMax),
+                         effective_bw, (options->AccountingMax),
                          interval_length);
 
     acc_bytes = options->AccountingMax;

+ 4 - 4
src/or/routerlist.c

@@ -3353,10 +3353,10 @@ dump_routerlist_mem_usage(int severity)
                     olddescs += sd->signed_descriptor_len);
 
   tor_log(severity, LD_DIR,
-      "In %d live descriptors: "U64_FORMAT" bytes.  "
-      "In %d old descriptors: "U64_FORMAT" bytes.",
-      smartlist_len(routerlist->routers), U64_PRINTF_ARG(livedescs),
-      smartlist_len(routerlist->old_routers), U64_PRINTF_ARG(olddescs));
+      "In %d live descriptors: %"PRIu64" bytes.  "
+      "In %d old descriptors: %"PRIu64" bytes.",
+      smartlist_len(routerlist->routers), (livedescs),
+      smartlist_len(routerlist->old_routers), (olddescs));
 }
 
 /** Debugging helper: If <b>idx</b> is nonnegative, assert that <b>ri</b> is

+ 85 - 85
src/or/routerparse.c

@@ -879,8 +879,8 @@ dump_desc_populate_fifo_from_directory(const char *dirname)
     /* Log some stats */
     log_info(LD_DIR,
              "Reloaded unparseable descriptor dump FIFO with %d dump(s) "
-             "totaling " U64_FORMAT " bytes",
-             smartlist_len(descs_dumped), U64_PRINTF_ARG(len_descs_dumped));
+             "totaling %"PRIu64 " bytes",
+             smartlist_len(descs_dumped), (len_descs_dumped));
   }
 
   /* Free the original list */
@@ -2729,7 +2729,7 @@ routerstatus_parse_entry_from_string(memarea_t *area,
     for (i=0; i < tok->n_args; ++i) {
       int p = smartlist_string_pos(vote->known_flags, tok->args[i]);
       if (p >= 0) {
-        vote_rs->flags |= (U64_LITERAL(1)<<p);
+        vote_rs->flags |= (UINT64_C(1)<<p);
       } else {
         log_warn(LD_DIR, "Flags line had a flag %s not listed in known_flags.",
                  escaped(tok->args[i]));
@@ -2952,8 +2952,8 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
   // We use > 1 as the check for these because they are computed as integers.
   // Sometimes there are rounding errors.
   if (fabs(Wmm - weight_scale) > 1) {
-    log_warn(LD_BUG, "Wmm=%f != "I64_FORMAT,
-             Wmm, I64_PRINTF_ARG(weight_scale));
+    log_warn(LD_BUG, "Wmm=%f != %"PRId64,
+             Wmm, (weight_scale));
     valid = 0;
   }
 
@@ -2973,20 +2973,20 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
   }
 
   if (fabs(Wgg + Wmg - weight_scale) > 0.001*weight_scale) {
-    log_warn(LD_BUG, "Wgg=%f != "I64_FORMAT" - Wmg=%f", Wgg,
-             I64_PRINTF_ARG(weight_scale), Wmg);
+    log_warn(LD_BUG, "Wgg=%f != %"PRId64" - Wmg=%f", Wgg,
+             (weight_scale), Wmg);
     valid = 0;
   }
 
   if (fabs(Wee + Wme - weight_scale) > 0.001*weight_scale) {
-    log_warn(LD_BUG, "Wee=%f != "I64_FORMAT" - Wme=%f", Wee,
-             I64_PRINTF_ARG(weight_scale), Wme);
+    log_warn(LD_BUG, "Wee=%f != %"PRId64" - Wme=%f", Wee,
+             (weight_scale), Wme);
     valid = 0;
   }
 
   if (fabs(Wgd + Wmd + Wed - weight_scale) > 0.001*weight_scale) {
-    log_warn(LD_BUG, "Wgd=%f + Wmd=%f + Wed=%f != "I64_FORMAT,
-             Wgd, Wmd, Wed, I64_PRINTF_ARG(weight_scale));
+    log_warn(LD_BUG, "Wgd=%f + Wmd=%f + Wed=%f != %"PRId64,
+             Wgd, Wmd, Wed, (weight_scale));
     valid = 0;
   }
 
@@ -3044,36 +3044,36 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
     if (fabs(Etotal-Mtotal) > 0.01*MAX(Etotal,Mtotal)) {
       log_warn(LD_DIR,
                "Bw Weight Failure for %s: Etotal %f != Mtotal %f. "
-               "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-               " T="I64_FORMAT". "
+               "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+               " T=%"PRId64". "
                "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                casename, Etotal, Mtotal,
-               I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-               I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+               (G), (M), (E),
+               (D), (T),
                Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
       valid = 0;
     }
     if (fabs(Etotal-Gtotal) > 0.01*MAX(Etotal,Gtotal)) {
       log_warn(LD_DIR,
                "Bw Weight Failure for %s: Etotal %f != Gtotal %f. "
-               "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-               " T="I64_FORMAT". "
+               "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+               " T=%"PRId64". "
                "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                casename, Etotal, Gtotal,
-               I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-               I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+               (G), (M), (E),
+               (D), (T),
                Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
       valid = 0;
     }
     if (fabs(Gtotal-Mtotal) > 0.01*MAX(Gtotal,Mtotal)) {
       log_warn(LD_DIR,
                "Bw Weight Failure for %s: Mtotal %f != Gtotal %f. "
-               "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-               " T="I64_FORMAT". "
+               "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+               " T=%"PRId64". "
                "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                casename, Mtotal, Gtotal,
-               I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-               I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+               (G), (M), (E),
+               (D), (T),
                Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
       valid = 0;
     }
@@ -3100,12 +3100,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
       if (Rtotal > Stotal) {
         log_warn(LD_DIR,
                    "Bw Weight Failure for %s: Rtotal %f > Stotal %f. "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                    casename, Rtotal, Stotal,
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
@@ -3113,12 +3113,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
       if (3*Rtotal > T) {
         log_warn(LD_DIR,
                    "Bw Weight Failure for %s: 3*Rtotal %f > T "
-                   I64_FORMAT". G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
-                   " D="I64_FORMAT" T="I64_FORMAT". "
+                   "%"PRId64". G=%"PRId64" M=%"PRId64" E=%"PRId64
+                   " D=%"PRId64" T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
-                   casename, Rtotal*3, I64_PRINTF_ARG(T),
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   casename, Rtotal*3, (T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
@@ -3126,12 +3126,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
       if (3*Stotal > T) {
         log_warn(LD_DIR,
                    "Bw Weight Failure for %s: 3*Stotal %f > T "
-                   I64_FORMAT". G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
-                   " D="I64_FORMAT" T="I64_FORMAT". "
+                   "%"PRId64". G=%"PRId64" M=%"PRId64" E=%"PRId64
+                   " D=%"PRId64" T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
-                   casename, Stotal*3, I64_PRINTF_ARG(T),
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   casename, Stotal*3, (T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
@@ -3139,13 +3139,13 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
       if (3*Mtotal < T) {
         log_warn(LD_DIR,
                    "Bw Weight Failure for %s: 3*Mtotal %f < T "
-                   I64_FORMAT". "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "%"PRId64". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
-                   casename, Mtotal*3, I64_PRINTF_ARG(T),
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   casename, Mtotal*3, (T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
@@ -3158,36 +3158,36 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
         if (fabs(Etotal-Mtotal) > 0.01*MAX(Etotal,Mtotal)) {
           log_warn(LD_DIR,
                    "Bw Weight Failure for %s: Etotal %f != Mtotal %f. "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                    casename, Etotal, Mtotal,
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
           valid = 0;
         }
         if (fabs(Etotal-Gtotal) > 0.01*MAX(Etotal,Gtotal)) {
           log_warn(LD_DIR,
                    "Bw Weight Failure for %s: Etotal %f != Gtotal %f. "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                    casename, Etotal, Gtotal,
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
           valid = 0;
         }
         if (fabs(Gtotal-Mtotal) > 0.01*MAX(Gtotal,Mtotal)) {
           log_warn(LD_DIR,
                    "Bw Weight Failure for %s: Mtotal %f != Gtotal %f. "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                    casename, Mtotal, Gtotal,
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
           valid = 0;
         }
@@ -3195,12 +3195,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
         if (fabs(Etotal-Gtotal) > 0.01*MAX(Etotal,Gtotal)) {
           log_warn(LD_DIR,
                    "Bw Weight Failure for %s: Etotal %f != Gtotal %f. "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                    casename, Etotal, Gtotal,
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
           valid = 0;
         }
@@ -3225,12 +3225,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
       if (3*Stotal > T) {
         log_warn(LD_DIR,
                    "Bw Weight Failure for %s: 3*Stotal %f > T "
-                   I64_FORMAT". G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
-                   " D="I64_FORMAT" T="I64_FORMAT". "
+                   "%"PRId64". G=%"PRId64" M=%"PRId64" E=%"PRId64
+                   " D=%"PRId64" T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
-                   casename, Stotal*3, I64_PRINTF_ARG(T),
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   casename, Stotal*3, (T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
@@ -3238,12 +3238,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
         if (fabs(NStotal-Mtotal) > 0.01*MAX(NStotal,Mtotal)) {
           log_warn(LD_DIR,
                    "Bw Weight Failure for %s: NStotal %f != Mtotal %f. "
-                   "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                   " T="I64_FORMAT". "
+                   "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                   " T=%"PRId64". "
                    "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                    casename, NStotal, Mtotal,
-                   I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                   I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                   (G), (M), (E),
+                   (D), (T),
                    Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
           valid = 0;
         }
@@ -3252,12 +3252,12 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
         if (3*NStotal < T) {
           log_warn(LD_DIR,
                      "Bw Weight Failure for %s: 3*NStotal %f < T "
-                     I64_FORMAT". G="I64_FORMAT" M="I64_FORMAT
-                     " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT". "
+                     "%"PRId64". G=%"PRId64" M=%"PRId64
+                     " E=%"PRId64" D=%"PRId64" T=%"PRId64". "
                      "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
-                     casename, NStotal*3, I64_PRINTF_ARG(T),
-                     I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                     I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                     casename, NStotal*3, (T),
+                     (G), (M), (E),
+                     (D), (T),
                      Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
           valid = 0;
         }
@@ -3267,36 +3267,36 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
       if (fabs(Etotal-Mtotal) > 0.01*MAX(Etotal,Mtotal)) {
         log_warn(LD_DIR,
                  "Bw Weight Failure for %s: Etotal %f != Mtotal %f. "
-                 "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                 " T="I64_FORMAT". "
+                 "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                 " T=%"PRId64". "
                  "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                  casename, Etotal, Mtotal,
-                 I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                 I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                 (G), (M), (E),
+                 (D), (T),
                  Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
       if (fabs(Etotal-Gtotal) > 0.01*MAX(Etotal,Gtotal)) {
         log_warn(LD_DIR,
                  "Bw Weight Failure for %s: Etotal %f != Gtotal %f. "
-                 "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                 " T="I64_FORMAT". "
+                 "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                 " T=%"PRId64". "
                  "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                  casename, Etotal, Gtotal,
-                 I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                 I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                 (G), (M), (E),
+                 (D), (T),
                  Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }
       if (fabs(Gtotal-Mtotal) > 0.01*MAX(Gtotal,Mtotal)) {
         log_warn(LD_DIR,
                  "Bw Weight Failure for %s: Mtotal %f != Gtotal %f. "
-                 "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
-                 " T="I64_FORMAT". "
+                 "G=%"PRId64" M=%"PRId64" E=%"PRId64" D=%"PRId64
+                 " T=%"PRId64". "
                  "Wgg=%f Wgd=%f Wmg=%f Wme=%f Wmd=%f Wee=%f Wed=%f",
                  casename, Mtotal, Gtotal,
-                 I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
-                 I64_PRINTF_ARG(D), I64_PRINTF_ARG(T),
+                 (G), (M), (E),
+                 (D), (T),
                  Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed);
         valid = 0;
       }

+ 8 - 8
src/or/scheduler_vanilla.c

@@ -72,9 +72,9 @@ vanilla_scheduler_run(void)
     n_cells = channel_num_cells_writeable(chan);
     if (n_cells > 0) {
       log_debug(LD_SCHED,
-                "Scheduler saw pending channel " U64_FORMAT " at %p with "
+                "Scheduler saw pending channel %"PRIu64 " at %p with "
                 "%d cells writeable",
-                U64_PRINTF_ARG(chan->global_identifier), chan, n_cells);
+                (chan->global_identifier), chan, n_cells);
 
       flushed = 0;
       while (flushed < n_cells) {
@@ -97,9 +97,9 @@ vanilla_scheduler_run(void)
             if (!to_readd) to_readd = smartlist_new();
             smartlist_add(to_readd, chan);
             log_debug(LD_SCHED,
-                      "Channel " U64_FORMAT " at %p "
+                      "Channel %"PRIu64 " at %p "
                       "is still pending",
-                      U64_PRINTF_ARG(chan->global_identifier),
+                      (chan->global_identifier),
                       chan);
           } else {
             /* It's waiting to be able to write more */
@@ -125,14 +125,14 @@ vanilla_scheduler_run(void)
 
       log_debug(LD_SCHED,
                 "Scheduler flushed %d cells onto pending channel "
-                U64_FORMAT " at %p",
-                (int)flushed, U64_PRINTF_ARG(chan->global_identifier),
+                "%"PRIu64 " at %p",
+                (int)flushed, (chan->global_identifier),
                 chan);
     } else {
       log_info(LD_SCHED,
-               "Scheduler saw pending channel " U64_FORMAT " at %p with "
+               "Scheduler saw pending channel %"PRIu64 " at %p with "
                "no cells writeable",
-               U64_PRINTF_ARG(chan->global_identifier), chan);
+               (chan->global_identifier), chan);
       /* Put it back to WAITING_TO_WRITE */
       scheduler_set_channel_state(chan, SCHED_CHAN_WAITING_TO_WRITE);
     }

+ 11 - 11
src/or/status.c

@@ -79,12 +79,12 @@ bytes_to_usage(uint64_t bytes)
   char *bw_string = NULL;
 
   if (bytes < (1<<20)) { /* Less than a megabyte. */
-    tor_asprintf(&bw_string, U64_FORMAT" kB", U64_PRINTF_ARG(bytes>>10));
+    tor_asprintf(&bw_string, "%"PRIu64" kB", (bytes>>10));
   } else if (bytes < (1<<30)) { /* Megabytes. Let's add some precision. */
-    double bw = U64_TO_DBL(bytes);
+    double bw = ((double)bytes);
     tor_asprintf(&bw_string, "%.2f MB", bw/(1<<20));
   } else { /* Gigabytes. */
-    double bw = U64_TO_DBL(bytes);
+    double bw = ((double)bytes);
     tor_asprintf(&bw_string, "%.2f GB", bw/(1<<30));
   }
 
@@ -152,8 +152,8 @@ log_heartbeat(time_t now)
   double fullness_pct = 100;
   if (stats_n_data_cells_packaged && !hibernating) {
     fullness_pct =
-      100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
-           U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE));
+      100*(((double)stats_n_data_bytes_packaged) /
+           ((double)stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE));
   }
   const double overhead_pct = ( r - 1.0 ) * 100.0;
 
@@ -190,12 +190,12 @@ log_heartbeat(time_t now)
     const uint64_t main_loop_idle_count = get_main_loop_idle_count();
 
     log_fn(LOG_NOTICE, LD_HEARTBEAT, "Main event loop statistics: "
-         U64_FORMAT " successful returns, "
-         U64_FORMAT " erroneous returns, and "
-         U64_FORMAT " idle returns.",
-         U64_PRINTF_ARG(main_loop_success_count),
-         U64_PRINTF_ARG(main_loop_error_count),
-         U64_PRINTF_ARG(main_loop_idle_count));
+         "%"PRIu64 " successful returns, "
+         "%"PRIu64 " erroneous returns, and "
+         "%"PRIu64 " idle returns.",
+         (main_loop_success_count),
+         (main_loop_error_count),
+         (main_loop_idle_count));
   }
 
   /** Now, if we are an HS service, log some stats about our usage */

+ 1 - 1
src/or/torcert.c

@@ -169,7 +169,7 @@ tor_cert_parse(const uint8_t *encoded, const size_t len)
 
   memcpy(cert->signed_key.pubkey, parsed->certified_key, 32);
   int64_t valid_until_64 = ((int64_t)parsed->exp_field) * 3600;
-#if SIZEOF_TIME_T < SIZEOF_INT64_T
+#if SIZEOF_TIME_T < 8
   if (valid_until_64 > TIME_MAX)
     valid_until_64 = TIME_MAX - 1;
 #endif

+ 2 - 2
src/test/test-timers.c

@@ -104,8 +104,8 @@ main(int argc, char **argv)
     total_square_difference += diff*diff;
   }
   const int64_t mean_diff = total_difference / n_active_timers;
-  printf("mean difference: "I64_FORMAT" usec\n",
-         I64_PRINTF_ARG(mean_diff));
+  printf("mean difference: %"PRId64" usec\n",
+         (mean_diff));
 
   const double mean_sq = ((double)total_square_difference)/ n_active_timers;
   const double sq_mean = mean_diff * mean_diff;

+ 7 - 15
src/test/test.h

@@ -50,28 +50,20 @@
   tt_double_op((a), OP_LE, (b)); \
   STMT_END
 
-#ifdef _MSC_VER
-#define U64_PRINTF_TYPE uint64_t
-#define I64_PRINTF_TYPE int64_t
-#else
-#define U64_PRINTF_TYPE unsigned long long
-#define I64_PRINTF_TYPE long long
-#endif /* defined(_MSC_VER) */
-
 #define tt_size_op(a,op,b)                                              \
   tt_assert_test_fmt_type(a,b,#a" "#op" "#b,size_t,(val1_ op val2_),    \
-    U64_PRINTF_TYPE, U64_FORMAT,                                        \
-    {print_ = (U64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION)
+    size_t, "%"TOR_PRIuSZ,                                              \
+    {print_ = (size_t) value_;}, {}, TT_EXIT_TEST_FUNCTION)
 
 #define tt_u64_op(a,op,b)                                              \
   tt_assert_test_fmt_type(a,b,#a" "#op" "#b,uint64_t,(val1_ op val2_), \
-    U64_PRINTF_TYPE, U64_FORMAT,                                       \
-    {print_ = (U64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION)
+    uint64_t, "%"PRIu64,                                               \
+    {print_ = (uint64_t) value_;}, {}, TT_EXIT_TEST_FUNCTION)
 
 #define tt_i64_op(a,op,b)                                              \
-  tt_assert_test_fmt_type(a,b,#a" "#op" "#b,int64_t,(val1_ op val2_), \
-    I64_PRINTF_TYPE, I64_FORMAT,                                       \
-    {print_ = (I64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION)
+  tt_assert_test_fmt_type(a,b,#a" "#op" "#b,int64_t,(val1_ op val2_),  \
+    int64_t, "%"PRId64,                                                \
+    {print_ = (int64_t) value_;}, {}, TT_EXIT_TEST_FUNCTION)
 
 /**
  * Declare that the test is done, even though no tt___op() calls were made.

+ 1 - 1
src/test/test_bwmgt.c

@@ -16,7 +16,7 @@
 // an imaginary time, in timestamp units. Chosen so it will roll over.
 static const uint32_t START_TS = UINT32_MAX-10;
 static const int32_t KB = 1024;
-static const uint32_t GB = (U64_LITERAL(1) << 30);
+static const uint32_t GB = (UINT64_C(1) << 30);
 
 static void
 test_bwmgt_token_buf_init(void *arg)

+ 1 - 1
src/test/test_channel.c

@@ -554,7 +554,7 @@ test_channel_outbound_cell(void *arg)
   /* Set the test time to be mocked, since this test assumes that no
    * time will pass, ewma values will not need to be re-scaled, and so on */
   monotime_enable_test_mocking();
-  monotime_set_mock_time_nsec(U64_LITERAL(1000000000) * 12345);
+  monotime_set_mock_time_nsec(UINT64_C(1000000000) * 12345);
 
   cmux_ewma_set_options(NULL,NULL);
 

+ 1 - 1
src/test/test_circuitmux.c

@@ -86,7 +86,7 @@ static void
 test_cmux_compute_ticks(void *arg)
 {
   const int64_t NS_PER_S = 1000 * 1000 * 1000;
-  const int64_t START_NS = U64_LITERAL(1217709000)*NS_PER_S;
+  const int64_t START_NS = UINT64_C(1217709000)*NS_PER_S;
   int64_t now;
   double rem;
   unsigned tick;

+ 2 - 2
src/test/test_config.c

@@ -5627,8 +5627,8 @@ test_config_include_opened_file_list(void *data)
 static void
 test_config_compute_max_mem_in_queues(void *data)
 {
-#define GIGABYTE(x) (U64_LITERAL(x) << 30)
-#define MEGABYTE(x) (U64_LITERAL(x) << 20)
+#define GIGABYTE(x) (UINT64_C(x) << 30)
+#define MEGABYTE(x) (UINT64_C(x) << 20)
   (void)data;
   MOCK(get_total_system_memory, get_total_system_memory_mock);
 

+ 8 - 8
src/test/test_crypto.c

@@ -215,10 +215,10 @@ test_crypto_rng(void *arg)
     j = crypto_rand_int(100);
     if (j < 0 || j >= 100)
       allok = 0;
-    big = crypto_rand_uint64(U64_LITERAL(1)<<40);
-    if (big >= (U64_LITERAL(1)<<40))
+    big = crypto_rand_uint64(UINT64_C(1)<<40);
+    if (big >= (UINT64_C(1)<<40))
       allok = 0;
-    big = crypto_rand_uint64(U64_LITERAL(5));
+    big = crypto_rand_uint64(UINT64_C(5));
     if (big >= 5)
       allok = 0;
     d = crypto_rand_double();
@@ -2826,8 +2826,8 @@ test_crypto_siphash(void *arg)
       { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
     };
 
-  const struct sipkey K = { U64_LITERAL(0x0706050403020100),
-                            U64_LITERAL(0x0f0e0d0c0b0a0908) };
+  const struct sipkey K = { UINT64_C(0x0706050403020100),
+                            UINT64_C(0x0f0e0d0c0b0a0908) };
   uint8_t input[64];
   int i, j;
 
@@ -2882,12 +2882,12 @@ crypto_rand_check_failure_mode_identical(void)
 {
   /* just in case the buffer size isn't a multiple of sizeof(int64_t) */
 #define FAILURE_MODE_BUFFER_SIZE_I64 \
-  (FAILURE_MODE_BUFFER_SIZE/SIZEOF_INT64_T)
+  (FAILURE_MODE_BUFFER_SIZE/8)
 #define FAILURE_MODE_BUFFER_SIZE_I64_BYTES \
-  (FAILURE_MODE_BUFFER_SIZE_I64*SIZEOF_INT64_T)
+  (FAILURE_MODE_BUFFER_SIZE_I64*8)
 
 #if FAILURE_MODE_BUFFER_SIZE_I64 < 2
-#error FAILURE_MODE_BUFFER_SIZE needs to be at least 2*SIZEOF_INT64_T
+#error FAILURE_MODE_BUFFER_SIZE needs to be at least 2*8
 #endif
 
   int64_t buf[FAILURE_MODE_BUFFER_SIZE_I64];

+ 5 - 5
src/test/test_dir.c

@@ -2110,7 +2110,7 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
     tt_int_op(rs->or_port,OP_EQ, 443);
     tt_int_op(rs->dir_port,OP_EQ, 8000);
     /* no flags except "running" (16) and "v2dir" (64) and "valid" (128) */
-    tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(0xd0));
+    tt_u64_op(vrs->flags, OP_EQ, UINT64_C(0xd0));
   } else if (tor_memeq(rs->identity_digest,
                        "\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
                        "\x5\x5\x5\x5",
@@ -2136,10 +2136,10 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
     tt_int_op(rs->ipv6_orport,OP_EQ, 4711);
     if (voter == 1) {
       /* all except "authority" (1) */
-      tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(254));
+      tt_u64_op(vrs->flags, OP_EQ, UINT64_C(254));
     } else {
       /* 1023 - authority(1) - madeofcheese(16) - madeoftin(32) */
-      tt_u64_op(vrs->flags, OP_EQ, U64_LITERAL(974));
+      tt_u64_op(vrs->flags, OP_EQ, UINT64_C(974));
     }
   } else if (tor_memeq(rs->identity_digest,
                        "\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
@@ -2949,8 +2949,8 @@ test_dir_scale_bw(void *testdata)
   for (i=0; i<8; ++i) {
     total += vals_u64[i];
   }
-  tt_assert(total >= (U64_LITERAL(1)<<60));
-  tt_assert(total <= (U64_LITERAL(1)<<62));
+  tt_assert(total >= (UINT64_C(1)<<60));
+  tt_assert(total <= (UINT64_C(1)<<62));
 
   for (i=0; i<8; ++i) {
     /* vals[2].u64 is the scaled value of 1.0 */

+ 0 - 1
src/test/test_geoip.c

@@ -575,4 +575,3 @@ struct testcase_t geoip_tests[] = {
 
   END_OF_TESTCASES
 };
-

+ 2 - 2
src/test/test_mainloop.c

@@ -21,7 +21,7 @@ test_mainloop_update_time_normal(void *arg)
 
   monotime_enable_test_mocking();
   /* This is arbitrary */
-  uint64_t mt_now = U64_LITERAL(7493289274986);
+  uint64_t mt_now = UINT64_C(7493289274986);
   /* This time is in the past as of when this test was written. */
   time_t now = 1525272090;
   monotime_coarse_set_mock_time_nsec(mt_now);
@@ -63,7 +63,7 @@ test_mainloop_update_time_jumps(void *arg)
 
   monotime_enable_test_mocking();
   /* This is arbitrary */
-  uint64_t mt_now = U64_LITERAL(7493289274986);
+  uint64_t mt_now = UINT64_C(7493289274986);
   /* This time is in the past as of when this test was written. */
   time_t now = 220897152;
   monotime_coarse_set_mock_time_nsec(mt_now);

+ 1 - 1
src/test/test_options.c

@@ -276,7 +276,7 @@ test_options_validate(void *arg)
   return;
 }
 
-#define MEGABYTEIFY(mb) (U64_LITERAL(mb) << 20)
+#define MEGABYTEIFY(mb) (UINT64_C(mb) << 20)
 static void
 test_have_enough_mem_for_dircache(void *arg)
 {

+ 1 - 1
src/test/test_status.c

@@ -232,7 +232,7 @@ NS(test_main)(void *arg)
   tor_free(actual);
 
   expected = "10.00 GB";
-  actual = bytes_to_usage((U64_LITERAL(1) << 30) * 10L);
+  actual = bytes_to_usage((UINT64_C(1) << 30) * 10L);
   tt_str_op(actual, OP_EQ, expected);
   tor_free(actual);
 

+ 18 - 18
src/test/test_util.c

@@ -1931,8 +1931,8 @@ test_util_strmisc(void *arg)
   tor_snprintf(buf, 10, "abcdef");
   tt_int_op(0,OP_EQ, buf[6]);
   /* uint64 */
-  tor_snprintf(buf, sizeof(buf), "x!"U64_FORMAT"!x",
-               U64_PRINTF_ARG(U64_LITERAL(12345678901)));
+  tor_snprintf(buf, sizeof(buf), "x!%"PRIu64"!x",
+               (UINT64_C(12345678901)));
   tt_str_op("x!12345678901!x",OP_EQ, buf);
 
   /* Test str{,case}cmpstart */
@@ -2179,17 +2179,17 @@ test_util_parse_integer(void *arg)
   tt_int_op(0,OP_EQ, i);
 
   /* Test parse_uint64 */
-  tt_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
+  tt_assert(UINT64_C(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
   tt_int_op(1,OP_EQ, i);
   tt_str_op(cp,OP_EQ, " x");
-  tt_assert(U64_LITERAL(12345678901) ==
+  tt_assert(UINT64_C(12345678901) ==
               tor_parse_uint64("12345678901",10,0,UINT64_MAX, &i, &cp));
   tt_int_op(1,OP_EQ, i);
   tt_str_op(cp,OP_EQ, "");
-  tt_assert(U64_LITERAL(0) ==
+  tt_assert(UINT64_C(0) ==
               tor_parse_uint64("12345678901",10,500,INT32_MAX, &i, &cp));
   tt_int_op(0,OP_EQ, i);
-  tt_assert(U64_LITERAL(0) ==
+  tt_assert(UINT64_C(0) ==
               tor_parse_uint64("123",-1,0,INT32_MAX, &i, &cp));
   tt_int_op(0,OP_EQ, i);
 
@@ -2197,10 +2197,10 @@ test_util_parse_integer(void *arg)
   /* Test parse_double */
   double d = tor_parse_double("10", 0, (double)UINT64_MAX,&i,NULL);
   tt_int_op(1,OP_EQ, i);
-  tt_assert(DBL_TO_U64(d) == 10);
+  tt_assert(((uint64_t)d) == 10);
   d = tor_parse_double("0", 0, (double)UINT64_MAX,&i,NULL);
   tt_int_op(1,OP_EQ, i);
-  tt_assert(DBL_TO_U64(d) == 0);
+  tt_assert(((uint64_t)d) == 0);
   d = tor_parse_double(" ", 0, (double)UINT64_MAX,&i,NULL);
   tt_double_op(fabs(d), OP_LT, 1e-10);
   tt_int_op(0,OP_EQ, i);
@@ -2212,7 +2212,7 @@ test_util_parse_integer(void *arg)
   tt_int_op(1,OP_EQ, i);
   d = tor_parse_double("-.0", 0, (double)UINT64_MAX,&i,NULL);
   tt_int_op(1,OP_EQ, i);
-  tt_assert(DBL_TO_U64(d) == 0);
+  tt_assert(((uint64_t)d) == 0);
   d = tor_parse_double("-10", -100.0, 100.0,&i,NULL);
   tt_int_op(1,OP_EQ, i);
   tt_double_op(fabs(d - -10.0),OP_LT, 1E-12);
@@ -2230,7 +2230,7 @@ test_util_parse_integer(void *arg)
     tt_int_op(i,OP_EQ, 0);
     tt_int_op(0UL,OP_EQ, tor_parse_ulong(TOOBIG, 10, 0, ULONG_MAX, &i, NULL));
     tt_int_op(i,OP_EQ, 0);
-    tt_u64_op(U64_LITERAL(0), OP_EQ, tor_parse_uint64(TOOBIG, 10,
+    tt_u64_op(UINT64_C(0), OP_EQ, tor_parse_uint64(TOOBIG, 10,
                                              0, UINT64_MAX, &i, NULL));
     tt_int_op(i,OP_EQ, 0);
   }
@@ -2253,17 +2253,17 @@ test_util_pow2(void *arg)
   tt_int_op(tor_log2(3),OP_EQ, 1);
   tt_int_op(tor_log2(4),OP_EQ, 2);
   tt_int_op(tor_log2(5),OP_EQ, 2);
-  tt_int_op(tor_log2(U64_LITERAL(40000000000000000)),OP_EQ, 55);
+  tt_int_op(tor_log2(UINT64_C(40000000000000000)),OP_EQ, 55);
   tt_int_op(tor_log2(UINT64_MAX),OP_EQ, 63);
 
   /* Test round_to_power_of_2 */
   tt_u64_op(round_to_power_of_2(120), OP_EQ, 128);
   tt_u64_op(round_to_power_of_2(128), OP_EQ, 128);
   tt_u64_op(round_to_power_of_2(130), OP_EQ, 128);
-  tt_u64_op(round_to_power_of_2(U64_LITERAL(40000000000000000)), OP_EQ,
-            U64_LITERAL(1)<<55);
-  tt_u64_op(round_to_power_of_2(U64_LITERAL(0xffffffffffffffff)), OP_EQ,
-          U64_LITERAL(1)<<63);
+  tt_u64_op(round_to_power_of_2(UINT64_C(40000000000000000)), OP_EQ,
+            UINT64_C(1)<<55);
+  tt_u64_op(round_to_power_of_2(UINT64_C(0xffffffffffffffff)), OP_EQ,
+          UINT64_C(1)<<63);
   tt_u64_op(round_to_power_of_2(0), OP_EQ, 1);
   tt_u64_op(round_to_power_of_2(1), OP_EQ, 1);
   tt_u64_op(round_to_power_of_2(2), OP_EQ, 2);
@@ -5570,15 +5570,15 @@ test_util_max_mem(void *arg)
   tt_int_op(r, OP_EQ, r2);
   tt_uint_op(memory2, OP_EQ, memory1);
 
-  TT_BLATHER(("System memory: "U64_FORMAT, U64_PRINTF_ARG(memory1)));
+  TT_BLATHER(("System memory: %"TOR_PRIuSZ, (memory1)));
 
   if (r==0) {
     /* You have at least a megabyte. */
     tt_uint_op(memory1, OP_GT, (1<<20));
   } else {
     /* You do not have a petabyte. */
-#if SIZEOF_SIZE_T == SIZEOF_UINT64_T
-    tt_u64_op(memory1, OP_LT, (U64_LITERAL(1)<<50));
+#if SIZEOF_SIZE_T >= 8
+    tt_u64_op(memory1, OP_LT, (UINT64_C(1)<<50));
 #endif
   }
 

+ 2 - 2
src/test/test_util_format.c

@@ -19,7 +19,7 @@ test_util_format_unaligned_accessors(void *ignored)
   char buf[9] = "onionsoup"; // 6f6e696f6e736f7570
 
   tt_u64_op(get_uint64(buf+1), OP_EQ,
-      tor_htonll(U64_LITERAL(0x6e696f6e736f7570)));
+      tor_htonll(UINT64_C(0x6e696f6e736f7570)));
   tt_uint_op(get_uint32(buf+1), OP_EQ, htonl(0x6e696f6e));
   tt_uint_op(get_uint16(buf+1), OP_EQ, htons(0x6e69));
   tt_uint_op(get_uint8(buf+1), OP_EQ, 0x6e);
@@ -33,7 +33,7 @@ test_util_format_unaligned_accessors(void *ignored)
   set_uint32(buf+1, htonl(0x78696465));
   tt_mem_op(buf, OP_EQ, "oxidestop", 9);
 
-  set_uint64(buf+1, tor_htonll(U64_LITERAL(0x6266757363617465)));
+  set_uint64(buf+1, tor_htonll(UINT64_C(0x6266757363617465)));
   tt_mem_op(buf, OP_EQ, "obfuscate", 9);
  done:
   ;