mirror of
https://github.com/curl/curl.git
synced 2026-08-25 18:43:41 +03:00
timeval: struct curltime is a struct timeval replacement
... to make all libcurl internals able to use the same data types for the struct members. The timeval struct differs subtly on several platforms so it makes it cumbersome to use everywhere. Ref: #1652 Closes #1693
This commit is contained in:
parent
7551e55d66
commit
4dee50b9c8
29 changed files with 152 additions and 128 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -100,7 +100,7 @@ void logmsg(const char *msg, ...)
|
|||
char buffer[2048 + 1];
|
||||
FILE *logfp;
|
||||
int error;
|
||||
struct timeval tv;
|
||||
struct curltime tv;
|
||||
time_t sec;
|
||||
struct tm *now;
|
||||
char timebuf[20];
|
||||
|
|
@ -211,9 +211,9 @@ int wait_ms(int timeout_ms)
|
|||
{
|
||||
#if !defined(MSDOS) && !defined(USE_WINSOCK)
|
||||
#ifndef HAVE_POLL_FINE
|
||||
struct timeval pending_tv;
|
||||
struct curltime pending_tv;
|
||||
#endif
|
||||
struct timeval initial_tv;
|
||||
struct curltime initial_tv;
|
||||
int pending_ms;
|
||||
int error;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -70,7 +70,7 @@ struct timetest {
|
|||
|
||||
UNITTEST_START
|
||||
{
|
||||
struct timeval now;
|
||||
struct curltime now;
|
||||
time_t timeout;
|
||||
unsigned int i;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,17 +74,19 @@ UNITTEST_START
|
|||
struct Curl_tree nodes[NUM_NODES*3];
|
||||
int rc;
|
||||
int i, j;
|
||||
struct timeval tv_now = {0, 0};
|
||||
struct curltime tv_now = {0, 0};
|
||||
root = NULL; /* the empty tree */
|
||||
|
||||
/* add nodes */
|
||||
for(i = 0; i < NUM_NODES; i++) {
|
||||
struct timeval key;
|
||||
struct curltime key;
|
||||
size_t payload;
|
||||
|
||||
key.tv_sec = 0;
|
||||
key.tv_usec = (541*i)%1023;
|
||||
payload = (size_t) key.tv_usec;
|
||||
|
||||
nodes[i].payload = (void *)key.tv_usec; /* for simplicity */
|
||||
nodes[i].payload = (void *)payload; /* for simplicity */
|
||||
root = Curl_splayinsert(key, root, &nodes[i]);
|
||||
}
|
||||
|
||||
|
|
@ -109,14 +111,15 @@ UNITTEST_START
|
|||
|
||||
/* rebuild tree */
|
||||
for(i = 0; i < NUM_NODES; i++) {
|
||||
struct timeval key;
|
||||
struct curltime key;
|
||||
|
||||
key.tv_sec = 0;
|
||||
key.tv_usec = (541*i)%1023;
|
||||
|
||||
/* add some nodes with the same key */
|
||||
for(j = 0; j <= i % 3; j++) {
|
||||
nodes[i*3+j].payload = (void *)(key.tv_usec*10 + j); /* for simplicity */
|
||||
size_t payload = key.tv_usec*10 + j;
|
||||
nodes[i*3+j].payload = (void *)payload; /* for simplicity */
|
||||
root = Curl_splayinsert(key, root, &nodes[i*3+j]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static bool usec_matches_seconds(time_t time_usec, int expected_seconds)
|
|||
|
||||
UNITTEST_START
|
||||
struct Curl_easy data;
|
||||
struct timeval now = Curl_tvnow();
|
||||
struct curltime now = Curl_tvnow();
|
||||
|
||||
data.progress.t_starttransfer = 0;
|
||||
data.progress.t_redirect = 0;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ static int runawhile(struct Curl_easy *easy,
|
|||
int dec)
|
||||
{
|
||||
int counter = 1;
|
||||
struct timeval now = {1, 0};
|
||||
struct curltime now = {1, 0};
|
||||
CURLcode result;
|
||||
int finaltime;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue