diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index c83c8e38b..c4c3ecbf7 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,3 +1,29 @@
+2010-02-14  Roumen Petrov  <rumen@users.sourceforge.net>
+
+	Issue [2134161]: time64 functions and types for msvcrt >= 8.0
+	(initial implementation)
+
+	* new type: __time32_t
+
+	* new structures: _finddata32_t, _finddata32i64_t, _finddata64i32_t,
+	__stat32, _stat32i64, _stat64i32, __timeb32, __utimbuf32,
+	__wfinddata32_t, _wfinddata32i64_t, _wfinddata64i32_t
+
+	* new functions: _ctime32, _difftime32, _difftime64, _findfirst32
+	_findfirst32i64, _findfirst64i32, _findnext32, _findnext32i64,
+	_findnext64i32, _fstat32, _fstat32i64, _fstat64i32, _ftime32,
+	_futime32, _gmtime32, _localtime32, _mkgmtime32, _mkgmtime64,
+	_mktime32, _stat32, _stat32i64, _stat64i32, _time32, _utime32,
+	_wctime32, _wfindfirst32, _wfindfirst32i64, _wfindfirst64i32,
+	_wfindnext32, _wfindnext32i64, _wfindnext64i32, _wstat32,
+	_wstat32i64, _wstat64i32,_wutime32
+
+	* new define _USE_32BIT_TIME_T set 32 or 64 aliases for: time_t,
+	ctime, difftime, _findfirst, _findfirsti64, _findnext, _findnexti64,
+	_fstat, _fstati64, _ftime, _futime, gmtime, localtime, mktime,
+	_stat, _stati64, time, _utime, _wctime, _wfindfirst, _wfindfirsti64,
+	_wfindnext, _wfindnexti64, _wstat, _wstati64, _wutime
+
 2010-01-25  Kai Tietz  <kai.tietz@onevision.com>
 
 	Implement TLS Callback.
diff --git a/winsup/mingw/Makefile.in b/winsup/mingw/Makefile.in
index 8f7358314..8914f1010 100644
--- a/winsup/mingw/Makefile.in
+++ b/winsup/mingw/Makefile.in
@@ -321,7 +321,11 @@ msvcr70.def msvcr70d.def \
 msvcr71.def msvcr71d.def \
 msvcr80.def msvcr80d.def \
 msvcr90.def msvcr90d.def: msvcrt.def.in
+	V=`echo $@ | sed -e 's|[a-z]*\([0-9]*\).*|\1|'`; \
+	test -z "$$V" && V=60; \
+	V="0x0$${V}0"; \
 	$(CC) -DRUNTIME=$(basename $(notdir $@)) \
+		-D__MSVCRT_VERSION__=$$V \
 		-D__$(basename $(notdir $@))__=1 \
 		-D__MSVCRT__ -C -E -P \
 		-xc-header $? > $@
@@ -387,6 +391,21 @@ check-headers: force
 		echo "$$lang -ansi"; \
 		$(CC) -x$$lang -ansi $(TEST_H_OPTIONS) ; \
 	done
