---
mingw-w64-crt/Makefile.am | 1 +
mingw-w64-crt/lib-common/msvcrt.def.in | 2 +-
mingw-w64-crt/misc/_mktime32.c | 29 ++++++++++++++++++++++++++
3 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 mingw-w64-crt/misc/_mktime32.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index d9578c909253..1e6d344bd40a 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -673,6 +673,7 @@ src_msvcrt64=\
misc/_initterm_e.c \
misc/_localtime32.c \
misc/_mkgmtime32.c \
+ misc/_mktime32.c \
misc/_set_doserrno.c \
misc/_set_fmode.c \
misc/output_format.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in
b/mingw-w64-crt/lib-common/msvcrt.def.in
index 1e7eda60a510..9caf981ac30c 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1597,7 +1597,7 @@ _mbstrnlen
_memicmp_l
F_ARM_ANY(_mkgmtime32) ; i386 and x64 _mkgmtime32 replaced by emu
F_ARM_ANY(_mktemp_s) ; i386 and x64 _mktemp_s replaced by emu
-_mktime32 F_I386(== mktime) ; i386 _mktime32 replaced by alias
+F_NON_X64(_mktime32 F_I386(== mktime)) ; i386 _mktime32 replaced by alias and
x64 _mktime32 replaced by emu
F_NON_I386(_msize_dbg)
F_I386(_msize_debug)
_printf_l
diff --git a/mingw-w64-crt/misc/_mktime32.c b/mingw-w64-crt/misc/_mktime32.c
new file mode 100644
index 000000000000..7b9ef1b73f8d
--- /dev/null
+++ b/mingw-w64-crt/misc/_mktime32.c
@@ -0,0 +1,29 @@
+/**
+ * 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 <time.h>
+#include <stdint.h>
+#include <errno.h>
+
+static __time32_t __cdecl emu__mktime32(struct tm *tmptr)
+{
+ struct tm tmbuf = *tmptr;
+ __time64_t time64 = _mktime64(&tmbuf);
+ if (time64 == -1)
+ return -1;
+ if (time64 < 0 || time64 > INT32_MAX) {
+ errno = EINVAL;
+ return -1;
+ }
+ *tmptr = tmbuf;
+ return (__time32_t)time64;
+}
+
+#define RETT __time32_t
+#define FUNC _mktime32
+#define ARGS struct tm *tmptr
+#define CALL tmptr
+#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