+2013-06-16 Earnie Boyd <earnie@users.sourceforge.net>
+
+ * include/_mingw.h (GCC system_header): Add a __CRT_TESTING__ filter.
+ * include/string.h (GCC system_header): Ditto.
+ * include/sys/stat.h (GCC system_header): Ditto.
+ (string.h): Move the include toward the top of the file.
+ (extern "C" {): Move above the filters so that it is not incorrectly
+ conditional.
+ Correct some comments and move the opening brace to the function
+ definition line throughout.
+ * include/sys/utime.h (utime): Move declaration to after the declaration
+ of _utime64(). Create a _CRTALIAS when _USE_32BIT_TIME_T is undefined.
+ Add datatype specifiers within the _CRTALIAS definitions throughout.
+ * include/wchar.h (GCC system_header): Add a __CRT_TESTING__ filter.
+ (FILENAME_MAX): Define macro if not already defined.
+ Correct comments throughout.
+ Correct #if...#endif misaligned pair.
+ (wcsicmp): Use _CRTALIAS instead of __CRT_INLINE since it is a one line
+ function definition.
+ (*wfinddata*): Use FILENAME_MAX throughout.
+ (_wstat32): Make a _CRTALIAS rather than a _CRTIMP.
+ (_wstat64i32): Use __CRT_MAYBE_INLINE instead of __CRT_INLINE.
+ (_wstat32i64): Define.
+ (_wstat, _wstati64): Remove the MSVCRT_VERSION >= 800 filter.
+
2013-06-07 Earnie Boyd <earnie@users.sourceforge.net>
* include/_mingw.h (_CRTALIAS): Add comments explaining its purpose.
*/
#ifndef __MINGW_H
#define __MINGW_H
+#ifndef __CRT_TESTING__
#pragma GCC system_header
+#endif
#include <sdkddkver.h>
#define __MINGW_VERSION 4.0
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*/
#ifndef _STRING_H
#define _STRING_H
+#ifndef __CRT_TESTING__
#pragma GCC system_header
+#endif
#include <_mingw.h>
/*
*/
#ifndef _STAT_H_
#define _STAT_H_
+#ifndef __CRT_TESTING__
#pragma GCC system_header
+#endif
#include <_mingw.h>
#define __need_size_t
#endif /* Not RC_INVOKED */
#include <sys/types.h>
+#include <string.h> /* Need memset declaration */
/*
* Constants for the stat st_mode member.
#ifndef RC_INVOKED
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifndef _STAT_DEFINED
/*
* The structure manipulated and returned by stat and fstat.
__time64_t st_ctime;
};
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* _stat32 does not exist in MSVCRT.DLL */
_CRTIMP int __cdecl __MINGW_NOTHROW _stat (const char*, struct _stat32*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _stat32 (const char* _v1, struct _stat32* _v2) {
_CRTIMP int __cdecl __MINGW_NOTHROW _fstat64 (int, struct _stat64*);
int __cdecl __MINGW_NOTHROW _fstat32i64 (int, struct _stat32i64*);
int __cdecl __MINGW_NOTHROW _fstat64i32 (int, struct _stat64i32*);
-#include <string.h> /* Need memset declaration */
+
__CRT_MAYBE_INLINE int __cdecl _fstat64i32(int desc, struct _stat64i32 *_stat) {
struct _stat64 st;
int ret = _fstat64(desc, &st);
_stat->st_ctime = st.st_ctime;
return ret;
}
-__CRT_MAYBE_INLINE int __cdecl _fstat32i64(int desc, struct _stat32i64 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _fstat32i64(int desc, struct _stat32i64 *_stat) {
struct _stat32 st;
int ret = _fstat32(desc, &st);
if (ret == -1) {
_stat->st_ctime = st.st_ctime;
return ret;
}
-__CRT_MAYBE_INLINE int __cdecl _stat64i32(const char *fname, struct _stat64i32 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _stat64i32(const char *fname, struct _stat64i32 *_stat) {
struct _stat64 st;
int ret = _stat64(fname, &st);
if (ret == -1) {
_stat->st_ctime = st.st_ctime;
return ret;
}
-__CRT_MAYBE_INLINE int __cdecl _stat32i64(const char *fname, struct _stat32i64 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _stat32i64(const char *fname, struct _stat32i64 *_stat) {
struct _stat32 st;
int ret = _stat32(fname, &st);
if (ret == -1) {
#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
/* _wstat32 does not exist in MSVCRT.DLL */
+_CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t* _v1, struct _stat32* _v2) {
- _CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
return _wstat(_v1, _v2);
}
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct _stat64*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32i64 (const wchar_t*, struct _stat32i64*);
int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
-#include <string.h> /* Need memset declaration */
-__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat) {
struct _stat64 st;
int ret = _wstat64(fname, &st);
if (ret == -1) {
_stat->st_ctime = st.st_ctime;
return ret;
}
-__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat) {
struct _stat32 st;
int ret = _wstat32(fname, &st);
if (ret == -1) {
#define _wstat _wstat32
#define _wstati64 _wstat32i64
-#else /* !_USE_32BIT_TIME_T */
+#else /* ! _USE_32BIT_TIME_T */
#define _wstat _wstat64i32
#define _wstati64 _wstat64
#endif /* _USE_32BIT_TIME_T */
#define _WSTAT_DEFINED
-#endif /* _WSTAT_DEFIND */
+#endif /* ! _WSTAT_DEFIND */
+
#ifdef __cplusplus
}
extern "C" {
#endif
-#ifndef _NO_OLDNAMES
-#ifdef _USE_32BIT_TIME_T
-_CRTIMP int __cdecl __MINGW_NOTHROW utime (const char*, struct utimbuf*);
-#else
-#define utime _utime
-#endif
-#endif /* Not _NO_OLDNAMES */
-
_CRTIMP int __cdecl __MINGW_NOTHROW _utime64 (const char*, struct __utimbuf64*);
_CRTIMP int __cdecl __MINGW_NOTHROW _futime64 (int, struct __utimbuf64*);
#else
_CRTIMP int __cdecl __MINGW_NOTHROW _utime (const char*, struct _utimbuf*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _utime32 (const char* _v1, struct __utimbuf32* _v2) {
- return _utime(_v1, _v2);
+ return _utime(_v1, (struct _utimbuf*)_v2);
}
_CRTIMP int __cdecl __MINGW_NOTHROW _futime (int, struct _utimbuf*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _futime32 (int _v1, struct __utimbuf32* _v2) {
- return _futime(_v1, _v2);
+ return _futime(_v1, (struct _utimbuf*)_v2);
}
#endif
+#ifndef _NO_OLDNAMES
+#ifdef _USE_32BIT_TIME_T
+_CRTIMP int __cdecl __MINGW_NOTHROW utime (const char*, struct utimbuf*);
+#else
+int __cdecl __MINGW_NOTHROW utime (const char*, struct utimbuf*);
+_CRTALIAS int __cdecl __MINGW_NOTHROW utime (const char* _v1, struct utimbuf* _v2) {
+ return _utime64(_v1, (struct __utimbuf64*)_v2);
+}
+#endif
+#endif /* Not _NO_OLDNAMES */
+
#ifndef _USE_32BIT_TIME_T
_CRTALIAS int __cdecl __MINGW_NOTHROW _utime (const char* _v1, struct _utimbuf* _v2) {
return(_utime64 (_v1,(struct __utimbuf64*)_v2));
#else /* MSVCRT_VERSION < 800 */
_CRTIMP int __cdecl __MINGW_NOTHROW _wutime (const wchar_t*, struct _utimbuf*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _wutime32 (const wchar_t* _v1, struct __utimbuf32* _v2) {
- return _wutime(_v1, _v2);
+ return _wutime(_v1, (struct _utimbuf*)_v2);
}
#endif /* MSVCRT_VERSION >= 800 */
*/
#ifndef _WCHAR_H_
#define _WCHAR_H_
+#ifndef __CRT_TESTING__
#pragma GCC system_header
+#endif
#include <_mingw.h>
#ifndef RC_INVOKED
#define __need___va_list
#include <stdarg.h>
#define __VALIST __builtin_va_list
-#endif
+#endif /* ndef __VALIST */
#endif /* Not RC_INVOKED */
#define WEOF (wchar_t)(0xFFFF)
#endif
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 260
+#endif
+
#ifndef RC_INVOKED
#ifdef __cplusplus
#endif /* MSVCRT_VERSION >= 800 */
#if MSVCRT_VERSION >= 800
-#if defined(_USE_32BIT_TIME_T)
+#ifdef _USE_32BIT_TIME_T
_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime32 (_v)); }
-#else /* MSVCRT_VERSION < 800 */
+#else /* ! _USE_32BIT_TIME_T */
_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime64 (_v)); }
-#endif /* defined(_USE_32BIT_TIME_T) */
-#endif /* MSVCRT_VERSION >= 800 */
+#endif /* _USE_32BIT_TIME_T */
#else /* MSVCRT_VERSION < 800 */
#ifdef _USE_32BIT_TIME_T
#else /* MSVCRT_VERSION < 800 */
_CRTIMP int __cdecl __MINGW_NOTHROW _wutime (const wchar_t*, struct _utimbuf*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _wutime32 (const wchar_t* _v1, struct __utimbuf32* _v2) {
- return _wutime(_v1, _v2);
+ return _wutime(_v1, (struct _utimbuf *)_v2);
}
#endif /* MSVCRT_VERSION >= 800 */
#ifndef _NO_OLDNAMES
/* NOTE: There is no _wcscmpi, but this is for compatibility. */
int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t *, const wchar_t *);
-#ifndef __NO_INLINE__
-__CRT_INLINE int __cdecl __MINGW_NOTHROW
+_CRTALIAS int __cdecl __MINGW_NOTHROW
wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2)
{return _wcsicmp (__ws1, __ws2);}
-#endif
_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsdup (const wchar_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW wcsicmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW wcsicoll (const wchar_t*, const wchar_t*);
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
- wchar_t name[260]; /* may include spaces. */
+ wchar_t name[FILENAME_MAX]; /* may include spaces. */
};
struct _wfinddatai64_t {
unsigned attrib;
time_t time_access;
time_t time_write;
__int64 size;
- wchar_t name[260];
+ wchar_t name[FILENAME_MAX];
};
struct _wfinddata64_t {
unsigned attrib;
__time64_t time_write;
/* 8 bytes are returned so it can't be _fsize_t */
__int64 size;
- wchar_t name[260];
+ wchar_t name[FILENAME_MAX];
};
-#include <stdio.h>
struct _wfinddata32_t {
unsigned attrib;
__time32_t time_create;
#define _wfindfirsti64 _wfindfirst32i64
#define _wfindnexti64 _wfindnext32i64
-#else /* !defined(_USE_32BIT_TIME_T)
+#else /* !defined(_USE_32BIT_TIME_T) */
#define _wfinddata_t _wfinddata64i32_t
#define _wfinddatai64_t _wfinddata64_t
#define _wfindfirst _wfindfirst64i32
};
#define __stat64 _stat64
-#if defined(_USE_32BIT_TIME_T) && MSVCRT_VERSION >= 800
+#if defined(_USE_32BIT_TIME_T)
#define _fstat _fstat32
#define _fstati64 _fstat32i64
#define _stat _stat32
#define _stati64 _stat32i64
-#else /* !_USE_32BIT_TIME_T */
+#else /* ! _USE_32BIT_TIME_T */
#define _fstat _fstat64i32
#define _fstati64 _fstat64
#define _stat _stat64i32
#define _stati64 _stat64
#endif /* _USE_32BIT_TIME_T */
#define _STAT_DEFINED
-#endif /* _STAT_DEFINED */
+#endif /* ! _STAT_DEFINED */
#if !defined ( _WSTAT_DEFINED) /* also declared in sys/stat.h */
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t*, struct _stat32*);
+/* _wstat32 does not exist in MSVCRT.DLL */
+_CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
+_CRTALIAS int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t* _v1, struct _stat32* _v2) {
+ return _wstat(_v1, _v2);
+}
+
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct _stat64*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32i64 (const wchar_t*, struct _stat32i64*);
int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
-#ifndef __NO_INLINE__
#include <string.h> /* Need memset declaration. */
- __CRT_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
+__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
{
struct _stat64 st;
int ret = _wstat64(fname, &st);
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
+}
+__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat) {
+ struct _stat32 st;
+ int ret = _wstat32(fname, &st);
+ if (ret == -1) {
+ memset(_stat, 0, sizeof(struct _stat32i64));
+ return -1;
}
-#else
-#define _wstat64i32 _wstat64
-#endif
+ _stat->st_dev = st.st_dev;
+ _stat->st_ino = st.st_ino;
+ _stat->st_mode = st.st_mode;
+ _stat->st_nlink = st.st_nlink;
+ _stat->st_uid = st.st_uid;
+ _stat->st_gid = st.st_gid;
+ _stat->st_rdev = st.st_rdev;
+ _stat->st_size = (_off_t) st.st_size;
+ _stat->st_atime = st.st_atime;
+ _stat->st_mtime = st.st_mtime;
+ _stat->st_ctime = st.st_ctime;
+ return ret;
+}
-#if defined(_USE_32BIT_TIME_T) && MSVCRT_VERSION >= 800
+#if defined(_USE_32BIT_TIME_T)
#define _wstat _wstat32
#define _wstati64 _wstat32i64
-#else
+#else /* ! _USE_32BIT_TIME_T */
#define _wstat _wstat64i32
#define _wstati64 _wstat64
#endif /* _USE_32BIT_TIME_T */