+	@echo; echo "Testing runtime 8.0 headers..."
+	@for lang in c c++ objective-c ; do \
+		echo "$$lang ..."; \
+		$(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 $(TEST_H_OPTIONS) ; \
+		echo "$$lang -ansi"; \
+		$(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -ansi $(TEST_H_OPTIONS) ; \
+	done
+	@echo; echo "Testing runtime 8.0(time32) headers..."
+	@for lang in c c++ objective-c ; do \
+		echo "$$lang ..."; \
+		$(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -D_USE_32BIT_TIME_T $(TEST_H_OPTIONS) ; \
+		echo "$$lang -ansi"; \
+		$(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -D_USE_32BIT_TIME_T -ansi $(TEST_H_OPTIONS) ; \
+	done
+	@echo; echo "Testing runtime 8.0(time32) headers..."
 # specify -std=xx only for C
 	@for std in gnu89 gnu99 c89 c99 ; do \
 		echo "std = $$std"; \
diff --git a/winsup/mingw/TODO b/winsup/mingw/TODO
index 60f6bc2af..67b70d624 100644
--- a/winsup/mingw/TODO
+++ b/winsup/mingw/TODO
@@ -1 +1,5 @@
 Finish the README.
+Timezone variables for msvcrt >= 8.0(now as functions):
+ _get_daylight, _get_dstbias, _get_timezone, _get_tzname.
+Functions with _s ("secure") suffix and may be deprecation
+warnings for "non-secure" functions.
diff --git a/winsup/mingw/include/_mingw.h b/winsup/mingw/include/_mingw.h
index 712b4ac22..e7cee80f4 100644
--- a/winsup/mingw/include/_mingw.h
+++ b/winsup/mingw/include/_mingw.h
@@ -195,6 +195,12 @@
 # endif
 #endif
 
+# ifdef __GNUC__
+#  define _CRTALIAS __CRT_INLINE __attribute__ ((__always_inline__))
+# else
+#  define _CRTALIAS __CRT_INLINE
+# endif
+
 #ifdef __cplusplus
 # define __UNUSED_PARAM(x)
 #else
diff --git a/winsup/mingw/include/io.h b/winsup/mingw/include/io.h
index b46d6bfda..3fdf85eae 100644
--- a/winsup/mingw/include/io.h
+++ b/winsup/mingw/include/io.h
@@ -91,6 +91,36 @@ struct __finddata64_t {
 };
 #endif
 
+#if __MSVCRT_VERSION__ >= 0x0800
+struct _finddata32_t {
+	unsigned	attrib;
+	__time32_t	time_create;
+	__time32_t	time_access;
+	__time32_t	time_write;
+	__int32		size;
+	char		name[FILENAME_MAX];
+};
+
+struct _finddata32i64_t {
+	unsigned	attrib;
+	__time32_t	time_create;
+	__time32_t	time_access;
+	__time32_t	time_write;
+	__int64		size;
+	char		name[FILENAME_MAX];
+};
+
+struct _finddata64i32_t {
+	unsigned	attrib;
+	__time64_t	time_create;
+	__time64_t	time_access;
+	__time64_t	time_write;
+	__int32		size;
+	char		name[FILENAME_MAX];
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
+
 #ifndef _WFINDDATA_T_DEFINED
 struct _wfinddata_t {
     	unsigned	attrib;
@@ -122,6 +152,36 @@ struct __wfinddata64_t {
 };
 #endif
 
+#if __MSVCRT_VERSION__ >= 0x0800
+struct __wfinddata32_t {
+	unsigned	attrib;
+	__time32_t	time_create;
+	__time32_t	time_access;
+	__time32_t	time_write;
+	__int32		size;
+	wchar_t		name[FILENAME_MAX];
+};
+
+struct _wfinddata32i64_t {
+	unsigned	attrib;
+	__time32_t	time_create;
+	__time32_t	time_access;
+	__time32_t	time_write;
+	__int64		size;
+	wchar_t		name[FILENAME_MAX];
+};
+
+struct _wfinddata64i32_t {
+	unsigned	attrib;
+	__time64_t	time_create;
+	__time64_t	time_access;
+	__time64_t	time_write;
+	__int32		size;
+	wchar_t		name[FILENAME_MAX];
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
+
 #define _WFINDDATA_T_DEFINED
 #endif
 
@@ -136,9 +196,56 @@ extern "C" {
  * and 0 if a match was found. Call _findclose when you are finished.
  */
 /*  FIXME: Should these all use intptr_t, as per recent MSDN docs?  */
+#if __MSVCRT_VERSION__ >= 0x0800
+/*
+intptr_t _findfirst      (const char *filespec,struct _finddata_t      *fileinfo);
+intptr_t _findfirst32    (const char *filespec,struct _finddata32_t    *fileinfo);
+intptr_t _findfirst64    (const char *filespec,struct __finddata64_t   *fileinfo);
+intptr_t _findfirsti64   (const char *filespec,struct _finddatai64_t   *fileinfo);
+intptr_t _findfirst32i64 (const char *filespec,struct _finddata32i64_t *fileinfo);
+intptr_t _findfirst64i32 (const char *filespec,struct _finddata64i32_t *fileinfo);
+
+intptr_t _wfindfirst     (const wchar_t *filespec,struct _wfinddata_t *fileinfo);
+intptr_t _wfindfirst32   (const wchar_t *filespec,struct __wfinddata32_t *fileinfo);
+intptr_t _wfindfirst64   (const wchar_t *filespec, struct __wfinddata64_t   *fileinfo);
+intptr_t _wfindfirsti64  (const wchar_t *filespec, struct _wfinddatai64_t   *fileinfo);
+intptr_t _wfindfirst32i64(const wchar_t *filespec, struct _wfinddata32i64_t *fileinfo);
+intptr_t _wfindfirst64i32(const wchar_t *filespec, struct _wfinddata64i32_t *fileinfo);
+
+Time Type and File Length Type Variations of _findfirst:
+Functions		_USE_32BIT_TIME_T defined?	Time type	File length type
+_findfirst,		Not defined			64-bit		32-bit
+_wfindfirst
+_findfirst,		Defined				32-bit		32-bit
+_wfindfirst
+
+_findfirst32,		Not affected by the macro	32-bit		32-bit
+_wfindfirst32		definition
+
+_findfirst64,		Not affected by the macro	64-bit		64-bit
+_wfindfirst64		definition
+
+_findfirsti64,		Not defined			64-bit		64-bit
+_wfindfirsti64
+_findfirsti64,		Defined				32-bit		64-bit
+_wfindfirsti64
+
+_findfirst32i64,	Not affected by the macro	32-bit		64-bit
+_wfindfirst32i64	definition
+
+_findfirst64i32,	Not affected by the macro	64-bit		32-bit
+_wfindfirst64i32	definition
+*/
+#endif
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP long __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _findnext (long, struct _finddata_t*);
+#endif /* __MSVCRT_VERSION__ < 0x0800 */
 _CRTIMP int __cdecl __MINGW_NOTHROW _findclose (long);
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP long __cdecl __MINGW_NOTHROW	_findfirst32 (const char*, struct _finddata32_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_findnext32 (long, struct _finddata32_t*);
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 
 _CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
 _CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
@@ -146,11 +253,17 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _mkdir (const char*);
 _CRTIMP char* __cdecl __MINGW_NOTHROW _mktemp (char*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _rmdir (const char*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
-
 #ifdef __MSVCRT__
 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP long __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(long, struct _finddatai64_t*);
+#else
+_CRTIMP long __cdecl __MINGW_NOTHROW	_findfirst32i64 (const char*, struct _finddata32i64_t*);
+_CRTIMP long __cdecl __MINGW_NOTHROW	_findfirst64i32 (const char*, struct _finddata64i32_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_findnext32i64 (long, struct _finddata32i64_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_findnext64i32 (long, struct _finddata64i32_t*);
+#endif /* __MSVCRT_VERSION__ < 0x0800 */
 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int);
 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
 /* These require newer versions of msvcrt.dll (6.1 or higher). */ 
@@ -158,6 +271,19 @@ _CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst64(const char*, struct __finddata64_t*);
 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findnext64(intptr_t, struct __finddata64_t*); 
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#if __MSVCRT_VERSION__ >= 0x0800
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_findfirst (const char* _v1, struct _finddata_t* _v2)	    { return(_findfirst64i32 (_v1,(struct _finddata64i32_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_findnext (long _v1, struct _finddata_t* _v2)		    { return(_findnext64i32  (_v1,(struct _finddata64i32_t*)_v2)); }
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_findfirsti64 (const char* _v1, struct _finddatai64_t* _v2) { return(_findfirst64 (_v1,(struct __finddata64_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_findnexti64 (long _v1, struct _finddatai64_t* _v2)	    { return(_findnext64  (_v1,(struct __finddata64_t*)_v2)); }
+#else
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_findfirst (const char* _v1, struct _finddata_t* _v2)	    { return(_findfirst32 (_v1,(struct _finddata32_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_findnext (long _v1, struct _finddata_t* _v2)		    { return(_findnext32  (_v1,(struct _finddata32_t*)_v2)); }
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_findfirsti64 (const char* _v1, struct _finddatai64_t* _v2) { return(_findfirst32i64 (_v1,(struct _finddata32i64_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_findnexti64 (long _v1, struct _finddatai64_t* _v2)	    { return(_findnext32i64  (_v1,(struct _finddata32i64_t*)_v2)); }
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #ifndef __NO_MINGW_LFS
 __CRT_INLINE off64_t lseek64 (int, off64_t, int);
 __CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence)
@@ -264,18 +390,43 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _write (int, const void*, unsigned int);
 _CRTIMP int __cdecl __MINGW_NOTHROW _waccess(const wchar_t*, int);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wchmod(const wchar_t*, int);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wcreat(const wchar_t*, int);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext(long, struct _wfinddata_t *);
+#else
+_CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst32 (const wchar_t*, struct __wfinddata32_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_wfindnext32 (long, struct __wfinddata32_t*);
+#endif /* __MSVCRT_VERSION__ < 0x0800 */
 _CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
 _CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(long, struct _wfinddatai64_t*);
+#else
+_CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst32i64 (const wchar_t*, struct _wfinddata32i64_t*);
+_CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst64i32 (const wchar_t*, struct _wfinddata64i32_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_wfindnext32i64 (long, struct _wfinddata32i64_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_wfindnext64i32 (long, struct _wfinddata64i32_t*);
+#endif /* __MSVCRT_VERSION__ < 0x0800 */
 #if __MSVCRT_VERSION__ >= 0x0601
 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*); 
 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);
 #endif
+#if __MSVCRT_VERSION__ >= 0x0800
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2)	 { return(_wfindfirst64i32 (_v1,(struct _wfinddata64i32_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnext (long _v1, struct _wfinddata_t* _v2)			 { return(_wfindnext64i32  (_v1,(struct _wfinddata64i32_t*)_v2)); }
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2) { return(_wfindfirst64 (_v1,(struct __wfinddata64_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2)		 { return(_wfindnext64  (_v1,(struct __wfinddata64_t*)_v2)); }
+#else
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2)	 { return(_wfindfirst32 (_v1,(struct __wfinddata32_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnext (long _v1, struct _wfinddata_t* _v2)			 { return(_wfindnext32  (_v1,(struct __wfinddata32_t*)_v2)); }
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2) { return(_wfindfirst32i64 (_v1,(struct _wfinddata32i64_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2)		 { return(_wfindnext32i64  (_v1,(struct _wfinddata32i64_t*)_v2)); }
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #endif /* defined (__MSVCRT__) */
 #define _WIO_DEFINED
 #endif /* _WIO_DEFINED */
diff --git a/winsup/mingw/include/sys/stat.h b/winsup/mingw/include/sys/stat.h
index 3bd462714..b20f29462 100644
--- a/winsup/mingw/include/sys/stat.h
+++ b/winsup/mingw/include/sys/stat.h
@@ -147,7 +147,49 @@ struct __stat64
     __time64_t st_mtime;
     __time64_t st_ctime;
 };
-#endif /* __MSVCRT_VERSION__ */
+#endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#if __MSVCRT_VERSION__ >= 0x0800
+struct __stat32
+{
+	_dev_t		st_dev;
+	_ino_t		st_ino;
+	_mode_t		st_mode;
+	short		st_nlink;
+	short		st_uid;
+	short		st_gid;
+	_dev_t		st_rdev;
+	__int32		st_size;
+	__time32_t	st_atime;
+	__time32_t	st_mtime;
+	__time32_t	st_ctime;
+};
+struct _stat32i64 {
+	_dev_t		st_dev;
+	_ino_t		st_ino;
+	_mode_t		st_mode;
+	short		st_nlink;
+	short		st_uid;
+	short		st_gid;
+	_dev_t		st_rdev;
+	__int64		st_size;
+	__time32_t	st_atime;
+	__time32_t	st_mtime;
+	__time32_t	st_ctime;
+};
+struct _stat64i32 {
+	_dev_t		st_dev;
+	_ino_t		st_ino;
+	_mode_t		st_mode;
+	short		st_nlink;
+	short		st_uid;
+	short		st_gid;
+	_dev_t		st_rdev;
+	__int32		st_size;
+	__time64_t	st_atime;
+	__time64_t	st_mtime;
+	__time64_t	st_ctime;
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #endif /* __MSVCRT__ */
 #define _STAT_DEFINED
 #endif /* _STAT_DEFINED */
@@ -156,12 +198,16 @@ struct __stat64
 extern "C" {
 #endif
 
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_fstat (int, struct _stat*);
+#endif
 _CRTIMP int __cdecl __MINGW_NOTHROW	_chmod (const char*, int);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_stat (const char*, struct _stat*);
+#endif
 
 #ifndef	_NO_OLDNAMES
-
+/* FIXME for __MSVCRT_VERSION__ >= 0x0800 */
 /* These functions live in liboldnames.a. */
 _CRTIMP int __cdecl __MINGW_NOTHROW	fstat (int, struct stat*);
 _CRTIMP int __cdecl __MINGW_NOTHROW	chmod (const char*, int);
@@ -170,19 +216,56 @@ _CRTIMP int __cdecl __MINGW_NOTHROW	stat (const char*, struct stat*);
 #endif	/* Not _NO_OLDNAMES */
 
 #if defined (__MSVCRT__)
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW  _fstati64(int, struct _stati64 *);
 _CRTIMP int __cdecl __MINGW_NOTHROW  _stati64(const char *, struct _stati64 *);
+#endif
 /* These require newer versions of msvcrt.dll (6.10 or higher).  */ 
 #if __MSVCRT_VERSION__ >= 0x0601
 _CRTIMP int __cdecl __MINGW_NOTHROW _fstat64 (int, struct __stat64*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _stat64 (const char*, struct __stat64*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP int __cdecl __MINGW_NOTHROW	_fstat32 (int, struct __stat32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_stat32 (const char*, struct __stat32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_fstat32i64 (int, struct _stat32i64*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_fstat64i32 (int, struct _stat64i32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_stat32i64 (const char*, struct _stat32i64*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_stat64i32 (const char*, struct _stat64i32*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_fstat (int _v1, struct _stat* _v2)		 { return(_fstat64i32 (_v1,(struct _stat64i32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_stat (const char* _v1, struct _stat* _v2)	 { return(_stat64i32  (_v1,(struct _stat64i32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_fstati64 (int _v1, struct _stati64* _v2)	 { return(_fstat64 (_v1,(struct __stat64*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_stati64 (const char* _v1, struct _stati64* _v2) { return(_stat64  (_v1,(struct __stat64*)_v2)); }
+#else
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_fstat (int _v1, struct _stat* _v2)		 { return(_fstat32 (_v1,(struct __stat32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_stat (const char* _v1, struct _stat* _v2)	 { return(_stat32  (_v1,(struct __stat32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_fstati64 (int _v1, struct _stati64* _v2)	 { return(_fstat32i64 (_v1,(struct _stat32i64*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_stati64 (const char* _v1, struct _stati64* _v2) { return(_stat32i64  (_v1,(struct _stat32i64*)_v2)); }
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
+
 #if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wstat(const wchar_t*, struct _stat*);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wstati64 (const wchar_t*, struct _stati64*);
+#endif
 #if __MSVCRT_VERSION__ >= 0x0601
 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct __stat64*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wstat32 (const wchar_t*, struct __stat32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wstat32i64 (const wchar_t*, struct _stat32i64*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wstat64i32 (const wchar_t*, struct _stat64i32*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstat (const wchar_t* _v1, struct _stat* _v2)	     { return(_wstat64i32 (_v1,(struct _stat64i32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat64 (_v1,(struct __stat64*)_v2)); }
+#else
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstat (const wchar_t* _v1, struct _stat* _v2)	     { return(_wstat32 (_v1,(struct __stat32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat32i64 (_v1,(struct _stat32i64*)_v2)); }
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #define _WSTAT_DEFINED
 #endif /* _WSTAT_DEFIND */
 #endif /* __MSVCRT__ */
diff --git a/winsup/mingw/include/sys/timeb.h b/winsup/mingw/include/sys/timeb.h
index 24af3673f..0c0d4445a 100644
--- a/winsup/mingw/include/sys/timeb.h
+++ b/winsup/mingw/include/sys/timeb.h
@@ -28,6 +28,19 @@ struct _timeb
 	short	dstflag;
 };
 
+#if __MSVCRT_VERSION__ >= 0x0800
+/*
+ * TODO: Structure not tested.
+ */
+struct __timeb32
+{
+	__time32_t	time;
+	short	millitm;
+	short	timezone;
+	short	dstflag;
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
 #ifndef	_NO_OLDNAMES
 /*
  * TODO: Structure not tested.
@@ -49,6 +62,7 @@ extern "C" {
 _CRTIMP void __cdecl __MINGW_NOTHROW	_ftime (struct _timeb*);
 
 #ifndef	_NO_OLDNAMES
+/* FIXME for __MSVCRT_VERSION__ >= 0x0800 */
 _CRTIMP void __cdecl __MINGW_NOTHROW	ftime (struct timeb*);
 #endif	/* Not _NO_OLDNAMES */
 
@@ -65,6 +79,15 @@ struct __timeb64
 _CRTIMP void __cdecl __MINGW_NOTHROW	_ftime64 (struct __timeb64*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
 
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP void __cdecl __MINGW_NOTHROW	_ftime32 (struct __timeb32*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS void __cdecl __MINGW_NOTHROW	_ftime (struct _timeb* _v) { return(_ftime64 ((struct __timeb64*)_v)); }
+#else
+_CRTALIAS void __cdecl __MINGW_NOTHROW	_ftime (struct _timeb* _v) { return(_ftime32 ((struct __timeb32*)_v)); }
+#endif
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
 #ifdef	__cplusplus
 }
 #endif
diff --git a/winsup/mingw/include/sys/types.h b/winsup/mingw/include/sys/types.h
index ed25e5270..82085e43b 100644
--- a/winsup/mingw/include/sys/types.h
+++ b/winsup/mingw/include/sys/types.h
@@ -23,9 +23,9 @@
 
 #ifndef RC_INVOKED
 
-#ifndef _TIME_T_DEFINED
-typedef	long	time_t;
-#define	_TIME_T_DEFINED
+#ifndef _TIME32_T_DEFINED
+typedef __int32 __time32_t;
+#define _TIME32_T_DEFINED
 #endif
 
 #ifndef _TIME64_T_DEFINED
@@ -33,6 +33,20 @@ typedef __int64 __time64_t;
 #define _TIME64_T_DEFINED
 #endif
 
+#ifndef _TIME_T_DEFINED
+/* FIXME __STRICT_ANSI__ ! */
+#if __MSVCRT_VERSION__ >= 0x0800
+#ifndef _USE_32BIT_TIME_T
+typedef	__time64_t time_t;
+#else
+typedef	__time32_t time_t;
+#endif /* !_USE_32BIT_TIME_T */
+#else
+typedef	__time32_t time_t;
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+#define _TIME_T_DEFINED
+#endif
+
 #ifndef	_OFF_T_
 #define	_OFF_T_
 typedef long _off_t;
diff --git a/winsup/mingw/include/sys/utime.h b/winsup/mingw/include/sys/utime.h
index b44479256..b2cbe9a7e 100644
--- a/winsup/mingw/include/sys/utime.h
+++ b/winsup/mingw/include/sys/utime.h
@@ -30,6 +30,13 @@ struct _utimbuf
 	time_t	actime;		/* Access time */
 	time_t	modtime;	/* Modification time */
 };
+#if __MSVCRT_VERSION__ >= 0x0800
+struct __utimbuf32
+{
+	__time32_t actime;
+	__time32_t modtime;
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 
 
 #ifndef	_NO_OLDNAMES
@@ -45,18 +52,25 @@ struct utimbuf
 extern "C" {
 #endif
 
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_utime (const char*, struct _utimbuf*);
+#endif
 
 #ifndef	_NO_OLDNAMES
+/* FIXME for __MSVCRT_VERSION__ >= 0x0800 */
 _CRTIMP int __cdecl __MINGW_NOTHROW	utime (const char*, struct utimbuf*);
 #endif	/* Not _NO_OLDNAMES */
 
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_futime (int, struct _utimbuf*);
+#endif
 
 /* The wide character version, only available for MSVCRT versions of the
  * C runtime library. */
 #ifdef __MSVCRT__
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wutime (const wchar_t*, struct _utimbuf*);
+#endif
 #endif /* MSVCRT runtime */
 
 /* These require newer versions of msvcrt.dll (6.10 or higher).  */ 
@@ -72,6 +86,21 @@ _CRTIMP int __cdecl __MINGW_NOTHROW	_wutime64 (const wchar_t*, struct __utimbuf6
 _CRTIMP int __cdecl __MINGW_NOTHROW	_futime64 (int, struct __utimbuf64*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
 
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP int __cdecl __MINGW_NOTHROW	_utime32 (const char*, struct __utimbuf32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wutime32 (const wchar_t*, struct __utimbuf32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_futime32 (int, struct __utimbuf32*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_utime (const char* _v1, struct _utimbuf* _v2)	   { return(_utime64  (_v1,(struct __utimbuf64*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wutime (const wchar_t* _v1, struct _utimbuf* _v2) { return(_wutime64 (_v1,(struct __utimbuf64*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_futime (int _v1, struct _utimbuf* _v2)		   { return(_futime64 (_v1,(struct __utimbuf64*)_v2)); }
+#else
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_utime (const char* _v1, struct _utimbuf* _v2)	   { return(_utime32  (_v1,(struct __utimbuf32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wutime (const wchar_t* _v1, struct _utimbuf* _v2) { return(_wutime32 (_v1,(struct __utimbuf32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_futime (int _v1, struct _utimbuf* _v2)		   { return(_futime32 (_v1,(struct __utimbuf32*)_v2)); }
+#endif
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
 #ifdef	__cplusplus
 }
 #endif
diff --git a/winsup/mingw/include/tchar.h b/winsup/mingw/include/tchar.h
index f68056263..6170d0491 100644
--- a/winsup/mingw/include/tchar.h
+++ b/winsup/mingw/include/tchar.h
@@ -169,9 +169,17 @@ typedef wchar_t _TCHAR;
 #define _ui64tot    _ui64tow
 #define	_tasctime	_wasctime
 #define	_tctime		_wctime
+#if __MSVCRT_VERSION__ >= 0x0800
+#define	_tctime32	_wctime32
+#define	_tctime64	_wctime64
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #define	_tstrdate	_wstrdate
 #define	_tstrtime	_wstrtime
 #define	_tutime		_wutime
+#if __MSVCRT_VERSION__ >= 0x0800
+#define	_tutime64	_wutime64
+#define	_tutime32	_wutime32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #define _tcsnccoll  _wcsncoll
 #define _tcsncoll   _wcsncoll
 #define _tcsncicoll _wcsnicoll
@@ -181,6 +189,12 @@ typedef wchar_t _TCHAR;
 #define _tcreat     _wcreat
 #define _tfindfirst _wfindfirst
 #define _tfindnext  _wfindnext
+#if __MSVCRT_VERSION__ >= 0x0800
+#define _tfindfirst64 _wfindfirst64
+#define _tfindfirst32 _wfindfirst32
+#define _tfindnext64  _wfindnext64
+#define _tfindnext32  _wfindnext32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #define _tfdopen    _wfdopen
 #define _tfopen     _wfopen
 #define _tfreopen   _wfreopen
@@ -203,6 +217,18 @@ typedef wchar_t _TCHAR;
 #define _tfindfirsti64  _wfindfirsti64
 #define _tfindnexti64   _wfindnexti64
 #define _tfinddatai64_t _wfinddatai64_t
+#if __MSVCRT_VERSION__ >= 0x0601
+#define _tfinddata64_t    _wfinddata64_t
+#endif
+#if __MSVCRT_VERSION__ >= 0x0800
+#define _tfinddata32_t    _wfinddata32_t
+#define _tfinddata32i64_t _wfinddata32i64_t
+#define _tfinddata64i32_t _wfinddata64i32_t
+#define _tfindfirst32i64  _wfindfirst32i64
+#define _tfindfirst64i32  _wfindfirst64i32
+#define _tfindnext32i64   _wfindnext32i64
+#define _tfindnext64i32   _wfindnext64i32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #define _tchdir		_wchdir
 #define _tgetcwd	_wgetcwd
 #define _tgetdcwd	_wgetdcwd
@@ -211,6 +237,11 @@ typedef wchar_t _TCHAR;
 #define _tstat		_wstat
 #define _tstati64	_wstati64
 #define _tstat64	_wstat64
+#if __MSVCRT_VERSION__ >= 0x0800
+#define _tstat32	_wstat32
+#define _tstat32i64	_wstat32i64
+#define _tstat64i32	_wstat64i32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #endif  /* __MSVCRT__ */
 
 /* dirent structures and functions */
@@ -342,9 +373,17 @@ typedef char	_TCHAR;
 #define	_totlower	tolower
 #define	_tasctime	asctime
 #define	_tctime		ctime
+#if __MSVCRT_VERSION__ >= 0x0800
+#define	_tctime32	_ctime32
+#define	_tctime64	_ctime64
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #define	_tstrdate	_strdate
 #define	_tstrtime	_strtime
 #define	_tutime		_utime
+#if __MSVCRT_VERSION__ >= 0x0800
+#define	_tutime64	_utime64
+#define	_tutime32	_utime32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #define _tcsftime	strftime
 /* Macro functions */ 
 #define _tcsdec     _strdec
@@ -365,6 +404,12 @@ typedef char	_TCHAR;
 #define _tcreat     _creat
 #define _tfindfirst _findfirst
 #define _tfindnext  _findnext
+#if __MSVCRT_VERSION__ >= 0x0800
+#define _tfindfirst64 _findfirst64
+#define _tfindfirst32 _findfirst32
+#define _tfindnext64  _findnext64
+#define _tfindnext32  _findnext32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #define _tmktemp    _mktemp
 #define _topen      _open
 #define _taccess    _access
@@ -393,8 +438,25 @@ typedef char	_TCHAR;
 #define _tfindfirsti64  _findfirsti64
 #define _tfindnexti64   _findnexti64
 #define _tfinddatai64_t _finddatai64_t
+#if __MSVCRT_VERSION__ >= 0x0601
+#define _tfinddata64_t    _finddata64_t
+#endif
+#if __MSVCRT_VERSION__ >= 0x0800
+#define _tfinddata32_t    _finddata32_t
+#define _tfinddata32i64_t _finddata32i64_t
+#define _tfinddata64i32_t _finddata64i32_t
+#define _tfindfirst32i64  _findfirst32i64
+#define _tfindfirst64i32  _findfirst64i32
+#define _tfindnext32i64   _findnext32i64
+#define _tfindnext64i32   _findnext64i32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #define _tstati64   _stati64
 #define _tstat64    _stat64
+#if __MSVCRT_VERSION__ >= 0x0800
+#define _tstat32	_stat32
+#define _tstat32i64	_stat32i64
+#define _tstat64i32	_stat64i32
+#endif /* __MSVCRT_VERSION__ > 0x0800 */
 #endif  /* __MSVCRT__ */
 
 /* dirent structures and functions */
diff --git a/winsup/mingw/include/time.h b/winsup/mingw/include/time.h
index 804778f43..a3ca1be2d 100644
--- a/winsup/mingw/include/time.h
+++ b/winsup/mingw/include/time.h
@@ -36,9 +36,9 @@
  * seconds since midnight Jan 1, 1970.
  * NOTE: This is also defined in non-ISO sys/types.h.
  */
-#ifndef _TIME_T_DEFINED
-typedef	long	time_t;
-#define _TIME_T_DEFINED
+#ifndef _TIME32_T_DEFINED
+typedef __int32 __time32_t;
+#define _TIME32_T_DEFINED
 #endif
 
 #ifndef __STRICT_ANSI__
@@ -48,6 +48,22 @@ typedef __int64 __time64_t;
 #define _TIME64_T_DEFINED
 #endif
 #endif
+
+#ifndef _TIME_T_DEFINED
+/* FIXME __STRICT_ANSI__ ! */
+#if __MSVCRT_VERSION__ >= 0x0800
+#ifndef _USE_32BIT_TIME_T
+typedef	__time64_t time_t;
+#else
+typedef	__time32_t time_t;
+#endif /* !_USE_32BIT_TIME_T */
+#else
+typedef	__time32_t time_t;
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+#define _TIME_T_DEFINED
+#endif
+
+
 /*
  * A type for measuring processor time (in clock ticks).
  */
@@ -82,9 +98,11 @@ extern "C" {
 #endif
 
 _CRTIMP clock_t __cdecl __MINGW_NOTHROW	clock (void);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP time_t __cdecl __MINGW_NOTHROW	time (time_t*);
 _CRTIMP double __cdecl __MINGW_NOTHROW	difftime (time_t, time_t);
 _CRTIMP time_t __cdecl __MINGW_NOTHROW	mktime (struct tm*);
+#endif
 
 /*
  * These functions write to and return pointers to static buffers that may
@@ -97,9 +115,11 @@ _CRTIMP time_t __cdecl __MINGW_NOTHROW	mktime (struct tm*);
  * a directory gives 'invalid' times in st_atime etc...
  */
 _CRTIMP char* __cdecl __MINGW_NOTHROW		asctime (const struct tm*);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP char* __cdecl __MINGW_NOTHROW		ctime (const time_t*);
 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW	gmtime (const time_t*);
 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW	localtime (const time_t*);
+#endif
 
 _CRTIMP size_t __cdecl __MINGW_NOTHROW		strftime (char*, size_t, const char*, const struct tm*);
 
@@ -123,6 +143,37 @@ _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
 
+/* These require newer versions of msvcrt.dll (8.00 or higher). */ 
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP __time32_t __cdecl __MINGW_NOTHROW	_time32 (__time32_t*);
+_CRTIMP double	   __cdecl __MINGW_NOTHROW	_difftime32 (__time32_t, __time32_t);
+_CRTIMP double	   __cdecl __MINGW_NOTHROW	_difftime64 (__time64_t, __time64_t);
+_CRTIMP __time32_t __cdecl __MINGW_NOTHROW	_mktime32 (struct tm*);
+_CRTIMP __time32_t __cdecl __MINGW_NOTHROW	_mkgmtime32 (struct tm*);
+_CRTIMP __time64_t __cdecl __MINGW_NOTHROW	_mkgmtime64 (struct tm*);
+_CRTIMP char*	   __cdecl __MINGW_NOTHROW	_ctime32 (const __time32_t*);
+_CRTIMP struct tm* __cdecl __MINGW_NOTHROW	_gmtime32 (const __time32_t*);
+_CRTIMP struct tm* __cdecl __MINGW_NOTHROW	_localtime32 (const __time32_t*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS time_t	   __cdecl __MINGW_NOTHROW	time (time_t* _v)		  { return(_time64 (_v)); }
+_CRTALIAS double	   __cdecl __MINGW_NOTHROW	difftime (time_t _v1, time_t _v2) { return(_difftime64 (_v1,_v2)); }
+_CRTALIAS time_t	   __cdecl __MINGW_NOTHROW	mktime (struct tm* _v)		  { return(_mktime64 (_v)); }
+_CRTALIAS time_t	   __cdecl __MINGW_NOTHROW	_mkgmtime (struct tm* _v)	  { return(_mkgmtime64 (_v)); }
+_CRTALIAS char*		   __cdecl __MINGW_NOTHROW	ctime (const time_t* _v)	  { return(_ctime64 (_v)); }
+_CRTALIAS struct tm*	   __cdecl __MINGW_NOTHROW	gmtime (const time_t* _v)	  { return(_gmtime64 (_v)); }
+_CRTALIAS struct tm*	   __cdecl __MINGW_NOTHROW	localtime (const time_t* _v)	  { return(_localtime64 (_v)); }
+#else
+_CRTALIAS time_t	   __cdecl __MINGW_NOTHROW	time (time_t* _v)		  { return(_time32 (_v)); }
+_CRTALIAS double	   __cdecl __MINGW_NOTHROW	difftime (time_t _v1, time_t _v2) { return(_difftime32 (_v1,_v2)); }
+_CRTALIAS time_t	   __cdecl __MINGW_NOTHROW	mktime (struct tm* _v)		  { return(_mktime32 (_v)); }
+_CRTALIAS time_t	   __cdecl __MINGW_NOTHROW	_mkgmtime (struct tm* _v)	  { return(_mkgmtime32 (_v)); }
+_CRTALIAS char*		   __cdecl __MINGW_NOTHROW	ctime (const time_t* _v)	  { return(_ctime32 (_v)); }
+_CRTALIAS struct tm*	   __cdecl __MINGW_NOTHROW	gmtime (const time_t* _v)	  { return(_gmtime32 (_v)); }
+_CRTALIAS struct tm*	   __cdecl __MINGW_NOTHROW	localtime (const time_t* _v)	  { return(_localtime32 (_v)); }
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
+
 /*
  * _daylight: non zero if daylight savings time is used.
  * _timezone: difference in seconds between GMT and local time.
@@ -196,12 +247,22 @@ __MINGW_IMPORT char 	*tzname[2];
 #ifndef __STRICT_ANSI__
 #ifdef __MSVCRT__
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wasctime(const struct tm*);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wctime(const time_t*);
+#endif
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wstrdate(wchar_t*);
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wstrtime(wchar_t*);
 #if __MSVCRT_VERSION__ >= 0x0601
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wctime64 (const __time64_t*);
 #endif
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wctime32 (const __time32_t*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW	_wctime (const time_t* _v) { return(_wctime64 (_v)); }
+#else
+_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW	_wctime (const time_t* _v) { return(_wctime32 (_v)); }
+#endif
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #endif /*  __MSVCRT__ */
 #endif /* __STRICT_ANSI__ */
 _CRTIMP size_t __cdecl __MINGW_NOTHROW		wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
diff --git a/winsup/mingw/include/wchar.h b/winsup/mingw/include/wchar.h
index 3f45c8fea..22acee726 100644
--- a/winsup/mingw/include/wchar.h
+++ b/winsup/mingw/include/wchar.h
@@ -185,12 +185,23 @@ _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wfullpath (wchar_t*, const wchar_t*, s
 #ifdef __MSVCRT__
 /* wide function prototypes, also declared in time.h */
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wasctime (const struct tm*);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wctime (const time_t*);
+#endif
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wstrdate (wchar_t*);
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wstrtime (wchar_t*);
 #if __MSVCRT_VERSION__ >= 0x601
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wctime64 (const __time64_t*);
 #endif
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW	_wctime32 (const __time32_t*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW	_wctime (const time_t* _v)	{ return(_wctime64 (_v)); }
+#else
+_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW	_wctime (const time_t* _v)	{ return(_wctime32 (_v)); }
+#endif
+#endif
+
 #endif /* __MSVCRT__ */
 #endif /* __STRICT_ANSI__ */
 _CRTIMP size_t __cdecl __MINGW_NOTHROW	wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
@@ -355,6 +366,34 @@ struct __wfinddata64_t {
         wchar_t     name[260];
 };
 #endif
+#if __MSVCRT_VERSION__ >= 0x0800
+struct __wfinddata32_t {
+	unsigned	attrib;
+	__time32_t	time_create;
+	__time32_t	time_access;
+	__time32_t	time_write;
+	__int32		size;
+	wchar_t		name[FILENAME_MAX];
+};
+
+struct _wfinddata32i64_t {
+	unsigned	attrib;
+	__time32_t	time_create;
+	__time32_t	time_access;
+	__time32_t	time_write;
+	__int64		size;
+	wchar_t		name[FILENAME_MAX];
+};
+
+struct _wfinddata64i32_t {
+	unsigned	attrib;
+	__time64_t	time_create;
+	__time64_t	time_access;
+	__time64_t	time_write;
+	__int32		size;
+	wchar_t		name[FILENAME_MAX];
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #define _WFINDDATA_T_DEFINED
 #endif
 
@@ -367,18 +406,43 @@ struct __wfinddata64_t {
 _CRTIMP int __cdecl __MINGW_NOTHROW	_waccess (const wchar_t*, int);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wchmod (const wchar_t*, int);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wcreat (const wchar_t*, int);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst (const wchar_t*, struct _wfinddata_t *);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wfindnext (long, struct _wfinddata_t *);
+#endif
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wunlink (const wchar_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wopen (const wchar_t*, int, ...);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wsopen (const wchar_t*, int, int, ...);
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wmktemp (wchar_t*);
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirsti64 (const wchar_t*, struct _wfinddatai64_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW 	_wfindnexti64 (long, struct _wfinddatai64_t*);
+#else
+_CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst32i64 (const wchar_t*, struct _wfinddata32i64_t*);
+_CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst64i32 (const wchar_t*, struct _wfinddata64i32_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_wfindnext32i64 (long, struct _wfinddata32i64_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_wfindnext64i32 (long, struct _wfinddata64i32_t*);
+#endif /* __MSVCRT_VERSION__ < 0x0800 */
 #if __MSVCRT_VERSION__ >= 0x0601
 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*); 
 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP long __cdecl __MINGW_NOTHROW	_wfindfirst32 (const wchar_t*, struct __wfinddata32_t*);
+_CRTIMP int  __cdecl __MINGW_NOTHROW	_wfindnext32 (long, struct __wfinddata32_t*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2)	 { return(_wfindfirst64i32 (_v1,(struct _wfinddata64i32_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnext (long _v1, struct _wfinddata_t* _v2)			 { return(_wfindnext64i32  (_v1,(struct _wfinddata64i32_t*)_v2)); }
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2) { return(_wfindfirst64 (_v1,(struct __wfinddata64_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2)		 { return(_wfindnext64  (_v1,(struct __wfinddata64_t*)_v2)); }
+#else
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2)	 { return(_wfindfirst32 (_v1,(struct __wfinddata32_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnext (long _v1, struct _wfinddata_t* _v2)			 { return(_wfindnext32  (_v1,(struct __wfinddata32_t*)_v2)); }
+_CRTALIAS long __cdecl __MINGW_NOTHROW	_wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2) { return(_wfindfirst32i64 (_v1,(struct _wfinddata32i64_t*)_v2)); }
+_CRTALIAS int  __cdecl __MINGW_NOTHROW	_wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2)		 { return(_wfindnext32i64  (_v1,(struct _wfinddata32i64_t*)_v2)); }
+#endif /* !_USE_32BIT_TIME_T*/
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
 #endif /* defined (__MSVCRT__) */
 #define _WIO_DEFINED
 #endif /* _WIO_DEFINED */
@@ -468,7 +532,51 @@ struct __stat64
     __time64_t st_mtime;
     __time64_t st_ctime;
 };
-#endif  /* __MSVCRT_VERSION__ */
+#endif  /* __MSVCRT_VERSION__ >= 0x0601*/
+
+#if __MSVCRT_VERSION__ >= 0x0800
+struct __stat32
+{
+	_dev_t		st_dev;
+	_ino_t		st_ino;
+	_mode_t		st_mode;
+	short		st_nlink;
+	short		st_uid;
+	short		st_gid;
+	_dev_t		st_rdev;
+	__int32		st_size;
+	__time32_t	st_atime;
+	__time32_t	st_mtime;
+	__time32_t	st_ctime;
+};
+struct _stat32i64 {
+	_dev_t		st_dev;
+	_ino_t		st_ino;
+	_mode_t		st_mode;
+	short		st_nlink;
+	short		st_uid;
+	short		st_gid;
+	_dev_t		st_rdev;
+	__int64		st_size;
+	__time32_t	st_atime;
+	__time32_t	st_mtime;
+	__time32_t	st_ctime;
+};
+struct _stat64i32 {
+	_dev_t		st_dev;
+	_ino_t		st_ino;
+	_mode_t		st_mode;
+	short		st_nlink;
+	short		st_uid;
+	short		st_gid;
+	_dev_t		st_rdev;
+	__int32		st_size;
+	__time64_t	st_atime;
+	__time64_t	st_mtime;
+	__time64_t	st_ctime;
+};
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+
 #endif  /* __MSVCRT__ */
 #define _STAT_DEFINED
 #endif /* _STAT_DEFINED */
@@ -476,11 +584,25 @@ struct __stat64
 #if !defined ( _WSTAT_DEFINED)
 /* also declared in sys/stat.h */
 #if defined __MSVCRT__
+#if __MSVCRT_VERSION__ < 0x0800
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wstat (const wchar_t*, struct _stat*);
 _CRTIMP int __cdecl __MINGW_NOTHROW	_wstati64 (const wchar_t*, struct _stati64*);
+#endif /* __MSVCRT_VERSION__ < 0x0800 */
 #if __MSVCRT_VERSION__ >= 0x0601
 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct __stat64*);
 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wstat32 (const wchar_t*, struct __stat32*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wstat32i64 (const wchar_t*, struct _stat32i64*);
+_CRTIMP int __cdecl __MINGW_NOTHROW	_wstat64i32 (const wchar_t*, struct _stat64i32*);
+#ifndef _USE_32BIT_TIME_T
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstat (const wchar_t* _v1, struct _stat* _v2)	     { return(_wstat64i32 (_v1,(struct _stat64i32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat64 (_v1,(struct __stat64*)_v2)); }
+#else
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstat (const wchar_t* _v1, struct _stat* _v2)	     { return(_wstat32 (_v1,(struct __stat32*)_v2)); }
+_CRTALIAS int __cdecl __MINGW_NOTHROW	_wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat32i64 (_v1,(struct _stat32i64*)_v2)); }
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= 0x0800 */
 #endif  /* __MSVCRT__ */
 #define _WSTAT_DEFINED
 #endif /* ! _WSTAT_DEFIND  */
diff --git a/winsup/mingw/msvcrt.def.in b/winsup/mingw/msvcrt.def.in
index 4e8728deb..44af9a1f5 100644
--- a/winsup/mingw/msvcrt.def.in
+++ b/winsup/mingw/msvcrt.def.in
@@ -185,10 +185,12 @@ _filelength
 _filelengthi64
 _fileno
 _findclose
+#if __MSVCRT_VERSION__ < 0x0800
 _findfirst
 _findfirsti64
 _findnext
 _findnexti64
+#endif
 _finite
 _flsbuf
 _flushall
@@ -199,12 +201,16 @@ _fpreset DATA
 _fputchar
 _fputwchar
 _fsopen
+#if __MSVCRT_VERSION__ < 0x0800
 _fstat
 _fstati64
 _ftime
+#endif
 _ftol
 _fullpath
+#if __MSVCRT_VERSION__ < 0x0800
 _futime
+#endif
 _gcvt
 _get_osfhandle
 _get_sbh_threshold
@@ -402,8 +408,10 @@ _spawnve
 _spawnvp
 _spawnvpe
 _splitpath
+#if __MSVCRT_VERSION__ < 0x0800
 _stat
 _stati64
+#endif
 _statusfp
 _strcmpi
 _strdate
@@ -440,7 +448,9 @@ _ungetch
 _unlink
 _unloaddll
 _unlock
+#if __MSVCRT_VERSION__ < 0x0800
 _utime
+#endif
 _vsnprintf
 _vsnwprintf
 _waccess
@@ -460,7 +470,9 @@ _wcsnset
 _wcsrev
 _wcsset
 _wcsupr
+#if __MSVCRT_VERSION__ < 0x0800
 _wctime
+#endif
 _wenviron DATA
 _wexecl
 _wexecle
@@ -471,10 +483,12 @@ _wexecve
 _wexecvp
 _wexecvpe
 _wfdopen
+#if __MSVCRT_VERSION__ < 0x0800
 _wfindfirst
 _wfindfirsti64
 _wfindnext
 _wfindnexti64
+#endif
 _wfopen
 _wfreopen
 _wfsopen
@@ -509,8 +523,10 @@ _wspawnve
 _wspawnvp
 _wspawnvpe
 _wsplitpath
+#if __MSVCRT_VERSION__ < 0x0800
 _wstat
 _wstati64
+#endif
 _wstrdate
 _wstrtime
 _wsystem
@@ -520,7 +536,9 @@ _wtoi
 _wtoi64
 _wtol
 _wunlink
+#if __MSVCRT_VERSION__ < 0x0800
 _wutime
+#endif
 _y0
 _y1
 _yn
@@ -542,8 +560,10 @@ clearerr
 clock
 cos
 cosh
+#if __MSVCRT_VERSION__ < 0x0800
 ctime
 difftime
+#endif
 div
 exit
 exp
@@ -582,7 +602,9 @@ getenv
 gets
 getwc
 getwchar
+#if __MSVCRT_VERSION__ < 0x0800
 gmtime
+#endif
 is_wctype
 isalnum
 isalpha
@@ -613,7 +635,9 @@ labs
 ldexp
 ldiv
 localeconv
+#if __MSVCRT_VERSION__ < 0x0800
 localtime
+#endif
 log
 log10
 longjmp
@@ -626,7 +650,9 @@ memcmp
 memcpy
 memmove
 memset
+#if __MSVCRT_VERSION__ < 0x0800
 mktime
+#endif
 modf
 perror
 pow
@@ -680,7 +706,7 @@ swscanf
 system
 tan
 tanh
-#if  !(__msvcr90__ || msvcr90d__)
+#if __MSVCRT_VERSION__ < 0x0800
 time
 #endif
 tmpfile
@@ -826,3 +852,40 @@ _ftelli64
 _fseeki64_nolock
 _ftelli64_nolock
 #endif /* 8.0 */
+#if __MSVCRT_VERSION__ >= 0x0800
+_ctime32
+_difftime32
+_difftime64
+_findfirst32
+_findfirst32i64
+_findfirst64i32
+_findnext32
+_findnext32i64
+_findnext64i32
+_fstat32
+_fstat32i64
+_fstat64i32
+_ftime32
+_futime32
+_gmtime32
+_localtime32
+_mkgmtime32
+_mkgmtime64
+_mktime32
+_stat32
+_stat32i64
+_stat64i32
+_time32
+_utime32
+_wctime32
+_wfindfirst32
+_wfindfirst32i64
+_wfindfirst64i32
+_wfindnext32
+_wfindnext32i64
+_wfindnext64i32
+_wstat32
+_wstat32i64
+_wstat64i32
+_wutime32
+#endif