time.h: Use inline functions for ctime_r and asctime_r implementations.
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 5fe8d51..b0ac2f2 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -271,7 +271,7 @@
   misc/wcstoimax.c       misc/wcstold.c             misc/wcstoumax.c        misc/wctob.c                 misc/wctrans.c         \
   misc/wctype.c          misc/wdirent.c             misc/winbs_uint64.c     misc/winbs_ulong.c           misc/winbs_ushort.c    \
   misc/wmemchr.c         misc/wmemcmp.c             misc/wmemcpy.c          misc/wmemmove.c              misc/wmempcpy.c        \
-  misc/wmemset.c         misc/ftw.c                 misc/ftw64.c            misc/time_r.c          \
+  misc/wmemset.c         misc/ftw.c                 misc/ftw64.c          \
   \
   stdio/mingw_pformat.h    \
   stdio/vfscanf2.S         stdio/vfwscanf2.S         stdio/vscanf2.S          stdio/vsscanf2.S          stdio/vswscanf2.S \
diff --git a/mingw-w64-crt/misc/time_r.c b/mingw-w64-crt/misc/time_r.c
deleted file mode 100644
index 8850e31..0000000
--- a/mingw-w64-crt/misc/time_r.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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 <errno.h>
-#include <time.h>
-#include <string.h>
-
-/* Both the 32-bit and 64-bit versions of gmtime, mktime, mkgmtime,
- * and localtime all use one common tm structure per thread for the
- * conversion. Each call to one of these functions destroys the
- * result of any previous call.
- */
-char *__cdecl ctime_r(const time_t *_Time, char * _Str)
-{
-    char *tmp;
-
-    if (_Time == NULL || _Str == NULL)
-    {
-        errno = EINVAL;
-        return NULL;
-    }
-
-    tmp = ctime(_Time);
-    if (tmp != NULL)
-        tmp = strcpy(_Str,tmp);
-    return tmp;
-}
-
- /* TODO: thread safe implementation */
-char *__cdecl asctime_r(const struct tm *_Tm, char * _Str)
-{
-    char *tmp;
-
-    if (_Tm == NULL || _Str == NULL)
-    {
-        errno = EINVAL;
-        return NULL;
-    }
-
-    tmp = asctime(_Tm);
-    if (tmp != NULL)
-        tmp = strcpy(_Str,tmp);
-
-    return tmp;
-}
diff --git a/mingw-w64-headers/crt/sec_api/time_s.h b/mingw-w64-headers/crt/sec_api/time_s.h
index a3f1eec..9352188 100644
--- a/mingw-w64-headers/crt/sec_api/time_s.h
+++ b/mingw-w64-headers/crt/sec_api/time_s.h
@@ -45,10 +45,12 @@
 #ifdef _USE_32BIT_TIME_T
 __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); }
+__forceinline errno_t __cdecl _ctime_s(char *_Buf,size_t _SizeInBytes,const time_t *_Time) { return _ctime32_s(_Buf,_SizeInBytes,_Time); }
 
 #else
 __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); }
+__forceinline errno_t __cdecl _ctime_s(char *_Buf,size_t _SizeInBytes,const time_t *_Time) { return _ctime64_s(_Buf,_SizeInBytes,_Time); }
 #endif
 #endif
 
diff --git a/mingw-w64-headers/crt/time.h b/mingw-w64-headers/crt/time.h
index 6d415a7..65ddddc 100644
--- a/mingw-w64-headers/crt/time.h
+++ b/mingw-w64-headers/crt/time.h
@@ -232,8 +232,12 @@
 __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);
+__forceinline char *__cdecl ctime_r(const time_t *_Time, char *_Str) {
+  return _ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str;
+}
+char *__cdecl asctime_r(const struct tm *_Tm, char * _Str) {
+  return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
+}
 #endif /* _POSIX */
 
 /* Adding timespec definition.  */