mirror of
https://github.com/curl/curl.git
synced 2026-08-24 14:03:35 +03:00
timeval: prefer time_t to hold seconds instead of long
... as long is still 32bit on modern 64bit windows machines, while time_t is generally 64bit.
This commit is contained in:
parent
56bb7b1a3c
commit
de4de4e3c7
5 changed files with 29 additions and 27 deletions
|
|
@ -249,24 +249,26 @@ long Curl_pgrsLimitWaitTime(curl_off_t cursize,
|
|||
struct timeval start,
|
||||
struct timeval now)
|
||||
{
|
||||
curl_off_t size = cursize - startsize;
|
||||
long minimum, actual;
|
||||
curl_off_t size = cursize - startsize;
|
||||
size_t minimum;
|
||||
size_t actual;
|
||||
|
||||
/* we don't have a starting point yet -- return 0 so it gets (re)set */
|
||||
if(start.tv_sec == 0 && start.tv_usec == 0)
|
||||
return 0;
|
||||
/* we don't have a starting point yet -- return 0 so it gets (re)set */
|
||||
if(start.tv_sec == 0 && start.tv_usec == 0)
|
||||
return 0;
|
||||
|
||||
/* not enough data yet */
|
||||
if(size < limit)
|
||||
return -1;
|
||||
/* not enough data yet */
|
||||
if(size < limit)
|
||||
return -1;
|
||||
|
||||
minimum = (long) (CURL_OFF_T_C(1000) * size / limit);
|
||||
actual = Curl_tvdiff(now, start);
|
||||
minimum = (time_t) (CURL_OFF_T_C(1000) * size / limit);
|
||||
actual = Curl_tvdiff(now, start);
|
||||
|
||||
if(actual < minimum)
|
||||
return minimum - actual;
|
||||
else
|
||||
return 0;
|
||||
if(actual < minimum)
|
||||
/* this is a conversion on some systems (64bit time_t => 32bit long) */
|
||||
return (long)(minimum - actual);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
|
||||
|
|
@ -373,7 +375,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||
(data->progress.timespent>0?data->progress.timespent:1));
|
||||
|
||||
/* Calculations done at most once a second, unless end is reached */
|
||||
if(data->progress.lastshow != (long)now.tv_sec) {
|
||||
if(data->progress.lastshow != now.tv_sec) {
|
||||
shownow = TRUE;
|
||||
|
||||
data->progress.lastshow = now.tv_sec;
|
||||
|
|
@ -400,7 +402,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||
|
||||
/* first of all, we don't do this if there's no counted seconds yet */
|
||||
if(countindex) {
|
||||
long span_ms;
|
||||
time_t span_ms;
|
||||
|
||||
/* Get the index position to compare with the 'nowindex' position.
|
||||
Get the oldest entry possible. While we have less than CURR_TIME
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue