[or-cvs] MSVC6 is apparently terrified of unnatural cross-breeding b...
Nick Mathewson
nickm at seul.org
Mon Jul 17 00:39:07 UTC 2006
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv12195/src/or
Modified Files:
hibernate.c main.c rephist.c
Log Message:
MSVC6 is apparently terrified of unnatural cross-breeding between uint64_t and double, and needs more persuasion than usual to cast one to the other. Issue identified by Frediano Ziglio; patch revised for minimal impact on non-MSVC6 compilers.
Index: hibernate.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/hibernate.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -p -d -r1.72 -r1.73
--- hibernate.c 24 Jun 2006 04:57:59 -0000 1.72
+++ hibernate.c 17 Jul 2006 00:39:05 -0000 1.73
@@ -683,7 +683,7 @@ hibernate_hard_limit_reached(void)
static int
hibernate_soft_limit_reached(void)
{
- uint64_t soft_limit = (uint64_t) ((get_options()->AccountingMax) * .95);
+ uint64_t soft_limit = DBL_TO_U64((get_options()->AccountingMax) * .95);
if (!soft_limit)
return 0;
return n_bytes_read_in_interval >= soft_limit
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.649
retrieving revision 1.650
diff -u -p -d -r1.649 -r1.650
--- main.c 4 Jul 2006 03:31:27 -0000 1.649
+++ main.c 17 Jul 2006 00:39:05 -0000 1.650
@@ -1359,11 +1359,11 @@ dumpstats(int severity)
U64_PRINTF_ARG(stats_n_destroy_cells_processed));
if (stats_n_data_cells_packaged)
log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
- 100*(((double)stats_n_data_bytes_packaged) /
+ 100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
if (stats_n_data_cells_received)
log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
- 100*(((double)stats_n_data_bytes_received) /
+ 100*(U64_TO_DBL(stats_n_data_bytes_received) /
(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
if (now - time_of_process_start >= 0)
Index: rephist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rephist.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -p -d -r1.90 -r1.91
--- rephist.c 8 Jun 2006 22:36:13 -0000 1.90
+++ rephist.c 17 Jul 2006 00:39:05 -0000 1.91
@@ -577,11 +577,9 @@ rep_hist_bandwidth_assess(void)
r = find_largest_max(read_array);
w = find_largest_max(write_array);
if (r>w)
- return (int)(w/(double)NUM_SECS_ROLLING_MEASURE);
+ return (int)(U64_TO_DBL(w)/NUM_SECS_ROLLING_MEASURE);
else
- return (int)(r/(double)NUM_SECS_ROLLING_MEASURE);
-
- return 0;
+ return (int)(U64_TO_DBL(r)/NUM_SECS_ROLLING_MEASURE);
}
/**
More information about the tor-commits
mailing list