OSDN Git Service

Some POSIX feature test adjustments.
[mingw/mingw-org-wsl.git] / mingwrt / include / stdlib.h
1 /*
2  * stdlib.h
3  * This file has no copyright assigned and is placed in the Public Domain.
4  * This file is a part of the mingw-runtime package.
5  * No warranty is given; refer to the file DISCLAIMER within the package.
6  *
7  * Definitions for common types, variables, and functions.
8  *
9  */
10
11 #ifndef _STDLIB_H_
12 #define _STDLIB_H_
13
14 /* All the headers include this file. */
15 #include <_mingw.h>
16
17 #define __need_size_t
18 #define __need_wchar_t
19 #define __need_NULL
20
21 #ifndef RC_INVOKED
22 #include <stddef.h>
23 #endif /* RC_INVOKED */
24
25 /*
26  * RAND_MAX is the maximum value that may be returned by rand.
27  * The minimum is zero.
28  */
29 #define RAND_MAX        0x7FFF
30
31 /*
32  * These values may be used as exit status codes.
33  */
34 #define EXIT_SUCCESS    0
35 #define EXIT_FAILURE    1
36
37 /*
38  * Definitions for path name functions.
39  * NOTE: All of these values have simply been chosen to be conservatively high.
40  *       Remember that with long file names we can no longer depend on
41  *       extensions being short.
42  */
43 #ifndef __STRICT_ANSI__
44
45 #ifndef MAX_PATH
46 #define MAX_PATH        (260)
47 #endif
48
49 #define _MAX_PATH       MAX_PATH
50 #define _MAX_DRIVE      (3)
51 #define _MAX_DIR        256
52 #define _MAX_FNAME      256
53 #define _MAX_EXT        256
54
55 #endif  /* Not __STRICT_ANSI__ */
56
57
58 #ifndef RC_INVOKED
59
60 _BEGIN_C_DECLS
61
62 #if !defined (__STRICT_ANSI__)
63
64 /*
65  * This seems like a convenient place to declare these variables, which
66  * give programs using WinMain (or main for that matter) access to main-ish
67  * argc and argv. environ is a pointer to a table of environment variables.
68  * NOTE: Strings in _argv and environ are ANSI strings.
69  */
70 extern int      _argc;
71 extern char**   _argv;
72
73 /* imports from runtime dll of the above variables */
74 #ifdef __MSVCRT__
75
76 extern int*  __cdecl __MINGW_NOTHROW   __p___argc(void);
77 extern char*** __cdecl __MINGW_NOTHROW  __p___argv(void);
78 extern wchar_t***  __cdecl __MINGW_NOTHROW __p___wargv(void);
79
80 #define __argc (*__p___argc())
81 #define __argv (*__p___argv())
82 #define __wargv (*__p___wargv())
83
84 #else /* !MSVCRT */
85
86 #ifndef __DECLSPEC_SUPPORTED
87
88 extern int*    _imp____argc_dll;
89 extern char***  _imp____argv_dll;
90 #define __argc (*_imp____argc_dll)
91 #define __argv (*_imp____argv_dll)
92
93 #else /* __DECLSPEC_SUPPORTED */
94
95 __MINGW_IMPORT int    __argc_dll;
96 __MINGW_IMPORT char**  __argv_dll;
97 #define __argc __argc_dll
98 #define __argv __argv_dll
99
100 #endif /* __DECLSPEC_SUPPORTED */
101
102 #endif /* __MSVCRT */
103 #endif /* __STRICT_ANSI__ */
104 /*
105  * Also defined in ctype.h.
106  */
107 #ifndef MB_CUR_MAX
108 #ifdef __DECLSPEC_SUPPORTED
109 # ifdef __MSVCRT__
110 #  define MB_CUR_MAX __mb_cur_max
111    __MINGW_IMPORT int __mb_cur_max;
112 # else          /* not __MSVCRT */
113 #  define MB_CUR_MAX __mb_cur_max_dll
114    __MINGW_IMPORT int __mb_cur_max_dll;
115 # endif         /* not __MSVCRT */
116
117 #else           /* ! __DECLSPEC_SUPPORTED */
118 # ifdef __MSVCRT__
119    extern int* _imp____mb_cur_max;
120 #  define MB_CUR_MAX (*_imp____mb_cur_max)
121 # else          /* not __MSVCRT */
122    extern int*  _imp____mb_cur_max_dll;
123 #  define MB_CUR_MAX (*_imp____mb_cur_max_dll)
124 # endif         /* not __MSVCRT */
125 #endif          /*  __DECLSPEC_SUPPORTED */
126 #endif  /* MB_CUR_MAX */
127
128 /*
129  * MS likes to declare errno in stdlib.h as well.
130  */
131
132 #ifdef _UWIN
133 #undef errno
134 extern int errno;
135 #else
136  _CRTIMP int* __cdecl __MINGW_NOTHROW   _errno(void);
137 #define errno           (*_errno())
138 #endif
139  _CRTIMP int* __cdecl __MINGW_NOTHROW   __doserrno(void);
140 #define _doserrno       (*__doserrno())
141
142 #if !defined (__STRICT_ANSI__)
143 /*
144  * Use environ from the DLL, not as a global.
145  */
146
147 #ifdef __MSVCRT__
148   extern _CRTIMP char *** __cdecl __MINGW_NOTHROW __p__environ(void);
149   extern _CRTIMP wchar_t *** __cdecl __MINGW_NOTHROW  __p__wenviron(void);
150 # define _environ (*__p__environ())
151 # define _wenviron (*__p__wenviron())
152 #else /* ! __MSVCRT__ */
153 # ifndef __DECLSPEC_SUPPORTED
154     extern char *** _imp___environ_dll;
155 #   define _environ (*_imp___environ_dll)
156 # else /* __DECLSPEC_SUPPORTED */
157     __MINGW_IMPORT char ** _environ_dll;
158 #   define _environ _environ_dll
159 # endif /* __DECLSPEC_SUPPORTED */
160 #endif /* ! __MSVCRT__ */
161
162 #define environ _environ
163
164 #ifdef  __MSVCRT__
165 /* One of the MSVCRTxx libraries */
166
167 #ifndef __DECLSPEC_SUPPORTED
168   extern int*   _imp___sys_nerr;
169 # define        sys_nerr        (*_imp___sys_nerr)
170 #else /* __DECLSPEC_SUPPORTED */
171   __MINGW_IMPORT int    _sys_nerr;
172 # ifndef _UWIN
173 #   define      sys_nerr        _sys_nerr
174 # endif /* _UWIN */
175 #endif /* __DECLSPEC_SUPPORTED */
176
177 #else /* ! __MSVCRT__ */
178
179 /* CRTDLL run time library */
180
181 #ifndef __DECLSPEC_SUPPORTED
182   extern int*   _imp___sys_nerr_dll;
183 # define sys_nerr       (*_imp___sys_nerr_dll)
184 #else /* __DECLSPEC_SUPPORTED */
185   __MINGW_IMPORT int    _sys_nerr_dll;
186 # define sys_nerr       _sys_nerr_dll
187 #endif /* __DECLSPEC_SUPPORTED */
188
189 #endif /* ! __MSVCRT__ */
190
191 #ifndef __DECLSPEC_SUPPORTED
192 extern char***  _imp__sys_errlist;
193 #define sys_errlist     (*_imp___sys_errlist)
194 #else /* __DECLSPEC_SUPPORTED */
195 __MINGW_IMPORT char*    _sys_errlist[];
196 #ifndef _UWIN
197 #define sys_errlist     _sys_errlist
198 #endif /* _UWIN */
199 #endif /* __DECLSPEC_SUPPORTED */
200
201 /*
202  * OS version and such constants.
203  */
204
205 #ifdef  __MSVCRT__
206 /* msvcrtxx.dll */
207
208 extern _CRTIMP unsigned __cdecl __MINGW_NOTHROW int*    __p__osver(void);
209 extern _CRTIMP unsigned __cdecl __MINGW_NOTHROW int*    __p__winver(void);
210 extern _CRTIMP unsigned __cdecl __MINGW_NOTHROW int*    __p__winmajor(void);
211 extern _CRTIMP unsigned __cdecl __MINGW_NOTHROW int*    __p__winminor(void);
212
213 #ifndef __DECLSPEC_SUPPORTED
214 # define _osver         (*__p__osver())
215 # define _winver        (*__p__winver())
216 # define _winmajor      (*__p__winmajor())
217 # define _winminor      (*__p__winminor())
218 #else
219 __MINGW_IMPORT unsigned int _osver;
220 __MINGW_IMPORT unsigned int _winver;
221 __MINGW_IMPORT unsigned int _winmajor;
222 __MINGW_IMPORT unsigned int _winminor;
223 #endif /* __DECLSPEC_SUPPORTED */
224
225 #else
226 /* Not msvcrtxx.dll, thus crtdll.dll */
227
228 #ifndef __DECLSPEC_SUPPORTED
229
230 extern unsigned int*    _imp___osver_dll;
231 extern unsigned int*    _imp___winver_dll;
232 extern unsigned int*    _imp___winmajor_dll;
233 extern unsigned int*    _imp___winminor_dll;
234
235 #define _osver          (*_imp___osver_dll)
236 #define _winver         (*_imp___winver_dll)
237 #define _winmajor       (*_imp___winmajor_dll)
238 #define _winminor       (*_imp___winminor_dll)
239
240 #else /* __DECLSPEC_SUPPORTED */
241
242 __MINGW_IMPORT unsigned int     _osver_dll;
243 __MINGW_IMPORT unsigned int     _winver_dll;
244 __MINGW_IMPORT unsigned int     _winmajor_dll;
245 __MINGW_IMPORT unsigned int     _winminor_dll;
246
247 #define _osver          _osver_dll
248 #define _winver         _winver_dll
249 #define _winmajor       _winmajor_dll
250 #define _winminor       _winminor_dll
251
252 #endif /* __DECLSPEC_SUPPORTED */
253
254 #endif
255
256 #if defined  __MSVCRT__
257 /* although the _pgmptr is exported as DATA,
258  * be safe and use the access function __p__pgmptr() to get it. */
259 _CRTIMP char** __cdecl __MINGW_NOTHROW __p__pgmptr(void);
260 #define _pgmptr     (*__p__pgmptr())
261 _CRTIMP wchar_t** __cdecl __MINGW_NOTHROW __p__wpgmptr(void);
262 #define _wpgmptr    (*__p__wpgmptr())
263 #else /* ! __MSVCRT__ */
264 # ifndef __DECLSPEC_SUPPORTED
265   extern char** __imp__pgmptr_dll;
266 # define _pgmptr (*_imp___pgmptr_dll)
267 # else /* __DECLSPEC_SUPPORTED */
268  __MINGW_IMPORT char* _pgmptr_dll;
269 # define _pgmptr _pgmptr_dll
270 # endif /* __DECLSPEC_SUPPORTED */
271 /* no wide version in CRTDLL */
272 #endif /* __MSVCRT__ */
273
274 /*
275  * This variable determines the default file mode.
276  * TODO: Which flags work?
277  */
278 #if !defined (__DECLSPEC_SUPPORTED) || defined (__IN_MINGW_RUNTIME)
279
280 #ifdef __MSVCRT__
281 extern int* _imp___fmode;
282 #define _fmode  (*_imp___fmode)
283 #else
284 /* CRTDLL */
285 extern int* _imp___fmode_dll;
286 #define _fmode  (*_imp___fmode_dll)
287 #endif
288
289 #else /* __DECLSPEC_SUPPORTED */
290
291 #ifdef __MSVCRT__
292 __MINGW_IMPORT  int _fmode;
293 #else /* ! __MSVCRT__ */
294 __MINGW_IMPORT  int _fmode_dll;
295 #define _fmode  _fmode_dll
296 #endif /* ! __MSVCRT__ */
297
298 #endif /* __DECLSPEC_SUPPORTED */
299
300 #endif /* Not __STRICT_ANSI__ */
301
302 _CRTIMP double __cdecl __MINGW_NOTHROW  atof    (const char*);
303 _CRTIMP int __cdecl __MINGW_NOTHROW     atoi    (const char*);
304 _CRTIMP long __cdecl __MINGW_NOTHROW    atol    (const char*);
305 #if !defined (__STRICT_ANSI__)
306 _CRTIMP double __cdecl __MINGW_NOTHROW  _wtof (const wchar_t *);
307 _CRTIMP int __cdecl __MINGW_NOTHROW     _wtoi (const wchar_t *);
308 _CRTIMP long __cdecl __MINGW_NOTHROW _wtol (const wchar_t *);
309 #endif
310 #if !defined __NO_ISOCEXT  /*  in libmingwex.a */
311 double __cdecl __MINGW_NOTHROW __strtod (const char*, char**);
312 extern double __cdecl __MINGW_NOTHROW
313 strtod (const char* __restrict__ __nptr, char** __restrict__ __endptr);
314 float __cdecl __MINGW_NOTHROW strtof (const char * __restrict__, char ** __restrict__);
315 long double __cdecl __MINGW_NOTHROW strtold (const char * __restrict__, char ** __restrict__);
316 #else
317 _CRTIMP double __cdecl __MINGW_NOTHROW  strtod  (const char*, char**);
318 #endif /* __NO_ISOCEXT */
319
320 _CRTIMP long __cdecl __MINGW_NOTHROW    strtol  (const char*, char**, int);
321 _CRTIMP unsigned long __cdecl __MINGW_NOTHROW   strtoul (const char*, char**, int);
322
323 #ifndef _WSTDLIB_DEFINED
324 /*  also declared in wchar.h */
325 _CRTIMP long __cdecl __MINGW_NOTHROW    wcstol  (const wchar_t*, wchar_t**, int);
326 _CRTIMP unsigned long __cdecl __MINGW_NOTHROW   wcstoul (const wchar_t*, wchar_t**, int);
327 _CRTIMP double __cdecl __MINGW_NOTHROW  wcstod  (const wchar_t*, wchar_t**);
328 #if !defined __NO_ISOCEXT /*  in libmingwex.a */
329 float __cdecl __MINGW_NOTHROW wcstof( const wchar_t * __restrict__, wchar_t ** __restrict__);
330 long double __cdecl __MINGW_NOTHROW wcstold (const wchar_t * __restrict__, wchar_t ** __restrict__);
331 #endif /* __NO_ISOCEXT */
332 #ifdef __MSVCRT__
333 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetenv(const wchar_t*);
334 _CRTIMP int __cdecl __MINGW_NOTHROW     _wputenv(const wchar_t*);
335 _CRTIMP void __cdecl __MINGW_NOTHROW    _wsearchenv(const wchar_t*, const wchar_t*, wchar_t*);
336 _CRTIMP int __cdecl __MINGW_NOTHROW     _wsystem(const wchar_t*);
337 _CRTIMP void __cdecl __MINGW_NOTHROW    _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*);
338 _CRTIMP void __cdecl __MINGW_NOTHROW    _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*);
339 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW   _wfullpath (wchar_t*, const wchar_t*, size_t);
340 #endif
341 #define _WSTDLIB_DEFINED
342 #endif
343
344 _CRTIMP size_t __cdecl __MINGW_NOTHROW  wcstombs        (char*, const wchar_t*, size_t);
345 _CRTIMP int __cdecl __MINGW_NOTHROW     wctomb          (char*, wchar_t);
346
347 _CRTIMP int __cdecl __MINGW_NOTHROW     mblen           (const char*, size_t);
348 _CRTIMP size_t __cdecl __MINGW_NOTHROW  mbstowcs        (wchar_t*, const char*, size_t);
349 _CRTIMP int __cdecl __MINGW_NOTHROW     mbtowc          (wchar_t*, const char*, size_t);
350
351 _CRTIMP int __cdecl __MINGW_NOTHROW     rand    (void);
352 _CRTIMP void __cdecl __MINGW_NOTHROW    srand   (unsigned int);
353
354 _CRTIMP void* __cdecl __MINGW_NOTHROW   calloc  (size_t, size_t) __MINGW_ATTRIB_MALLOC;
355 _CRTIMP void* __cdecl __MINGW_NOTHROW   malloc  (size_t) __MINGW_ATTRIB_MALLOC;
356 _CRTIMP void* __cdecl __MINGW_NOTHROW   realloc (void*, size_t);
357 _CRTIMP void __cdecl __MINGW_NOTHROW    free    (void*);
358 _CRTIMP void __cdecl __MINGW_NOTHROW    abort   (void) __MINGW_ATTRIB_NORETURN;
359 _CRTIMP void __cdecl __MINGW_NOTHROW    exit    (int) __MINGW_ATTRIB_NORETURN;
360
361 /* Note: This is in startup code, not imported directly from dll */
362 int __cdecl __MINGW_NOTHROW     atexit  (void (*)(void));
363
364 _CRTIMP int __cdecl __MINGW_NOTHROW     system  (const char*);
365 _CRTIMP char* __cdecl __MINGW_NOTHROW   getenv  (const char*);
366
367 /* bsearch and qsort are also in non-ANSI header search.h  */
368 _CRTIMP void* __cdecl bsearch (const void*, const void*, size_t, size_t,
369                                int (*)(const void*, const void*));
370 _CRTIMP void __cdecl qsort(void*, size_t, size_t,
371                            int (*)(const void*, const void*));
372
373 _CRTIMP int __cdecl __MINGW_NOTHROW     abs     (int) __MINGW_ATTRIB_CONST;
374 _CRTIMP long __cdecl __MINGW_NOTHROW    labs    (long) __MINGW_ATTRIB_CONST;
375
376 /*
377  * div_t and ldiv_t are structures used to return the results of div and
378  * ldiv.
379  *
380  * NOTE: div and ldiv appear not to work correctly unless
381  *       -fno-pcc-struct-return is specified. This is included in the
382  *       mingw32 specs file.
383  */
384 typedef struct { int quot, rem; } div_t;
385 typedef struct { long quot, rem; } ldiv_t;
386
387 _CRTIMP div_t __cdecl __MINGW_NOTHROW   div     (int, int) __MINGW_ATTRIB_CONST;
388 _CRTIMP ldiv_t __cdecl __MINGW_NOTHROW  ldiv    (long, long) __MINGW_ATTRIB_CONST;
389
390 #if !defined (__STRICT_ANSI__)
391
392 /*
393  * NOTE: Officially the three following functions are obsolete. The Win32 API
394  *       functions SetErrorMode, Beep and Sleep are their replacements.
395  */
396 _CRTIMP void __cdecl __MINGW_NOTHROW    _beep (unsigned int, unsigned int) __MINGW_ATTRIB_DEPRECATED;
397 /* Not to be confused with  _set_error_mode (int).  */
398 _CRTIMP void __cdecl __MINGW_NOTHROW    _seterrormode (int) __MINGW_ATTRIB_DEPRECATED;
399 _CRTIMP void __cdecl __MINGW_NOTHROW    _sleep (unsigned long) __MINGW_ATTRIB_DEPRECATED;
400
401 _CRTIMP void __cdecl __MINGW_NOTHROW    _exit   (int) __MINGW_ATTRIB_NORETURN;
402
403 /* _onexit is MS extension. Use atexit for portability.  */
404 /* Note: This is in startup code, not imported directly from dll */
405 typedef  int (* _onexit_t)(void);
406 _onexit_t __cdecl __MINGW_NOTHROW _onexit( _onexit_t );
407
408 _CRTIMP int __cdecl __MINGW_NOTHROW     _putenv (const char*);
409 _CRTIMP void __cdecl __MINGW_NOTHROW    _searchenv (const char*, const char*, char*);
410
411 _CRTIMP char* __cdecl __MINGW_NOTHROW   _ecvt (double, int, int*, int*);
412 _CRTIMP char* __cdecl __MINGW_NOTHROW   _fcvt (double, int, int*, int*);
413 _CRTIMP char* __cdecl __MINGW_NOTHROW   _gcvt (double, int, char*);
414
415 _CRTIMP void __cdecl __MINGW_NOTHROW    _makepath (char*, const char*, const char*, const char*, const char*);
416 _CRTIMP void __cdecl __MINGW_NOTHROW    _splitpath (const char*, char*, char*, char*, char*);
417 _CRTIMP char* __cdecl __MINGW_NOTHROW   _fullpath (char*, const char*, size_t);
418
419 _CRTIMP char* __cdecl __MINGW_NOTHROW   _itoa (int, char*, int);
420 _CRTIMP char* __cdecl __MINGW_NOTHROW   _ltoa (long, char*, int);
421 _CRTIMP char* __cdecl __MINGW_NOTHROW   _ultoa(unsigned long, char*, int);
422 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW  _itow (int, wchar_t*, int);
423 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW  _ltow (long, wchar_t*, int);
424 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW  _ultow (unsigned long, wchar_t*, int);
425
426 #ifdef __MSVCRT__
427 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _atoi64(const char *);
428 _CRTIMP char* __cdecl __MINGW_NOTHROW   _i64toa(__int64, char *, int);
429 _CRTIMP char* __cdecl __MINGW_NOTHROW   _ui64toa(unsigned __int64, char *, int);
430 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _wtoi64(const wchar_t *);
431 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _i64tow(__int64, wchar_t *, int);
432 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _ui64tow(unsigned __int64, wchar_t *, int);
433
434 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW (_rotl)(unsigned int, int) __MINGW_ATTRIB_CONST;
435 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW (_rotr)(unsigned int, int) __MINGW_ATTRIB_CONST;
436 _CRTIMP unsigned long __cdecl __MINGW_NOTHROW (_lrotl)(unsigned long, int) __MINGW_ATTRIB_CONST;
437 _CRTIMP unsigned long __cdecl __MINGW_NOTHROW (_lrotr)(unsigned long, int) __MINGW_ATTRIB_CONST;
438
439 _CRTIMP int __cdecl __MINGW_NOTHROW _set_error_mode (int);
440
441 # define _OUT_TO_DEFAULT        0
442 # define _OUT_TO_STDERR         1
443 # define _OUT_TO_MSGBOX         2
444 # define _REPORT_ERRMODE        3
445
446 # if __MSVCRT_VERSION__ >= 0x800
447 #  ifndef _UINTPTR_T_DEFINED
448 #   define _UINTPTR_T_DEFINED
449 #   ifdef _WIN64
450       typedef unsigned __int64 uintptr_t;
451 #   else
452       typedef unsigned int uintptr_t;
453 #   endif
454 #  endif
455
456 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _set_abort_behavior (unsigned int, unsigned int);
457
458 /* These masks work with msvcr80.dll version 8.0.50215.44 (a beta release).  */
459 #  define _WRITE_ABORT_MSG      1
460 #  define _CALL_REPORTFAULT     2
461
462 typedef void
463 (* _invalid_parameter_handler) (
464     const wchar_t *,
465     const wchar_t *,
466     const wchar_t *,
467     unsigned int,
468     uintptr_t);
469 _invalid_parameter_handler _set_invalid_parameter_handler (_invalid_parameter_handler);
470
471 # endif /* __MSVCRT_VERSION__ >= 0x800 */
472 #endif /* __MSVCRT__ */
473
474 #ifndef _NO_OLDNAMES
475
476 _CRTIMP int __cdecl __MINGW_NOTHROW     putenv (const char*);
477 _CRTIMP void __cdecl __MINGW_NOTHROW    searchenv (const char*, const char*, char*);
478
479 _CRTIMP char* __cdecl __MINGW_NOTHROW   itoa (int, char*, int);
480 _CRTIMP char* __cdecl __MINGW_NOTHROW   ltoa (long, char*, int);
481
482 #ifndef _UWIN
483 _CRTIMP char* __cdecl __MINGW_NOTHROW   ecvt (double, int, int*, int*);
484 _CRTIMP char* __cdecl __MINGW_NOTHROW   fcvt (double, int, int*, int*);
485 _CRTIMP char* __cdecl __MINGW_NOTHROW   gcvt (double, int, char*);
486 #endif /* _UWIN */
487 #endif  /* Not _NO_OLDNAMES */
488
489 #endif  /* Not __STRICT_ANSI__ */
490
491 /* C99 names */
492
493 #if !defined __NO_ISOCEXT /* externs in static libmingwex.a */
494
495 /* C99 name for _exit */
496 void __cdecl __MINGW_NOTHROW _Exit(int) __MINGW_ATTRIB_NORETURN;
497 #if !defined __NO_INLINE__ && !defined __STRICT_ANSI__
498 __CRT_INLINE __JMPSTUB__(( FUNCTION = _Exit, REMAPPED = _exit ))
499 void __cdecl __MINGW_NOTHROW _Exit( int __status ){ _exit (__status); }
500 #endif
501
502 typedef struct { long long quot, rem; } lldiv_t;
503
504 lldiv_t __cdecl __MINGW_NOTHROW lldiv (long long, long long) __MINGW_ATTRIB_CONST;
505
506 long long __cdecl __MINGW_NOTHROW llabs(long long);
507 #ifndef __NO_INLINE__
508 __CRT_INLINE
509 /* No JMPSTUB or LIBIMPL reference here -- we provide a free-standing
510  * implementation, along with imaxabs(), in mingwex/imaxabs.c
511  */
512 long long __cdecl __MINGW_NOTHROW llabs( long long __j )
513 { return __j >= 0 ? __j : -__j; }
514 #endif
515
516 long long  __cdecl __MINGW_NOTHROW strtoll (const char* __restrict__, char** __restrict, int);
517 unsigned long long  __cdecl __MINGW_NOTHROW strtoull (const char* __restrict__, char** __restrict__, int);
518
519 #if defined (__MSVCRT__) /* these are stubs for MS _i64 versions */
520 long long  __cdecl __MINGW_NOTHROW atoll (const char *);
521
522 #if !defined (__STRICT_ANSI__)
523 long long  __cdecl __MINGW_NOTHROW wtoll (const wchar_t *);
524 char* __cdecl __MINGW_NOTHROW lltoa (long long, char *, int);
525 char* __cdecl __MINGW_NOTHROW ulltoa (unsigned long long , char *, int);
526 wchar_t* __cdecl __MINGW_NOTHROW lltow (long long, wchar_t *, int);
527 wchar_t* __cdecl __MINGW_NOTHROW ulltow (unsigned long long, wchar_t *, int);
528
529 #ifndef __NO_INLINE__ /* inline support for non-ansi functions */
530
531 __CRT_INLINE __JMPSTUB__(( FUNCTION = atoll, REMAPPED = _atoi64 ))
532 long long __cdecl __MINGW_NOTHROW atoll (const char * _c){ return _atoi64 (_c); }
533
534 __CRT_INLINE __JMPSTUB__(( FUNCTION = lltoa, REMAPPED = _i64toa ))
535 char* __cdecl __MINGW_NOTHROW lltoa (long long _n, char * _c, int _i)
536 { return _i64toa (_n, _c, _i); }
537
538 __CRT_INLINE __JMPSTUB__(( FUNCTION = ulltoa, REMAPPED = _ui64toa ))
539 char* __cdecl __MINGW_NOTHROW ulltoa (unsigned long long _n, char * _c, int _i)
540 { return _ui64toa (_n, _c, _i); }
541
542 __CRT_INLINE __JMPSTUB__(( FUNCTION = wtoll, REMAPPED = _wtoi64 ))
543 long long __cdecl __MINGW_NOTHROW wtoll (const wchar_t * _w){ return _wtoi64 (_w); }
544
545 __CRT_INLINE __JMPSTUB__(( FUNCTION = lltow, REMAPPED = _i64tow ))
546 wchar_t* __cdecl __MINGW_NOTHROW lltow (long long _n, wchar_t * _w, int _i)
547 { return _i64tow (_n, _w, _i); }
548
549 __CRT_INLINE __JMPSTUB__(( FUNCTION = ulltow, REMAPPED = _ui64tow ))
550 wchar_t* __cdecl __MINGW_NOTHROW ulltow (unsigned long long _n, wchar_t * _w, int _i)
551 { return _ui64tow (_n, _w, _i); }
552
553 #endif /* (__NO_INLINE__) */
554 #endif /* (__STRICT_ANSI__)  */
555
556 #endif /* __MSVCRT__ */
557 #endif /* !__NO_ISOCEXT */
558
559 /* POSIX/BSD extensions in libmingwex.a; these should be exposed only on
560  * the basis of appropriate POSIX or BSD specific feature tests...
561  *
562  * mkstemp(3) function support; added per feature request #2003.
563  * POSIX wants _XOPEN_SOURCE >= 500, (implying _POSIX_C_SOURCE >= 200112L).
564  */
565 #if _POSIX_C_SOURCE >= 200112L
566
567 int __cdecl __MINGW_NOTHROW mkstemp( char * );
568 int __cdecl __MINGW_NOTHROW __mingw_mkstemp( int, char * );
569
570 /* The following macros are a MinGW specific extension, to facilite
571  * use of _O_TEMPORARY, (in addition to the POSIX required attributes),
572  * when creating the temporary file.  Note that they require fcntl.h,
573  * which stdlib.h should NOT automatically include; we leave the onus
574  * on the user to explicitly include it, if using MKSTEMP_SETMODE.
575  */
576 #define _MKSTEMP_INVOKE       0
577 #define _MKSTEMP_DEFAULT     _O_CREAT | _O_EXCL | _O_RDWR
578 #define _MKSTEMP_SETMODE(M) __mingw_mkstemp( _MKSTEMP_DEFAULT | (M), NULL )
579
580 #ifndef _NO_OLDNAMES
581 #define MKSTEMP_SETMODE(M)  __mingw_mkstemp( _MKSTEMP_DEFAULT | (M), NULL )
582 #endif
583
584 __CRT_ALIAS __LIBIMPL__(( FUNCTION = mkstemp ))
585 int __cdecl __MINGW_NOTHROW mkstemp( char *__filename_template )
586 { return __mingw_mkstemp( _MKSTEMP_INVOKE, __filename_template ); }
587
588 #endif /* _POSIX_C_SOURCE >= 200112L (for mkstemp()) */
589
590 /* mkdtemp(3) function support: added as adjunct to feature request #2003.
591  * POSIX wants _XOPEN_SOURCE >= 700, (implying _POSIX_C_SOURCE >= 200809L).
592  */
593 #if _POSIX_C_SOURCE >= 200809L
594
595 char * __cdecl __MINGW_NOTHROW mkdtemp( char * );
596 char * __cdecl __MINGW_NOTHROW __mingw_mkdtemp( char * );
597
598 __CRT_ALIAS __JMPSTUB__(( FUNCTION = mkdtemp ))
599 char * __cdecl __MINGW_NOTHROW mkdtemp( char *__dirname_template )
600 { return __mingw_mkdtemp( __dirname_template ); }
601
602 #endif /* _POSIX_C_SOURCE >= 200809L (for mkdtemp()) */
603
604 _END_C_DECLS
605
606 #endif  /* Not RC_INVOKED */
607 #endif  /* Not _STDLIB_H_ */