timediff: make it 64 bit (if possible) even with 32 bit time_t

... to make it hold microseconds too.

Fixes #4165
Closes #4168
This commit is contained in:
Daniel Stenberg 2019-07-31 15:30:31 +02:00
parent 7c14dde924
commit b1616dad8f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
15 changed files with 53 additions and 57 deletions

View file

@ -26,6 +26,7 @@
#include "sendf.h"
#include "multiif.h"
#include "progress.h"
#include "timeval.h"
#include "curl_printf.h"
/* check rate limits within this many recent milliseconds, at minimum. */
@ -168,7 +169,7 @@ void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{
struct curltime now = Curl_now();
time_t *delta = NULL;
timediff_t *delta = NULL;
switch(timer) {
default:
@ -270,8 +271,8 @@ timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
struct curltime now)
{
curl_off_t size = cursize - startsize;
time_t minimum;
time_t actual;
timediff_t minimum;
timediff_t actual;
if(!limit || !size)
return 0;
@ -284,10 +285,10 @@ timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
minimum = (time_t) (CURL_OFF_T_C(1000) * size / limit);
else {
minimum = (time_t) (size / limit);
if(minimum < TIME_T_MAX/1000)
if(minimum < TIMEDIFF_T_MAX/1000)
minimum *= 1000;
else
minimum = TIME_T_MAX;
minimum = TIMEDIFF_T_MAX;
}
/*