From 9c181baf3c648e95a150c76eebd7ae5b5633c578 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 9 Nov 2015 15:27:54 +0100 Subject: [PATCH] Use mingw's gettimeofday() mingw has a perfectly functional gettimeofday() so use that instead of having multiple copies of our own version. --- common/rdr/FdInStream.cxx | 34 +-------------------------------- common/rfb/Timer.cxx | 40 ++------------------------------------- 2 files changed, 3 insertions(+), 71 deletions(-) diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx index 9f35c9fb..a8b30857 100644 --- a/common/rdr/FdInStream.cxx +++ b/common/rdr/FdInStream.cxx @@ -23,11 +23,9 @@ #include #include #include +#include #ifdef _WIN32 #include -#ifndef _WIN32_WCE -#include -#endif #define read(s,b,l) recv(s,(char*)b,l,0) #define close closesocket #undef errno @@ -36,7 +34,6 @@ #else #include #include -#include #endif #ifndef vncmin @@ -161,35 +158,6 @@ int FdInStream::overrun(int itemSize, int nItems, bool wait) return nItems; } -#ifdef _WIN32 -static void gettimeofday(struct timeval* tv, void*) -{ - LARGE_INTEGER counts, countsPerSec; - static double usecPerCount = 0.0; - - if (QueryPerformanceCounter(&counts)) { - if (usecPerCount == 0.0) { - QueryPerformanceFrequency(&countsPerSec); - usecPerCount = 1000000.0 / countsPerSec.QuadPart; - } - - LONGLONG usecs = (LONGLONG)(counts.QuadPart * usecPerCount); - tv->tv_usec = (long)(usecs % 1000000); - tv->tv_sec = (long)(usecs / 1000000); - - } else { -#ifndef _WIN32_WCE - struct timeb tb; - ftime(&tb); - tv->tv_sec = tb.time; - tv->tv_usec = tb.millitm * 1000; -#else - throw SystemException("QueryPerformanceCounter", GetLastError()); -#endif - } -} -#endif - // // readWithTimeoutOrCallback() reads up to the given length in bytes from the // file descriptor into a buffer. If the wait argument is false, then zero is diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx index 5f9c6f2f..676f24e1 100644 --- a/common/rfb/Timer.cxx +++ b/common/rfb/Timer.cxx @@ -19,11 +19,8 @@ // -=- Timer.cxx #include -#ifdef WIN32 -#ifndef _WIN32_WCE -#include -#endif -#endif +#include + #include #include #include @@ -40,39 +37,6 @@ static LogWriter vlog("Timer"); #endif -// Win32 does not provide gettimeofday, so we emulate it to simplify the -// Timer code. - -#ifdef _WIN32 -static void gettimeofday(struct timeval* tv, void*) -{ - LARGE_INTEGER counts, countsPerSec; - static double usecPerCount = 0.0; - - if (QueryPerformanceCounter(&counts)) { - if (usecPerCount == 0.0) { - QueryPerformanceFrequency(&countsPerSec); - usecPerCount = 1000000.0 / countsPerSec.QuadPart; - } - - LONGLONG usecs = (LONGLONG)(counts.QuadPart * usecPerCount); - tv->tv_usec = (long)(usecs % 1000000); - tv->tv_sec = (long)(usecs / 1000000); - - } else { -#ifndef _WIN32_WCE - struct timeb tb; - ftime(&tb); - tv->tv_sec = tb.time; - tv->tv_usec = tb.millitm * 1000; -#else - throw SystemException("QueryPerformanceCounter", GetLastError()); -#endif - } -} -#endif - - // Millisecond timeout processing helper functions inline static timeval addMillis(timeval inTime, int millis) { -- 2.39.5