4 * ANSI/POSIX + Microsoft compatible standard library function prototypes,
5 * associated macros, and manifest constant definitions.
9 * Written by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
10 * Copyright (C) 1997-2009, 2011, 2014-2016, MinGW.org Project.
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
20 * The above copyright notice, this permission notice, and the following
21 * disclaimer shall be included in all copies or substantial portions of
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
30 * DEALINGS IN THE SOFTWARE.
34 #pragma GCC system_header
36 /* Some of the content of this header is made selectively accessible,
37 * when indirectly included via <wchar.h>; only when we have established
38 * that this inclusion is NOT via this selective method...
40 #ifndef __WCHAR_H_SOURCED__
41 /* ...do we define the repeat inclusion guard for <stdlib.h> itself.
45 /* All MinGW headers must include <_mingw.h>; if included via <wchar.h>,
46 * we assume that this has been done already, otherwise we must attend to
53 #define __need_wchar_t
56 #endif /* RC_INVOKED */
58 /* RAND_MAX is the maximum value that may be returned by rand.
59 * The minimum is zero.
61 #define RAND_MAX 0x7FFF
63 /* These values may be used as exit status codes.
65 #define EXIT_SUCCESS 0
66 #define EXIT_FAILURE 1
68 /* Definitions for path name functions.
69 * NOTE: All of these values have simply been chosen to be conservatively
70 * high. Remember that with long file names we can no longer depend on
71 * extensions being short.
73 #ifndef __STRICT_ANSI__
76 #define MAX_PATH (260)
79 #define _MAX_PATH MAX_PATH
80 #define _MAX_DRIVE (3)
82 #define _MAX_FNAME 256
85 #endif /* !__STRICT_ANSI__ */
86 #endif /* !__WCHAR_H_SOURCED__ */
93 #if ! defined __STRICT_ANSI__
94 /* This seems like a convenient place to declare these variables, which
95 * give programs using WinMain (or main for that matter) access to main-ish
96 * argc and argv. environ is a pointer to a table of environment variables.
97 * NOTE: Strings in _argv and environ are ANSI strings.
103 /* Imports from the runtime DLL, for the above variables.
105 extern __cdecl __MINGW_NOTHROW int *__p___argc(void);
106 extern __cdecl __MINGW_NOTHROW char ***__p___argv(void);
107 extern __cdecl __MINGW_NOTHROW wchar_t ***__p___wargv(void);
109 #define __argc (*__p___argc())
110 #define __argv (*__p___argv())
111 #define __wargv (*__p___wargv())
113 #else /* ! __MSVCRT__ */
115 #ifndef __DECLSPEC_SUPPORTED
117 extern int *_imp____argc_dll;
118 extern char ***_imp____argv_dll;
120 #define __argc (*_imp____argc_dll)
121 #define __argv (*_imp____argv_dll)
123 #else /* __DECLSPEC_SUPPORTED */
125 __MINGW_IMPORT int __argc_dll;
126 __MINGW_IMPORT char **__argv_dll;
128 #define __argc __argc_dll
129 #define __argv __argv_dll
131 #endif /* __DECLSPEC_SUPPORTED */
133 #endif /* __MSVCRT__ */
134 #endif /* __STRICT_ANSI__ */
137 /* FIXME: also defined in <ctype.h>; should be factored out.
139 #ifdef __DECLSPEC_SUPPORTED
141 # define MB_CUR_MAX __mb_cur_max
142 __MINGW_IMPORT int __mb_cur_max;
143 # else /* ! __MSVCRT__ */
144 # define MB_CUR_MAX __mb_cur_max_dll
145 __MINGW_IMPORT int __mb_cur_max_dll;
146 # endif /* ! __MSVCRT__ */
148 #else /* ! __DECLSPEC_SUPPORTED */
150 extern int* _imp____mb_cur_max;
151 # define MB_CUR_MAX (*_imp____mb_cur_max)
152 # else /* ! __MSVCRT__ */
153 extern int* _imp____mb_cur_max_dll;
154 # define MB_CUR_MAX (*_imp____mb_cur_max_dll)
155 # endif /* ! __MSVCRT__ */
156 #endif /* __DECLSPEC_SUPPORTED */
157 #endif /* MB_CUR_MAX */
159 /* FIXME: Nominally in <errno.h>, Microsoft likes to declare errno
160 * in <stdlib.h> as well; we should factor this out.
166 _CRTIMP __cdecl __MINGW_NOTHROW int *_errno(void);
167 # define errno (*_errno())
169 _CRTIMP __cdecl __MINGW_NOTHROW int *__doserrno(void);
170 #define _doserrno (*__doserrno())
172 #if !defined (__STRICT_ANSI__)
173 /* Use environ from the DLL, not as a global.
176 # define _environ (*__p__environ())
177 extern _CRTIMP __cdecl __MINGW_NOTHROW char ***__p__environ(void);
178 # define _wenviron (*__p__wenviron())
179 extern _CRTIMP __cdecl __MINGW_NOTHROW wchar_t ***__p__wenviron(void);
181 #else /* ! __MSVCRT__ */
182 # ifndef __DECLSPEC_SUPPORTED
183 # define _environ (*_imp___environ_dll)
184 extern char ***_imp___environ_dll;
186 # else /* __DECLSPEC_SUPPORTED */
187 # define _environ _environ_dll
188 __MINGW_IMPORT char ** _environ_dll;
189 # endif /* __DECLSPEC_SUPPORTED */
190 #endif /* ! __MSVCRT__ */
192 #define environ _environ
195 /* One of the MSVCRTxx libraries */
197 #ifndef __DECLSPEC_SUPPORTED
198 # define sys_nerr (*_imp___sys_nerr)
199 extern int *_imp___sys_nerr;
201 #else /* __DECLSPEC_SUPPORTED */
202 __MINGW_IMPORT int _sys_nerr;
205 # define sys_nerr _sys_nerr
207 #endif /* __DECLSPEC_SUPPORTED */
209 #else /* ! __MSVCRT__ */
210 /* CRTDLL run time library */
212 #ifndef __DECLSPEC_SUPPORTED
213 extern int* _imp___sys_nerr_dll;
214 # define sys_nerr (*_imp___sys_nerr_dll)
215 #else /* __DECLSPEC_SUPPORTED */
216 __MINGW_IMPORT int _sys_nerr_dll;
217 # define sys_nerr _sys_nerr_dll
218 #endif /* __DECLSPEC_SUPPORTED */
220 #endif /* ! __MSVCRT__ */
222 #ifndef __DECLSPEC_SUPPORTED
223 #define sys_errlist (*_imp___sys_errlist)
224 extern char ***_imp__sys_errlist;
226 #else /* __DECLSPEC_SUPPORTED */
227 __MINGW_IMPORT char *_sys_errlist[];
230 #define sys_errlist _sys_errlist
232 #endif /* __DECLSPEC_SUPPORTED */
234 /* OS version and such constants.
236 #ifdef __MSVCRT__ /* MSVCRT.DLL and MSVCRxx.DLL variants */
238 extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__osver(void);
239 extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__winver(void);
240 extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__winmajor(void);
241 extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__winminor(void);
243 #ifndef __DECLSPEC_SUPPORTED
244 # define _osver (*__p__osver())
245 # define _winver (*__p__winver())
246 # define _winmajor (*__p__winmajor())
247 # define _winminor (*__p__winminor())
249 #else /* __DECLSPEC_SUPPORTED */
250 __MINGW_IMPORT unsigned int _osver;
251 __MINGW_IMPORT unsigned int _winver;
252 __MINGW_IMPORT unsigned int _winmajor;
253 __MINGW_IMPORT unsigned int _winminor;
254 #endif /* __DECLSPEC_SUPPORTED */
256 #else /* ! __MSVCRT__; thus CRTDLL */
257 #ifndef __DECLSPEC_SUPPORTED
259 #define _osver (*_imp___osver_dll)
260 #define _winver (*_imp___winver_dll)
261 #define _winmajor (*_imp___winmajor_dll)
262 #define _winminor (*_imp___winminor_dll)
264 extern unsigned int *_imp___osver_dll;
265 extern unsigned int *_imp___winver_dll;
266 extern unsigned int *_imp___winmajor_dll;
267 extern unsigned int *_imp___winminor_dll;
269 #else /* __DECLSPEC_SUPPORTED */
271 #define _osver _osver_dll
272 #define _winver _winver_dll
273 #define _winmajor _winmajor_dll
274 #define _winminor _winminor_dll
276 __MINGW_IMPORT unsigned int _osver_dll;
277 __MINGW_IMPORT unsigned int _winver_dll;
278 __MINGW_IMPORT unsigned int _winmajor_dll;
279 __MINGW_IMPORT unsigned int _winminor_dll;
281 #endif /* __DECLSPEC_SUPPORTED */
284 #if defined __MSVCRT__
285 /* Although _pgmptr is exported as DATA, be safe and use the access
286 * function __p__pgmptr() to get it.
288 #define _pgmptr (*__p__pgmptr())
289 _CRTIMP __cdecl __MINGW_NOTHROW char **__p__pgmptr(void);
291 #define _wpgmptr (*__p__wpgmptr())
292 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t **__p__wpgmptr(void);
294 #else /* ! __MSVCRT__; thus CRTDLL */
296 # ifndef __DECLSPEC_SUPPORTED
297 # define _pgmptr (*_imp___pgmptr_dll)
298 extern char **__imp__pgmptr_dll;
300 # else /* __DECLSPEC_SUPPORTED */
302 # define _pgmptr _pgmptr_dll
303 __MINGW_IMPORT char *_pgmptr_dll;
304 /* no wide version in CRTDLL */
306 # endif /* __DECLSPEC_SUPPORTED */
309 /* This variable determines the default file mode.
310 * TODO: Which flags work?
312 #if !defined (__DECLSPEC_SUPPORTED) || defined (__IN_MINGW_RUNTIME)
315 #define _fmode (*_imp___fmode)
316 extern int *_imp___fmode;
319 #define _fmode (*_imp___fmode_dll)
320 extern int *_imp___fmode_dll;
323 #else /* __DECLSPEC_SUPPORTED */
325 __MINGW_IMPORT int _fmode;
327 #else /* ! __MSVCRT__ */
328 #define _fmode _fmode_dll
329 __MINGW_IMPORT int _fmode_dll;
331 #endif /* !__MSVCRT__ */
332 #endif /* __DECLSPEC_SUPPORTED */
333 #endif /* !__STRICT_ANSI__ */
335 _CRTIMP __cdecl __MINGW_NOTHROW int atoi (const char *);
336 _CRTIMP __cdecl __MINGW_NOTHROW long atol (const char *);
338 _CRTIMP __cdecl __MINGW_NOTHROW double strtod (const char *, char **);
339 _CRTIMP __cdecl __MINGW_NOTHROW double atof (const char *);
341 #if !defined (__STRICT_ANSI__)
342 _CRTIMP __cdecl __MINGW_NOTHROW double _wtof (const wchar_t *);
343 _CRTIMP __cdecl __MINGW_NOTHROW int _wtoi (const wchar_t *);
344 _CRTIMP __cdecl __MINGW_NOTHROW long _wtol (const wchar_t *);
347 #if __USE_MINGW_ANSI_STDIO
348 /* Microsoft's strtod() and atof() implementations, (in MSVCRT.DLL),
349 * mishandle infinities and NaNs; on the basis that this conditional
350 * exposes a more ISO-C conforming printf() I/O family implementaion,
351 * we substitute a similarly more conforming implementation for each
352 * of this pair of (somewhat related) functions.
354 * Note that we provide neither __JMPSTUB__ nor __LIBIMPL__ external
355 * equivalents for either of these two inline functions, because they
356 * would conflict with the runtime DLL implementations; users needing
357 * an address reference for either must provide an equivalent of the
358 * inline implementation, as non-inlined within their own code.
360 extern __cdecl __MINGW_NOTHROW
361 double __strtod (const char *__restrict__, char **__restrict__);
363 __CRT_ALIAS __cdecl __MINGW_NOTHROW
364 double strtod (const char *__restrict__ __nptr, char **__restrict__ __endptr)
365 { return __strtod( __nptr, __endptr ); }
367 __CRT_ALIAS __cdecl __MINGW_NOTHROW
368 double atof (const char *__nptr) { return __strtod( __nptr, NULL ); }
370 #endif /* __USE_MINGW_ANSI_STDIO */
372 #ifdef _ISOC99_SOURCE
373 /* Irrespective of requested standards conformity, where MSVCRT.DLL
374 * falls short, ISO-C99 offers this pair of alternative return type
375 * specific variants of strtod(), which MSVCRT.DLL does not, but we
376 * do, in libmingwex.a:
378 __cdecl __MINGW_NOTHROW
379 float strtof (const char *__restrict__, char **__restrict__);
381 __cdecl __MINGW_NOTHROW
382 long double strtold (const char *__restrict__, char **__restrict__);
383 #endif /* _ISOC99_SOURCE */
385 _CRTIMP __cdecl __MINGW_NOTHROW long strtol (const char *, char **, int);
386 _CRTIMP __cdecl __MINGW_NOTHROW unsigned long strtoul (const char *, char **, int);
388 #endif /* _STDLIB_H only */
389 #if ! (defined _STDLIB_H && defined _WCHAR_H)
390 /* Prototypes which are to be declared both here, in <stdlib.h>,
391 * and also in <wchar.h>; declare them here, such that they may be
392 * selectively included by <wchar.h>.
394 _CRTIMP __cdecl __MINGW_NOTHROW
395 long wcstol (const wchar_t *, wchar_t **, int);
397 _CRTIMP __cdecl __MINGW_NOTHROW
398 unsigned long wcstoul (const wchar_t *, wchar_t **, int);
400 _CRTIMP __cdecl __MINGW_NOTHROW double wcstod (const wchar_t *, wchar_t **);
402 #ifdef _ISOC99_SOURCE
403 /* Variants on wcstod(), specified by ISO-C99; once again, MSVCRT.DLL
404 * doesn't have them, but we offer them in libmingwex.a
406 __cdecl __MINGW_NOTHROW
407 float wcstof (const wchar_t *__restrict__, wchar_t **__restrict__);
409 __cdecl __MINGW_NOTHROW
410 long double wcstold (const wchar_t *__restrict__, wchar_t **__restrict__);
411 #endif /* _ISOC99_SOURCE */
414 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wgetenv (const wchar_t *);
415 _CRTIMP __cdecl __MINGW_NOTHROW int _wputenv (const wchar_t *);
417 _CRTIMP __cdecl __MINGW_NOTHROW
418 void _wsearchenv (const wchar_t *, const wchar_t *, wchar_t *);
420 _CRTIMP __cdecl __MINGW_NOTHROW int _wsystem (const wchar_t *);
422 _CRTIMP __cdecl __MINGW_NOTHROW
423 void _wmakepath (wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
427 _CRTIMP __cdecl __MINGW_NOTHROW
428 void _wsplitpath (const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
430 _CRTIMP __cdecl __MINGW_NOTHROW
431 wchar_t *_wfullpath (wchar_t *, const wchar_t *, size_t);
433 #endif /* __MSVCRT__ */
434 #endif /* _STDLIB_H || _WCHAR_H */
436 #ifdef _STDLIB_H /* <stdlib.h> only */
437 _CRTIMP __cdecl __MINGW_NOTHROW size_t wcstombs (char *, const wchar_t *, size_t);
438 _CRTIMP __cdecl __MINGW_NOTHROW int wctomb (char *, wchar_t);
440 _CRTIMP __cdecl __MINGW_NOTHROW int mblen (const char *, size_t);
441 _CRTIMP __cdecl __MINGW_NOTHROW size_t mbstowcs (wchar_t *, const char *, size_t);
442 _CRTIMP __cdecl __MINGW_NOTHROW int mbtowc (wchar_t *, const char *, size_t);
444 _CRTIMP __cdecl __MINGW_NOTHROW int rand (void);
445 _CRTIMP __cdecl __MINGW_NOTHROW void srand (unsigned int);
447 _CRTIMP __cdecl __MINGW_NOTHROW void *calloc (size_t, size_t) __MINGW_ATTRIB_MALLOC;
448 _CRTIMP __cdecl __MINGW_NOTHROW void *malloc (size_t) __MINGW_ATTRIB_MALLOC;
449 _CRTIMP __cdecl __MINGW_NOTHROW void *realloc (void *, size_t);
450 _CRTIMP __cdecl __MINGW_NOTHROW void free (void *);
451 _CRTIMP __cdecl __MINGW_NOTHROW void abort (void) __MINGW_ATTRIB_NORETURN;
452 _CRTIMP __cdecl __MINGW_NOTHROW void exit (int) __MINGW_ATTRIB_NORETURN;
454 /* Note: this is in startup code, not imported directly from the runtime DLL
456 int __cdecl __MINGW_NOTHROW atexit (void (*)(void));
458 _CRTIMP __cdecl __MINGW_NOTHROW int system (const char *);
459 _CRTIMP __cdecl __MINGW_NOTHROW char *getenv (const char *);
461 /* bsearch() and qsort() are declared both here, in <stdlib.h>, and in
462 * non-ANSI header <search.h>; we reproduce these declarations in both,
463 * with no attempt to guard them, so the compiler may verify that they
464 * are consistent, if both headers are included.
466 _CRTIMP __cdecl void *bsearch
467 (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
469 _CRTIMP __cdecl void qsort
470 (void *, size_t, size_t, int (*)(const void *, const void *));
472 _CRTIMP __cdecl __MINGW_NOTHROW int abs (int) __MINGW_ATTRIB_CONST;
473 _CRTIMP __cdecl __MINGW_NOTHROW long labs (long) __MINGW_ATTRIB_CONST;
475 /* div_t and ldiv_t are structures used to return the results of div()
476 * and ldiv() functions.
478 * NOTE: div() and ldiv() appear not to work correctly unless
479 * -fno-pcc-struct-return is specified. This is included in the
480 * mingw32 specs file.
482 typedef struct { int quot, rem; } div_t;
483 typedef struct { long quot, rem; } ldiv_t;
485 _CRTIMP __cdecl __MINGW_NOTHROW div_t div (int, int) __MINGW_ATTRIB_CONST;
486 _CRTIMP __cdecl __MINGW_NOTHROW ldiv_t ldiv (long, long) __MINGW_ATTRIB_CONST;
488 #if !defined (__STRICT_ANSI__)
489 /* NOTE: Officially the three following functions are obsolete. The Win32 API
490 * functions SetErrorMode, Beep and Sleep are their replacements.
492 _CRTIMP __cdecl __MINGW_NOTHROW void _beep (unsigned int, unsigned int) __MINGW_ATTRIB_DEPRECATED;
493 /* Not to be confused with _set_error_mode (int). */
494 _CRTIMP __cdecl __MINGW_NOTHROW void _seterrormode (int) __MINGW_ATTRIB_DEPRECATED;
495 _CRTIMP __cdecl __MINGW_NOTHROW void _sleep (unsigned long) __MINGW_ATTRIB_DEPRECATED;
497 _CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN;
499 /* _onexit is a Microsoft extension. Use atexit for portability. */
500 /* Note: This is in startup code, not imported directly from dll */
501 typedef int (* _onexit_t)(void);
502 __cdecl __MINGW_NOTHROW _onexit_t _onexit( _onexit_t );
504 _CRTIMP __cdecl __MINGW_NOTHROW int _putenv (const char *);
505 _CRTIMP __cdecl __MINGW_NOTHROW
506 void _searchenv (const char *, const char *, char *);
508 _CRTIMP __cdecl __MINGW_NOTHROW char *_ecvt (double, int, int *, int *);
509 _CRTIMP __cdecl __MINGW_NOTHROW char *_fcvt (double, int, int *, int *);
510 _CRTIMP __cdecl __MINGW_NOTHROW char *_gcvt (double, int, char *);
512 _CRTIMP __cdecl __MINGW_NOTHROW
513 void _makepath (char *, const char *, const char *, const char *, const char *);
515 _CRTIMP __cdecl __MINGW_NOTHROW
516 void _splitpath (const char *, char *, char *, char *, char *);
518 _CRTIMP __cdecl __MINGW_NOTHROW char *_fullpath (char*, const char*, size_t);
520 _CRTIMP __cdecl __MINGW_NOTHROW char *_itoa (int, char *, int);
521 _CRTIMP __cdecl __MINGW_NOTHROW char *_ltoa (long, char *, int);
522 _CRTIMP __cdecl __MINGW_NOTHROW char *_ultoa(unsigned long, char *, int);
523 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_itow (int, wchar_t *, int);
524 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_ltow (long, wchar_t *, int);
525 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_ultow (unsigned long, wchar_t *, int);
528 _CRTIMP __cdecl __MINGW_NOTHROW __int64 _atoi64 (const char *);
529 _CRTIMP __cdecl __MINGW_NOTHROW char* _i64toa (__int64, char *, int);
530 _CRTIMP __cdecl __MINGW_NOTHROW char* _ui64toa (unsigned __int64, char *, int);
531 _CRTIMP __cdecl __MINGW_NOTHROW __int64 _wtoi64 (const wchar_t *);
532 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t* _i64tow (__int64, wchar_t *, int);
533 _CRTIMP __cdecl __MINGW_NOTHROW wchar_t* _ui64tow (unsigned __int64, wchar_t *, int);
535 _CRTIMP __cdecl __MINGW_NOTHROW unsigned int (_rotl)(unsigned int, int) __MINGW_ATTRIB_CONST;
536 _CRTIMP __cdecl __MINGW_NOTHROW unsigned int (_rotr)(unsigned int, int) __MINGW_ATTRIB_CONST;
537 _CRTIMP __cdecl __MINGW_NOTHROW unsigned long (_lrotl)(unsigned long, int) __MINGW_ATTRIB_CONST;
538 _CRTIMP __cdecl __MINGW_NOTHROW unsigned long (_lrotr)(unsigned long, int) __MINGW_ATTRIB_CONST;
540 _CRTIMP __cdecl __MINGW_NOTHROW int _set_error_mode (int);
542 # define _OUT_TO_DEFAULT 0
543 # define _OUT_TO_STDERR 1
544 # define _OUT_TO_MSGBOX 2
545 # define _REPORT_ERRMODE 3
547 # if __MSVCRT_VERSION__ >= __MSVCR80_DLL
548 # ifndef _UINTPTR_T_DEFINED
549 # define _UINTPTR_T_DEFINED
551 typedef unsigned __int64 uintptr_t;
553 typedef unsigned int uintptr_t;
557 _CRTIMP __cdecl __MINGW_NOTHROW
558 unsigned int _set_abort_behavior (unsigned int, unsigned int);
560 /* These masks work with msvcr80.dll version 8.0.50215.44 (a beta release).
562 # define _WRITE_ABORT_MSG 1
563 # define _CALL_REPORTFAULT 2
566 (* _invalid_parameter_handler) (
572 _invalid_parameter_handler _set_invalid_parameter_handler (_invalid_parameter_handler);
574 # endif /* __MSVCRT_VERSION__ >= __MSVCR80_DLL */
575 #endif /* __MSVCRT__ */
578 _CRTIMP __cdecl __MINGW_NOTHROW int putenv (const char*);
579 _CRTIMP __cdecl __MINGW_NOTHROW void searchenv (const char*, const char*, char*);
581 _CRTIMP __cdecl __MINGW_NOTHROW char* itoa (int, char*, int);
582 _CRTIMP __cdecl __MINGW_NOTHROW char* ltoa (long, char*, int);
585 _CRTIMP __cdecl __MINGW_NOTHROW char* ecvt (double, int, int*, int*);
586 _CRTIMP __cdecl __MINGW_NOTHROW char* fcvt (double, int, int*, int*);
587 _CRTIMP __cdecl __MINGW_NOTHROW char* gcvt (double, int, char*);
590 #endif /* ! _NO_OLDNAMES */
591 #endif /* ! __STRICT_ANSI__ */
593 #ifdef _ISOC99_SOURCE
594 /* Further APIs required to support ISO-C99, but missing from MSVCRT.DLL;
595 * we provide them in libmingwex.a:
597 * ISO-C99 name for _exit()
599 __cdecl __MINGW_NOTHROW void _Exit(int) __MINGW_ATTRIB_NORETURN;
601 #ifndef __NO_INLINE__
602 __CRT_INLINE __JMPSTUB__(( FUNCTION = _Exit, REMAPPED = _exit ))
603 __cdecl __MINGW_NOTHROW void _Exit( int __status ){ _exit (__status); }
606 typedef struct { long long quot, rem; } lldiv_t;
607 __cdecl __MINGW_NOTHROW lldiv_t lldiv (long long, long long) __MINGW_ATTRIB_CONST;
609 __cdecl __MINGW_NOTHROW long long llabs (long long);
611 #ifndef __NO_INLINE__
613 /* No JMPSTUB or LIBIMPL reference here -- we provide a free-standing
614 * implementation, along with imaxabs(), in mingwex/imaxabs.c
616 __cdecl __MINGW_NOTHROW long long llabs( long long __j )
617 { return __j >= 0 ? __j : -__j; }
620 __cdecl __MINGW_NOTHROW
621 long long strtoll (const char *__restrict__, char **__restrict, int);
623 __cdecl __MINGW_NOTHROW
624 unsigned long long strtoull (const char *__restrict__, char **__restrict__, int);
627 /* MSVCRT.DLL does not provide ISO-C99's atoll() function, but it does
628 * provide an analogue, in _atoi64(); map it accordingly.
630 __cdecl __MINGW_NOTHROW long long atoll (const char *);
632 #ifndef __NO_INLINE__
633 __CRT_INLINE __JMPSTUB__(( FUNCTION = atoll, REMAPPED = _atoi64 ))
634 __cdecl __MINGW_NOTHROW long long atoll (const char * _c){ return _atoi64 (_c); }
637 #endif /* __MSVCRT__ */
638 #endif /* _ISOC99_SOURCE */
640 #if defined __MSVCRT__ && ! defined __STRICT_ANSI__
641 /* Type long long analogues for MSVCRT.DLL specific type long functions;
642 * none are actually provided by any version of MSVCRT.DLL, with names as
643 * specified here, but rather as called by the inline functions used to
644 * implement them, (i.e. the REMAPPED name specified in each__JMPSTUB__
645 * function reference respectively).
647 * FIXME: Not one of these is specified by ISO-C99, nor by POSIX, either;
648 * is there really any justification for us to specify them at all? For
649 * the time being, declare as deprecated; perhaps remove later?
651 __cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED long long wtoll (const wchar_t *);
652 __cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED char *lltoa (long long, char *, int);
653 __cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED char *ulltoa (unsigned long long , char *, int);
654 __cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED wchar_t *lltow (long long, wchar_t *, int);
655 __cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED wchar_t *ulltow (unsigned long long, wchar_t *, int);
657 #ifndef __NO_INLINE__
658 /* None of these functions would exist at all, without either these inline
659 * implementations, or their respective __JMPSTUB__ equivalents.
661 __CRT_INLINE __JMPSTUB__(( FUNCTION = lltoa, REMAPPED = _i64toa ))
662 __cdecl __MINGW_NOTHROW char *lltoa (long long __n, char * __c, int __i)
663 { return _i64toa (__n, __c, __i); }
665 __CRT_INLINE __JMPSTUB__(( FUNCTION = ulltoa, REMAPPED = _ui64toa ))
666 __cdecl __MINGW_NOTHROW char *ulltoa (unsigned long long __n, char * __c, int __i)
667 { return _ui64toa (__n, __c, __i); }
669 __CRT_INLINE __JMPSTUB__(( FUNCTION = wtoll, REMAPPED = _wtoi64 ))
670 __cdecl __MINGW_NOTHROW long long wtoll (const wchar_t * __w){ return _wtoi64 (__w); }
672 __CRT_INLINE __JMPSTUB__(( FUNCTION = lltow, REMAPPED = _i64tow ))
673 __cdecl __MINGW_NOTHROW wchar_t *lltow (long long __n, wchar_t * __w, int __i)
674 { return _i64tow (__n, __w, __i); }
676 __CRT_INLINE __JMPSTUB__(( FUNCTION = ulltow, REMAPPED = _ui64tow ))
677 __cdecl __MINGW_NOTHROW wchar_t *ulltow (unsigned long long __n, wchar_t * __w, int __i)
678 { return _ui64tow (__n, __w, __i); }
680 #endif /* ! __NO_INLINE__ */
681 #endif /* __MSVCRT__ && ! __STRICT_ANSI__ */
683 /* POSIX/BSD extensions in libmingwex.a; these should be exposed only on
684 * the basis of appropriate POSIX or BSD specific feature tests...
686 * mkstemp(3) function support; added per feature request #2003.
687 * POSIX wants _XOPEN_SOURCE >= 500, (implying _POSIX_C_SOURCE >= 200112L).
689 #if _POSIX_C_SOURCE >= 200112L
691 __cdecl __MINGW_NOTHROW int mkstemp (char *);
692 __cdecl __MINGW_NOTHROW int __mingw_mkstemp (int, char *);
694 /* On POSIX platforms, programmers may adopt an idiom such as:
696 * if( mkstemp( template ) >= 0 )
697 * { unlink( template );
701 * to ensure that a temporary file does NOT persist after it is
702 * closed; MS-Windows does not allow such use of unlink(2), while
703 * the file remains open. Thus, MS-Windows programmers must take
704 * extra care, to close and unlink temporary files AFTER use, if
705 * similar behaviour is desired.
707 * To mitigate this MS-Windows limitation, we provide support for
708 * an alternative, MinGW specific idiom:
712 * _MKSTEMP_SETMODE( _O_TEMPORARY );
713 * if( mkstemp( template ) >= 0 )
718 * to achieve a similar effect to that of the above POSIX idiom; the
719 * following macros are a MinGW specific extension, to facilite such
720 * use of _O_TEMPORARY, (in addition to the POSIX required attributes),
721 * when creating the temporary file. Note that they require <fcntl.h>,
722 * which <stdlib.h> should NOT automatically include; we leave it to
723 * the user to explicitly include it, if using _MKSTEMP_SETMODE.
725 #define _MKSTEMP_INVOKE 0
726 #define _MKSTEMP_DEFAULT _O_CREAT | _O_EXCL | _O_RDWR
727 #define _MKSTEMP_SETMODE(M) __mingw_mkstemp( _MKSTEMP_DEFAULT | (M), NULL )
730 #define MKSTEMP_SETMODE(M) __mingw_mkstemp( _MKSTEMP_DEFAULT | (M), NULL )
733 __CRT_ALIAS __LIBIMPL__(( FUNCTION = mkstemp ))
734 __cdecl __MINGW_NOTHROW int mkstemp (char *__filename_template)
735 { return __mingw_mkstemp( _MKSTEMP_INVOKE, __filename_template ); }
737 #endif /* _POSIX_C_SOURCE >= 200112L (for mkstemp()) */
739 /* mkdtemp(3) function support: added as adjunct to feature request #2003.
740 * POSIX wants _XOPEN_SOURCE >= 700, (implying _POSIX_C_SOURCE >= 200809L).
742 #if _POSIX_C_SOURCE >= 200809L
744 __cdecl __MINGW_NOTHROW char *mkdtemp (char *);
745 __cdecl __MINGW_NOTHROW char *__mingw_mkdtemp (char *);
747 __CRT_ALIAS __JMPSTUB__(( FUNCTION = mkdtemp ))
748 __cdecl __MINGW_NOTHROW char *mkdtemp (char *__dirname_template)
749 { return __mingw_mkdtemp( __dirname_template ); }
751 #endif /* _POSIX_C_SOURCE >= 200809L (for mkdtemp()) */
752 #endif /* _STDLIB_H */
756 #endif /* ! RC_INVOKED */
757 #endif /* ! _STDLIB_H: $RCSfile$: end of file */