POSIX ftime() function returns int. MS _ftime() returns void. Add new
mingw-w64 wrappers around _ftime32() and _ftime64() which returns int 0
for implementing proper POSIX ftime() function.

Function ftime() defined in sys/timeb.h now redirects to either ftime32
or ftime64 symbol, which correctly returns an integer 0.
---
 mingw-w64-crt/Makefile.am                    |  1 +
 mingw-w64-crt/def-include/crt-aliases.def.in |  7 +------
 mingw-w64-crt/misc/ftime32.c                 | 19 +++++++++++++++++++
 mingw-w64-crt/misc/ftime64.c                 | 19 +++++++++++++++++++
 mingw-w64-headers/crt/sys/timeb.h            |  4 ++--
 5 files changed, 42 insertions(+), 8 deletions(-)
 create mode 100644 mingw-w64-crt/misc/ftime32.c
 create mode 100644 mingw-w64-crt/misc/ftime64.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 841d0e11c28f..4482a5c1b117 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -1148,6 +1148,7 @@ src_libmingwex=\
   misc/mingw_setfp.c \
   misc/feupdateenv.c     misc/ftruncate.c           misc/fwide.c            
misc/getlogin.c              misc/getopt.c          \
   misc/gettimeofday.c    misc/__mingw_has_sse.c      \
+  misc/ftime32.c         misc/ftime64.c              \
   misc/mempcpy.c         misc/mingw-aligned-malloc.c \
   misc/mingw_matherr.c   misc/mingw_mbwc_convert.c  misc/mingw_usleep.c     
misc/mingw_wcstod.c          misc/mingw_wcstof.c    \
   misc/mingw_wcstold.c \
diff --git a/mingw-w64-crt/def-include/crt-aliases.def.in 
b/mingw-w64-crt/def-include/crt-aliases.def.in
index 472828e377ef..46ab79261dd4 100644
--- a/mingw-w64-crt/def-include/crt-aliases.def.in
+++ b/mingw-w64-crt/def-include/crt-aliases.def.in
@@ -72,12 +72,7 @@ ADD_UNDERSCORE(fstat)
 F32(fstat == _fstat32)
 F64(fstat == _fstat64i32)
 #endif
-#ifdef FIXED_SIZE_SYMBOLS
-ADD_UNDERSCORE(ftime)
-#else
-F32(ftime == _ftime32)
-F64(ftime == _ftime64)
-#endif
+; ftime is provided in misc/ftime32.c or misc/ftime64.c as MS _ftime is not 
ABI compatible with POSIX ftime
 #if defined(UCRTBASE)
 ; HUGE alias and _HUGE variable are provided by math/_huge.c
 #elif defined(CRTDLL)
diff --git a/mingw-w64-crt/misc/ftime32.c b/mingw-w64-crt/misc/ftime32.c
new file mode 100644
index 000000000000..41cc31a6673c
--- /dev/null
+++ b/mingw-w64-crt/misc/ftime32.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 <sys/timeb.h>
+
+int __cdecl ftime32(struct __timeb32 *tb32);
+int __cdecl ftime32(struct __timeb32 *tb32)
+{
+    _ftime32(tb32);
+    return 0;
+}
+
+/* On 32-bit systems is ftime ABI using 32-bit time_t */
+#ifndef _WIN64
+int __attribute__ ((alias("ftime32"))) __cdecl ftime(struct timeb *);
+#endif
diff --git a/mingw-w64-crt/misc/ftime64.c b/mingw-w64-crt/misc/ftime64.c
new file mode 100644
index 000000000000..c30003b0302a
--- /dev/null
+++ b/mingw-w64-crt/misc/ftime64.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 <sys/timeb.h>
+
+int __cdecl ftime64(struct __timeb64 *tb64);
+int __cdecl ftime64(struct __timeb64 *tb64)
+{
+    _ftime64(tb64);
+    return 0;
+}
+
+/* On 64-bit systems is ftime ABI using 64-bit time_t */
+#ifdef _WIN64
+int __attribute__ ((alias("ftime64"))) __cdecl ftime(struct timeb *);
+#endif
diff --git a/mingw-w64-headers/crt/sys/timeb.h 
b/mingw-w64-headers/crt/sys/timeb.h
index c35398539441..d52fd9c7f760 100644
--- a/mingw-w64-headers/crt/sys/timeb.h
+++ b/mingw-w64-headers/crt/sys/timeb.h
@@ -122,9 +122,9 @@ struct itimerspec {
 #ifndef _CRTBLD
 #if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
 #ifndef _USE_32BIT_TIME_T
-  void __cdecl ftime (struct timeb *) __MINGW_ASM_CALL(_ftime64);
+  int __cdecl ftime (struct timeb *) __MINGW_ASM_CALL(ftime64);
 #else
-  void __cdecl ftime (struct timeb *) __MINGW_ASM_CALL(_ftime32);
+  int __cdecl ftime (struct timeb *) __MINGW_ASM_CALL(ftime32);
 #endif /* _USE_32BIT_TIME_T */
 #endif
 #endif /* _CRTBLD */
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to