mirror of
https://github.com/videolan/vlc.git
synced 2024-11-27 03:47:46 +08:00
compat: provide a win32 specific version of timespec_get
On mingw64 clock_gettime() is defined in winpthread which we don't want to use. This implementation is based on the winpthread internal processing.
This commit is contained in:
parent
b19a415075
commit
f0a7bc050f
@ -22,6 +22,28 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
int timespec_get(struct timespec *ts, int base)
|
||||
{
|
||||
FILETIME ft;
|
||||
ULARGE_INTEGER s;
|
||||
ULONGLONG t;
|
||||
|
||||
if (base != TIME_UTC)
|
||||
return 0;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
s.LowPart = ft.dwLowDateTime;
|
||||
s.HighPart = ft.dwHighDateTime;
|
||||
t = s.QuadPart - 116444736000000000ULL;
|
||||
ts->tv_sec = t / 10000000;
|
||||
ts->tv_nsec = ((int) (t % 10000000)) * 100;
|
||||
return base;
|
||||
}
|
||||
#else /* !_WIN32 */
|
||||
|
||||
#include <time.h>
|
||||
#include <unistd.h> /* _POSIX_TIMERS */
|
||||
#ifndef _POSIX_TIMERS
|
||||
@ -58,3 +80,4 @@ int timespec_get(struct timespec *ts, int base)
|
||||
}
|
||||
return base;
|
||||
}
|
||||
#endif /* !_WIN32 */
|
||||
|
Loading…
Reference in New Issue
Block a user