OSDN Git Service

Factor out <wchar.h> vs. <io.h> duplicate declarations.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Wed, 6 Apr 2016 12:57:56 +0000 (13:57 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Wed, 6 Apr 2016 12:57:56 +0000 (13:57 +0100)
mingwrt/ChangeLog
mingwrt/include/io.h
mingwrt/include/wchar.h

index 693b3ce..54c41bd 100644 (file)
@@ -1,3 +1,47 @@
+2016-04-06  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Factor out <wchar.h> vs. <io.h> duplicate declarations.
+
+       * include/io.h: Assert copyright; tidy layout.
+       (_IO_H_): Rename this multiple inclusion guard macro...
+       (_IO_H): ...to this preferred form; do not define it when...
+       [__WCHAR_H_SOURCED__]: ...this is defined, in which case declare...
+       (_waccess, _wchmod, _wcreat, _wopen, _wsopen, _wunlink, _wmktemp)
+       (_wfindfirst, _wfindnext, _wfindfirst64, _wfindnext64, _wfindfirsti64)
+       (_wfindnexti64, _wfindfirst32i64, _wfindnext32i64, _wfindfirst64i32)
+       (_wfindnext64i32, _wfindfirst32, _wfindnext32, _findclose): ...only
+       these function prototypes, common to <wchar.h>, together with...
+       (_fsize_t, struct _wfinddata_t, struct _wfinddatai64_t)
+       (struct __wfinddata64_t, struct _wfinddata64i32_t)
+       (struct _wfinddata32i64_t, struct __wfinddata32_t): ...these
+       requisite data type definitions.
+       (pragma GCC system_header): Declare it.
+       (__need_intptr_t): Define, and include <stdint.h> to get...
+       (intptr_t): ...this typedef; neither define it locally, nor define...
+       (_INTPTR_T_DEFINED): ...this; delete all references.
+       (_FSIZE_T_DEFINED): Do not define it; delete all references; rather...
+       [!(defined _IO_H && defined _WCHAR)] (_fsize_t): Define it.
+       (FILENAME_MAX): Define it unconditionally.
+       (__struct_finddata_t): New temporary macro; define and use it to...
+       (struct _finddata_t, struct _wfinddata_t, struct _finddatai64_t)
+       (struct _wfinddatai64_t, struct __finddata64_t, struct __wfinddata64_t)
+       (struct _finddata64i32_t, struct _wfinddata64i32_t)
+       (struct _finddata32i64_t, struct _wfinddata32i64_t)
+       (struct __finddata32_t, struct __wfinddata32_t): ...define these.
+
+       * include/wchar.h (_WFINDDATA_T_DEFINED): Do not define it; delete all
+       references; filter out associated data type definitions, namely...
+       (struct _wfinddata_t, struct _wfinddatai64_t): ...these, and also...
+       (struct __wfinddata64_t, struct _wfinddata64i32_t): ...these, and...
+       (struct _wfinddata32i64_t, struct __wfinddata32_t): ...these.
+       (_WIO_DEFINED): Likewise, do not define it; delete all references;
+       filter out associated function prototype declarations for all of...
+       (_waccess, _wchmod, _wcreat, _wopen, _wsopen, _wunlink, _wmktemp)
+       (_wfindfirst, _wfindnext, _wfindfirst64, _wfindnext64, _wfindfirsti64)
+       (_wfindnexti64, _wfindfirst32i64, _wfindnext32i64, _wfindfirst64i32)
+       (_wfindnext64i32, _wfindfirst32, _wfindnext32): ...these; reproduce
+       them by selective inclusion of <io.h>.
+
 2016-04-04  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Factor out <wchar.h> vs. <process.h> duplicate declarations.
index f059f7e..1e0efdd 100644 (file)
 /*
  * io.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
  *
  * System level I/O functions and types.
  *
- * TODO: File requires review; rationalization and refactoring recommended.
+ * $Id$
+ *
+ * Written by Rob Savoye <rob@cygnus.com>
+ * Copyright (C) 1997-2004, 2007, 2009, 2010, 2014-2016, MinGW.org Project.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * 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, this permission notice, and the following
+ * disclaimer 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * NOTE: The file manipulation functions provided by Microsoft seem to
+ * work with either slash (/) or backslash (\) as the directory separator;
+ * (this is consistent with Microsoft's own documentation, on MSDN).
+ *
  */
-#ifndef        _IO_H_
-#define        _IO_H_
+#ifndef _IO_H
+#pragma GCC system_header
 
-/* All the headers include this file. */
+/* Defer definition of the _IO_H multiple inclusion guard, to allow
+ * for selective inclusion by <wchar.h>, (in which case we should
+ * NOT define it).
+ */
+#ifndef __WCHAR_H_SOURCED__
+#define _IO_H
+
+/* All MinGW headers must include <_mingw.h>; we may do it here,
+ * assuming that <wchar.h> will have already take care to do so in
+ * the selective inclusion case.
+ */
 #include <_mingw.h>
 
-/* MSVC's io.h contains the stuff from dir.h, so I will too.
- * NOTE: This also defines off_t, the file offset type, through
- *       an inclusion of sys/types.h */
+/* We also need time_t, and off_t, (and their variants); although
+ * it gives us more than we really need, this will provide them...
+ */
+#include <sys/types.h>
 
-#include <sys/types.h> /* To get time_t.  */
+#endif /* !__WCHAR_H_SOURCED__ */
 
-/*
- * Attributes of files as returned by _findfirst et al.
+/* This will give us intptr_t, which we need in ALL cases, whether
+ * including <io.h> directly, or selectively via <wchar.h>.
  */
-#define        _A_NORMAL       0x00000000
-#define        _A_RDONLY       0x00000001
-#define        _A_HIDDEN       0x00000002
-#define        _A_SYSTEM       0x00000004
-#define        _A_VOLID        0x00000008
-#define        _A_SUBDIR       0x00000010
-#define        _A_ARCH         0x00000020
-
+#define __need_intptr_t
+#include <stdint.h>
+
+/* Attributes of files as returned by _findfirst() et al.  MSDN is not
+ * explicit about whether or not these should be defined when including
+ * <wchar.h>, but since they complement the _wfindfirst() API, which is
+ * declared there, it seems logical to make them visible in all cases
+ * of <io.h> inclusion.
+ */
+#define _A_NORMAL      0x00000000
+#define _A_RDONLY      0x00000001
+#define _A_HIDDEN      0x00000002
+#define _A_SYSTEM      0x00000004
+#define _A_VOLID       0x00000008
+#define _A_SUBDIR      0x00000010
+#define _A_ARCH                0x00000020
 
 #ifndef RC_INVOKED
 
-#ifndef _INTPTR_T_DEFINED
-#define _INTPTR_T_DEFINED
-#ifdef _WIN64
-  typedef __int64 intptr_t;
-#else
-  typedef int intptr_t;
-#endif
-#endif
+/* The maximum length of a file name.  It may be better to use the Windows'
+ * GetVolumeInformation() function in preference to this constant, but hey,
+ * this works!  In any case, we use this manifest constant when we declare
+ * the _findfirst() API, so its definition must be visible in all places
+ * where this, or any of its variants, is declared.
+ *
+ * Note that <stdio.h> also defines this, but we don't guard it, so that
+ * the compiler has a chance to catch inconsistencies.
+ */
+#define FILENAME_MAX   (260)
 
-#ifndef        _FSIZE_T_DEFINED
+/* We must define _fsize_t, but some compilers (including GCC prior to
+ * version 4.0), may choke if we try to do so more than once...
+ */
+#if ! (defined _IO_H && defined _WCHAR_H)
+ /* ...so DO NOT define it during direct <io.h> inclusion, (i.e. _IO_H
+  * is defined), if <wchar.h> has already caused it to be defined, (i.e.
+  * _WCHAR_H is ALSO defined).
+  */
 typedef        unsigned long   _fsize_t;
-#define _FSIZE_T_DEFINED
-#endif
+#endif /* ! (_IO_H && _WCHAR_H)
+
+/* Functions for searching for files: _findfirst() sets errno to ENOENT,
+ * and returns -1 if no match is found; otherwise it returns a handle to
+ * be used in _findnext() and _findclose() calls. _findnext() may then be
+ * used to identify further matches; it updates the search data, returning
+ * zero, each time a further match is found, ultimately setting errno to
+ * ENOENT, and returning -1 when no further match can be found.  When all
+ * expected matches have been identified, _findclose() should be called,
+ * to release the resources allocated to the search data.
+ *
+ * The API comprises several variants of the _findfirst() and _findnext()
+ * functions, conforming generally to the usage model:
+ *
+ *  intptr_t handle = _findfirst (filespec, &search_data );
+ *  if (handle >= (intptr_t)(0)) do { process search_data;
+ *   } while (_findnext (handle, &search_data));
+ *
+ * where "filespec" represents a char *, or a wchar_t * specification,
+ * (which may include wild cards), for a file name pattern to be matched,
+ * and "search_data" represents a variant of the structure:
+ */
+#define __struct_finddata_t(__fd_time_t, __fd_size_t)                  \
+{ unsigned     attrib;         /* Attributes, see constants above. */  \
+  __fd_time_t  time_create;                                            \
+  __fd_time_t  time_access;    /* always midnight local time */        \
+  __fd_time_t  time_write;                                             \
+  __fd_size_t  size;                                                   \
+  __fd_name_t  name[FILENAME_MAX];     /* may include spaces. */       \
+}
+
+/* Time type and file size variations for __struct_finddata_t apply, for the
+ * various functions comprising the file name search API, as tabulated below:
+ *
+ * Note: this is a reproduction of reference data as published in the MSDN
+ * online documentation for the file name search API; it applies, specifically,
+ * to the implementation of this API in the non-free run-time library versions
+ * from MSVCR80.DLL onwards, (i.e. when __MSVCRT_VERSION__ is defined, and is
+ * assigned a value >= 0x800).  When linking to the freely available MSVCRT.DLL
+ * runtime, (__MSVCRT_VERSION__ should not be defined), or any earlier version
+ * of the non-free run-time, the _USE_32BIT_TIME_T feature test is irrelevant;
+ * the information presented in this table should be interpreted as if this
+ * feature is always implicitly enabled.
+ *
+ *  Functions         _USE_32BIT_TIME_T defined?    __fd_time_t     __fd_size_t
+ *
+ * _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
+ *
+ */
+_BEGIN_C_DECLS
 
-/*
- * The maximum length of a file name. You should use GetVolumeInformation
- * instead of this constant. But hey, this works.
- * Also defined in stdio.h.
+#ifdef _IO_H
+#define __fd_name_t  char
+
+/* The most universally available variants of the file name search
+ * API employ either a generic representation of the related data, or
+ * a variant in which the time stamps are represented generically, but
+ * the file size is explicitly expressed as a 64-bit value.
  */
-#ifndef FILENAME_MAX
-#define        FILENAME_MAX    (260)
-#endif
+struct _finddata_t __struct_finddata_t (time_t, _fsize_t);
+struct _finddatai64_t __struct_finddata_t (time_t, __int64);
+
+/* Functions to manipulate data in either of these representations are
+ * provided, as physical entities, in ALL versions of MSVCRT.DLL, and
+ * in the non-free variants predating MSVCR80.DLL; (each such physical
+ * function implementation interprets "generic" as 32-bit for both the
+ * time_t and _fsize_t data fields).  From MSVCR80.DLL onward, there is
+ * no physical implementation of these functions; they are emulated by
+ * inline replacements (implemented below), which introduce ambiguity
+ * in the interpretation of "generic", (noted as applicable): thus...
+ */
+#if __MSVCRT_VERSION__ < __MSVCR80_DLL
+/* ...these physical function APIs are declared only when it is NOT
+ * specified that MSVCR80.DLL or later is to be used.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _findfirst (const char *, struct _finddata_t *);
 
-/*
- * The following structure is filled in by _findfirst or _findnext when
- * they succeed in finding a match.
- */
-struct _finddata_t
-{
-       unsigned        attrib;         /* Attributes, see constants above. */
-       time_t          time_create;
-       time_t          time_access;    /* always midnight local time */
-       time_t          time_write;
-       _fsize_t        size;
-       char            name[FILENAME_MAX];     /* may include spaces. */
-};
-
-struct _finddatai64_t {
-    unsigned    attrib;
-    time_t      time_create;
-    time_t      time_access;
-    time_t      time_write;
-    __int64     size;
-    char        name[FILENAME_MAX];
-};
-
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __finddata64_t {
-        unsigned    attrib;
-        __time64_t  time_create;
-        __time64_t  time_access;
-        __time64_t  time_write;
-/* 8 bytes are returned so it can't be _fsize_t */
-        __int64    size;
-         char       name[FILENAME_MAX];
-};
-#endif
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _findnext (intptr_t, struct _finddata_t *);
 
-#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;
-       time_t          time_create;    /* -1 for FAT file systems */
-       time_t          time_access;    /* -1 for FAT file systems */
-       time_t          time_write;
-       _fsize_t        size;
-       wchar_t         name[FILENAME_MAX];     /* may include spaces. */
-};
-
-struct _wfinddatai64_t {
-    unsigned    attrib;
-    time_t      time_create;
-    time_t      time_access;
-    time_t      time_write;
-    __int64     size;
-    wchar_t     name[FILENAME_MAX];
-};
-
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __wfinddata64_t {
-        unsigned    attrib;
-        __time64_t  time_create;
-        __time64_t  time_access;
-        __time64_t  time_write;
-/* 8 bytes are returned so it can't be _fsize_t */
-        __int64    size;
-        wchar_t     name[FILENAME_MAX];
-};
-#endif
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _findfirsti64 (const char *, struct _finddatai64_t *);
 
