mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 07:45:26 +00:00
The gettimeofday() function spandsp provided for Windows apparently falls over
after 25 hours. I guess not many people are inserting header lines on FAX pages. Hopefully this update fixes the problem.
This commit is contained in:
parent
30c27efb62
commit
46ec57c415
@ -4,11 +4,33 @@
|
|||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
|
const unsigned long long int DELTA_EPOCH_IN_MICROSECS = 11644473600000000LLU
|
||||||
|
|
||||||
void gettimeofday(struct timeval *tv, void *tz)
|
void gettimeofday(struct timeval *tv, void *tz)
|
||||||
{
|
{
|
||||||
long int l = GetTickCount();
|
FILETIME ft;
|
||||||
|
unsigned long long int highResolutionTime;
|
||||||
tv->tv_sec = l / 1000;
|
TIME_ZONE_INFORMATION tz_winapi;
|
||||||
tv->tv_usec = (l % 1000) * 1000;
|
int result_tz;
|
||||||
return;
|
long long int timezone_time_bias_in_minutes;
|
||||||
}
|
|
||||||
|
ZeroMemory(&ft, sizeof(ft));
|
||||||
|
ZeroMemory(&tz_winapi, sizeof(tz_winapi));
|
||||||
|
|
||||||
|
GetSystemTimeAsFileTime(&ft);
|
||||||
|
result_tz = GetTimeZoneInformation(&tz_winapi);
|
||||||
|
timezone_time_bias_in_minutes = tz_winapi.Bias + ((result_tz == TIME_ZONE_ID_DAYLIGHT) ? tz_winapi.DaylightBias : 0);
|
||||||
|
|
||||||
|
highResolutionTime = ft.dwHighDateTime;
|
||||||
|
highResolutionTime <<= 32;
|
||||||
|
highResolutionTime |= ft.dwLowDateTime;
|
||||||
|
|
||||||
|
/* Converting file time to unix epoch */
|
||||||
|
/* Convert to microseconds */
|
||||||
|
highResolutionTime /= 10;
|
||||||
|
/* Add timezone bias conververt from minutes to microsecond */
|
||||||
|
highResolutionTime -= timezone_time_bias_in_minutes*60*1000000;
|
||||||
|
highResolutionTime -= DELTA_EPOCH_IN_MICROSECS;
|
||||||
|
tv->tv_sec = (long int) (highResolutionTime/1000000LLU);
|
||||||
|
tv->tv_usec = (highResolutionTime%1000000LLU);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user