summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-01-22 16:28:12 +0000
committerNick Mathewson <nickm@torproject.org>2009-01-22 16:28:12 +0000
commit25c6ff6f559a177786591fff09750eef40e0600b (patch)
treebaaddd11f2097104f8dc50978a82cf44ae5b1948 /src/common
parent15d3c285034c105f826481f9e104a268651492bb (diff)
downloadtor-25c6ff6f559a177786591fff09750eef40e0600b.tar.gz
tor-25c6ff6f559a177786591fff09750eef40e0600b.zip
Support 64-bit time_t. Patch from Matthias Drochner. Partial backport candidate.
svn:r18234
Diffstat (limited to 'src/common')
-rw-r--r--src/common/torint.h2
-rw-r--r--src/common/util.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/common/torint.h b/src/common/torint.h
index e603aa5fa4..657974d579 100644
--- a/src/common/torint.h
+++ b/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
diff --git a/src/common/util.c b/src/common/util.c
index d9c0495ed9..1ca3f8d859 100644
--- a/src/common/util.c
+++ b/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 */