Functions _ctime64 and _wctime64 are available since msvcr70.dll. For older
msvcrt versions provide mingw-w64 emulation via asctime() and _wasctime()
functions and then via _localtime64() function which is now available in
all CRT import libraries (either as native symbols or as mingw-w64 emulation).
---
mingw-w64-crt/Makefile.am | 4 ++++
mingw-w64-crt/lib-common/msvcrt.def.in | 4 ++--
mingw-w64-crt/misc/_ctime64.c | 19 +++++++++++++++++++
mingw-w64-crt/misc/_wctime64.c | 19 +++++++++++++++++++
4 files changed, 44 insertions(+), 2 deletions(-)
create mode 100644 mingw-w64-crt/misc/_ctime64.c
create mode 100644 mingw-w64-crt/misc/_wctime64.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 92da88f12f74..3de7e15da12b 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -573,6 +573,7 @@ src_msvcrt32=\
misc/_aligned_offset_realloc.c \
misc/_aligned_realloc.c \
misc/_create_locale.c \
+ misc/_ctime64.c \
misc/_difftime64.c \
misc/_free_locale.c \
misc/_ftime64.c \
@@ -587,6 +588,7 @@ src_msvcrt32=\
misc/_set_doserrno.c \
misc/_set_fmode.c \
misc/_time64.c \
+ misc/_wctime64.c \
misc/imaxabs.c \
misc/output_format.c \
misc/_get_errno.c \
@@ -891,10 +893,12 @@ src_pre_msvcr70=\
misc/_aligned_offset_malloc.c \
misc/_aligned_offset_realloc.c \
misc/_aligned_realloc.c \
+ misc/_ctime64.c \
misc/_ftime64.c \
misc/_gmtime64.c \
misc/_localtime64.c \
misc/_time64.c \
+ misc/_wctime64.c \
misc/strtoimax.c \
misc/strtoumax.c \
misc/wcstoimax.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in
b/mingw-w64-crt/lib-common/msvcrt.def.in
index d4f50f316b3b..77f18305b27b 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1150,7 +1150,7 @@ F_I386(_chkesp)
; void __cdecl operator delete[](void *)
??_V@YAXPAX@Z
#endif
-_ctime64
+F_NON_I386(_ctime64) ; i386 _ctime64 replaced by emu
_findfirst64
_findnext64
F_NON_I386(_fstat64) ; i386 _fstat64 replaced by emu
@@ -1163,7 +1163,7 @@ F_X86_ANY(_osplatform DATA)
F_NON_I386(_stat64) ; i386 _stat64 replaced by emu
F_NON_I386(_time64) ; i386 _time64 replaced by emu
_utime64
-_wctime64
+F_NON_I386(_wctime64) ; i386 _wctime64 replaced by emu
_wfindfirst64
_wfindnext64
F_NON_I386(_wstat64) ; i386 _wstat64 replaced by emu
diff --git a/mingw-w64-crt/misc/_ctime64.c b/mingw-w64-crt/misc/_ctime64.c
new file mode 100644
index 000000000000..64c5e9524a68
--- /dev/null
+++ b/mingw-w64-crt/misc/_ctime64.c
@@ -0,0 +1,19 @@
+/**
+ * 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>
+
+static char *__cdecl emu__ctime64(const __time64_t *timeptr)
+{
+ struct tm *tmptr = _localtime64(timeptr);
+ return tmptr ? asctime(tmptr) : NULL;
+}
+
+#define RETT char *
+#define FUNC _ctime64
+#define ARGS const __time64_t *timeptr
+#define CALL timeptr
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_wctime64.c b/mingw-w64-crt/misc/_wctime64.c
new file mode 100644
index 000000000000..5c184bc13948
--- /dev/null
+++ b/mingw-w64-crt/misc/_wctime64.c
@@ -0,0 +1,19 @@
+/**
+ * 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>
+
+static wchar_t *__cdecl emu__wctime64(const __time64_t *timeptr)
+{
+ struct tm *tmptr = _localtime64(timeptr);
+ return tmptr ? _wasctime(tmptr) : NULL;
+}
+
+#define RETT wchar_t *
+#define FUNC _wctime64
+#define ARGS const __time64_t *timeptr
+#define CALL timeptr
+#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