source: Daodan/MinGW/include/stdlib.h@ 1088

Last change on this file since 1088 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 28.2 KB
RevLine 
[1046]1/*
2 * stdlib.h
3 *
4 * ANSI/POSIX + Microsoft compatible standard library function prototypes,
5 * associated macros, and manifest constant definitions.
6 *
7 * $Id: stdlib.h,v 0e4f78dbc1ba 2016/06/17 14:16:01 keithmarshall $
8 *
9 * Written by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
10 * Copyright (C) 1997-2009, 2011, 2014-2016, MinGW.org Project.
11 *
12 *
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:
19 *
20 * The above copyright notice, this permission notice, and the following
21 * disclaimer shall be included in all copies or substantial portions of
22 * the Software.
23 *
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.
31 *
32 */
33#ifndef _STDLIB_H
34#pragma GCC system_header
35
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...
39 */
40#ifndef __WCHAR_H_SOURCED__
41 /* ...do we define the repeat inclusion guard for <stdlib.h> itself.
42 */
43#define _STDLIB_H
44
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
47 * it for <stdlib.h>.
48 */
49#include <_mingw.h>
50
51#ifndef RC_INVOKED
52#define __need_size_t
53#define __need_wchar_t
54#define __need_NULL
55#include <stddef.h>
56#endif /* RC_INVOKED */
57
58/* RAND_MAX is the maximum value that may be returned by rand.
59 * The minimum is zero.
60 */
61#define RAND_MAX 0x7FFF
62
63/* These values may be used as exit status codes.
64 */
65#define EXIT_SUCCESS 0
66#define EXIT_FAILURE 1
67
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.
72 */
73#ifndef __STRICT_ANSI__
74
75#ifndef MAX_PATH
76#define MAX_PATH (260)
77#endif
78
79#define _MAX_PATH MAX_PATH
80#define _MAX_DRIVE (3)
81#define _MAX_DIR 256
82#define _MAX_FNAME 256
83#define _MAX_EXT 256
84
85#endif /* !__STRICT_ANSI__ */
86#endif /* !__WCHAR_H_SOURCED__ */
87
88#ifndef RC_INVOKED
89
90_BEGIN_C_DECLS
91
92#ifdef _STDLIB_H
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.
98 */
99extern int _argc;
100extern char **_argv;
101
102#ifdef __MSVCRT__
103/* Imports from the runtime DLL, for the above variables.
104 */
105extern __cdecl __MINGW_NOTHROW int *__p___argc(void);
106extern __cdecl __MINGW_NOTHROW char ***__p___argv(void);
107extern __cdecl __MINGW_NOTHROW wchar_t ***__p___wargv(void);
108
109#define __argc (*__p___argc())
110#define __argv (*__p___argv())
111#define __wargv (*__p___wargv())
112
113#else /* ! __MSVCRT__ */
114
115#ifndef __DECLSPEC_SUPPORTED
116
117extern int *_imp____argc_dll;
118extern char ***_imp____argv_dll;
119
120#define __argc (*_imp____argc_dll)
121#define __argv (*_imp____argv_dll)
122
123#else /* __DECLSPEC_SUPPORTED */
124
125__MINGW_IMPORT int __argc_dll;
126__MINGW_IMPORT char **__argv_dll;
127
128#define __argc __argc_dll
129#define __argv __argv_dll
130
131#endif /* __DECLSPEC_SUPPORTED */
132
133#endif /* __MSVCRT__ */
134#endif /* __STRICT_ANSI__ */
135
136#ifndef MB_CUR_MAX
137/* FIXME: also defined in <ctype.h>; should be factored out.
138 */
139#ifdef __DECLSPEC_SUPPORTED
140# ifdef __MSVCRT__
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__ */
147
148#else /* ! __DECLSPEC_SUPPORTED */
149# ifdef __MSVCRT__
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 */
158
159/* FIXME: Nominally in <errno.h>, Microsoft likes to declare errno
160 * in <stdlib.h> as well; we should factor this out.
161 */
162#ifdef _UWIN
163# undef errno
164 extern int errno;
165#else
166_CRTIMP __cdecl __MINGW_NOTHROW int *_errno(void);
167# define errno (*_errno())
168#endif
169_CRTIMP __cdecl __MINGW_NOTHROW int *__doserrno(void);
170#define _doserrno (*__doserrno())
171
172#if !defined (__STRICT_ANSI__)
173/* Use environ from the DLL, not as a global.
174 */
175#ifdef __MSVCRT__
176# define _environ (*__p__environ())
177extern _CRTIMP __cdecl __MINGW_NOTHROW char ***__p__environ(void);
178# define _wenviron (*__p__wenviron())
179extern _CRTIMP __cdecl __MINGW_NOTHROW wchar_t ***__p__wenviron(void);
180
181#else /* ! __MSVCRT__ */
182# ifndef __DECLSPEC_SUPPORTED
183# define _environ (*_imp___environ_dll)
184extern char ***_imp___environ_dll;
185
186# else /* __DECLSPEC_SUPPORTED */
187# define _environ _environ_dll
188__MINGW_IMPORT char ** _environ_dll;
189# endif /* __DECLSPEC_SUPPORTED */
190#endif /* ! __MSVCRT__ */
191
192#define environ _environ
193
194#ifdef __MSVCRT__
195/* One of the MSVCRTxx libraries */
196
197#ifndef __DECLSPEC_SUPPORTED
198# define sys_nerr (*_imp___sys_nerr)
199extern int *_imp___sys_nerr;
200
201#else /* __DECLSPEC_SUPPORTED */
202__MINGW_IMPORT int _sys_nerr;
203
204# ifndef _UWIN
205# define sys_nerr _sys_nerr
206# endif /* _UWIN */
207#endif /* __DECLSPEC_SUPPORTED */
208
209#else /* ! __MSVCRT__ */
210/* CRTDLL run time library */
211
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 */
219
220#endif /* ! __MSVCRT__ */
221
222#ifndef __DECLSPEC_SUPPORTED
223#define sys_errlist (*_imp___sys_errlist)
224extern char ***_imp__sys_errlist;
225
226#else /* __DECLSPEC_SUPPORTED */
227__MINGW_IMPORT char *_sys_errlist[];
228
229#ifndef _UWIN
230#define sys_errlist _sys_errlist
231#endif /* _UWIN */
232#endif /* __DECLSPEC_SUPPORTED */
233
234/* OS version and such constants.
235 */
236#ifdef __MSVCRT__ /* MSVCRT.DLL and MSVCRxx.DLL variants */
237
238extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__osver(void);
239extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__winver(void);
240extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__winmajor(void);
241extern _CRTIMP __cdecl __MINGW_NOTHROW unsigned int *__p__winminor(void);
242
243#ifndef __DECLSPEC_SUPPORTED
244# define _osver (*__p__osver())
245# define _winver (*__p__winver())
246# define _winmajor (*__p__winmajor())
247# define _winminor (*__p__winminor())
248
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 */
255
256#else /* ! __MSVCRT__; thus CRTDLL */
257#ifndef __DECLSPEC_SUPPORTED
258
259#define _osver (*_imp___osver_dll)
260#define _winver (*_imp___winver_dll)
261#define _winmajor (*_imp___winmajor_dll)
262#define _winminor (*_imp___winminor_dll)
263
264extern unsigned int *_imp___osver_dll;
265extern unsigned int *_imp___winver_dll;
266extern unsigned int *_imp___winmajor_dll;
267extern unsigned int *_imp___winminor_dll;
268
269#else /* __DECLSPEC_SUPPORTED */
270
271#define _osver _osver_dll
272#define _winver _winver_dll
273#define _winmajor _winmajor_dll
274#define _winminor _winminor_dll
275
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;
280
281#endif /* __DECLSPEC_SUPPORTED */
282#endif /* CRTDLL */
283
284#if defined __MSVCRT__
285/* Although _pgmptr is exported as DATA, be safe and use the access
286 * function __p__pgmptr() to get it.
287 */
288#define _pgmptr (*__p__pgmptr())
289_CRTIMP __cdecl __MINGW_NOTHROW char **__p__pgmptr(void);
290
291#define _wpgmptr (*__p__wpgmptr())
292_CRTIMP __cdecl __MINGW_NOTHROW wchar_t **__p__wpgmptr(void);
293
294#else /* ! __MSVCRT__; thus CRTDLL */
295
296# ifndef __DECLSPEC_SUPPORTED
297# define _pgmptr (*_imp___pgmptr_dll)
298extern char **__imp__pgmptr_dll;
299
300# else /* __DECLSPEC_SUPPORTED */
301
302# define _pgmptr _pgmptr_dll
303__MINGW_IMPORT char *_pgmptr_dll;
304/* no wide version in CRTDLL */
305
306# endif /* __DECLSPEC_SUPPORTED */
307#endif /* CRTDLL */
308
309/* This variable determines the default file mode.
310 * TODO: Which flags work?
311 */
312#if !defined (__DECLSPEC_SUPPORTED) || defined (__IN_MINGW_RUNTIME)
313
314#ifdef __MSVCRT__
315#define _fmode (*_imp___fmode)
316extern int *_imp___fmode;
317#else
318/* CRTDLL */
319#define _fmode (*_imp___fmode_dll)
320extern int *_imp___fmode_dll;
321#endif
322
323#else /* __DECLSPEC_SUPPORTED */
324#ifdef __MSVCRT__
325__MINGW_IMPORT int _fmode;
326
327#else /* ! __MSVCRT__ */
328#define _fmode _fmode_dll
329__MINGW_IMPORT int _fmode_dll;
330
331#endif /* !__MSVCRT__ */
332#endif /* __DECLSPEC_SUPPORTED */
333#endif /* !__STRICT_ANSI__ */
334
335_CRTIMP __cdecl __MINGW_NOTHROW int atoi (const char *);
336_CRTIMP __cdecl __MINGW_NOTHROW long atol (const char *);
337
338_CRTIMP __cdecl __MINGW_NOTHROW double strtod (const char *, char **);
339_CRTIMP __cdecl __MINGW_NOTHROW double atof (const char *);
340
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 *);
345#endif
346
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.
353 *
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.
359 */
360extern __cdecl __MINGW_NOTHROW
361double __strtod (const char *__restrict__, char **__restrict__);
362
363__CRT_ALIAS __cdecl __MINGW_NOTHROW
364double strtod (const char *__restrict__ __nptr, char **__restrict__ __endptr)
365{ return __strtod( __nptr, __endptr ); }
366
367__CRT_ALIAS __cdecl __MINGW_NOTHROW
368double atof (const char *__nptr) { return __strtod( __nptr, NULL ); }
369
370#endif /* __USE_MINGW_ANSI_STDIO */
371
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:
377 */
378__cdecl __MINGW_NOTHROW
379float strtof (const char *__restrict__, char **__restrict__);
380
381__cdecl __MINGW_NOTHROW
382long double strtold (const char *__restrict__, char **__restrict__);
383#endif /* _ISOC99_SOURCE */
384
385_CRTIMP __cdecl __MINGW_NOTHROW long strtol (const char *, char **, int);
386_CRTIMP __cdecl __MINGW_NOTHROW unsigned long strtoul (const char *, char **, int);
387
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>.
393 */
394_CRTIMP __cdecl __MINGW_NOTHROW
395long wcstol (const wchar_t *, wchar_t **, int);
396
397_CRTIMP __cdecl __MINGW_NOTHROW
398unsigned long wcstoul (const wchar_t *, wchar_t **, int);
399
400_CRTIMP __cdecl __MINGW_NOTHROW double wcstod (const wchar_t *, wchar_t **);
401
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
405 */
406__cdecl __MINGW_NOTHROW
407float wcstof (const wchar_t *__restrict__, wchar_t **__restrict__);
408
409__cdecl __MINGW_NOTHROW
410long double wcstold (const wchar_t *__restrict__, wchar_t **__restrict__);
411#endif /* _ISOC99_SOURCE */
412
413#ifdef __MSVCRT__
414#if __MSVCRT_VERSION__ >= __MSVCR70_DLL || _WIN32_WINNT >= _WIN32_WINNT_WINXP
415/* This pair of wide character equivalents for ISO-C99's strtoll() and
416 * strtoull() require either WinXP (or later), or a non-free MSVC runtime
417 * from MSVCR70.DLL onwards...
418 */
419_CRTIMP __cdecl __MINGW_NOTHROW
420__int64 _wcstoi64(const wchar_t *, wchar_t **, int);
421
422_CRTIMP __cdecl __MINGW_NOTHROW
423unsigned __int64 _wcstoui64(const wchar_t *, wchar_t **, int);
424
425#endif /* WinXP || MSVCR70.DLL || later */
426
427#if __MSVCRT_VERSION__ >= __MSVCR80_DLL || _WIN32_WINNT >= _WIN32_WINNT_VISTA
428/* ...while the following pair require Win-Vista (or later), or non-free
429 * MSVCRT runtime from MSVCR80.DLL onwards; they also require...
430 */
431#ifndef __have_typedef_locale_t
432/* ...this opaque data type, which we may obtain by selective inclusion
433 * from <locale.h>. (Note that this may render them unusable for users of
434 * MSVCRT.DLL; see the explanation in <locale.h>, regarding the difficulty
435 * in creating, or otherwise acquiring a reference to, a _locale_t object,
436 * notwithstanding the availability of the functions in MSVCRT.DLL, from
437 * the release of Win-Vista onwards).
438 */
439#define __need_locale_t
440#include <locale.h>
441#endif /* !__have_typedef_locale_t */
442
443_CRTIMP __cdecl __MINGW_NOTHROW
444__int64 _wcstoi64_l(const wchar_t *, wchar_t **, int, _locale_t);
445
446_CRTIMP __cdecl __MINGW_NOTHROW
447unsigned __int64 _wcstoui64_l(const wchar_t *, wchar_t **, int, _locale_t);
448
449#endif /* Win-Vista || MSVCR80.DLL || later */
450
451_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wgetenv (const wchar_t *);
452_CRTIMP __cdecl __MINGW_NOTHROW int _wputenv (const wchar_t *);
453
454_CRTIMP __cdecl __MINGW_NOTHROW
455void _wsearchenv (const wchar_t *, const wchar_t *, wchar_t *);
456
457_CRTIMP __cdecl __MINGW_NOTHROW int _wsystem (const wchar_t *);
458
459_CRTIMP __cdecl __MINGW_NOTHROW
460void _wmakepath (wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
461 const wchar_t *
462 );
463
464_CRTIMP __cdecl __MINGW_NOTHROW
465void _wsplitpath (const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
466
467_CRTIMP __cdecl __MINGW_NOTHROW
468wchar_t *_wfullpath (wchar_t *, const wchar_t *, size_t);
469
470#endif /* __MSVCRT__ */
471#endif /* _STDLIB_H || _WCHAR_H */
472
473#ifdef _STDLIB_H /* <stdlib.h> only */
474_CRTIMP __cdecl __MINGW_NOTHROW size_t wcstombs (char *, const wchar_t *, size_t);
475_CRTIMP __cdecl __MINGW_NOTHROW int wctomb (char *, wchar_t);
476
477_CRTIMP __cdecl __MINGW_NOTHROW int mblen (const char *, size_t);
478_CRTIMP __cdecl __MINGW_NOTHROW size_t mbstowcs (wchar_t *, const char *, size_t);
479_CRTIMP __cdecl __MINGW_NOTHROW int mbtowc (wchar_t *, const char *, size_t);
480
481_CRTIMP __cdecl __MINGW_NOTHROW int rand (void);
482_CRTIMP __cdecl __MINGW_NOTHROW void srand (unsigned int);
483
484_CRTIMP __cdecl __MINGW_NOTHROW void *calloc (size_t, size_t) __MINGW_ATTRIB_MALLOC;
485_CRTIMP __cdecl __MINGW_NOTHROW void *malloc (size_t) __MINGW_ATTRIB_MALLOC;
486_CRTIMP __cdecl __MINGW_NOTHROW void *realloc (void *, size_t);
487_CRTIMP __cdecl __MINGW_NOTHROW void free (void *);
488_CRTIMP __cdecl __MINGW_NOTHROW void abort (void) __MINGW_ATTRIB_NORETURN;
489_CRTIMP __cdecl __MINGW_NOTHROW void exit (int) __MINGW_ATTRIB_NORETURN;
490
491/* Note: this is in startup code, not imported directly from the runtime DLL
492 */
493int __cdecl __MINGW_NOTHROW atexit (void (*)(void));
494
495_CRTIMP __cdecl __MINGW_NOTHROW int system (const char *);
496_CRTIMP __cdecl __MINGW_NOTHROW char *getenv (const char *);
497
498/* bsearch() and qsort() are declared both here, in <stdlib.h>, and in
499 * non-ANSI header <search.h>; we reproduce these declarations in both,
500 * with no attempt to guard them, so the compiler may verify that they
501 * are consistent, if both headers are included.
502 */
503_CRTIMP __cdecl void *bsearch
504(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
505
506_CRTIMP __cdecl void qsort
507(void *, size_t, size_t, int (*)(const void *, const void *));
508
509_CRTIMP __cdecl __MINGW_NOTHROW int abs (int) __MINGW_ATTRIB_CONST;
510_CRTIMP __cdecl __MINGW_NOTHROW long labs (long) __MINGW_ATTRIB_CONST;
511
512/* div_t and ldiv_t are structures used to return the results of div()
513 * and ldiv() functions.
514 *
515 * NOTE: div() and ldiv() appear not to work correctly unless
516 * -fno-pcc-struct-return is specified. This is included in the
517 * mingw32 specs file.
518 */
519typedef struct { int quot, rem; } div_t;
520typedef struct { long quot, rem; } ldiv_t;
521
522_CRTIMP __cdecl __MINGW_NOTHROW div_t div (int, int) __MINGW_ATTRIB_CONST;
523_CRTIMP __cdecl __MINGW_NOTHROW ldiv_t ldiv (long, long) __MINGW_ATTRIB_CONST;
524
525#if !defined (__STRICT_ANSI__)
526/* NOTE: Officially the three following functions are obsolete. The Win32 API
527 * functions SetErrorMode, Beep and Sleep are their replacements.
528 */
529_CRTIMP __cdecl __MINGW_NOTHROW void _beep (unsigned int, unsigned int) __MINGW_ATTRIB_DEPRECATED;
530/* Not to be confused with _set_error_mode (int). */
531_CRTIMP __cdecl __MINGW_NOTHROW void _seterrormode (int) __MINGW_ATTRIB_DEPRECATED;
532_CRTIMP __cdecl __MINGW_NOTHROW void _sleep (unsigned long) __MINGW_ATTRIB_DEPRECATED;
533
534_CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN;
535
536/* _onexit is a Microsoft extension. Use atexit for portability. */
537/* Note: This is in startup code, not imported directly from dll */
538typedef int (* _onexit_t)(void);
539__cdecl __MINGW_NOTHROW _onexit_t _onexit( _onexit_t );
540
541_CRTIMP __cdecl __MINGW_NOTHROW int _putenv (const char *);
542_CRTIMP __cdecl __MINGW_NOTHROW
543void _searchenv (const char *, const char *, char *);
544
545_CRTIMP __cdecl __MINGW_NOTHROW char *_ecvt (double, int, int *, int *);
546_CRTIMP __cdecl __MINGW_NOTHROW char *_fcvt (double, int, int *, int *);
547_CRTIMP __cdecl __MINGW_NOTHROW char *_gcvt (double, int, char *);
548
549_CRTIMP __cdecl __MINGW_NOTHROW
550void _makepath (char *, const char *, const char *, const char *, const char *);
551
552_CRTIMP __cdecl __MINGW_NOTHROW
553void _splitpath (const char *, char *, char *, char *, char *);
554
555_CRTIMP __cdecl __MINGW_NOTHROW char *_fullpath (char*, const char*, size_t);
556
557_CRTIMP __cdecl __MINGW_NOTHROW char *_itoa (int, char *, int);
558_CRTIMP __cdecl __MINGW_NOTHROW char *_ltoa (long, char *, int);
559_CRTIMP __cdecl __MINGW_NOTHROW char *_ultoa(unsigned long, char *, int);
560_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_itow (int, wchar_t *, int);
561_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_ltow (long, wchar_t *, int);
562_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_ultow (unsigned long, wchar_t *, int);
563
564#ifdef __MSVCRT__
565_CRTIMP __cdecl __MINGW_NOTHROW __int64 _atoi64 (const char *);
566_CRTIMP __cdecl __MINGW_NOTHROW char* _i64toa (__int64, char *, int);
567_CRTIMP __cdecl __MINGW_NOTHROW char* _ui64toa (unsigned __int64, char *, int);
568_CRTIMP __cdecl __MINGW_NOTHROW __int64 _wtoi64 (const wchar_t *);
569_CRTIMP __cdecl __MINGW_NOTHROW wchar_t* _i64tow (__int64, wchar_t *, int);
570_CRTIMP __cdecl __MINGW_NOTHROW wchar_t* _ui64tow (unsigned __int64, wchar_t *, int);
571
572_CRTIMP __cdecl __MINGW_NOTHROW unsigned int (_rotl)(unsigned int, int) __MINGW_ATTRIB_CONST;
573_CRTIMP __cdecl __MINGW_NOTHROW unsigned int (_rotr)(unsigned int, int) __MINGW_ATTRIB_CONST;
574_CRTIMP __cdecl __MINGW_NOTHROW unsigned long (_lrotl)(unsigned long, int) __MINGW_ATTRIB_CONST;
575_CRTIMP __cdecl __MINGW_NOTHROW unsigned long (_lrotr)(unsigned long, int) __MINGW_ATTRIB_CONST;
576
577_CRTIMP __cdecl __MINGW_NOTHROW int _set_error_mode (int);
578
579# define _OUT_TO_DEFAULT 0
580# define _OUT_TO_STDERR 1
581# define _OUT_TO_MSGBOX 2
582# define _REPORT_ERRMODE 3
583
584# if __MSVCRT_VERSION__ >= __MSVCR80_DLL
585# ifndef _UINTPTR_T_DEFINED
586# define _UINTPTR_T_DEFINED
587# ifdef _WIN64
588 typedef unsigned __int64 uintptr_t;
589# else
590 typedef unsigned int uintptr_t;
591# endif
592# endif
593
594_CRTIMP __cdecl __MINGW_NOTHROW
595unsigned int _set_abort_behavior (unsigned int, unsigned int);
596
597/* These masks work with msvcr80.dll version 8.0.50215.44 (a beta release).
598 */
599# define _WRITE_ABORT_MSG 1
600# define _CALL_REPORTFAULT 2
601
602typedef void
603(* _invalid_parameter_handler) (
604 const wchar_t *,
605 const wchar_t *,
606 const wchar_t *,
607 unsigned int,
608 uintptr_t);
609_invalid_parameter_handler _set_invalid_parameter_handler (_invalid_parameter_handler);
610
611# endif /* __MSVCRT_VERSION__ >= __MSVCR80_DLL */
612#endif /* __MSVCRT__ */
613
614#ifndef _NO_OLDNAMES
615_CRTIMP __cdecl __MINGW_NOTHROW int putenv (const char*);
616_CRTIMP __cdecl __MINGW_NOTHROW void searchenv (const char*, const char*, char*);
617
618_CRTIMP __cdecl __MINGW_NOTHROW char* itoa (int, char*, int);
619_CRTIMP __cdecl __MINGW_NOTHROW char* ltoa (long, char*, int);
620
621#ifndef _UWIN
622_CRTIMP __cdecl __MINGW_NOTHROW char* ecvt (double, int, int*, int*);
623_CRTIMP __cdecl __MINGW_NOTHROW char* fcvt (double, int, int*, int*);
624_CRTIMP __cdecl __MINGW_NOTHROW char* gcvt (double, int, char*);
625
626#endif /* ! _UWIN */
627#endif /* ! _NO_OLDNAMES */
628#endif /* ! __STRICT_ANSI__ */
629
630#ifdef _ISOC99_SOURCE
631/* Further APIs required to support ISO-C99, but missing from MSVCRT.DLL;
632 * we provide them in libmingwex.a:
633 *
634 * ISO-C99 name for _exit()
635 */
636__cdecl __MINGW_NOTHROW void _Exit(int) __MINGW_ATTRIB_NORETURN;
637
638#ifndef __NO_INLINE__
639__CRT_INLINE __JMPSTUB__(( FUNCTION = _Exit, REMAPPED = _exit ))
640__cdecl __MINGW_NOTHROW void _Exit( int __status ){ _exit (__status); }
641#endif
642
643typedef struct { long long quot, rem; } lldiv_t;
644__cdecl __MINGW_NOTHROW lldiv_t lldiv (long long, long long) __MINGW_ATTRIB_CONST;
645
646__cdecl __MINGW_NOTHROW long long llabs (long long);
647
648#ifndef __NO_INLINE__
649__CRT_INLINE
650/* No JMPSTUB or LIBIMPL reference here -- we provide a free-standing
651 * implementation, along with imaxabs(), in mingwex/imaxabs.c
652 */
653__cdecl __MINGW_NOTHROW long long llabs( long long __j )
654{ return __j >= 0 ? __j : -__j; }
655#endif
656
657__cdecl __MINGW_NOTHROW
658long long strtoll (const char *__restrict__, char **__restrict, int);
659
660__cdecl __MINGW_NOTHROW
661unsigned long long strtoull (const char *__restrict__, char **__restrict__, int);
662
663#ifdef __MSVCRT__
664/* MSVCRT.DLL does not provide ISO-C99's atoll() function, but it does
665 * provide an analogue, in _atoi64(); map it accordingly.
666 */
667__cdecl __MINGW_NOTHROW long long atoll (const char *);
668
669#ifndef __NO_INLINE__
670__CRT_INLINE __JMPSTUB__(( FUNCTION = atoll, REMAPPED = _atoi64 ))
671__cdecl __MINGW_NOTHROW long long atoll (const char * _c){ return _atoi64 (_c); }
672#endif
673
674#endif /* __MSVCRT__ */
675#endif /* _ISOC99_SOURCE */
676
677#if defined __MSVCRT__ && ! defined __STRICT_ANSI__
678#if __MSVCRT_VERSION__ >= __MSVCR70_DLL || _WIN32_WINNT >= _WIN32_WINNT_WINXP
679/* Microsoft specific alternatives to ISO-C99 strtoll() and strtoull(); the
680 * first pair require WinXP (or later) or non-free MSVCR70.DLL onwards...
681 */
682_CRTIMP __cdecl __MINGW_NOTHROW
683__int64 _strtoi64(const char*, char **, int);
684
685_CRTIMP __cdecl __MINGW_NOTHROW
686unsigned __int64 _strtoui64(const char*, char **, int);
687
688#endif /* WinXP || MSVCR70.DLL || later */
689#if __MSVCRT_VERSION__ >= __MSVCR80_DLL || _WIN32_WINNT >= _WIN32_WINNT_VISTA
690/* ...while the following pair require Win-Vista (or later), or non-free
691 * MSVCR80.DLL onwards; (note that, like their wide character counterparts,
692 * they may actually be unusable without MSVCR80.DLL onwards, because of
693 * the difficulty in acquiring a reference to a _locale_t object).
694 */
695_CRTIMP __cdecl __MINGW_NOTHROW
696__int64 _strtoi64_l(const char *, char **, int, _locale_t);
697
698_CRTIMP __cdecl __MINGW_NOTHROW
699unsigned __int64 _strtoui64_l(const char *, char **, int, _locale_t);
700
701#endif /* Win-Vista || MSVCR80.DLL || later */
702
703/* Type long long analogues for MSVCRT.DLL specific type long functions;
704 * none are actually provided by any version of MSVCRT.DLL, with names as
705 * specified here, but rather as called by the inline functions used to
706 * implement them, (i.e. the REMAPPED name specified in each__JMPSTUB__
707 * function reference respectively).
708 *
709 * FIXME: Not one of these is specified by ISO-C99, nor by POSIX, either;
710 * is there really any justification for us to specify them at all? For
711 * the time being, declare as deprecated; perhaps remove later?
712 */
713__cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED long long wtoll (const wchar_t *);
714__cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED char *lltoa (long long, char *, int);
715__cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED char *ulltoa (unsigned long long , char *, int);
716__cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED wchar_t *lltow (long long, wchar_t *, int);
717__cdecl __MINGW_NOTHROW __MINGW_ATTRIB_DEPRECATED wchar_t *ulltow (unsigned long long, wchar_t *, int);
718
719#ifndef __NO_INLINE__
720/* None of these functions would exist at all, without either these inline
721 * implementations, or their respective __JMPSTUB__ equivalents.
722 */
723__CRT_INLINE __JMPSTUB__(( FUNCTION = lltoa, REMAPPED = _i64toa ))
724__cdecl __MINGW_NOTHROW char *lltoa (long long __n, char * __c, int __i)
725{ return _i64toa (__n, __c, __i); }
726
727__CRT_INLINE __JMPSTUB__(( FUNCTION = ulltoa, REMAPPED = _ui64toa ))
728__cdecl __MINGW_NOTHROW char *ulltoa (unsigned long long __n, char * __c, int __i)
729{ return _ui64toa (__n, __c, __i); }
730
731__CRT_INLINE __JMPSTUB__(( FUNCTION = wtoll, REMAPPED = _wtoi64 ))
732__cdecl __MINGW_NOTHROW long long wtoll (const wchar_t * __w){ return _wtoi64 (__w); }
733
734__CRT_INLINE __JMPSTUB__(( FUNCTION = lltow, REMAPPED = _i64tow ))
735__cdecl __MINGW_NOTHROW wchar_t *lltow (long long __n, wchar_t * __w, int __i)
736{ return _i64tow (__n, __w, __i); }
737
738__CRT_INLINE __JMPSTUB__(( FUNCTION = ulltow, REMAPPED = _ui64tow ))
739__cdecl __MINGW_NOTHROW wchar_t *ulltow (unsigned long long __n, wchar_t * __w, int __i)
740{ return _ui64tow (__n, __w, __i); }
741
742#endif /* ! __NO_INLINE__ */
743#endif /* __MSVCRT__ && ! __STRICT_ANSI__ */
744
745/* POSIX/BSD extensions in libmingwex.a; these should be exposed only on
746 * the basis of appropriate POSIX or BSD specific feature tests...
747 *
748 * mkstemp(3) function support; added per feature request #2003.
749 * POSIX wants _XOPEN_SOURCE >= 500, (implying _POSIX_C_SOURCE >= 200112L).
750 */
751#if _POSIX_C_SOURCE >= 200112L
752
753__cdecl __MINGW_NOTHROW int mkstemp (char *);
754__cdecl __MINGW_NOTHROW int __mingw_mkstemp (int, char *);
755
756/* On POSIX platforms, programmers may adopt an idiom such as:
757 *
758 * if( mkstemp( template ) >= 0 )
759 * { unlink( template );
760 * . . .
761 * }
762 *
763 * to ensure that a temporary file does NOT persist after it is
764 * closed; MS-Windows does not allow such use of unlink(2), while
765 * the file remains open. Thus, MS-Windows programmers must take
766 * extra care, to close and unlink temporary files AFTER use, if
767 * similar behaviour is desired.
768 *
769 * To mitigate this MS-Windows limitation, we provide support for
770 * an alternative, MinGW specific idiom:
771 *
772 * #include <fcntl.h>
773 *
774 * _MKSTEMP_SETMODE( _O_TEMPORARY );
775 * if( mkstemp( template ) >= 0 )
776 * {
777 * . . .
778 * }
779 *
780 * to achieve a similar effect to that of the above POSIX idiom; the
781 * following macros are a MinGW specific extension, to facilite such
782 * use of _O_TEMPORARY, (in addition to the POSIX required attributes),
783 * when creating the temporary file. Note that they require <fcntl.h>,
784 * which <stdlib.h> should NOT automatically include; we leave it to
785 * the user to explicitly include it, if using _MKSTEMP_SETMODE.
786 */
787#define _MKSTEMP_INVOKE 0
788#define _MKSTEMP_DEFAULT _O_CREAT | _O_EXCL | _O_RDWR
789#define _MKSTEMP_SETMODE(M) __mingw_mkstemp( _MKSTEMP_DEFAULT | (M), NULL )
790
791#ifndef _NO_OLDNAMES
792#define MKSTEMP_SETMODE(M) __mingw_mkstemp( _MKSTEMP_DEFAULT | (M), NULL )
793#endif
794
795__CRT_ALIAS __LIBIMPL__(( FUNCTION = mkstemp ))
796__cdecl __MINGW_NOTHROW int mkstemp (char *__filename_template)
797{ return __mingw_mkstemp( _MKSTEMP_INVOKE, __filename_template ); }
798
799#endif /* _POSIX_C_SOURCE >= 200112L (for mkstemp()) */
800
801/* mkdtemp(3) function support: added as adjunct to feature request #2003.
802 * POSIX wants _XOPEN_SOURCE >= 700, (implying _POSIX_C_SOURCE >= 200809L).
803 */
804#if _POSIX_C_SOURCE >= 200809L
805
806__cdecl __MINGW_NOTHROW char *mkdtemp (char *);
807__cdecl __MINGW_NOTHROW char *__mingw_mkdtemp (char *);
808
809__CRT_ALIAS __JMPSTUB__(( FUNCTION = mkdtemp ))
810__cdecl __MINGW_NOTHROW char *mkdtemp (char *__dirname_template)
811{ return __mingw_mkdtemp( __dirname_template ); }
812
813#endif /* _POSIX_C_SOURCE >= 200809L (for mkdtemp()) */
814#endif /* _STDLIB_H */
815
816_END_C_DECLS
817
818#endif /* ! RC_INVOKED */
819#endif /* ! _STDLIB_H: $RCSfile: stdlib.h,v $: end of file */
Note: See TracBrowser for help on using the repository browser.