Commit d5a3bb96 authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

Retire U64_TO_DBL and DBL_TO_U64

These were necessary long ago to work around a bug in VC6.
parent 9568c0ce
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -106,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
+2 −2
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -1117,7 +1117,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;
  }

+1 −1
Original line number Diff line number Diff line
@@ -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;
}
+1 −2
Original line number Diff line number Diff line
@@ -799,7 +799,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;
  }
@@ -1227,4 +1227,3 @@ hibernate_set_state_for_testing_(hibernate_state_t newstate)
  hibernate_state = newstate;
}
#endif /* defined(TOR_UNIT_TESTS) */
Loading