Explorar el Código

Support 64-bit time_t. Patch from Matthias Drochner. Partial backport candidate.

svn:r18234
Nick Mathewson hace 15 años
padre
commit
25c6ff6f55
Se han modificado 5 ficheros con 11 adiciones y 6 borrados
  1. 4 0
      ChangeLog
  2. 2 0
      src/common/torint.h
  3. 3 4
      src/common/util.c
  4. 1 1
      src/or/circuituse.c
  5. 1 1
      src/or/main.c

+ 4 - 0
ChangeLog

@@ -10,6 +10,10 @@ Changes in version 0.2.1.12-alpha - 2009-01-??
       enabled when accounting was turned on.  Fixes bug 907.  Bugfix on
       0.0.9pre6.
 
+  o Minor features:
+    - Support platforms where time_t is 64 bits long. (Congratulations,
+      NetBSD!)  Patch from Matthias Drochner.
+
 
 Changes in version 0.2.1.11-alpha - 2009-01-20
   o Security fixes:

+ 2 - 0
src/common/torint.h

@@ -288,6 +288,8 @@ typedef uint32_t uintptr_t;
 #define TIME_MAX ((time_t)INT_MAX)
 #elif (SIZEOF_TIME_T == SIZEOF_LONG)
 #define TIME_MAX ((time_t)LONG_MAX)
+#elif (SIZEOF_TIME_T == 8)
+#define TIME_MAX ((time_t)INT64_MAX)
 #else
 #error "Can't define (signed) TIME_MAX"
 #endif

+ 3 - 4
src/common/util.c

@@ -1031,8 +1031,7 @@ tor_timegm(struct tm *tm)
   /* This is a pretty ironclad timegm implementation, snarfed from Python2.2.
    * It's way more brute-force than fiddling with tzset().
    */
-  time_t ret;
-  unsigned long year, days, hours, minutes;
+  time_t year, days, hours, minutes, seconds;
   int i;
   year = tm->tm_year + 1900;
   if (year < 1970 || tm->tm_mon < 0 || tm->tm_mon > 11) {
@@ -1049,8 +1048,8 @@ tor_timegm(struct tm *tm)
   hours = days*24 + tm->tm_hour;
 
   minutes = hours*60 + tm->tm_min;
-  ret = minutes*60 + tm->tm_sec;
-  return ret;
+  seconds = minutes*60 + tm->tm_sec;
+  return seconds;
 }
 
 /* strftime is locale-specific, so we need to replace those parts */

+ 1 - 1
src/or/circuituse.c

@@ -530,7 +530,7 @@ circuit_predict_and_launch_new(void)
 void
 circuit_build_needed_circs(time_t now)
 {
-  static long time_to_new_circuit = 0;
+  static time_t time_to_new_circuit = 0;
   or_options_t *options = get_options();
 
   /* launch a new circ for any pending streams that need one */

+ 1 - 1
src/or/main.c

@@ -1138,7 +1138,7 @@ second_elapsed_callback(int fd, short event, void *args)
    * could use libevent's timers for this rather than checking the current
    * time against a bunch of timeouts every second. */
   static struct timeval one_second;
-  static long current_second = 0;
+  static time_t current_second = 0;
   time_t now;
   size_t bytes_written;
   size_t bytes_read;