Internal time differences now use monotonic time source if available.
This also implies the removal of the winmm.lib dependency for WIN32.
This commit is contained in:
@@ -10,7 +10,7 @@ CC = wcc386
|
||||
|
||||
CFLAGS = -3r -mf -d3 -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm -bt=nt &
|
||||
-bd -d+ -dWIN32 -dCURL_CA_BUNDLE=getenv("CURL_CA_BUNDLE") &
|
||||
-dBUILDING_LIBCURL -dWITHOUT_MM_LIB -dHAVE_SPNEGO=1 -dENABLE_IPV6 &
|
||||
-dBUILDING_LIBCURL -dHAVE_SPNEGO=1 -dENABLE_IPV6 &
|
||||
-dDEBUG_THREADING_GETADDRINFO -dDEBUG=1 -dCURLDEBUG -d_WIN32_WINNT=0x0501 &
|
||||
-dWINBERAPI=__declspec(cdecl) -dWINLDAPAPI=__declspec(cdecl) &
|
||||
-I. -I..\include
|
||||
|
||||
@@ -96,7 +96,7 @@ ifndef USE_LDAP_OPENLDAP
|
||||
DLL_LIBS += -lwldap32
|
||||
endif
|
||||
endif
|
||||
DLL_LIBS += -lws2_32 -lwinmm
|
||||
DLL_LIBS += -lws2_32
|
||||
COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
|
||||
@@ -66,10 +66,6 @@ WINDOWS_SDK_PATH = "C:\Program Files\Microsoft SDK"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# Use the high resolution time by default. Comment this out to use low
|
||||
# resolution time and not require winmm.lib
|
||||
USEMM_LIBS = YES
|
||||
|
||||
#############################################################
|
||||
## Nothing more to do below this line!
|
||||
|
||||
@@ -85,13 +81,9 @@ LFLAGS = /nologo /machine:$(MACHINE)
|
||||
SSLLIBS = libeay32.lib ssleay32.lib
|
||||
ZLIBLIBSDLL= zdll.lib
|
||||
ZLIBLIBS = zlib.lib
|
||||
!IFDEF USEMM_LIBS
|
||||
WINLIBS = wsock32.lib wldap32.lib winmm.lib
|
||||
!ELSE
|
||||
WINLIBS = wsock32.lib wldap32.lib
|
||||
CFLAGS = $(CFLAGS) /DWITHOUT_MM_LIB
|
||||
!ENDIF
|
||||
# RSAglue.lib was formerly needed in the SSLLIBS
|
||||
CFLAGS = $(CFLAGS)
|
||||
|
||||
CFGSET = FALSE
|
||||
|
||||
!IFDEF WINDOWS_SSPI
|
||||
|
||||
@@ -350,7 +350,6 @@
|
||||
#define CURL_DISABLE_FILE 1
|
||||
#define CURL_DISABLE_TELNET 1
|
||||
#define CURL_DISABLE_LDAP 1
|
||||
#define WITHOUT_MM_LIB 1
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
|
||||
@@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib ws2_32.lib wldap32.lib winmm.lib /nologo /dll /map /debug /machine:I386 /out:"Release/libcurl.dll"
|
||||
# ADD LINK32 kernel32.lib ws2_32.lib wldap32.lib /nologo /dll /map /debug /machine:I386 /out:"Release/libcurl.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "curllib - Win32 Debug"
|
||||
|
||||
@@ -81,7 +81,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib ws2_32.lib wldap32.lib winmm.lib /nologo /dll /incremental:no /map /debug /machine:I386 /out:"Debug/libcurl.dll" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib ws2_32.lib wldap32.lib /nologo /dll /incremental:no /map /debug /machine:I386 /out:"Debug/libcurl.dll" /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -184,7 +184,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Avoid initial timestamp, avoid gettimeofday() call, when elapsed
|
||||
/* Avoid initial timestamp, avoid curlx_tvnow() call, when elapsed
|
||||
time in this function does not need to be measured. This happens
|
||||
when function is called with a zero timeout or a negative timeout
|
||||
value indicating a blocking call should be performed. */
|
||||
@@ -368,7 +368,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Avoid initial timestamp, avoid gettimeofday() call, when elapsed
|
||||
/* Avoid initial timestamp, avoid curlx_tvnow() call, when elapsed
|
||||
time in this function does not need to be measured. This happens
|
||||
when function is called with a zero timeout or a negative timeout
|
||||
value indicating a blocking call should be performed. */
|
||||
|
||||
113
lib/timeval.c
113
lib/timeval.c
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2008, 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
|
||||
@@ -23,69 +23,70 @@
|
||||
|
||||
#include "timeval.h"
|
||||
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
#if defined(WIN32) && !defined(MSDOS)
|
||||
|
||||
#ifdef WIN32
|
||||
#include <mmsystem.h>
|
||||
|
||||
static int gettimeofday(struct timeval *tp, void *nothing)
|
||||
{
|
||||
#ifdef WITHOUT_MM_LIB
|
||||
SYSTEMTIME st;
|
||||
time_t tt;
|
||||
struct tm tmtm;
|
||||
/* mktime converts local to UTC */
|
||||
GetLocalTime (&st);
|
||||
tmtm.tm_sec = st.wSecond;
|
||||
tmtm.tm_min = st.wMinute;
|
||||
tmtm.tm_hour = st.wHour;
|
||||
tmtm.tm_mday = st.wDay;
|
||||
tmtm.tm_mon = st.wMonth - 1;
|
||||
tmtm.tm_year = st.wYear - 1900;
|
||||
tmtm.tm_isdst = -1;
|
||||
tt = mktime (&tmtm);
|
||||
tp->tv_sec = tt;
|
||||
tp->tv_usec = st.wMilliseconds * 1000;
|
||||
#else
|
||||
/**
|
||||
** The earlier time calculations using GetLocalTime
|
||||
** had a time resolution of 10ms.The timeGetTime, part
|
||||
** of multimedia apis offer a better time resolution
|
||||
** of 1ms.Need to link against winmm.lib for this
|
||||
**/
|
||||
unsigned long Ticks = 0;
|
||||
unsigned long Sec =0;
|
||||
unsigned long Usec = 0;
|
||||
Ticks = timeGetTime();
|
||||
|
||||
Sec = Ticks/1000;
|
||||
Usec = (Ticks - (Sec*1000))*1000;
|
||||
tp->tv_sec = Sec;
|
||||
tp->tv_usec = Usec;
|
||||
#endif /* WITHOUT_MM_LIB */
|
||||
(void)nothing;
|
||||
return 0;
|
||||
}
|
||||
#else /* WIN32 */
|
||||
/* non-win32 version of Curl_gettimeofday() */
|
||||
static int gettimeofday(struct timeval *tp, void *nothing)
|
||||
{
|
||||
(void)nothing; /* we don't support specific time-zones */
|
||||
tp->tv_sec = (long)time(NULL);
|
||||
tp->tv_usec = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_GETTIMEOFDAY */
|
||||
|
||||
/* Return the current time in a timeval struct */
|
||||
struct timeval curlx_tvnow(void)
|
||||
{
|
||||
/*
|
||||
** GetTickCount() is available on _all_ Windows versions from W95 up
|
||||
** to nowadays. Returns milliseconds elapsed since last system boot,
|
||||
** increases monotonically and wraps once 49.7 days have elapsed.
|
||||
*/
|
||||
struct timeval now;
|
||||
DWORD milliseconds = GetTickCount();
|
||||
now.tv_sec = milliseconds / 1000;
|
||||
now.tv_usec = (milliseconds % 1000) * 1000;
|
||||
return now;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
||||
|
||||
struct timeval curlx_tvnow(void)
|
||||
{
|
||||
/*
|
||||
** clock_gettime() is granted to be increased monotonically when the
|
||||
** monotonic clock is queried. Time starting point is unspecified, it
|
||||
** could be the system start-up time, the Epoch, or something else,
|
||||
** in any case the time starting point does not change once that the
|
||||
** system has started up.
|
||||
*/
|
||||
struct timeval now;
|
||||
struct timespec tsnow;
|
||||
(void)clock_gettime(CLOCK_MONOTONIC, &tsnow)
|
||||
now.tv_sec = tsnow.tv_sec;
|
||||
now.tv_usec = tsnow.tv_nsec / 1000;
|
||||
return now;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_GETTIMEOFDAY)
|
||||
|
||||
struct timeval curlx_tvnow(void)
|
||||
{
|
||||
/*
|
||||
** gettimeofday() is not granted to be increased monotonically, due to
|
||||
** clock drifting and external source time synchronization it can jump
|
||||
** forward or backward in time.
|
||||
*/
|
||||
struct timeval now;
|
||||
(void)gettimeofday(&now, NULL);
|
||||
return now;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct timeval curlx_tvnow(void)
|
||||
{
|
||||
/*
|
||||
** time() returns the value of time in seconds since the Epoch.
|
||||
*/
|
||||
struct timeval now;
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
return now;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make sure that the first argument is the more recent time, as otherwise
|
||||
* we'll get a weird negative time-diff back...
|
||||
|
||||
Reference in New Issue
Block a user