-#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
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _findnexti64 (intptr_t, struct _finddatai64_t *);
 
-_BEGIN_C_DECLS
+#endif /* __MSVCRT_VERSION__ < __MSVCR80_DLL */
 
-/*
- * Functions for searching for files. _findfirst returns -1 if no match
- * is found. Otherwise it returns a handle to be used in _findnext and
- * _findclose calls. _findnext also returns -1 if no match could be found,
- * and 0 if a match was found. Call _findclose when you are finished.
+#if _WIN32_WINNT >= _WIN32_WINNT_WIN2K || __MSVCRT_VERSION__ >= __MSVCR61_DLL
+/* The Win2K release of MSVCRT.DLL added a third variant of the API,
+ * which had originally been introduced in MSVCR61.DLL; this variant
+ * uses a data representation having both 64-bit time stamp values,
+ * and 64-bit file size values.  (Note that there was no explictly
+ * all 32-bit variant added at this point in the evolution of the
+ * API; had there been, it would have been identically equivalent
+ * to the original generic _findfirst()/_findnext() implementation).
  */
-/*  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 intptr_t __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _findnext (intptr_t, struct _finddata_t*);
-#endif /* __MSVCRT_VERSION__ < 0x0800 */
-_CRTIMP int __cdecl __MINGW_NOTHROW _findclose (intptr_t);
-#if __MSVCRT_VERSION__ >= 0x0800
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst32 (const char*, struct _finddata32_t*);
-_CRTIMP int  __cdecl __MINGW_NOTHROW   _findnext32 (intptr_t, struct _finddata32_t*);
-#endif /* __MSVCRT_VERSION__ >= 0x0800 */
-
-_CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
-_CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
-_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);
+struct __finddata64_t __struct_finddata_t (__time64_t, __int64);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _findfirst64 (const char *, struct __finddata64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _findnext64 (intptr_t, struct __finddata64_t *);
+
+#if __MSVCRT_VERSION__ >= __MSVCR80_DLL
+/* MSVCR80.DLL introduced three new data structures, with explicitly
+ * sized elements; in the order specified below, the first and second
+ * of these three are identically equivalent to the representations of
+ * struct _finddata_t, and struct _finddatai64_t, as they are required
+ * to be implemented to match the implementations of the corresponding
+ * functions in ALL versions of MSVCRT.DLL, whereas the third has no
+ * counterpart, in ANY version of MSVCRT.DLL.
+ */
+struct _finddata32_t __struct_finddata_t (__time32_t, __int32);
+struct _finddata32i64_t __struct_finddata_t (__time32_t, __int64);
+struct _finddata64i32_t __struct_finddata_t (__time64_t, __int32);
+
+/* The actual functions implemented in MSVCR80.DLL, and its derivatives,
+ * corresponding to each of these three data structures are:
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _findfirst32 (const char *, struct _finddata32_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _findnext32 (intptr_t, struct _finddata32_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _findfirst32i64 (const char *, struct _finddata32i64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _findnext32i64 (intptr_t, struct _finddata32i64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _findfirst64i32 (const char *, struct _finddata64i32_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _findnext64i32 (intptr_t, struct _finddata64i32_t *);
+
+/* Since MSVCR80.DLL, and its later derivatives, provide no physical
+ * implementations of the original file name search API functions, we
+ * must emulate them, (as Microsoft do), by providing replacements in
+ * the form of inline functions; in doing so, we also need to contend
+ * with the insane ambiguity of Microsoft's _USE_32BIT_TIME_T feature
+ * test; thus...
+ */
+#if defined _USE_32BIT_TIME_T
+/* ...when the user has defined the _USE_32BIT_TIME_T macro, we provide
+ * inline implementations which remain fully compatible with the actual
+ * functions, as provided by MSVCRT.DLL; (note that we do not provide
+ * __JMPSTUB__ or __LIBIMPL__ references here, since we have no basis
+ * for a rational choice between ambiguous alternatives).
+ */
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _findfirst (const char *__filespec, struct _finddata_t *__search)
+{ return _findfirst32 (__filespec, (struct _finddata32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _findnext (intptr_t __handle, struct _finddata_t *__search)
+{ return _findnext32 (__handle, (struct _finddata32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _findfirsti64 (const char *__filespec, struct _finddatai64_t *__search)
+{ return _findfirst32i64 (__filespec, (struct _finddata32i64_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _findnexti64 (intptr_t __handle, struct _finddatai64_t *__search)
+{ return _findnext32i64 (__handle, (struct _finddata32i64_t *)(__search)); }
+
+#else  /* !_USE_32BIT_TIME_T */
+/* ...but, when the user has NOT defined _USE_32BIT_TIME_T, we emulate
+ * the brain damaged default behaviour of Microsoft's own SDKs.  This
+ * accommodates an extended range of valid time stamp values, but it
+ * utterly destroys compatibility with MSVCRT.DLL!
+ */
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _findfirst (const char *__filespec, struct _finddata_t *__search)
+{ return _findfirst64i32 (__filespec, (struct _finddata64i32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _findnext (intptr_t __handle, struct _finddata_t *__search)
+{ return _findnext64i32 (__handle, (struct _finddata64i32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _findfirsti64 (const char *__filespec, struct _finddatai64_t *__search)
+{ return _findfirst64 (__filespec, (struct __finddata64_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _findnexti64 (intptr_t __handle, struct _finddatai64_t *__search)
+{ return _findnext64 (__handle, (struct __finddata64_t *)(__search)); }
+
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= __MSVCR80_DLL */
+#endif /* >= WIN2K || >= MSVCR61.DLL */
+
+#undef  __fd_name_t
+#endif /* _IO_H */
+
+#if ! (defined _IO_H && defined _WCHAR_H)
+/* Wide character file name analogue of the file name search API;
+ * declared both here, in <io.h>, and via selective inclusion from
+ * <wchar.h>, it mirrors all aspects of the preceding API declarations,
+ * except that all file names are expressed as wchar_t.
+ */
+#define __fd_name_t  wchar_t
+
+/* Thus, the original API comprised this pair of generically specified
+ * data structures...
+ */
+struct _wfinddata_t __struct_finddata_t (time_t, _fsize_t);
+struct _wfinddatai64_t __struct_finddata_t (time_t, __int64);
+
+#if __MSVCRT_VERSION__ < __MSVCR80_DLL
+/* ...with corresponding functions to manipulate them; once again, there
+ * is no physical implementation of these in MSVCR80.DLL or later, so we
+ * declare them only when it is NOT specified that one of these run-time
+ * library versions is to be used.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst (const wchar_t *, struct _wfinddata_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _wfindnext (intptr_t, struct _wfinddata_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirsti64 (const wchar_t *, struct _wfinddatai64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _wfindnexti64 (intptr_t, struct _wfinddatai64_t *);
+
+#endif /* __MSVCRT_VERSION__ < __MSVCR80_DLL */
+
+#if _WIN32_WINNT >= _WIN32_WINNT_WIN2K || __MSVCRT_VERSION__ >= __MSVCR61_DLL
+/* Win2K also added an all-64-bit variant of the _wfinddata API to
+ * MSVCRT.DLL, after it originally appeared in MSVCR61.DLL.
+ */
+struct __wfinddata64_t __struct_finddata_t (__time64_t, __int64);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst64 (const wchar_t *, struct __wfinddata64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _wfindnext64 (intptr_t, struct __wfinddata64_t *);
+
+#if __MSVCRT_VERSION__ >= __MSVCR80_DLL
+/* MSVCR80.DLL introduced a further three variants, which remain
+ * exclusive to it and its later derivatives; none of these are
+ * available in any version of MSVCRT.DLL.
+ */
+struct __wfinddata32_t __struct_finddata_t (__time32_t, __int32);
+struct _wfinddata32i64_t __struct_finddata_t (__time32_t, __int64);
+struct _wfinddata64i32_t __struct_finddata_t (__time64_t, __int32);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst32 (const wchar_t *, struct __wfinddata32_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _wfindnext32 (intptr_t, struct __wfinddata32_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst32i64 (const wchar_t *, struct _wfinddata32i64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _wfindnext32i64 (intptr_t, struct _wfinddata32i64_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst64i32 (const wchar_t *, struct _wfinddata64i32_t *);
+
+_CRTIMP __cdecl __MINGW_NOTHROW
+int _wfindnext64i32 (intptr_t, struct _wfinddata64i32_t *);
+
+/* Once again, the variants of this API with generic time_t data
+ * fields are NOT supported by any physical function implementation
+ * in MSVCR80.DLL and later, so must be emulated; (again, we do not
+ * provide any __JMPSTUB__ or __LIBIMPL__ references).
+ */
+#ifdef _USE_32BIT_TIME_T
+/* First, we provide inline implementations which retain compatibility
+ * with the physical implementations in MSVCRT.DLL; they require the
+ * user to define the _USE_32BIT_TIME_T feature test macro...
+ */
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst (const wchar_t *__filespec, struct _wfinddata_t *__search)
+{ return _wfindfirst32 (__filespec, (struct __wfinddata32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _wfindnext (intptr_t __handle, struct _wfinddata_t *__search)
+{ return _wfindnext32 (__handle, (struct __wfinddata32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirsti64 (const wchar_t *__filespec, struct _wfinddatai64_t *__search)
+{ return _wfindfirst32i64 (__filespec, (struct _wfinddata32i64_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _wfindnexti64 (intptr_t __handle, struct _wfinddatai64_t *__search)
+{ return _wfindnext32i64 (__handle, (struct _wfinddata32i64_t *)(__search)); }
+
+#else  /* !_USE_32BIT_TIME_T */
+/* ...whereas the brain damaged Microsoft defaults, which apply when
+ * _USE_32BIT_TIME_T is not defined, break MSVCRT.DLL compatibility.
+ */
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirst (const wchar_t *__filespec, struct _wfinddata_t *__search)
+{ return _wfindfirst64i32 (__filespec, (struct _wfinddata64i32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _wfindnext (intptr_t __handle, struct _wfinddata_t *__search)
+{ return _wfindnext64i32 (__handle, (struct _wfinddata64i32_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+intptr_t _wfindfirsti64 (const wchar_t *__filespec, struct _wfinddatai64_t *__search)
+{ return _wfindfirst64 (__filespec, (struct __wfinddata64_t *)(__search)); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW
+int _wfindnexti64 (intptr_t __handle, struct _wfinddatai64_t *__search)
+{ return _wfindnext64 (__handle, (struct __wfinddata64_t *)(__search)); }
+
+#endif /* !_USE_32BIT_TIME_T */
+#endif /* __MSVCRT_VERSION__ >= MSVCR80.DLL */
+#endif /* >= _WIN2K || >= MSVCR61.DLL */
+
+#undef __fd_name_t
+#endif /* ! (_IO_H && _WCHAR_H) */
+
+/* We have no further use for the __struct_finddata_t macro; delete it!
+ */
+#undef __struct_finddata_t
+
+/* MSDN documents that <io.h> must be included to get a prototype for
+ * _findclose(), which kind of negates the usefulness of declaring the
+ * wchar_t variants of the file name search API in <wchar.h>; mitigate
+ * this anomaly, by declaring _findclose() such that either <io.h> or
+ * <wchar.h> will provide it.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _findclose (intptr_t);
+
+#ifdef _IO_H
+/* The following declarations are to be exposed only when <io.h> is
+ * included directly.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _chdir (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  char *_getcwd (char *, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _mkdir (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  char *_mktemp (char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _rmdir (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _chmod (const char *, int);
+
 #ifdef __MSVCRT__
-_CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
-#if __MSVCRT_VERSION__ < 0x0800
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(intptr_t, struct _finddatai64_t*);
-#else
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst32i64 (const char*, struct _finddata32i64_t*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst64i32 (const char*, struct _finddata64i32_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW    _findnext32i64 (intptr_t, struct _finddata32i64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW    _findnext64i32 (intptr_t, 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). */
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst64(const char*, struct __finddata64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _findnext64(intptr_t, struct __finddata64_t*);
-#endif /* __MSVCRT_VERSION__ >= 0x0601 */
-#if __MSVCRT_VERSION__ >= 0x0800
-#ifndef _USE_32BIT_TIME_T
-/* No __JMPSTUB__ or __LIBIMPL__ here; all of these represent
- * call redirections within the MSVC runtime library itself.
- */
-__CRT_ALIAS intptr_t __cdecl __MINGW_NOTHROW _findfirst (const char* _v1, struct _finddata_t* _v2)
-{ return(_findfirst64i32 (_v1,(struct _finddata64i32_t*)_v2)); }
-__CRT_ALIAS int __cdecl __MINGW_NOTHROW        _findnext (intptr_t _v1, struct _finddata_t* _v2)
-{ return(_findnext64i32 (_v1,(struct _finddata64i32_t*)_v2)); }
-__CRT_ALIAS intptr_t __cdecl __MINGW_NOTHROW _findfirsti64 (const char* _v1, struct _finddatai64_t* _v2)
-{ return(_findfirst64 (_v1,(struct __finddata64_t*)_v2)); }
-__CRT_ALIAS int __cdecl __MINGW_NOTHROW        _findnexti64 (intptr_t _v1, struct _finddatai64_t* _v2)
-{ return(_findnext64 (_v1,(struct __finddata64_t*)_v2)); }
-#else
-__CRT_ALIAS intptr_t __cdecl __MINGW_NOTHROW _findfirst (const char* _v1, struct _finddata_t* _v2)
-{ return(_findfirst32 (_v1,(struct _finddata32_t*)_v2)); }
-__CRT_ALIAS int __cdecl __MINGW_NOTHROW        _findnext (intptr_t _v1, struct _finddata_t* _v2)
-{ return(_findnext32 (_v1,(struct _finddata32_t*)_v2)); }
-__CRT_ALIAS intptr_t __cdecl __MINGW_NOTHROW _findfirsti64 (const char* _v1, struct _finddatai64_t* _v2)
-{ return(_findfirst32i64 (_v1,(struct _finddata32i64_t*)_v2)); }
-__CRT_ALIAS int __cdecl __MINGW_NOTHROW        _findnexti64 (intptr_t _v1, struct _finddatai64_t* _v2)
-{ return(_findnext32i64 (_v1,(struct _finddata32i64_t*)_v2)); }
-#endif /* !_USE_32BIT_TIME_T */
-#endif /* __MSVCRT_VERSION__ >= 0x0800 */
+_CRTIMP __cdecl __MINGW_NOTHROW  __int64 _filelengthi64 (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  __int64 _lseeki64 (int, __int64, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  __int64 _telli64 (int);
 
 #ifndef __NO_MINGW_LFS
 __CRT_INLINE __off64_t lseek64 (int, __off64_t, int);
 __CRT_INLINE __JMPSTUB__(( FUNCTION = lseek64, REMAPPED = _lseeki64 ))
 __off64_t lseek64 (int fd, __off64_t offset, int whence)
-{ return _lseeki64(fd, (__int64)(offset), whence); }
+{ return _lseeki64 (fd, (__int64)(offset), whence); }
 #endif
 
 #endif /* __MSVCRT__ */
@@ -307,186 +484,179 @@ __off64_t lseek64 (int fd, __off64_t offset, int whence)
 #ifndef _NO_OLDNAMES
 
 #ifndef _UWIN
-_CRTIMP int __cdecl __MINGW_NOTHROW chdir (const char*);
-_CRTIMP char* __cdecl __MINGW_NOTHROW getcwd (char*, int);
-_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);
+_CRTIMP __cdecl __MINGW_NOTHROW  int chdir (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  char *getcwd (char *, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int mkdir (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  char *mktemp (char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int rmdir (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int chmod (const char *, int);
 #endif /* _UWIN */
 
-#endif /* Not _NO_OLDNAMES */
+#endif /* !_NO_OLDNAMES */
+#endif /* _IO_H */
 
 _END_C_DECLS
 
-#endif /* Not RC_INVOKED */
+#endif /* ! RC_INVOKED */
 
-/* TODO: Maximum number of open handles has not been tested, I just set
- * it the same as FOPEN_MAX. */
-#define        HANDLE_MAX      FOPEN_MAX
+#ifdef _IO_H
+/* Still applicable only when <io.h> is included directly, but we also
+ * allow the resource compiler to see these.
+ *
+ * TODO: Maximum number of open handles has not been tested; we just set
+ * it the same as FOPEN_MAX.
+ */
+#define HANDLE_MAX     FOPEN_MAX
 
-/* Some defines for _access nAccessMode (MS doesn't define them, but
- * it doesn't seem to hurt to add them). */
-#define        F_OK    0       /* Check for file existence */
-/* Well maybe it does hurt.  On newer versions of MSVCRT, an access mode
-   of 1 causes invalid parameter error. */
-#define        X_OK    1       /* MS access() doesn't check for execute permission. */
-#define        W_OK    2       /* Check for write permission */
-#define        R_OK    4       /* Check for read permission */
+/* Some defines for _access() mode checking: (Microsoft doesn't define
+ * them, but it doesn't seem to hurt to add them ... or perhaps it does
+ * hurt; on newer versions of MSVCRT.DLL, an access mode of 1 may raise
+ * an invalid parameter error!
+ */
+#define F_OK   0       /* Check for file existence */
+#define X_OK   1       /* MS access() doesn't check for execute permission. */
+#define W_OK   2       /* Check for write permission */
+#define R_OK   4       /* Check for read permission */
+#endif /* _IO_H */
 
 #ifndef RC_INVOKED
 
 _BEGIN_C_DECLS
 
-_CRTIMP int __cdecl __MINGW_NOTHROW _access (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _chsize (int, long);
-_CRTIMP int __cdecl __MINGW_NOTHROW _close (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _commit(int);
+#ifdef _IO_H
+/* Again, specific to <io.h>, but not applicable to resources.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _access (const char *, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _chsize (int, long);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _close (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _commit (int);
 
-/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
- *       the "owner write permission" bit (on FAT). */
-_CRTIMP int __cdecl __MINGW_NOTHROW _creat (const char*, int);
+/* NOTE: The only significant permissions bit appears to be
+ * bit 7 (0x80), the "owner write permission" bit (on FAT).
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _creat (const char *, int);
 
-_CRTIMP int __cdecl __MINGW_NOTHROW _dup (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _dup2 (int, int);
-_CRTIMP long __cdecl __MINGW_NOTHROW _filelength (int);
-_CRTIMP long __cdecl __MINGW_NOTHROW _get_osfhandle (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _isatty (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _dup (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _dup2 (int, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  long _filelength (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  long _get_osfhandle (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _isatty (int);
 
+#ifndef        _STREAM_COMPAT
 /* In a very odd turn of events this function is excluded from those
  * files which define _STREAM_COMPAT. This is required in order to
  * build GNU libio because of a conflict with _eof in streambuf.h
  * line 107. Actually I might just be able to change the name of
- * the enum member in streambuf.h... we'll see. TODO */
-#ifndef        _STREAM_COMPAT
-_CRTIMP int __cdecl __MINGW_NOTHROW _eof (int);
+ * the enum member in streambuf.h ... we'll see. TODO
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _eof (int);
 #endif
 
-/* LK_... locking commands defined in sys/locking.h. */
-_CRTIMP int __cdecl __MINGW_NOTHROW _locking (int, int, long);
-
-_CRTIMP long __cdecl __MINGW_NOTHROW _lseek (int, long, int);
-
-/* Optional third argument is unsigned unPermissions. */
-_CRTIMP int __cdecl __MINGW_NOTHROW _open (const char*, int, ...);
-
-_CRTIMP int __cdecl __MINGW_NOTHROW _open_osfhandle (intptr_t, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _pipe (int *, unsigned int, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _read (int, void*, unsigned int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _setmode (int, int);
-/* MS puts remove & rename (but not wide versions) in io.h as well
-   as in stdio.h. */
-_CRTIMP int __cdecl __MINGW_NOTHROW    remove (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW    rename (const char*, const char*);
-
-/* SH_... flags for nShFlags defined in share.h
- * Optional fourth argument is unsigned unPermissions */
-_CRTIMP int __cdecl __MINGW_NOTHROW _sopen (const char*, int, int, ...);
-
-_CRTIMP long __cdecl __MINGW_NOTHROW _tell (int);
-/* Should umask be in sys/stat.h and/or sys/types.h instead? */
-_CRTIMP int __cdecl __MINGW_NOTHROW _umask (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _unlink (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _write (int, const void*, unsigned int);
-
-/* Wide character versions. Also declared in wchar.h. */
-/* Not in crtdll.dll */
-#if !defined (_WIO_DEFINED)
-#if defined (__MSVCRT__)
-_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
-/* No __JMPSTUB__ or __LIBIMPL__ here; all of these represent
- * call redirections within the MSVC runtime library itself.
- */
-__CRT_ALIAS long __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2)
-{ return(_wfindfirst64i32 (_v1,(struct _wfinddata64i32_t*)_v2)); }
-__CRT_ALIAS int  __cdecl __MINGW_NOTHROW _wfindnext (long _v1, struct _wfinddata_t* _v2)
-{ return(_wfindnext64i32  (_v1,(struct _wfinddata64i32_t*)_v2)); }
-__CRT_ALIAS long __cdecl __MINGW_NOTHROW _wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2)
-{ return(_wfindfirst64 (_v1,(struct __wfinddata64_t*)_v2)); }
-__CRT_ALIAS int  __cdecl __MINGW_NOTHROW _wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2)
-{ return(_wfindnext64 (_v1,(struct __wfinddata64_t*)_v2)); }
-#else
-__CRT_ALIAS long __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2)
-{ return(_wfindfirst32 (_v1,(struct __wfinddata32_t*)_v2)); }
-__CRT_ALIAS int  __cdecl __MINGW_NOTHROW _wfindnext (long _v1, struct _wfinddata_t* _v2)
-{ return(_wfindnext32 (_v1,(struct __wfinddata32_t*)_v2)); }
-__CRT_ALIAS long __cdecl __MINGW_NOTHROW _wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2)
-{ return(_wfindfirst32i64 (_v1,(struct _wfinddata32i64_t*)_v2)); }
-__CRT_ALIAS 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 */
-
-#ifndef        _NO_OLDNAMES
-/*
- * Non-underscored versions of non-ANSI functions to improve portability.
- * These functions live in libmoldname.a.
+/* Locking files: attribute constants are defined in <sys/locking.h>,
+ * which users are expected to include.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _locking (int, int, long);
+
+_CRTIMP __cdecl __MINGW_NOTHROW  long _lseek (int, long, int);
+
+/* Opening files, (or streams); manifest constants for construction of
+ * the mode flags are defined in <fctl.h>, which users are expected to
+ * include.  The "optional" third argument is an unsigned int; it is
+ * REQUIRED, when creating a new file, to specify the permissions to
+ * apply when said file is released by the creating process.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _open (const char *, int, ...);
+
+_CRTIMP __cdecl __MINGW_NOTHROW  int _open_osfhandle (intptr_t, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _pipe (int *, unsigned int, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _read (int, void *, unsigned int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _setmode (int, int);
+
+/* Microsoft declares remove() & rename(), (but not their wchar_t
+ * counterparts), in <io.h> as well as in <stdio.h>; these should be
+ * consistent with <stdio.h>, but we trust the compiler to alert us
+ * (eventually) if not.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int remove (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int rename (const char *, const char *);
+
+/* Open files with specified sharing attributes; manifest constants
+ * for constructing the sharing mode argument are in <share.h>, which
+ * users must include.  The optional fourth argument is an unsigned
+ * int, specifing permissions to apply after closing a new file.
  */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _sopen (const char *, int, int, ...);
+
+_CRTIMP __cdecl __MINGW_NOTHROW  long _tell (int);
 
+/* FIXME: POSIX wants umask() in <sys/stat.h>, and, although vague,
+ * Microsoft may agree; we declare it here as well!
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _umask (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _unlink (const char *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _write (int, const void *, unsigned int);
+#endif /* _IO_H */
+
+#if defined __MSVCRT__ && ! (defined _IO_H && defined _WCHAR_H)
+/* These wchar_t functions are made available for selective inclusion
+ * by <wchar.h>, in addition to direct inclusion of <io.h>, but they
+ * are only supported by MSVCRT.DLL and derivatives; they don't exist
+ * in CRTDLL.DLL.  Furthermore, if both _IO_H and _WCHAR_H have been
+ * defined, by the time we get here, then this must be direct <io.h>
+ * inclusion, and we've already declared these by prior inclusion of
+ * <wchar.h>; there is no need to declare them again.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW  int _waccess (const wchar_t *, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _wchmod (const wchar_t *, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _wcreat (const wchar_t *, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _wunlink (const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _wopen (const wchar_t *, int, ...);
+_CRTIMP __cdecl __MINGW_NOTHROW  int _wsopen (const wchar_t *, int, int, ...);
+_CRTIMP __cdecl __MINGW_NOTHROW  wchar_t *_wmktemp (wchar_t *);
+#endif /* __MSVCRT__ && ! (_IO_H && _WCHAR_H) */
+
+#if defined _IO_H && ! defined _NO_OLDNAMES
+/* Non-underscored versions of non-ANSI functions to improve portability;
+ * these are implemented in libmoldname.a, and once again are declared
+ * only when <io.h> is included directly.
+ */
 #ifndef _UWIN
-_CRTIMP int __cdecl __MINGW_NOTHROW access (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW chsize (int, long );
-_CRTIMP int __cdecl __MINGW_NOTHROW close (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW creat (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW dup (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW dup2 (int, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW eof (int);
-_CRTIMP long __cdecl __MINGW_NOTHROW filelength (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW isatty (int);
-_CRTIMP long __cdecl __MINGW_NOTHROW lseek (int, long, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW open (const char*, int, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW read (int, void*, unsigned int);
-_CRTIMP int __cdecl __MINGW_NOTHROW setmode (int, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW sopen (const char*, int, int, ...);
-_CRTIMP long __cdecl __MINGW_NOTHROW tell (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW umask (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW write (int, const void*, unsigned int);
-#endif /* _UWIN */
+_CRTIMP __cdecl __MINGW_NOTHROW  int access (const char*, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int chsize (int, long );
+_CRTIMP __cdecl __MINGW_NOTHROW  int close (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int creat (const char*, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int dup (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int dup2 (int, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int eof (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  long filelength (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int isatty (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  long lseek (int, long, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int open (const char*, int, ...);
+_CRTIMP __cdecl __MINGW_NOTHROW  int read (int, void*, unsigned int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int setmode (int, int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int sopen (const char*, int, int, ...);
+_CRTIMP __cdecl __MINGW_NOTHROW  long tell (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int umask (int);
+_CRTIMP __cdecl __MINGW_NOTHROW  int unlink (const char*);
+_CRTIMP __cdecl __MINGW_NOTHROW  int write (int, const void*, unsigned int);
+#endif /* !_UWIN */
 
 #ifdef __USE_MINGW_ACCESS
-/*  Old versions of MSVCRT access() just ignored X_OK, while the version
-    shipped with Vista, returns an error code.  This will restore the
-    old behaviour  */
-static inline int __mingw_access (const char* __fname, int __mode)
+/* Old versions of MSVCRT.DLL's access() just ignored X_OK, while the
+ * version shipped with Vista fails; this inline implementation of the
+ * portably named access() function protects against such failure.
+ */
+#define access(__fname,__mode)  __mingw_access (__fname, __mode)
+static __inline__ int __mingw_access (const char* __fname, int __mode)
   { return  _access (__fname, __mode & ~X_OK); }
-#define access(__f,__m)  __mingw_access (__f, __m)
-#endif
+#endif /* _USE_MINGW_ACCESS */
 
-/* Wide character versions. Also declared in wchar.h. */
-/* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
 #if 0
+/* FIXME:
+ * Wide character versions: may also be declared in <wchar.h>.
+ * Where do these live?  Not in libmoldname.a nor in libmsvcrt.a;
+ * do they exist at all?
+ */
 int            waccess(const wchar_t *, int);
 int            wchmod(const wchar_t *, int);
 int            wcreat(const wchar_t *, int);
@@ -499,10 +669,9 @@ int                wsopen(const wchar_t *, int, int, ...);
 wchar_t *      wmktemp(wchar_t *);
 #endif
 
-#endif /* Not _NO_OLDNAMES */
+#endif /* !_NO_OLDNAMES */
 
 _END_C_DECLS
 
-#endif /* Not RC_INVOKED */
-
-#endif /* _IO_H_ not defined */
+#endif /* ! RC_INVOKED */
+#endif /* !_IO_H: $RCSfile$: end of file */
index 8be0812..2e19b96 100644 (file)
  *  int _wstat64i32 (const wchar_t *, struct _stat64i32 *);
  *
  *
+ * while from...
+ */
+#include <io.h>
+/* ...we obtain function prototypes for each of the following, which
+ * are available in all versions of MSVCRT.DLL, (and all its non-free
+ * derivatives), but are not supported by CRTDLL.DLL:
+ *
+ *  int _waccess (const wchar_t *, int);
+ *  int _wchmod (const wchar_t *, int);
+ *  int _wcreat (const wchar_t *, int);
+ *  int _wopen (const wchar_t *, int, ...);
+ *  int _wsopen (const wchar_t *, int, int, ...);
+ *  int _wunlink (const wchar_t *);
+ *  wchar_t *_wmktemp (wchar_t *);
+ *
+ * ...and also function prototypes and definitions of all associated
+ * data types and manifest constants for the following, each of which
+ * is physically implemented in all versions of MSVCRT.DLL, and in each
+ * of its non-free variants prior to MSVCR80.DLL, or emulated by inline
+ * replacement functions for MSVCR80.DLL and later:
+ *
+ *  intptr_t _wfindfirst (wchar_t *, struct _wfinddata_t *);
+ *  int _wfindnext (intptr_t, struct _wfinddata_t *);
+ *
+ *  intptr_t _wfindfirsti64 (wchar_t *, struct _wfinddatai64_t *);
+ *  int _wfindnexti64 (intptr_t, struct _wfinddatai64_t *);
+ *
+ * ...this additional pair of functions, available in all versions of
+ * MSVCRT.DLL from Win2K, and non-free variants from MSVCR61.DLL:
+ *
+ *  intptr_t _wfindfirst64 (wchar_t *, struct __wfinddata64_t *);
+ *  int _wfindnext64 (intptr_t, struct __wfinddata64_t *);
+ *
+ * ...and these, which are only available in the non-free run-times
+ * from MSVCR80.DLL onwards:
+ *
+ *  intptr_t _wfindfirst32 (wchar_t *, struct __wfinddata32_t *);
+ *  int _wfindnext32 (intptr_t, struct __wfinddata32_t *);
+ *
+ *  intptr_t _wfindfirst32i64 (wchar_t *, struct _wfinddata32i64_t *);
+ *  int _wfindnext32i64 (intptr_t, struct _wfinddata32i64_t *);
+ *
+ *  intptr_t _wfindfirst64i32 (wchar_t *, struct _wfinddata64i32_t *);
+ *  int _wfindnext64i32 (intptr_t, struct _wfinddata64i32_t *);
+ *
+ * Additionally, although Microsoft's <wchar.h> may not declare it,
+ * this is required to complement all variants of the _wfindfirst()
+ * and _wfindnext() API, so we also declare the prototype for:
+ *
+ *  int _findclose (intptr_t);
+ *
+ *
  * and from...
  */
 #include <time.h>
@@ -395,172 +447,71 @@ _CRTIMP __cdecl __MINGW_NOTHROW  wchar_t *wcsupr (wchar_t *);
 #endif /* !(RC_INVOKED || (_WCHAR_H && _STRING_H)) */
 #if defined _WCHAR_H && ! defined RC_INVOKED
 
-/* These are resolved by -lmingwex. Alternatively, they can be resolved by
-   adding -lmsvcp60 to your command line, which will give you the VC++
-   versions of these functions. If you want the latter and don't have
-   msvcp60.dll in your windows system directory, you can easily obtain
-   it with a search from your favorite search engine.  */
 #ifndef __STRICT_ANSI__
-typedef wchar_t _Wint_t;
+typedef wchar_t  _Wint_t;
 #endif
 
 typedef int mbstate_t;
 
-wint_t __cdecl __MINGW_NOTHROW btowc(int);
-size_t __cdecl __MINGW_NOTHROW mbrlen(const char * __restrict__, size_t,
-                     mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW mbrtowc(wchar_t * __restrict__, const char * __restrict__,
-                      size_t, mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW mbsrtowcs(wchar_t * __restrict__, const char ** __restrict__,
-                        size_t, mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW wcrtomb(char * __restrict__, wchar_t,
-                      mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW wcsrtombs(char * __restrict__, const wchar_t ** __restrict__,
-                        size_t, mbstate_t * __restrict__);
-int __cdecl __MINGW_NOTHROW wctob(wint_t);
-
-#ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */
-int __cdecl __MINGW_NOTHROW fwide(FILE*, int);
-int __cdecl __MINGW_NOTHROW mbsinit(const mbstate_t*);
+/* The following multi-byte character conversion functions are
+ * implemented in libmingwex.a, (and maybe also in some non-free
+ * Microsoft libraries, such as MSVCP60.DLL and later).
+ */
+__cdecl __MINGW_NOTHROW  wint_t btowc (int);
+__cdecl __MINGW_NOTHROW  int wctob (wint_t);
+
+__cdecl __MINGW_NOTHROW
+size_t mbrlen (const char *__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW  size_t mbrtowc
+(wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW  size_t mbsrtowcs
+(wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW
+size_t wcrtomb (char * __restrict__, wchar_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW  size_t wcsrtombs
+(char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
+
+#ifdef _ISOC99_SOURCE
+/* These ISO-C99 functions are implemented in libmingwex.a,
+ * or, in some cases, by inline stubs.
+ */
+__cdecl __MINGW_NOTHROW  int fwide (FILE *, int);
+__cdecl __MINGW_NOTHROW  int mbsinit (const mbstate_t *);
+
 #ifndef __NO_INLINE__
-__CRT_INLINE int __cdecl __MINGW_NOTHROW fwide(FILE* __UNUSED_PARAM(stream),
-                                              int mode)
-  {return mode;} /* Nothing to do  */
-__CRT_INLINE int __cdecl __MINGW_NOTHROW mbsinit(const mbstate_t* __UNUSED_PARAM(ps))
-  {return 1;}
+__CRT_INLINE __cdecl __MINGW_NOTHROW
+int fwide (FILE *__UNUSED_PARAM(stream), int mode)
+  { return mode; } /* Nothing to do  */
+
+__CRT_INLINE __cdecl __MINGW_NOTHROW
+int mbsinit (const mbstate_t *__UNUSED_PARAM(ps))
+  { return 1; }
 #endif
-wchar_t* __cdecl __MINGW_NOTHROW wmemset(wchar_t *, wchar_t, size_t);
-wchar_t* __cdecl __MINGW_NOTHROW wmemchr(const wchar_t*, wchar_t, size_t);
-int wmemcmp(const wchar_t*, const wchar_t *, size_t);
-wchar_t* __cdecl __MINGW_NOTHROW wmemcpy(wchar_t* __restrict__,
-                        const wchar_t* __restrict__,
-                        size_t);
-wchar_t* __cdecl __MINGW_NOTHROW wmemmove(wchar_t* s1, const wchar_t *, size_t);
-long long __cdecl __MINGW_NOTHROW wcstoll(const wchar_t * __restrict__,
-                         wchar_t** __restrict__, int);
-unsigned long long __cdecl __MINGW_NOTHROW wcstoull(const wchar_t * __restrict__,
-                           wchar_t ** __restrict__, int);
-#endif /* __NO_ISOCEXT */
 
-#ifndef __STRICT_ANSI__
-/* non-ANSI wide char functions from io.h, direct.h, sys/stat.h and locale.h
- * FIXME: these should be factored out, to avoid duplication.
+__cdecl __MINGW_NOTHROW  wchar_t *wmemset (wchar_t *, wchar_t, size_t);
+__cdecl __MINGW_NOTHROW  wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
+
+/* FIXME: what makes this so different from every other function
+ * in this group?  Why is it not qualified with the __cdecl, and
+ * __MINGW_NOTHROW attributes?
  */
-#ifndef _FSIZE_T_DEFINED
-typedef unsigned long  _fsize_t;
-#define _FSIZE_T_DEFINED
-#endif
+int wmemcmp (const wchar_t *, const wchar_t *, size_t);
 
-#ifndef _WFINDDATA_T_DEFINED
-struct _wfinddata_t {
-       unsigned        attrib;
-       time_t          time_create;    /* -1 for FAT file systems */
-       time_t          time_access;    /* -1 for FAT file systems */
-       time_t          time_write;
-       _fsize_t        size;
-       wchar_t         name[260];      /* may include spaces. */
-};
-struct _wfinddatai64_t {
-       unsigned    attrib;
-       time_t      time_create;
-       time_t      time_access;
-       time_t      time_write;
-       __int64     size;
-       wchar_t     name[260];
-};
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __wfinddata64_t {
-        unsigned    attrib;
-        __time64_t  time_create;
-        __time64_t  time_access;
-        __time64_t  time_write;
-/* 8 bytes are returned so it can't be _fsize_t */
-        __int64    size;
-        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
+__cdecl __MINGW_NOTHROW
+wchar_t *wmemcpy (wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
 
-/* Wide character versions. Also defined in io.h. */
-/* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also
-   applies to other wide character versions? */
-#if !defined (_WIO_DEFINED)
-#if defined (__MSVCRT__)
-#include <stdint.h>  /* For intptr_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 */
-
-#endif /* ! __STRICT_ANSI__ */
+__cdecl __MINGW_NOTHROW  wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
+
+__cdecl __MINGW_NOTHROW
+long long wcstoll (const wchar_t *__restrict__, wchar_t **__restrict__, int);
+
+__cdecl __MINGW_NOTHROW  unsigned long long wcstoull
+(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+#endif /* _ISOC99_SOURCE */
 
 _END_C_DECLS