4 * Declarations relating to support for wide characters; many are simply
5 * inherited by (sub-optimal) inclusion of other header files.
9 * Unattributed original source.
10 * Adapted by Rob Savoye <rob@cygnus.com>
11 * Copyright (C) 1997, 1999-2009, 2011, 2015, 2016, 2018-2020,
15 * Permission is hereby granted, free of charge, to any person obtaining a
16 * copy of this software and associated documentation files (the "Software"),
17 * to deal in the Software without restriction, including without limitation
18 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 * and/or sell copies of the Software, and to permit persons to whom the
20 * Software is furnished to do so, subject to the following conditions:
22 * The above copyright notice, this permission notice, and the following
23 * disclaimer shall be included in all copies or substantial portions of
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
29 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
32 * DEALINGS IN THE SOFTWARE.
36 #pragma GCC system_header
38 /* This header declares prototypes for wchar_t string functions, as are
39 * prescribed by ISO-C, but which MSVC also expects, (in contravention of
40 * ISO-C prescriptions), to find in <string.h>. To accommodate this MSVC
41 * anomaly, we make provision for <string.h> to include a selected subset
42 * of <wchar.h>; thus, we do not immediately define _WCHAR_T...
44 #ifndef __STRING_H_SOURCED__
45 /* ...but defer it until we have confirmed that this is NOT inclusion for
46 * only this subset of <wchar.h> declarations.
50 /* All MinGW headers are required to include <_mingw.h>; in the case of
51 * selective inclusion by <string.h>, we expect it to have already done
52 * so, but since that doesn't apply here, we must do it ourselves.
56 #ifndef __STRICT_ANSI__
57 /* MSDN says that isw* char classifications appear in both <wchar.h>,
58 * and in <wctype.h>. Although these <wctype.h> classifications are as
59 * prescribed by ISO-C, their exposure in <wchar.h> is not; nonetheless,
60 * we replicate them here, for MSDN conformity.
64 /* This is also necessary, to support the non-ANSI wchar.h declarations
65 * which MSDN identifies as being provided here.
67 # include <sys/types.h>
69 #endif /* !__STRICT_ANSI__ */
72 #define WCHAR_MAX 0xffff
74 #define WEOF (wchar_t)(0xffff)
77 #define __WCHAR_H_SOURCED__
78 /* ISO-C, POSIX, and Microsoft specify an overlap of content between
79 * <wchar.h> and other system header files; by inclusion of such other
80 * headers within this "__WCHAR_H_SOURCED__" scope, we may selectively
81 * retrieve the overlapping content, without requiring duplication of
82 * that content here; thus, from...
85 /* ...we obtain (possibly indirect) definitions and declarations for:
87 * macros NULL, FILENAME_MAX
88 * types size_t, wchar_t, wint_t, va_list (a.k.a. __VALIST), FILE
89 * types ssize_t, off_t, __off64_t, (conditionally, as needed)
91 * int fwprintf (FILE *, const wchar_t *, ...);
92 * int wprintf (const wchar_t *, ...);
93 * int vfwprintf (FILE *, const wchar_t *, __VALIST);
94 * int vwprintf (const wchar_t *, __VALIST);
95 * int snwprintf (wchar_t *, size_t, const wchar_t *, ...);
96 * int _snwprintf (wchar_t *, size_t, const wchar_t *, ...);
97 * int _vscwprintf (const wchar_t *, __VALIST);
98 * int _vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
99 * int vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
100 * int fwscanf (FILE *, const wchar_t *, ...);
101 * int wscanf (const wchar_t *, ...);
102 * int swscanf (const wchar_t *, const wchar_t *, ...);
103 * int vwscanf (const wchar_t *, __VALIST);
104 * int vfwscanf (FILE *, const wchar_t *, __VALIST);
105 * int vswscanf (const wchar_t *, const wchar_t *, __VALIST);
106 * wint_t fgetwc (FILE *);
107 * wint_t fputwc (wchar_t, FILE *);
108 * wint_t ungetwc (wchar_t, FILE *);
110 * The following pair of Microsoft functions conflict with their
111 * corresponding ISO-C prototypes; consequently they will not be
112 * declared when "__STRICT_ANSI__" checking is in effect:
114 * int swprintf (wchar_t *, const wchar_t *, ...);
115 * int vswprintf (wchar_t *, const wchar_t *, __VALIST);
117 * The following group of functions is specified by ISO-C, but
118 * their Microsoft implementations are available only if use of
119 * "__MSVCRT__" is specified:
121 * wchar_t * fgetws (wchar_t *, int, FILE *);
122 * int fputws (const wchar_t *, FILE *);
123 * wint_t getwc (FILE *);
124 * wint_t getwchar (void);
125 * wint_t putwc (wint_t, FILE *);
126 * wint_t putwchar (wint_t);
128 * The following group of functions is also dependent on use of
129 * "__MSVCRT__"; however, these are Microsoft specific, so they
130 * are not declared if "__STRICT_ANSI__" checking is specified:
132 * wchar_t * _getws (wchar_t *);
133 * int _putws (const wchar_t *);
134 * FILE * _wfdopen (int, const wchar_t *);
135 * FILE * _wfopen (const wchar_t *, const wchar_t *);
136 * FILE * _wfreopen (const wchar_t *, const wchar_t *, FILE *);
137 * FILE * _wfsopen (const wchar_t *, const wchar_t *, int);
138 * wchar_t * _wtmpnam (wchar_t *);
139 * wchar_t * _wtempnam (const wchar_t *, const wchar_t *);
140 * int _wrename (const wchar_t *, const wchar_t *);
141 * int _wremove (const wchar_t *);
142 * void _wperror (const wchar_t *);
143 * FILE * _wpopen (const wchar_t *, const wchar_t *);
146 * In similar fashion, from...
149 /* ...we obtain prototypes for universally supported functions:
151 * long wcstol (const wchar_t *, wchar_t **, int);
152 * unsigned long wcstoul (const wchar_t *, wchar_t **, int);
153 * double wcstod (const wchar_t *, wchar_t **);
155 * The following are Microsoft specific, and require MSCVRT.DLL,
156 * or any of its non-free derivatives; they are not available to
157 * applications which use CRTDLL.DLL:
159 * wchar_t *_wgetenv (const wchar_t *);
160 * int _wputenv (const wchar_t *);
161 * void _wsearchenv (const wchar_t *, const wchar_t *, wchar_t *);
162 * int _wsystem (const wchar_t *);
163 * void _wmakepath (wchar_t *, const wchar_t *, const wchar_t *,
164 * const wchar_t *, const wchar_t *
166 * void _wsplitpath (const wchar_t *, wchar_t *, wchar_t *,
167 * wchar_t *, wchar_t *
169 * wchar_t *_wfullpath (wchar_t *, const wchar_t *, size_t);
171 * ...with this pair requiring either WinXP (or later), or one of
172 * the non-free MSVC runtimes from MSVCR70.DLL onwards:
174 * __int64 _wcstoi64 (const wchar_t *, wchar_t **, int);
175 * unsigned __int64 _wcstoui64 (const wchar_t *, wchar_t **, int);
177 * ...and this pair requiring Win-Vista (or later), or a non-free
178 * MSVC runtime from MSVCR80.DLL onwards:
180 * __int64 _wcstoi64_l (const wchar_t *, wchar_t **, int, _locale_t);
181 * unsigned __int64 _wcstoui64_l (const wchar_t *, wchar_t **,
185 * ...while this pair are ISO-C99 standards, which are available
186 * in libmingwex.a, but not in any version of MSVCRT.DLL, (nor in
187 * any of its non-free derivatives prior to MSVCR120.DLL), nor in
190 * float wcstof (const wchar_t *restrict, wchar_t **restrict);
191 * long double wcstold (const wchar_t *restrict, wchar_t **restrict);
196 #ifndef __STRICT_ANSI__
197 /* ...when NOT compiling with "__STRICT_ANSI__" conformity checking,
201 /* ...we obtain prototypes for each of the following functions,
202 * (none of which are available when using CRTDLL.DLL):
204 * int _wchdir (const wchar_t *);
205 * wchar_t *_wgetcwd (wchar_t *, int);
206 * wchar_t *_wgetdcwd (int, wchar_t *, int);
207 * int _wmkdir (const wchar_t *);
208 * int _wrmdir (const wchar_t *);
213 #include "sys/stat.h"
214 /* ...we obtain function prototypes, and all associated data type
215 * definitions for this pair of actual functions, in all versions of
216 * MSVCRT.DLL, and its non-free derivatives preceding MSVCR80.DLL, (or
217 * inline replacement implementations for MSVCR80.DLL and later):
219 * int _wstat (const wchar_t *, struct _stat *);
220 * int _wstati64 (const wchar_t *, struct _stati64 *);
222 * ...this additional actual function, available in MSVCRT.DLL from
223 * Win2K onwards, or in non-free MSVCR61.DLL and again requiring an
224 * inline replacement from MSVCR80.DLL onwards:
226 * int _wstat64 (const wchar_t *, struct __stat64 *);
228 * ...and these actual functions, which are available only in non-free
229 * MSVCR80.DLL, and its later derivatives:
231 * int _wstat32 (const wchar_t *, struct __stat32 *);
232 * int _wstat32i64 (const wchar_t *, struct _stat32i64 *);
233 * int _wstat64i32 (const wchar_t *, struct _stat64i32 *);
239 /* ...we obtain, depending on active MSVCRT.DLL version conformity,
240 * or non-free run-time version selection, an appropriate subset of:
242 * wint_t _getwch (void);
243 * wint_t _getwche (void);
244 * wint_t _ungetwch (wint_t);
246 * ...and for non-free run-times from MSVCR80.DLL onwards only:
248 * wint_t _getwch_nolock (void);
249 * wint_t _getwche_nolock (void);
250 * wint_t _ungetwch_nolock (wint_t);
256 /* ...we obtain function prototypes for each of the following, which
257 * are available in all versions of MSVCRT.DLL, (and all its non-free
258 * derivatives), but are not supported by CRTDLL.DLL:
260 * int _waccess (const wchar_t *, int);
261 * int _wchmod (const wchar_t *, int);
262 * int _wcreat (const wchar_t *, int);
263 * int _wopen (const wchar_t *, int, ...);
264 * int _wsopen (const wchar_t *, int, int, ...);
265 * int _wunlink (const wchar_t *);
266 * wchar_t *_wmktemp (wchar_t *);
268 * ...and also function prototypes and definitions of all associated
269 * data types and manifest constants for the following, each of which
270 * is physically implemented in all versions of MSVCRT.DLL, and in each
271 * of its non-free variants prior to MSVCR80.DLL, or emulated by inline
272 * replacement functions for MSVCR80.DLL and later:
274 * intptr_t _wfindfirst (wchar_t *, struct _wfinddata_t *);
275 * int _wfindnext (intptr_t, struct _wfinddata_t *);
277 * intptr_t _wfindfirsti64 (wchar_t *, struct _wfinddatai64_t *);
278 * int _wfindnexti64 (intptr_t, struct _wfinddatai64_t *);
280 * ...this additional pair of functions, available in all versions of
281 * MSVCRT.DLL from Win2K, and non-free variants from MSVCR61.DLL:
283 * intptr_t _wfindfirst64 (wchar_t *, struct __wfinddata64_t *);
284 * int _wfindnext64 (intptr_t, struct __wfinddata64_t *);
286 * ...and these, which are only available in the non-free run-times
287 * from MSVCR80.DLL onwards:
289 * intptr_t _wfindfirst32 (wchar_t *, struct _wfinddata32_t *);
290 * int _wfindnext32 (intptr_t, struct _wfinddata32_t *);
292 * intptr_t _wfindfirst32i64 (wchar_t *, struct _wfinddata32i64_t *);
293 * int _wfindnext32i64 (intptr_t, struct _wfinddata32i64_t *);
295 * intptr_t _wfindfirst64i32 (wchar_t *, struct _wfinddata64i32_t *);
296 * int _wfindnext64i32 (intptr_t, struct _wfinddata64i32_t *);
298 * Additionally, although Microsoft's <wchar.h> may not declare it,
299 * this is required to complement all variants of the _wfindfirst()
300 * and _wfindnext() API, so we also declare the prototype for:
302 * int _findclose (intptr_t);
304 #endif /* !__STRICT_ANSI__ */
309 /* ...we always obtain an opaque forward declaration of:
313 * ...and prototype declarations for the following ISO-C99 function,
314 * (which is always provided):
316 * size_t wcsftime (wchar_t *, size_t, const wchar_t *, const struct tm *);
318 * ...together with the following non-ISO-C functions, (which are
319 * NOT exposed when "__STRICT_ANSI__" checking is enabled):
321 * wchar_t *_wctime (const time_t *);
322 * wchar_t *_wasctime (const struct tm *);
323 * wchar_t *_wstrdate (wchar_t *);
324 * wchar_t *_wstrtime (wchar_t *);
326 * Of the preceding group, we also note that, while it remains in
327 * all versions of MSVCRT.DLL, (using a strictly 32-bit data type
328 * to represent its "time_t" argument), the _wctime() function is
329 * NOT present in MSVCR80.DLL, and later versions of the non-free
330 * MSVC runtime libraries, in which it is replaced by either of:
332 * wchar_t *_wctime64 (const __time64_t *);
333 * wchar_t *_wctime32 (const __time32_t *);
335 * ...with the actual replacement being chosen at compile time, on
336 * the basis of the user specified "_USE_32BIT_TIME_T" feature test
337 * macro, (a Microsoft specific, brain damaged concept), which maps
338 * _wctime() itself, as an in-line alias for its corresponding
339 * replacement library function.
342 #ifndef __STRICT_ANSI__
343 /* Once again, when NOT compiling with "__STRICT_ANSI__" conformity
347 /* ...we obtain the declaration for:
349 * wchar_t *_wsetlocale (int, const wchar_t *);
355 /* ...we obtain function prototypes for:
357 * intptr_t _wexecl (const wchar_t *, const wchar_t *, ...);
358 * intptr_t _wexecle (const wchar_t *, const wchar_t *, ...);
359 * intptr_t _wexeclp (const wchar_t *, const wchar_t *, ...);
360 * intptr_t _wexeclpe (const wchar_t *, const wchar_t *, ...);
362 * intptr_t _wexecv (const wchar_t *, const wchar_t * const *);
363 * intptr_t _wexecve (
364 * const wchar_t *, const wchar_t * const *, const wchar_t * const *
366 * intptr_t _wexecvp (const wchar_t *, const wchar_t * const *);
367 * intptr_t _wexecvpe (
368 * const wchar_t *, const wchar_t * const *, const wchar_t * const *
371 * intptr_t _wspawnl (int, const wchar_t *, const wchar_t *, ...);
372 * intptr_t _wspawnle (int, const wchar_t *, const wchar_t *, ...);
373 * intptr_t _wspawnlp (int, const wchar_t *, const wchar_t *, ...);
374 * intptr_t _wspawnlpe (int, const wchar_t *, const wchar_t *, ...);
376 * intptr_t _wspawnv (int, const wchar_t *, const wchar_t * const *);
377 * intptr_t _wspawnve (
378 * int, const wchar_t *, const wchar_t * const *, const wchar_t * const *
380 * intptr_t _wspawnvp (int, const wchar_t *, const wchar_t * const *);
381 * intptr_t _wspawnvpe (
382 * int, const wchar_t *, const wchar_t * const *, const wchar_t * const *
386 #endif /* !__STRICT_ANSI__ */
390 /* Wide character string functions must be specified here, as required
391 * by the ISO-C Standard; however, MSVC contravenes this standard by also
392 * requiring them to appear in <string.h>. We declare them here, where
393 * they rightfully belong, but we also arrange for them to be available
394 * for selective inclusion by <string.h>; to facilitate this, we must
395 * change the declarative condition...
397 #endif /* ! RC_INVOKED */
398 #endif /* !__STRING_H_SOURCED__ */
399 #if ! defined RC_INVOKED
400 #if !(defined _WCHAR_H && (defined _STRING_H && ! defined __STRICT_ANSI__))
401 /* ...such that these declarations are exposed when either _WCHAR_H is defined,
402 * or when _STRING_H is defined and __STRICT_ANSI__ is not, but NOT when BOTH of
403 * these apply, since that indicates that this group of declarations has already
404 * been processed, during partial inclusion of <wchar.h> by <string.h>, whereas
405 * we are now including <wchar.h> in its own right.
408 * Wide character versions of the ISO-C standard string functions.
410 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcscat (wchar_t *, const wchar_t *);
411 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcschr (const wchar_t *, wchar_t);
412 _CRTIMP __cdecl __MINGW_NOTHROW int wcscmp (const wchar_t *, const wchar_t *);
413 _CRTIMP __cdecl __MINGW_NOTHROW int wcscoll (const wchar_t *, const wchar_t *);
414 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcscpy (wchar_t *, const wchar_t *);
415 _CRTIMP __cdecl __MINGW_NOTHROW size_t wcscspn (const wchar_t *, const wchar_t *);
416 _CRTIMP __cdecl __MINGW_NOTHROW size_t wcslen (const wchar_t *);
417 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsncat (wchar_t *, const wchar_t *, size_t);
418 _CRTIMP __cdecl __MINGW_NOTHROW int wcsncmp (const wchar_t *, const wchar_t *, size_t);
419 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsncpy (wchar_t *, const wchar_t *, size_t);
420 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
421 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsrchr (const wchar_t *, wchar_t);
422 _CRTIMP __cdecl __MINGW_NOTHROW size_t wcsspn (const wchar_t *, const wchar_t *);
423 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsstr (const wchar_t *, const wchar_t *);
424 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcstok (wchar_t *, const wchar_t *);
425 _CRTIMP __cdecl __MINGW_NOTHROW size_t wcsxfrm (wchar_t *, const wchar_t *, size_t);
427 #ifndef __STRICT_ANSI__
428 /* UTF-16LE versions of non-ANSI string functions provided by CRTDLL.DLL
430 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsdup (const wchar_t *);
431 _CRTIMP __cdecl __MINGW_NOTHROW int _wcsicmp (const wchar_t *, const wchar_t *);
432 _CRTIMP __cdecl __MINGW_NOTHROW int _wcsicoll (const wchar_t *, const wchar_t *);
433 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcslwr (wchar_t*);
434 _CRTIMP __cdecl __MINGW_NOTHROW int _wcsnicmp (const wchar_t *, const wchar_t *, size_t);
435 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsnset (wchar_t *, wchar_t, size_t);
436 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsrev (wchar_t *);
437 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsset (wchar_t *, wchar_t);
438 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsupr (wchar_t *);
441 _CRTIMP __cdecl __MINGW_NOTHROW int _wcsncoll (const wchar_t *, const wchar_t *, size_t);
442 _CRTIMP __cdecl __MINGW_NOTHROW int _wcsnicoll (const wchar_t *, const wchar_t *, size_t);
444 /* A wide character counterpart to the strerror() API was introduced in
445 * MSVCR70.DLL, and subsequently back-ported to MSVCRT.DLL in WinXP.
447 #if __MSVCRT_VERSION__ >= __MSVCR70_DLL || NTDDI_VERSION >= NTDDI_WINXP
449 * These are are the wide character counterparts to the strerror()
450 * function itself, and the _strerror() function, respectively.
452 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcserror (int);
453 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *__wcserror (const wchar_t *);
455 #endif /* MSVCR70.DLL || WinXP */
456 #endif /* __MSVCRT__ */
458 /* MSVCRT.DLL provides neither _wcscmpi() nor wcscmpi(); the heritage
459 * is uncertain, but for the convenience, (and portability), of legacy
460 * applications which assume wcscmpi() should be available:
462 #define _wcscmpi _wcsicmp
463 int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t *, const wchar_t *);
465 #ifndef __NO_INLINE__
466 __CRT_ALIAS __JMPSTUB__(( FUNCTION = wcscmpi, REMAPPED = _wcsicmp ))
467 int wcscmpi (const wchar_t *__ws1, const wchar_t *__ws2)
468 { return _wcsicmp (__ws1, __ws2); }
469 #endif /* __NO_INLINE__ */
472 /* Older CRTDLL.DLL versions may have provided these alternatively named
473 * functions; we continue to support them, via the OLDNAME libraries:
475 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsdup (const wchar_t *);
476 _CRTIMP __cdecl __MINGW_NOTHROW int wcsicmp (const wchar_t *, const wchar_t *);
477 _CRTIMP __cdecl __MINGW_NOTHROW int wcsicoll (const wchar_t *, const wchar_t *);
478 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcslwr (wchar_t *);
479 _CRTIMP __cdecl __MINGW_NOTHROW int wcsnicmp (const wchar_t *, const wchar_t *, size_t);
480 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsnset (wchar_t *, wchar_t, size_t);
481 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsrev (wchar_t *);
482 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsset (wchar_t *, wchar_t);
483 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsupr (wchar_t *);
485 #endif /* !_NO_OLDNAMES */
486 #endif /* !__STRICT_ANSI__ */
488 #if _POSIX_C_SOURCE >= 200809L
489 #if __MSVCRT_VERSION__ >= __MSVCR80_DLL
490 /* MSVCR80.DLL adds a (mostly) POSIX.1-2008 conforming wcsnlen(); (it's
491 * also available in MSVCRT.DLL from _WIN32_WINNT_VISTA onwards, but we
492 * pretend otherwise, since recent GCC will try to use the function when
493 * it can be found in libmsvcrt.a, so breaking it for use on WinXP and
496 #ifndef __STRICT_ANSI__ /* N.B.: this is not an ISO-C function */
497 _CRTIMP __cdecl __MINGW_NOTHROW char *wcsnlen (const wchar_t *, size_t);
500 #else /* MSVCRT.DLL || pre-MSVCR80.DLL */
501 /* Emulation, to support recent POSIX.1; we prefer this for ALL versions
502 * of MSVCRT.DLL, (even those which already provide wcsnlen()); to avoid
503 * the GCC breakage noted above. (Note that we implement wcsnlen() with
504 * the alternative external name, __mingw_wcsnlen() in libmingwex.a, to
505 * avoid possible link time collision with MSVCR80.DLL's implementation,
506 * then map this to wcsnlen() via a __CRT_ALIAS, with stubs designated
507 * for linking from within the appropriate oldname libraries.
509 extern size_t __mingw_wcsnlen (const wchar_t *, size_t);
511 __JMPSTUB__(( LIB=coldname; FUNCTION=wcsnlen ))
512 __CRT_ALIAS size_t wcsnlen (const wchar_t *__text, size_t __maxlen)
513 { return __mingw_wcsnlen (__text, __maxlen); }
515 #endif /* MSVCRT.DLL || pre-MSVCR80.DLL */
516 #endif /* _POSIX_C_SOURCE >= 200809L */
518 /* This completes the set of declarations which are to be duplicated by
519 * inclusion of <string.h>; revert the declarative condition, to make it
520 * specific to <wchar.h> alone.
522 #endif /* !(_WCHAR_H && (_STRING_H && !__STRICT_ANSI__)) */
523 #endif /* ! RC_INVOKED */
525 #if defined _WCHAR_H && ! defined RC_INVOKED
526 #ifndef __STRICT_ANSI__
527 typedef wchar_t _Wint_t;
530 typedef int mbstate_t;
532 /* The following multi-byte character conversion functions have been
533 * implemented by Microsoft, in non-free MSVCR80.DLL and later, (and
534 * maybe also in some earlier non-free DLLs, such as MSVCP60.DLL and
535 * later); they are also available in MSVCRT.DLL, from Vista onward,
536 * but to provide continuing support for earlier Windows versions,
537 * we invoke them via MinGW specific wrappers, defined below.
539 __cdecl __MINGW_NOTHROW wint_t btowc (int);
540 __cdecl __MINGW_NOTHROW int wctob (wint_t);
542 __cdecl __MINGW_NOTHROW size_t mbrlen
543 (const char *__restrict__, size_t, mbstate_t *__restrict__);
545 __cdecl __MINGW_NOTHROW size_t mbrtowc
546 (wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
548 __cdecl __MINGW_NOTHROW size_t mbsrtowcs
549 (wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
551 __cdecl __MINGW_NOTHROW size_t wcrtomb
552 (char * __restrict__, wchar_t, mbstate_t *__restrict__);
554 __cdecl __MINGW_NOTHROW size_t wcsrtombs
555 (char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
557 /* To provide support for the above, on legacy Windows versions,
558 * we implement fall back wrappers in libmingwex.a; each of these
559 * will delegate to the corresponding Microsoft implementation, if
560 * it exists in the process address space; otherwise, execution
561 * will fall back to a MinGW implementation...
563 __cdecl __MINGW_NOTHROW size_t __msvcrt_mbrlen
564 (const char *__restrict__, size_t, mbstate_t *__restrict__);
566 __cdecl __MINGW_NOTHROW size_t __msvcrt_mbrtowc
567 (wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
569 __cdecl __MINGW_NOTHROW size_t __msvcrt_mbsrtowcs
570 (wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
572 __cdecl __MINGW_NOTHROW size_t __msvcrt_wcrtomb
573 (char * __restrict__, wchar_t, mbstate_t *__restrict__);
575 __cdecl __MINGW_NOTHROW size_t __msvcrt_wcsrtombs
576 (char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
578 /* ...whereas, these alternatives will always invoke the MinGW
579 * fall back implementations, without considering any possible
580 * reference to MSVCRT.DLL or MSVCR80.DLL implementations.
582 __cdecl __MINGW_NOTHROW size_t __mingw_mbrlen
583 (const char *__restrict__, size_t, mbstate_t *__restrict__);
585 __cdecl __MINGW_NOTHROW size_t __mingw_mbrtowc
586 (wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
588 __cdecl __MINGW_NOTHROW size_t __mingw_mbsrtowcs
589 (wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
591 __cdecl __MINGW_NOTHROW size_t __mingw_wcrtomb
592 (char * __restrict__, wchar_t, mbstate_t *__restrict__);
594 __cdecl __MINGW_NOTHROW size_t __mingw_wcsrtombs
595 (char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
597 #if __MSVCRT_VERSION__ < __MSVCR80_DLL
598 /* FIXME: Maybe consider these mappings, even for linking with the
599 * non-free MSVCR80.DLL, and its descendants.
601 * For linking with all versions of MSVCRT.DLL, and with non-free
602 * alternatives predating MSVCR80.DLL, we enforce inline mapping to
603 * the libmingwex.a implementations, (which will delegate the calls
604 * to the Microsoft DLL implementations, when they are available).
606 __CRT_ALIAS __cdecl __MINGW_NOTHROW size_t mbrlen
607 (const char *__mbc, size_t __n, mbstate_t *__ps)
608 { return __msvcrt_mbrlen( __mbc, __n, __ps ); }
610 __CRT_ALIAS __cdecl __MINGW_NOTHROW size_t mbrtowc
611 (wchar_t *__wc, const char *__mbc, size_t __n, mbstate_t *__ps)
612 { return __msvcrt_mbrtowc( __wc, __mbc, __n, __ps ); }
614 __CRT_ALIAS __cdecl __MINGW_NOTHROW size_t mbsrtowcs
615 (wchar_t *__wcs, const char **__mbs, size_t __n, mbstate_t *__ps)
616 { return __msvcrt_mbsrtowcs( __wcs, __mbs, __n, __ps ); }
618 __CRT_ALIAS __cdecl __MINGW_NOTHROW size_t wcrtomb
619 (char * __mbc, wchar_t __wc, mbstate_t *__ps)
620 { return __msvcrt_wcrtomb(__mbc, __wc, __ps); }
622 __CRT_ALIAS __cdecl __MINGW_NOTHROW size_t wcsrtombs
623 (char *__mbs, const wchar_t **__wcs, size_t __len, mbstate_t *__ps)
624 { return __msvcrt_wcsrtombs(__mbs, __wcs, __len, __ps); }
626 #endif /* ! MSVCR80.DLL or later */
628 #if defined _ISOC99_SOURCE || defined __cplusplus
629 /* These ISO-C99 functions are implemented in libmingwex.a,
630 * or, in some cases, as inline stubs; while provided as MinGW
631 * extensions to support ISO-C99, they are also required by
634 __cdecl __MINGW_NOTHROW int fwide (FILE *, int);
635 __cdecl __MINGW_NOTHROW int mbsinit (const mbstate_t *);
637 #ifndef __NO_INLINE__
638 __CRT_INLINE __cdecl __MINGW_NOTHROW
639 int fwide (FILE *__UNUSED_PARAM(stream), int mode)
640 { return mode; } /* Nothing to do */
642 __CRT_INLINE __cdecl __MINGW_NOTHROW
643 int mbsinit (const mbstate_t *__UNUSED_PARAM(ps))
647 __cdecl __MINGW_NOTHROW wchar_t *wmemset (wchar_t *, wchar_t, size_t);
648 __cdecl __MINGW_NOTHROW wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
650 /* FIXME: what makes this so different from every other function
651 * in this group? Why is it not qualified with the __cdecl, and
652 * __MINGW_NOTHROW attributes?
654 int wmemcmp (const wchar_t *, const wchar_t *, size_t);
656 __cdecl __MINGW_NOTHROW
657 wchar_t *wmemcpy (wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
659 __cdecl __MINGW_NOTHROW wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
661 __cdecl __MINGW_NOTHROW
662 long long wcstoll (const wchar_t *__restrict__, wchar_t **__restrict__, int);
664 __cdecl __MINGW_NOTHROW unsigned long long wcstoull
665 (const wchar_t *__restrict__, wchar_t **__restrict__, int);
666 #endif /* _ISOC99_SOURCE */
670 #undef __WCHAR_H_SOURCED__
671 #endif /* _WCHAR_H && ! RC_INVOKED */
672 #endif /* !_WCHAR_H: $RCSfile$: end of file */