Function _time64 is available since msvcr70.dll. For older msvcrt versions provide emulation via WinAPI GetSystemTime() function which is available on all Windows versions and returns native value in SYSTEMTIME format. --- mingw-w64-crt/Makefile.am | 2 ++ mingw-w64-crt/lib-common/msvcrt.def.in | 2 +- mingw-w64-crt/misc/_time64.c | 31 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 mingw-w64-crt/misc/_time64.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index c6794fa6616f..d7bc3026f1f8 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -534,6 +534,7 @@ src_msvcrt32=\ misc/_free_locale.c \ misc/_get_current_locale.c \ misc/_initterm_e.c \ + misc/_time64.c \ misc/btowc.c \ misc/imaxabs.c \ misc/lc_locale_func.c \ @@ -815,6 +816,7 @@ src_pre_msvcr70=\ misc/_aligned_offset_malloc.c \ misc/_aligned_offset_realloc.c \ misc/_aligned_realloc.c \ + misc/_time64.c \ misc/lc_locale_func.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 2df0c026a7d0..82694e41f7e8 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -1161,7 +1161,7 @@ _localtime64 _mktime64 F_X86_ANY(_osplatform DATA) F_NON_I386(_stat64) ; i386 _stat64 replaced by emu -_time64 +F_NON_I386(_time64) ; i386 _time64 replaced by emu _utime64 _wctime64 _wfindfirst64 diff --git a/mingw-w64-crt/misc/_time64.c b/mingw-w64-crt/misc/_time64.c new file mode 100644 index 000000000000..0eb9a9988a2d --- /dev/null +++ b/mingw-w64-crt/misc/_time64.c @@ -0,0 +1,31 @@ +/** + * 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 <time.h> + +#include "filetime_to_time64.h" + +static __time64_t __cdecl emu__time64(__time64_t *timeptr) +{ + SYSTEMTIME systemtime; + FILETIME filetime; + __time64_t time64; + GetSystemTime(&systemtime); + if (SystemTimeToFileTime(&systemtime, &filetime)) + time64 = filetime_to_time64(&filetime); + else + time64 = -1; + if (timeptr) + *timeptr = time64; + return time64; +} + +#define RETT __time64_t +#define FUNC _time64 +#define ARGS __time64_t *timeptr +#define CALL timeptr +#include "msvcrt_or_emu_glue.h" -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public