time.h: Use inline functions for localtime_r and gmtime_r implementations.
diff --git a/mingw-w64-crt/misc/time_r.c b/mingw-w64-crt/misc/time_r.c
index 8087032..8850e31 100644
--- a/mingw-w64-crt/misc/time_r.c
+++ b/mingw-w64-crt/misc/time_r.c
@@ -12,38 +12,6 @@
* conversion. Each call to one of these functions destroys the
* result of any previous call.
*/
-struct tm *__cdecl localtime_r(const time_t *_Time, struct tm *_Tm)
-{
- struct tm *tmp;
-
- if (_Time == NULL || _Tm == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
-
- tmp = localtime(_Time);
- if (tmp != NULL)
- memcpy(_Tm, tmp, sizeof(struct tm));
- return tmp;
-}
-
-struct tm *__cdecl gmtime_r(const time_t *_Time, struct tm *_Tm)
-{
- struct tm *tmp;
-
- if (_Time == NULL || _Tm == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
-
- tmp = gmtime(_Time);
- if (tmp != NULL)
- memcpy(_Tm, tmp, sizeof(struct tm));
- return tmp;
-}
-
char *__cdecl ctime_r(const time_t *_Time, char * _Str)
{
char *tmp;
diff --git a/mingw-w64-headers/crt/sec_api/time_s.h b/mingw-w64-headers/crt/sec_api/time_s.h
index 6abfaf4..a3f1eec 100644
--- a/mingw-w64-headers/crt/sec_api/time_s.h
+++ b/mingw-w64-headers/crt/sec_api/time_s.h
@@ -43,12 +43,12 @@
#ifndef RC_INVOKED
#ifdef _USE_32BIT_TIME_T
-__CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime32_s(_Tm,_Time); }
-__CRT_INLINE errno_t __cdecl gmtime_s(struct tm *_Tm, const time_t *_Time) { return _gmtime32_s(_Tm, _Time); }
+__forceinline errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime32_s(_Tm,_Time); }
+__forceinline errno_t __cdecl gmtime_s(struct tm *_Tm, const time_t *_Time) { return _gmtime32_s(_Tm, _Time); }
#else
-__CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime64_s(_Tm,_Time); }
-__CRT_INLINE errno_t __cdecl gmtime_s(struct tm *_Tm, const time_t *_Time) { return _gmtime64_s(_Tm, _Time); }
+__forceinline errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime64_s(_Tm,_Time); }
+__forceinline errno_t __cdecl gmtime_s(struct tm *_Tm, const time_t *_Time) { return _gmtime64_s(_Tm, _Time); }
#endif
#endif
diff --git a/mingw-w64-headers/crt/time.h b/mingw-w64-headers/crt/time.h
index e880558..6d415a7 100644
--- a/mingw-w64-headers/crt/time.h
+++ b/mingw-w64-headers/crt/time.h
@@ -169,13 +169,6 @@
struct tm *__cdecl gmtime(const time_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
struct tm *__cdecl localtime(const time_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-#if defined(_POSIX) || defined(_POSIX_THREAD_SAFE_FUNCTIONS)
-struct tm *__cdecl localtime_r(const time_t *_Time, struct tm *_Tm);
-struct tm *__cdecl gmtime_r(const time_t *_Time, struct tm *_Tm);
-char *__cdecl ctime_r(const time_t *_Time, char * _Str);
-char *__cdecl asctime_r(const struct tm *_Tm, char * _Str);
-#endif /* _POSIX */
-
time_t __cdecl mktime(struct tm *_Tm);
time_t __cdecl _mkgmtime(struct tm *_Tm);
time_t __cdecl time(time_t *_Time);
@@ -232,6 +225,17 @@
#include <sec_api/time_s.h>
+#if defined(_POSIX) || defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+__forceinline struct tm *__cdecl localtime_r(const time_t *_Time, struct tm *_Tm) {
+ return localtime_s(_Tm, _Time) ? NULL : _Tm;
+}
+__forceinline struct tm *__cdecl gmtime_r(const time_t *_Time, struct tm *_Tm) {
+ return gmtime_s(_Tm, _Time) ? NULL : _Tm;
+}
+char *__cdecl ctime_r(const time_t *_Time, char * _Str);
+char *__cdecl asctime_r(const struct tm *_Tm, char * _Str);
+#endif /* _POSIX */
+
/* Adding timespec definition. */
#include <sys/timeb.h>