Commit 52884f56 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

Replace U64_LITERAL with the standard UINT64_C

parent cf0b07c2
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -189,9 +189,7 @@
#endif

#define U64_PRINTF_ARG(a) ((uint64_t)a)
#define U64_LITERAL(n) UINT64_C(n)
#define I64_PRINTF_ARG(a) ((int64_t)a)
#define I64_LITERAL(n) INT64_C(n)
#define U64_FORMAT "%"PRIu64
#define I64_FORMAT "%"PRId64

+8 −8
Original line number Diff line number Diff line
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -4581,8 +4581,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;
+2 −2
Original line number Diff line number Diff line
@@ -24,9 +24,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));
Loading