The mingw-w64 runtime should not call those time functions as they are
conditionally defined based on application compile-time macro
_USE_32BIT_TIME_T.

So hide all those time functions when building the mingw-w64 runtime to
prevent possible ABI issues in future.
---
 mingw-w64-headers/crt/sys/timeb.h | 12 ++++++++++++
 mingw-w64-headers/crt/time.h      |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/mingw-w64-headers/crt/sys/timeb.h 
b/mingw-w64-headers/crt/sys/timeb.h
index 8613661a11cd..c35398539441 100644
--- a/mingw-w64-headers/crt/sys/timeb.h
+++ b/mingw-w64-headers/crt/sys/timeb.h
@@ -78,6 +78,11 @@ extern "C" {
   _CRTIMP void __cdecl _ftime64(struct __timeb64 *_Time);
   _CRTIMP void __cdecl _ftime32(struct __timeb32 *_Time);
 
+/*
+ * To prevent ABI issues, the mingw-w64 runtime should not call the
+ * _timeb and _ftime functions. Instead it should call the fixed-size variants.
+ */
+#ifndef _CRTBLD
 #ifndef _USE_32BIT_TIME_T
 #define _timeb __timeb64
 #define _ftime _ftime64
@@ -85,6 +90,7 @@ extern "C" {
 #define _timeb __timeb32
 #define _ftime _ftime32
 #endif
+#endif /* _CRTBLD */
 
 struct _timespec32 {
   __time32_t tv_sec;
@@ -109,6 +115,11 @@ struct itimerspec {
 };
 #endif
 
+/*
+ * To prevent ABI issues, the mingw-w64 runtime should not call the
+ * ftime function. Instead it should call the fixed-size variants.
+ */
+#ifndef _CRTBLD
 #if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
 #ifndef _USE_32BIT_TIME_T
   void __cdecl ftime (struct timeb *) __MINGW_ASM_CALL(_ftime64);
@@ -116,6 +127,7 @@ struct itimerspec {
   void __cdecl ftime (struct timeb *) __MINGW_ASM_CALL(_ftime32);
 #endif /* _USE_32BIT_TIME_T */
 #endif
+#endif /* _CRTBLD */
 
 #ifdef __cplusplus
 }
diff --git a/mingw-w64-headers/crt/time.h b/mingw-w64-headers/crt/time.h
index 2a475eeff944..9f1f9013cc7d 100644
--- a/mingw-w64-headers/crt/time.h
+++ b/mingw-w64-headers/crt/time.h
@@ -227,6 +227,11 @@ extern "C" {
 
 #ifndef RC_INVOKED
 
+/*
+ * To prevent ABI issues, the mingw-w64 runtime should not call these
+ * functions. Instead it should call the fixed-size variants.
+ */
+#ifndef _CRTBLD
 #ifdef _USE_32BIT_TIME_T
 time_t __CRTDECL time(time_t *_Time) __MINGW_ASM_CALL(_time32);
 #ifdef _UCRT
@@ -256,6 +261,7 @@ errno_t __CRTDECL ctime_s(char *_Buf,size_t 
_SizeInBytes,const time_t *_Time) __
 time_t __CRTDECL mktime(struct tm *_Tm) __MINGW_ASM_CALL(_mktime64);
 time_t __CRTDECL _mkgmtime(struct tm *_Tm) __MINGW_ASM_CALL(_mkgmtime64);
 #endif
+#endif /* _CRTBLD */
 
 #endif /* !RC_INVOKED */
 
-- 
2.20.1



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

Reply via email to