Function _ftime64 is available since msvcr70.dll. For older msvcrt versions
provide emulation via 32-bit CRT ftime() function and fill 64-bit time
value via WinAPI GetSystemTime() function which is available on all Windows
versions and returns value in SYSTEMTIME format, including milliseconds.
---
mingw-w64-crt/Makefile.am | 2 ++
mingw-w64-crt/lib-common/msvcrt.def.in | 2 +-
mingw-w64-crt/misc/_ftime64.c | 39 ++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 mingw-w64-crt/misc/_ftime64.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index f7ada9062c5f..841d0e11c28f 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -566,6 +566,7 @@ src_msvcrt32=\
misc/_aligned_realloc.c \
misc/_create_locale.c \
misc/_free_locale.c \
+ misc/_ftime64.c \
misc/_get_current_locale.c \
misc/_get_doserrno.c \
misc/_get_fmode.c \
@@ -877,6 +878,7 @@ src_pre_msvcr70=\
misc/_aligned_offset_malloc.c \
misc/_aligned_offset_realloc.c \
misc/_aligned_realloc.c \
+ misc/_ftime64.c \
misc/_time64.c \
misc/strtoimax.c \
misc/strtoumax.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in
b/mingw-w64-crt/lib-common/msvcrt.def.in
index fcee56a512ca..6bc43bb24bb0 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1154,7 +1154,7 @@ _ctime64
_findfirst64
_findnext64
F_NON_I386(_fstat64) ; i386 _fstat64 replaced by emu
-_ftime64
+F_NON_I386(_ftime64) ; i386 _ftime64 replaced by emu
_futime64
_gmtime64
_localtime64
diff --git a/mingw-w64-crt/misc/_ftime64.c b/mingw-w64-crt/misc/_ftime64.c
new file mode 100644
index 000000000000..db020215bdbe
--- /dev/null
+++ b/mingw-w64-crt/misc/_ftime64.c
@@ -0,0 +1,39 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <windows.h>
+#include <sys/timeb.h>
+
+#include "filetime_to_time64.h"
+
+static void __cdecl emu__ftime64(struct __timeb64 *tb64)
+{
+ struct __timeb32 tb32;
+ SYSTEMTIME systemtime;
+ FILETIME filetime;
+
+ _ftime32(&tb32);
+ tb64->timezone = tb32.timezone;
+ tb64->dstflag = tb32.dstflag;
+
+ GetSystemTime(&systemtime);
+ if (SystemTimeToFileTime(&systemtime, &filetime))
+ {
+ tb64->time = filetime_to_time64(&filetime);
+ tb64->millitm = systemtime.wMilliseconds;
+ }
+ else
+ {
+ tb64->time = (__time64_t)tb32.time; /* truncated */
+ tb64->millitm = tb32.millitm;
+ }
+}
+
+#define RETT void
+#define FUNC _ftime64
+#define ARGS struct __timeb64 *tb
+#define CALL tb
+#include "msvcrt_or_emu_glue.h"
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public