[vlc-commits] compat: provide a win32 specific version of timespec_get
Steve Lhomme
git at videolan.org
Fri Jun 19 08:25:57 CEST 2020
vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue May 15 14:35:52 2018 +0200| [416ba0eca6567e326c0ebd03bd1374b47cc26695] | committer: Steve Lhomme
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.
(cherry picked from commit f0a7bc050fd5ff9f06502333703ce19bff2997a5)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=416ba0eca6567e326c0ebd03bd1374b47cc26695
---
compat/timespec_get.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/compat/timespec_get.c b/compat/timespec_get.c
index 350e912fd0..fb9adca7a1 100644
--- a/compat/timespec_get.c
+++ b/compat/timespec_get.c
@@ -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 */
More information about the vlc-commits
mailing list