summaryrefslogtreecommitdiff
path: root/lib/timeval.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-07-31 15:30:31 +0200
committerDaniel Stenberg <daniel@haxx.se>2019-08-01 07:43:24 +0200
commitb1616dad8f088d873d88f88b4d884335a4ca285f (patch)
tree31637b618958b051693d23591042468243fe0b35 /lib/timeval.c
parent7c14dde9240a6a113358fe551f378328a41477e2 (diff)
downloadcurl-b1616dad8f088d873d88f88b4d884335a4ca285f.tar.gz
timediff: make it 64 bit (if possible) even with 32 bit time_t
... to make it hold microseconds too. Fixes #4165 Closes #4168
Diffstat (limited to 'lib/timeval.c')
-rw-r--r--lib/timeval.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/timeval.c b/lib/timeval.c
index e2bd7fd14..9b05cf051 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -174,14 +174,6 @@ struct curltime Curl_now(void)
#endif
-#if SIZEOF_TIME_T < 8
-#define TIME_MAX INT_MAX
-#define TIME_MIN INT_MIN
-#else
-#define TIME_MAX 9223372036854775807LL
-#define TIME_MIN -9223372036854775807LL
-#endif
-
/*
* Returns: time difference in number of milliseconds. For too large diffs it
* returns max value.
@@ -191,10 +183,10 @@ struct curltime Curl_now(void)
timediff_t Curl_timediff(struct curltime newer, struct curltime older)
{
timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
- if(diff >= (TIME_MAX/1000))
- return TIME_MAX;
- else if(diff <= (TIME_MIN/1000))
- return TIME_MIN;
+ if(diff >= (TIMEDIFF_T_MAX/1000))
+ return TIMEDIFF_T_MAX;
+ else if(diff <= (TIMEDIFF_T_MIN/1000))
+ return TIMEDIFF_T_MIN;
return diff * 1000 + (newer.tv_usec-older.tv_usec)/1000;
}
@@ -205,9 +197,9 @@ timediff_t Curl_timediff(struct curltime newer, struct curltime older)
timediff_t Curl_timediff_us(struct curltime newer, struct curltime older)
{
timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
- if(diff >= (TIME_MAX/1000000))
- return TIME_MAX;
- else if(diff <= (TIME_MIN/1000000))
- return TIME_MIN;
+ if(diff >= (TIMEDIFF_T_MAX/1000000))
+ return TIMEDIFF_T_MAX;
+ else if(diff <= (TIMEDIFF_T_MIN/1000000))
+ return TIMEDIFF_T_MIN;
return diff * 1000000 + newer.tv_usec-older.tv_usec;
}