Sync with trunk revision 64099.
[reactos.git] / include / crt / stdlib.h
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
5 */
6 #ifndef _INC_STDLIB
7 #define _INC_STDLIB
8
9 #include <crtdefs.h>
10 #include <limits.h>
11
12 #pragma pack(push,_CRT_PACKING)
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #ifndef NULL
19 #ifdef __cplusplus
20 #ifndef _WIN64
21 #define NULL 0
22 #else
23 #define NULL 0LL
24 #endif /* W64 */
25 #else
26 #define NULL ((void *)0)
27 #endif
28 #endif
29
30 #ifndef MB_LEN_MAX
31 #define MB_LEN_MAX 5
32 #endif
33
34 #define EXIT_SUCCESS 0
35 #define EXIT_FAILURE 1
36
37 #ifndef _ONEXIT_T_DEFINED
38 #define _ONEXIT_T_DEFINED
39
40 typedef int (__cdecl *_onexit_t)(void);
41
42 #ifndef NO_OLDNAMES
43 #define onexit_t _onexit_t
44 #endif
45 #endif
46
47 #ifndef _DIV_T_DEFINED
48 #define _DIV_T_DEFINED
49
50 typedef struct _div_t {
51 int quot;
52 int rem;
53 } div_t;
54
55 typedef struct _ldiv_t {
56 long quot;
57 long rem;
58 } ldiv_t;
59 #endif
60
61 #ifndef _CRT_DOUBLE_DEC
62 #define _CRT_DOUBLE_DEC
63
64 #pragma pack(4)
65 typedef struct {
66 unsigned char ld[10];
67 } _LDOUBLE;
68 #pragma pack()
69
70 #define _PTR_LD(x) ((unsigned char *)(&(x)->ld))
71
72 typedef struct {
73 double x;
74 } _CRT_DOUBLE;
75
76 typedef struct {
77 float f;
78 } _CRT_FLOAT;
79 #if __MINGW_GNUC_PREREQ(4,4)
80 #pragma push_macro("long")
81 #undef long
82 #endif
83
84 typedef struct {
85 long double x;
86 } _LONGDOUBLE;
87
88 #if __MINGW_GNUC_PREREQ(4,4)
89 #pragma pop_macro("long")
90 #endif
91
92 #pragma pack(4)
93 typedef struct {
94 unsigned char ld12[12];
95 } _LDBL12;
96 #pragma pack()
97 #endif
98
99 #define RAND_MAX 0x7fff
100
101 #ifndef MB_CUR_MAX
102 #define MB_CUR_MAX ___mb_cur_max_func()
103 #ifdef _M_CEE_PURE
104 _CRTIMP int* __cdecl __p___mb_cur_max();
105 #define __mb_cur_max (*__p___mb_cur_max())
106 #else /* !_M_CEE_PURE */
107 _CRTIMP extern int __mb_cur_max;
108 #endif /* !_M_CEE_PURE */
109 _CRTIMP int __cdecl ___mb_cur_max_func(void);
110 _CRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t);
111 #endif /* !MB_CUR_MAX */
112
113 #define __max(a,b) (((a) > (b)) ? (a) : (b))
114 #define __min(a,b) (((a) < (b)) ? (a) : (b))
115
116 #define _MAX_PATH 260
117 #define _MAX_DRIVE 3
118 #define _MAX_DIR 256
119 #define _MAX_FNAME 256
120 #define _MAX_EXT 256
121
122 #define _OUT_TO_DEFAULT 0
123 #define _OUT_TO_STDERR 1
124 #define _OUT_TO_MSGBOX 2
125 #define _REPORT_ERRMODE 3
126
127 #define _WRITE_ABORT_MSG 0x1
128 #define _CALL_REPORTFAULT 0x2
129
130 #define _MAX_ENV 32767
131
132 typedef void (__cdecl *_purecall_handler)(void);
133
134 _CRTIMP _purecall_handler __cdecl _set_purecall_handler(_In_opt_ _purecall_handler _Handler);
135 _CRTIMP _purecall_handler __cdecl _get_purecall_handler(void);
136
137 typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t *,const wchar_t *,const wchar_t *,unsigned int,uintptr_t);
138 _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_In_opt_ _invalid_parameter_handler _Handler);
139 _invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
140
141 #include <errno.h>
142 _CRTIMP unsigned long *__cdecl __doserrno(void);
143 #define _doserrno (*__doserrno())
144 errno_t __cdecl _set_doserrno(_In_ unsigned long _Value);
145 errno_t __cdecl _get_doserrno(_Out_ unsigned long *_Value);
146
147 _CRTIMP extern char *_sys_errlist[];
148 _CRTIMP extern int _sys_nerr;
149
150 #if defined(_DLL) && defined(_M_IX86)
151 _CRTIMP int *__cdecl __p___argc(void);
152 _CRTIMP char ***__cdecl __p___argv(void);
153 _CRTIMP wchar_t ***__cdecl __p___wargv(void);
154 _CRTIMP char ***__cdecl __p__environ(void);
155 _CRTIMP wchar_t ***__cdecl __p__wenviron(void);
156 _CRTIMP char **__cdecl __p__pgmptr(void);
157 _CRTIMP wchar_t **__cdecl __p__wpgmptr(void);
158 #endif
159
160 // FIXME: move inside _M_CEE_PURE section
161 _CRTIMP int *__cdecl __p___argc();
162 _CRTIMP char ***__cdecl __p___argv();
163 _CRTIMP wchar_t ***__cdecl __p___wargv();
164 _CRTIMP char ***__cdecl __p__environ();
165 _CRTIMP wchar_t ***__cdecl __p__wenviron();
166 _CRTIMP char **__cdecl __p__pgmptr();
167 _CRTIMP wchar_t **__cdecl __p__wpgmptr();
168
169 #ifdef _M_CEE_PURE
170 #define __argv (*__p___argv())
171 #define __argc (*__p___argc())
172 #define __wargv (*__p___wargv())
173 #define _environ (*__p__environ())
174 #define _wenviron (*__p__wenviron())
175 #define _pgmptr (*__p__pgmptr())
176 #define _wpgmptr (*__p__wpgmptr())
177 #else /* !_M_CEE_PURE */
178 _CRTIMP extern int __argc;
179 _CRTIMP extern char **__argv;
180 _CRTIMP extern wchar_t **__wargv;
181 _CRTIMP extern char **_environ;
182 _CRTIMP extern wchar_t **_wenviron;
183 _CRTIMP extern char *_pgmptr;
184 _CRTIMP extern wchar_t *_wpgmptr;
185 #endif /* !_M_CEE_PURE */
186
187 _CRTIMP errno_t __cdecl _get_environ(_Out_ char***);
188 _CRTIMP errno_t __cdecl _get_wenviron(_Out_ wchar_t***);
189 _CRTIMP errno_t __cdecl _get_pgmptr(_Outptr_result_z_ char **_Value);
190 _CRTIMP errno_t __cdecl _get_wpgmptr(_Outptr_result_z_ wchar_t **_Value);
191
192 #ifdef _M_CEE_PURE
193 _CRTIMP int* __cdecl __p__fmode();
194 #define _fmode (*__p__fmode())
195 #else
196 _CRTIMP extern int _fmode;
197 #endif /* !_M_CEE_PURE */
198 _CRTIMP errno_t __cdecl _set_fmode(_In_ int _Mode);
199 _CRTIMP errno_t __cdecl _get_fmode(_Out_ int *_PMode);
200
201 #ifdef _M_CEE_PURE
202 _CRTIMP unsigned int* __cdecl __p__osplatform();
203 _CRTIMP unsigned int* __cdecl __p__osver();
204 _CRTIMP unsigned int* __cdecl __p__winver();
205 _CRTIMP unsigned int* __cdecl __p__winmajor();
206 _CRTIMP unsigned int* __cdecl __p__winminor();
207 #define _osplatform (*__p__osplatform())
208 #define _osver (*__p__osver())
209 #define _winver (*__p__winver())
210 #define _winmajor (*__p__winmajor())
211 #define _winminor (*__p__winminor())
212 #else /* !_M_CEE_PURE */
213 _CRTIMP extern unsigned int _osplatform;
214 _CRTIMP extern unsigned int _osver;
215 _CRTIMP extern unsigned int _winver;
216 _CRTIMP extern unsigned int _winmajor;
217 _CRTIMP extern unsigned int _winminor;
218 #endif /* !_M_CEE_PURE */
219
220 errno_t __cdecl _get_osplatform(_Out_ unsigned int *_Value);
221 errno_t __cdecl _get_osver(_Out_ unsigned int *_Value);
222 errno_t __cdecl _get_winver(_Out_ unsigned int *_Value);
223 errno_t __cdecl _get_winmajor(_Out_ unsigned int *_Value);
224 errno_t __cdecl _get_winminor(_Out_ unsigned int *_Value);
225
226 #ifndef _countof
227 #ifndef __cplusplus
228 #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
229 #else
230 extern "C++" {
231 template <typename _CountofType,size_t _SizeOfArray>
232 char (*__countof_helper(/*UNALIGNED*/ _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
233 #define _countof(_Array) sizeof(*__countof_helper(_Array))
234 }
235 #endif
236 #endif
237
238 #ifndef _CRT_TERMINATE_DEFINED
239 #define _CRT_TERMINATE_DEFINED
240 __declspec(noreturn) void __cdecl exit(_In_ int _Code);
241 _CRTIMP __declspec(noreturn) void __cdecl _exit(_In_ int _Code);
242 #if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
243 /* C99 function name */
244 __declspec(noreturn) void __cdecl _Exit(int); /* Declare to get noreturn attribute. */
245 __CRT_INLINE void __cdecl _Exit(int status)
246 { _exit(status); }
247 #endif
248 #if __MINGW_GNUC_PREREQ(4,4)
249 #pragma push_macro("abort")
250 #undef abort
251 #endif
252 __declspec(noreturn) void __cdecl abort(void);
253 #if __MINGW_GNUC_PREREQ(4,4)
254 #pragma pop_macro("abort")
255 #endif
256 #endif
257
258 _CRTIMP unsigned int __cdecl _set_abort_behavior(_In_ unsigned int _Flags, _In_ unsigned int _Mask);
259
260 #ifndef _CRT_ABS_DEFINED
261 #define _CRT_ABS_DEFINED
262 int __cdecl abs(_In_ int _X);
263 long __cdecl labs(_In_ long _X);
264 #endif
265
266 #if _INTEGRAL_MAX_BITS >= 64
267 __MINGW_EXTENSION __int64 __cdecl _abs64(__int64);
268 #endif
269 int __cdecl atexit(void (__cdecl *)(void));
270
271 #ifndef _CRT_ATOF_DEFINED
272 #define _CRT_ATOF_DEFINED
273
274 _Check_return_
275 double
276 __cdecl
277 atof(
278 _In_z_ const char *_String);
279
280 _Check_return_
281 double
282 __cdecl
283 _atof_l(
284 _In_z_ const char *_String,
285 _In_opt_ _locale_t _Locale);
286
287 #endif /* _CRT_ATOF_DEFINED */
288
289 _Check_return_
290 int
291 __cdecl
292 atoi(
293 _In_z_ const char *_Str);
294
295 _Check_return_
296 _CRTIMP
297 int
298 __cdecl
299 _atoi_l(
300 _In_z_ const char *_Str,
301 _In_opt_ _locale_t _Locale);
302
303 _Check_return_
304 long
305 __cdecl
306 atol(
307 _In_z_ const char *_Str);
308
309 _Check_return_
310 _CRTIMP
311 long
312 __cdecl
313 _atol_l(
314 _In_z_ const char *_Str,
315 _In_opt_ _locale_t _Locale);
316
317 #ifndef _CRT_ALGO_DEFINED
318 #define _CRT_ALGO_DEFINED
319
320 _Check_return_
321 void*
322 __cdecl
323 bsearch(
324 _In_ const void *_Key,
325 _In_reads_bytes_(_NumOfElements * _SizeOfElements) const void *_Base,
326 _In_ size_t _NumOfElements,
327 _In_ size_t _SizeOfElements,
328 _In_ int (__cdecl *_PtFuncCompare)(const void *,const void *));
329
330 void
331 __cdecl
332 qsort(
333 _Inout_updates_bytes_(_NumOfElements * _SizeOfElements) _Post_readable_byte_size_(_NumOfElements * _SizeOfElements) void *_Base,
334 _In_ size_t _NumOfElements,
335 _In_ size_t _SizeOfElements,
336 _In_ int (__cdecl *_PtFuncCompare)(const void *,const void *));
337
338 #endif /* _CRT_ALGO_DEFINED */
339
340 #if !defined(__GNUC__) && !defined(__clang__)
341
342 _Check_return_
343 unsigned short
344 __cdecl
345 _byteswap_ushort(
346 _In_ unsigned short _Short);
347
348 _Check_return_
349 unsigned long
350 __cdecl
351 _byteswap_ulong(
352 _In_ unsigned long _Long);
353
354 #if _INTEGRAL_MAX_BITS >= 64
355 _Check_return_
356 __MINGW_EXTENSION
357 unsigned __int64
358 __cdecl
359 _byteswap_uint64(
360 _In_ unsigned __int64 _Int64);
361 #endif
362
363 #endif /* !defined(__GNUC__) && !defined(__clang__) */
364
365 _Check_return_
366 div_t
367 __cdecl
368 div(
369 _In_ int _Numerator,
370 _In_ int _Denominator);
371
372 _Check_return_
373 char*
374 __cdecl
375 getenv(
376 _In_z_ const char *_VarName);
377
378 _CRTIMP
379 char*
380 __cdecl
381 _itoa(
382 _In_ int _Value,
383 _Pre_notnull_ _Post_z_ char *_Dest,
384 _In_ int _Radix);
385
386 #if _INTEGRAL_MAX_BITS >= 64
387
388 __MINGW_EXTENSION
389 _CRTIMP
390 char*
391 __cdecl
392 _i64toa(
393 _In_ __int64 _Val,
394 _Pre_notnull_ _Post_z_ char *_DstBuf,
395 _In_ int _Radix);
396
397 __MINGW_EXTENSION
398 _CRTIMP
399 char*
400 __cdecl
401 _ui64toa(
402 _In_ unsigned __int64 _Val,
403 _Pre_notnull_ _Post_z_ char *_DstBuf,
404 _In_ int _Radix);
405
406 _Check_return_
407 __MINGW_EXTENSION
408 _CRTIMP
409 __int64
410 __cdecl
411 _atoi64(
412 _In_z_ const char *_String);
413
414 _Check_return_
415 __MINGW_EXTENSION
416 _CRTIMP
417 __int64
418 __cdecl
419 _atoi64_l(
420 _In_z_ const char *_String,
421 _In_opt_ _locale_t _Locale);
422
423 _Check_return_
424 __MINGW_EXTENSION
425 _CRTIMP
426 __int64
427 __cdecl
428 _strtoi64(
429 _In_z_ const char *_String,
430 _Out_opt_ _Deref_post_z_ char **_EndPtr,
431 _In_ int _Radix);
432
433 _Check_return_
434 __MINGW_EXTENSION
435 _CRTIMP
436 __int64
437 __cdecl
438 _strtoi64_l(
439 _In_z_ const char *_String,
440 _Out_opt_ _Deref_post_z_ char **_EndPtr,
441 _In_ int _Radix,
442 _In_opt_ _locale_t _Locale);
443
444 _Check_return_
445 __MINGW_EXTENSION
446 _CRTIMP
447 unsigned __int64
448 __cdecl
449 _strtoui64(
450 _In_z_ const char *_String,
451 _Out_opt_ _Deref_post_z_ char **_EndPtr,
452 _In_ int _Radix);
453
454 _Check_return_
455 __MINGW_EXTENSION
456 _CRTIMP
457 unsigned __int64
458 __cdecl
459 _strtoui64_l(
460 _In_z_ const char *_String,
461 _Out_opt_ _Deref_post_z_ char **_EndPtr,
462 _In_ int _Radix,
463 _In_opt_ _locale_t _Locale);
464
465 #endif /* _INTEGRAL_MAX_BITS >= 64 */
466
467 _Check_return_
468 ldiv_t
469 __cdecl
470 ldiv(
471 _In_ long _Numerator,
472 _In_ long _Denominator);
473
474 _CRTIMP
475 char*
476 __cdecl
477 _ltoa(
478 _In_ long _Value,
479 _Pre_notnull_ _Post_z_ char *_Dest,
480 _In_ int _Radix);
481
482 _Check_return_
483 int
484 __cdecl
485 mblen(
486 _In_reads_bytes_opt_(_MaxCount) _Pre_opt_z_ const char *_Ch,
487 _In_ size_t _MaxCount);
488
489 _Check_return_
490 _CRTIMP
491 int
492 __cdecl
493 _mblen_l(
494 _In_reads_bytes_opt_(_MaxCount) _Pre_opt_z_ const char *_Ch,
495 _In_ size_t _MaxCount,
496 _In_opt_ _locale_t _Locale);
497
498 _Check_return_
499 _CRTIMP
500 size_t
501 __cdecl
502 _mbstrlen(
503 _In_z_ const char *_Str);
504
505 _Check_return_
506 _CRTIMP
507 size_t
508 __cdecl
509 _mbstrlen_l(
510 _In_z_ const char *_Str,
511 _In_opt_ _locale_t _Locale);
512
513 _Success_(return>0)
514 _Check_return_
515 _CRTIMP
516 size_t
517 __cdecl
518 _mbstrnlen(
519 _In_z_ const char *_Str,
520 _In_ size_t _MaxCount);
521
522 _Check_return_
523 _CRTIMP
524 size_t
525 __cdecl
526 _mbstrnlen_l(
527 _In_z_ const char *_Str,
528 _In_ size_t _MaxCount,
529 _In_opt_ _locale_t _Locale);
530
531 int
532 __cdecl
533 mbtowc(
534 _Pre_notnull_ _Post_z_ wchar_t *_DstCh,
535 _In_reads_bytes_opt_(_SrcSizeInBytes) _Pre_opt_z_ const char *_SrcCh,
536 _In_ size_t _SrcSizeInBytes);
537
538 _CRTIMP
539 int
540 __cdecl
541 _mbtowc_l(
542 _Pre_notnull_ _Post_z_ wchar_t *_DstCh,
543 _In_reads_bytes_opt_(_SrcSizeInBytes) _Pre_opt_z_ const char *_SrcCh,
544 _In_ size_t _SrcSizeInBytes,
545 _In_opt_ _locale_t _Locale);
546
547 size_t
548 __cdecl
549 mbstowcs(
550 _Out_writes_opt_z_(_MaxCount) wchar_t *_Dest,
551 _In_z_ const char *_Source,
552 _In_ size_t _MaxCount);
553
554 _CRTIMP
555 size_t
556 __cdecl
557 _mbstowcs_l(
558 _Out_writes_opt_z_(_MaxCount) wchar_t *_Dest,
559 _In_z_ const char *_Source,
560 _In_ size_t _MaxCount,
561 _In_opt_ _locale_t _Locale);
562
563 _Check_return_
564 int
565 __cdecl
566 rand(void);
567
568 _Check_return_opt_
569 _CRTIMP
570 int
571 __cdecl
572 _set_error_mode(
573 _In_ int _Mode);
574
575 void
576 __cdecl
577 srand(
578 _In_ unsigned int _Seed);
579
580 _Check_return_
581 double
582 __cdecl
583 strtod(
584 _In_z_ const char *_Str,
585 _Out_opt_ _Deref_post_z_ char **_EndPtr);
586
587 float
588 __cdecl
589 strtof(
590 const char *nptr,
591 char **endptr);
592
593 #if !defined __NO_ISOCEXT /* in libmingwex.a */
594 float __cdecl strtof (const char * __restrict__, char ** __restrict__);
595 long double __cdecl strtold(const char * __restrict__, char ** __restrict__);
596 #endif /* __NO_ISOCEXT */
597
598 _Check_return_
599 _CRTIMP
600 double
601 __cdecl
602 _strtod_l(
603 _In_z_ const char *_Str,
604 _Out_opt_ _Deref_post_z_ char **_EndPtr,
605 _In_opt_ _locale_t _Locale);
606
607 _Check_return_
608 long
609 __cdecl
610 strtol(
611 _In_z_ const char *_Str,
612 _Out_opt_ _Deref_post_z_ char **_EndPtr,
613 _In_ int _Radix);
614
615 _Check_return_
616 _CRTIMP
617 long
618 __cdecl
619 _strtol_l(
620 _In_z_ const char *_Str,
621 _Out_opt_ _Deref_post_z_ char **_EndPtr,
622 _In_ int _Radix,
623 _In_opt_ _locale_t _Locale);
624
625 _Check_return_
626 unsigned long
627 __cdecl
628 strtoul(
629 _In_z_ const char *_Str,
630 _Out_opt_ _Deref_post_z_ char **_EndPtr,
631 _In_ int _Radix);
632
633 _Check_return_
634 _CRTIMP
635 unsigned long
636 __cdecl
637 _strtoul_l(
638 _In_z_ const char *_Str,
639 _Out_opt_ _Deref_post_z_ char **_EndPtr,
640 _In_ int _Radix,
641 _In_opt_ _locale_t _Locale);
642
643 #ifndef _CRT_SYSTEM_DEFINED
644 #define _CRT_SYSTEM_DEFINED
645 int
646 __cdecl
647 system(
648 _In_opt_z_ const char *_Command);
649 #endif
650
651 _CRTIMP
652 char*
653 __cdecl
654 _ultoa(
655 _In_ unsigned long _Value,
656 _Pre_notnull_ _Post_z_ char *_Dest,
657 _In_ int _Radix);
658
659 int
660 __cdecl
661 wctomb(
662 _Out_writes_opt_z_(MB_LEN_MAX) char *_MbCh,
663 _In_ wchar_t _WCh);
664
665 _CRTIMP
666 int
667 __cdecl
668 _wctomb_l(
669 _Pre_maybenull_ _Post_z_ char *_MbCh,
670 _In_ wchar_t _WCh,
671 _In_opt_ _locale_t _Locale);
672
673 size_t
674 __cdecl
675 wcstombs(
676 _Out_writes_opt_z_(_MaxCount) char *_Dest,
677 _In_z_ const wchar_t *_Source,
678 _In_ size_t _MaxCount);
679
680 _CRTIMP
681 size_t
682 __cdecl
683 _wcstombs_l(
684 _Out_writes_opt_z_(_MaxCount) char *_Dest,
685 _In_z_ const wchar_t *_Source,
686 _In_ size_t _MaxCount,
687 _In_opt_ _locale_t _Locale);
688
689 #ifndef _CRT_ALLOCATION_DEFINED
690 #define _CRT_ALLOCATION_DEFINED
691
692 _Check_return_
693 _Ret_maybenull_
694 _Post_writable_byte_size_(_NumOfElements * _SizeOfElements)
695 void*
696 __cdecl
697 calloc(
698 _In_ size_t _NumOfElements,
699 _In_ size_t _SizeOfElements);
700
701 void
702 __cdecl
703 free(
704 _Pre_maybenull_ _Post_invalid_ void *_Memory);
705
706 _Check_return_
707 _Ret_maybenull_
708 _Post_writable_byte_size_(_Size)
709 void*
710 __cdecl
711 malloc(
712 _In_ size_t _Size);
713
714 _Success_(return != 0)
715 _Check_return_
716 _Ret_maybenull_
717 _Post_writable_byte_size_(_NewSize)
718 void*
719 __cdecl
720 realloc(
721 _Pre_maybenull_ _Post_invalid_ void *_Memory,
722 _In_ size_t _NewSize);
723
724 _Success_(return != 0)
725 _Check_return_
726 _Ret_maybenull_
727 _Post_writable_byte_size_(_Count * _Size)
728 _CRTIMP
729 void*
730 __cdecl
731 _recalloc(
732 _Pre_maybenull_ _Post_invalid_ void *_Memory,
733 _In_ size_t _Count,
734 _In_ size_t _Size);
735
736 /* Make sure that X86intrin.h doesn't produce here collisions. */
737 #if (!defined (_XMMINTRIN_H_INCLUDED) && !defined (_MM_MALLOC_H_INCLUDED)) || defined(_aligned_malloc)
738 #pragma push_macro("_aligned_free")
739 #pragma push_macro("_aligned_malloc")
740 #undef _aligned_free
741 #undef _aligned_malloc
742
743 _CRTIMP
744 void
745 __cdecl
746 _aligned_free(
747 _Pre_maybenull_ _Post_invalid_ void *_Memory);
748
749 _Check_return_
750 _Ret_maybenull_
751 _Post_writable_byte_size_(_Size)
752 _CRTIMP
753 void*
754 __cdecl
755 _aligned_malloc(
756 _In_ size_t _Size,
757 _In_ size_t _Alignment);
758
759 #pragma pop_macro("_aligned_free")
760 #pragma pop_macro("_aligned_malloc")
761 #endif
762
763 _Check_return_
764 _Ret_maybenull_
765 _Post_writable_byte_size_(_Size)
766 _CRTIMP
767 void*
768 __cdecl
769 _aligned_offset_malloc(
770 _In_ size_t _Size,
771 _In_ size_t _Alignment,
772 _In_ size_t _Offset);
773
774 _Success_(return != 0)
775 _Check_return_
776 _Ret_maybenull_
777 _Post_writable_byte_size_(_Size)
778 _CRTIMP
779 void*
780 __cdecl
781 _aligned_realloc(
782 _Pre_maybenull_ _Post_invalid_ void *_Memory,
783 _In_ size_t _Size,
784 _In_ size_t _Alignment);
785
786 _Success_(return != 0)
787 _Check_return_
788 _Ret_maybenull_
789 _Post_writable_byte_size_(_Count * _Size)
790 _CRTIMP
791 void*
792 __cdecl
793 _aligned_recalloc(
794 _Pre_maybenull_ _Post_invalid_ void *_Memory,
795 _In_ size_t _Count,
796 _In_ size_t _Size,
797 _In_ size_t _Alignment);
798
799 _Success_(return != 0)
800 _Check_return_
801 _Ret_maybenull_
802 _Post_writable_byte_size_(_Size)
803 _CRTIMP
804 void*
805 __cdecl
806 _aligned_offset_realloc(
807 _Pre_maybenull_ _Post_invalid_ void *_Memory,
808 _In_ size_t _Size,
809 _In_ size_t _Alignment,
810 _In_ size_t _Offset);
811
812 _Check_return_
813 _Ret_maybenull_
814 _Post_writable_byte_size_(_Count * _Size)
815 _CRTIMP
816 void*
817 __cdecl
818 _aligned_offset_recalloc(
819 _Pre_maybenull_ _Post_invalid_ void *_Memory,
820 _In_ size_t _Count,
821 _In_ size_t _Size,
822 _In_ size_t _Alignment,
823 _In_ size_t _Offset);
824
825 #endif /* _CRT_ALLOCATION_DEFINED */
826
827 #ifndef _WSTDLIB_DEFINED
828 #define _WSTDLIB_DEFINED
829
830 _CRTIMP
831 wchar_t*
832 __cdecl
833 _itow(
834 _In_ int _Value,
835 _Pre_notnull_ _Post_z_ wchar_t *_Dest,
836 _In_ int _Radix);
837
838 _CRTIMP
839 wchar_t*
840 __cdecl
841 _ltow(
842 _In_ long _Value,
843 _Pre_notnull_ _Post_z_ wchar_t *_Dest,
844 _In_ int _Radix);
845
846 _CRTIMP
847 wchar_t*
848 __cdecl
849 _ultow(
850 _In_ unsigned long _Value,
851 _Pre_notnull_ _Post_z_ wchar_t *_Dest,
852 _In_ int _Radix);
853
854 _Check_return_
855 double
856 __cdecl
857 wcstod(
858 _In_z_ const wchar_t *_Str,
859 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr);
860
861 float
862 __cdecl
863 wcstof(
864 const wchar_t *nptr,
865 wchar_t **endptr);
866
867 #if !defined __NO_ISOCEXT /* in libmingwex.a */
868 float __cdecl wcstof( const wchar_t * __restrict__, wchar_t ** __restrict__);
869 long double __cdecl wcstold(const wchar_t * __restrict__, wchar_t ** __restrict__);
870 #endif /* __NO_ISOCEXT */
871
872 _Check_return_
873 _CRTIMP
874 double
875 __cdecl
876 _wcstod_l(
877 _In_z_ const wchar_t *_Str,
878 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
879 _In_opt_ _locale_t _Locale);
880
881 _Check_return_
882 long
883 __cdecl
884 wcstol(
885 _In_z_ const wchar_t *_Str,
886 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
887 _In_ int _Radix);
888
889 _Check_return_
890 _CRTIMP
891 long
892 __cdecl
893 _wcstol_l(
894 _In_z_ const wchar_t *_Str,
895 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
896 _In_ int _Radix,
897 _In_opt_ _locale_t _Locale);
898
899 _Check_return_
900 unsigned long
901 __cdecl
902 wcstoul(
903 _In_z_ const wchar_t *_Str,
904 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
905 _In_ int _Radix);
906
907 _Check_return_
908 _CRTIMP
909 unsigned long
910 __cdecl
911 _wcstoul_l(
912 _In_z_ const wchar_t *_Str,
913 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
914 _In_ int _Radix,
915 _In_opt_ _locale_t _Locale);
916
917 _Check_return_
918 _CRTIMP
919 wchar_t*
920 __cdecl
921 _wgetenv(
922 _In_z_ const wchar_t *_VarName);
923
924 #ifndef _CRT_WSYSTEM_DEFINED
925 #define _CRT_WSYSTEM_DEFINED
926 _CRTIMP
927 int
928 __cdecl
929 _wsystem(
930 _In_opt_z_ const wchar_t *_Command);
931 #endif
932
933 _Check_return_
934 _CRTIMP
935 double
936 __cdecl
937 _wtof(
938 _In_z_ const wchar_t *_Str);
939
940 _Check_return_
941 _CRTIMP
942 double
943 __cdecl
944 _wtof_l(
945 _In_z_ const wchar_t *_Str,
946 _In_opt_ _locale_t _Locale);
947
948 _Check_return_
949 _CRTIMP
950 int
951 __cdecl
952 _wtoi(
953 _In_z_ const wchar_t *_Str);
954
955 _Check_return_
956 _CRTIMP
957 int
958 __cdecl
959 _wtoi_l(
960 _In_z_ const wchar_t *_Str,
961 _In_opt_ _locale_t _Locale);
962
963 _Check_return_
964 _CRTIMP
965 long
966 __cdecl
967 _wtol(
968 _In_z_ const wchar_t *_Str);
969
970 _Check_return_
971 _CRTIMP
972 long
973 __cdecl
974 _wtol_l(
975 _In_z_ const wchar_t *_Str,
976 _In_opt_ _locale_t _Locale);
977
978 #if _INTEGRAL_MAX_BITS >= 64
979
980 __MINGW_EXTENSION
981 _CRTIMP
982 wchar_t*
983 __cdecl
984 _i64tow(
985 _In_ __int64 _Val,
986 _Pre_notnull_ _Post_z_ wchar_t *_DstBuf,
987 _In_ int _Radix);
988
989 __MINGW_EXTENSION
990 _CRTIMP
991 wchar_t*
992 __cdecl
993 _ui64tow(
994 _In_ unsigned __int64 _Val,
995 _Pre_notnull_ _Post_z_ wchar_t *_DstBuf,
996 _In_ int _Radix);
997
998 _Check_return_
999 __MINGW_EXTENSION
1000 _CRTIMP
1001 __int64
1002 __cdecl
1003 _wtoi64(
1004 _In_z_ const wchar_t *_Str);
1005
1006 _Check_return_
1007 __MINGW_EXTENSION
1008 _CRTIMP
1009 __int64
1010 __cdecl
1011 _wtoi64_l(
1012 _In_z_ const wchar_t *_Str,
1013 _In_opt_ _locale_t _Locale);
1014
1015 _Check_return_
1016 __MINGW_EXTENSION
1017 _CRTIMP
1018 __int64
1019 __cdecl
1020 _wcstoi64(
1021 _In_z_ const wchar_t *_Str,
1022 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
1023 _In_ int _Radix);
1024
1025 _Check_return_
1026 __MINGW_EXTENSION
1027 _CRTIMP
1028 __int64
1029 __cdecl
1030 _wcstoi64_l(
1031 _In_z_ const wchar_t *_Str,
1032 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
1033 _In_ int _Radix,
1034 _In_opt_ _locale_t _Locale);
1035
1036 _Check_return_
1037 __MINGW_EXTENSION
1038 _CRTIMP
1039 unsigned __int64
1040 __cdecl
1041 _wcstoui64(
1042 _In_z_ const wchar_t *_Str,
1043 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
1044 _In_ int _Radix);
1045
1046 _Check_return_
1047 __MINGW_EXTENSION
1048 _CRTIMP
1049 unsigned __int64
1050 __cdecl
1051 _wcstoui64_l(
1052 _In_z_ const wchar_t *_Str,
1053 _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr,
1054 _In_ int _Radix,
1055 _In_opt_ _locale_t _Locale);
1056
1057 #endif /* _INTEGRAL_MAX_BITS >= 64 */
1058
1059 #endif /* _WSTDLIB_DEFINED */
1060
1061 #ifndef _POSIX_
1062 #define _CVTBUFSIZE (309+40)
1063
1064 _Check_return_
1065 _CRTIMP
1066 char*
1067 __cdecl
1068 _fullpath(
1069 _Out_writes_opt_z_(_SizeInBytes) char *_FullPath,
1070 _In_z_ const char *_Path,
1071 _In_ size_t _SizeInBytes);
1072
1073 _Check_return_
1074 _CRTIMP
1075 char*
1076 __cdecl
1077 _ecvt(
1078 _In_ double _Val,
1079 _In_ int _NumOfDigits,
1080 _Out_ int *_PtDec,
1081 _Out_ int *_PtSign);
1082
1083 _Check_return_
1084 _CRTIMP
1085 char*
1086 __cdecl
1087 _fcvt(
1088 _In_ double _Val,
1089 _In_ int _NumOfDec,
1090 _Out_ int *_PtDec,
1091 _Out_ int *_PtSign);
1092
1093 _CRTIMP
1094 char*
1095 __cdecl
1096 _gcvt(
1097 _In_ double _Val,
1098 _In_ int _NumOfDigits,
1099 _Pre_notnull_ _Post_z_ char *_DstBuf);
1100
1101 _Check_return_
1102 _CRTIMP
1103 int
1104 __cdecl
1105 _atodbl(
1106 _Out_ _CRT_DOUBLE *_Result,
1107 _In_z_ char *_Str);
1108
1109 _Check_return_
1110 _CRTIMP
1111 int
1112 __cdecl
1113 _atoldbl(
1114 _Out_ _LDOUBLE *_Result,
1115 _In_z_ char *_Str);
1116
1117 _Check_return_
1118 _CRTIMP
1119 int
1120 __cdecl
1121 _atoflt(
1122 _Out_ _CRT_FLOAT *_Result,
1123 _In_z_ char *_Str);
1124
1125 _Check_return_
1126 _CRTIMP
1127 int
1128 __cdecl
1129 _atodbl_l(
1130 _Out_ _CRT_DOUBLE *_Result,
1131 _In_z_ char *_Str,
1132 _In_opt_ _locale_t _Locale);
1133
1134 _Check_return_
1135 _CRTIMP
1136 int
1137 __cdecl
1138 _atoldbl_l(
1139 _Out_ _LDOUBLE *_Result,
1140 _In_z_ char *_Str,
1141 _In_opt_ _locale_t _Locale);
1142
1143 _Check_return_
1144 _CRTIMP
1145 int
1146 __cdecl
1147 _atoflt_l(
1148 _Out_ _CRT_FLOAT *_Result,
1149 _In_z_ char *_Str,
1150 _In_opt_ _locale_t _Locale);
1151
1152 _Check_return_
1153 unsigned long
1154 __cdecl
1155 _lrotl(
1156 _In_ unsigned long _Val,
1157 _In_ int _Shift);
1158
1159 _Check_return_
1160 unsigned long
1161 __cdecl
1162 _lrotr(
1163 _In_ unsigned long _Val,
1164 _In_ int _Shift);
1165
1166 _CRTIMP
1167 void
1168 __cdecl
1169 _makepath(
1170 _Pre_notnull_ _Post_z_ char *_Path,
1171 _In_opt_z_ const char *_Drive,
1172 _In_opt_z_ const char *_Dir,
1173 _In_opt_z_ const char *_Filename,
1174 _In_opt_z_ const char *_Ext);
1175
1176 _onexit_t
1177 __cdecl
1178 _onexit(
1179 _In_opt_ _onexit_t _Func);
1180
1181 #ifndef _CRT_PERROR_DEFINED
1182 #define _CRT_PERROR_DEFINED
1183 void
1184 __cdecl
1185 perror(
1186 _In_opt_z_ const char *_ErrMsg);
1187 #endif
1188
1189 _Check_return_
1190 _CRTIMP
1191 int
1192 __cdecl
1193 _putenv(
1194 _In_z_ const char *_EnvString);
1195
1196 #if !defined(__GNUC__) && !defined(__clang__)
1197
1198 unsigned int
1199 __cdecl
1200 _rotl(
1201 _In_ unsigned int _Val,
1202 _In_ int _Shift);
1203
1204 #if _INTEGRAL_MAX_BITS >= 64
1205 _Check_return_
1206 __MINGW_EXTENSION
1207 unsigned __int64
1208 __cdecl
1209 _rotl64(
1210 _In_ unsigned __int64 _Val,
1211 _In_ int _Shift);
1212 #endif
1213
1214 unsigned int
1215 __cdecl
1216 _rotr(
1217 _In_ unsigned int _Val,
1218 _In_ int _Shift);
1219
1220 #if _INTEGRAL_MAX_BITS >= 64
1221 _Check_return_
1222 __MINGW_EXTENSION
1223 unsigned __int64
1224 __cdecl
1225 _rotr64(
1226 _In_ unsigned __int64 _Val,
1227 _In_ int _Shift);
1228 #endif
1229
1230 #endif /* !defined(__GNUC__) && !defined(__clang__) */
1231
1232 _CRTIMP
1233 void
1234 __cdecl
1235 _searchenv(
1236 _In_z_ const char *_Filename,
1237 _In_z_ const char *_EnvVar,
1238 _Pre_notnull_ _Post_z_ char *_ResultPath);
1239
1240 _CRTIMP
1241 void
1242 __cdecl
1243 _splitpath(
1244 _In_z_ const char *_FullPath,
1245 _Pre_maybenull_ _Post_z_ char *_Drive,
1246 _Pre_maybenull_ _Post_z_ char *_Dir,
1247 _Pre_maybenull_ _Post_z_ char *_Filename,
1248 _Pre_maybenull_ _Post_z_ char *_Ext);
1249
1250 _CRTIMP
1251 void
1252 __cdecl
1253 _swab(
1254 _Inout_updates_(_SizeInBytes) _Post_readable_size_(_SizeInBytes) char *_Buf1,
1255 _Inout_updates_(_SizeInBytes) _Post_readable_size_(_SizeInBytes) char *_Buf2,
1256 int _SizeInBytes);
1257
1258 #ifndef _WSTDLIBP_DEFINED
1259 #define _WSTDLIBP_DEFINED
1260
1261 _Check_return_
1262 _CRTIMP
1263 wchar_t*
1264 __cdecl
1265 _wfullpath(
1266 _Out_writes_opt_z_(_SizeInWords) wchar_t *_FullPath,
1267 _In_z_ const wchar_t *_Path,
1268 _In_ size_t _SizeInWords);
1269
1270 _CRTIMP
1271 void
1272 __cdecl
1273 _wmakepath(
1274 _Pre_notnull_ _Post_z_ wchar_t *_ResultPath,
1275 _In_opt_z_ const wchar_t *_Drive,
1276 _In_opt_z_ const wchar_t *_Dir,
1277 _In_opt_z_ const wchar_t *_Filename,
1278 _In_opt_z_ const wchar_t *_Ext);
1279
1280 #ifndef _CRT_WPERROR_DEFINED
1281 #define _CRT_WPERROR_DEFINED
1282 _CRTIMP
1283 void
1284 __cdecl
1285 _wperror(
1286 _In_opt_z_ const wchar_t *_ErrMsg);
1287 #endif
1288
1289 _Check_return_
1290 _CRTIMP
1291 int
1292 __cdecl
1293 _wputenv(
1294 _In_z_ const wchar_t *_EnvString);
1295
1296 _CRTIMP
1297 void
1298 __cdecl
1299 _wsearchenv(
1300 _In_z_ const wchar_t *_Filename,
1301 _In_z_ const wchar_t *_EnvVar,
1302 _Pre_notnull_ _Post_z_ wchar_t *_ResultPath);
1303
1304 _CRTIMP
1305 void
1306 __cdecl
1307 _wsplitpath(
1308 _In_z_ const wchar_t *_FullPath,
1309 _Pre_maybenull_ _Post_z_ wchar_t *_Drive,
1310 _Pre_maybenull_ _Post_z_ wchar_t *_Dir,
1311 _Pre_maybenull_ _Post_z_ wchar_t *_Filename,
1312 _Pre_maybenull_ _Post_z_ wchar_t *_Ext);
1313
1314 #endif /* _WSTDLIBP_DEFINED */
1315
1316 _CRTIMP
1317 __MINGW_ATTRIB_DEPRECATED
1318 void
1319 __cdecl
1320 _beep(
1321 _In_ unsigned _Frequency,
1322 _In_ unsigned _Duration);
1323
1324 /* Not to be confused with _set_error_mode (int). */
1325 _CRTIMP
1326 __MINGW_ATTRIB_DEPRECATED
1327 void
1328 __cdecl
1329 _seterrormode(
1330 _In_ int _Mode);
1331
1332 _CRTIMP
1333 __MINGW_ATTRIB_DEPRECATED
1334 void
1335 __cdecl
1336 _sleep(
1337 _In_ unsigned long _Duration);
1338
1339 #endif /* _POSIX_ */
1340
1341 #ifndef NO_OLDNAMES
1342 #ifndef _POSIX_
1343 #if 0
1344 #ifndef __cplusplus
1345 #ifndef NOMINMAX
1346 #ifndef max
1347 #define max(a,b) (((a) > (b)) ? (a) : (b))
1348 #endif
1349 #ifndef min
1350 #define min(a,b) (((a) < (b)) ? (a) : (b))
1351 #endif
1352 #endif /* NOMINMAX */
1353 #endif /* __cplusplus */
1354 #endif
1355
1356 #define sys_errlist _sys_errlist
1357 #define sys_nerr _sys_nerr
1358 #define environ _environ
1359
1360 _Check_return_
1361 _CRTIMP
1362 char*
1363 __cdecl
1364 ecvt(
1365 _In_ double _Val,
1366 _In_ int _NumOfDigits,
1367 _Out_ int *_PtDec,
1368 _Out_ int *_PtSign);
1369
1370 _Check_return_
1371 _CRTIMP
1372 char*
1373 __cdecl
1374 fcvt(
1375 _In_ double _Val,
1376 _In_ int _NumOfDec,
1377 _Out_ int *_PtDec,
1378 _Out_ int *_PtSign);
1379
1380 _CRTIMP
1381 char*
1382 __cdecl
1383 gcvt(
1384 _In_ double _Val,
1385 _In_ int _NumOfDigits,
1386 _Pre_notnull_ _Post_z_ char *_DstBuf);
1387
1388 _CRTIMP
1389 char*
1390 __cdecl
1391 itoa(
1392 _In_ int _Val,
1393 _Pre_notnull_ _Post_z_ char *_DstBuf,
1394 _In_ int _Radix);
1395
1396 _CRTIMP
1397 char*
1398 __cdecl
1399 ltoa(
1400 _In_ long _Val,
1401 _Pre_notnull_ _Post_z_ char *_DstBuf,
1402 _In_ int _Radix);
1403
1404 _Check_return_
1405 _CRTIMP
1406 int
1407 __cdecl
1408 putenv(
1409 _In_z_ const char *_EnvString);
1410
1411 _CRTIMP
1412 void
1413 __cdecl
1414 swab(
1415 _Inout_updates_z_(_SizeInBytes) char *_Buf1,
1416 _Inout_updates_z_(_SizeInBytes) char *_Buf2,
1417 _In_ int _SizeInBytes);
1418
1419 _CRTIMP
1420 char*
1421 __cdecl
1422 ultoa(
1423 _In_ unsigned long _Val,
1424 _Pre_notnull_ _Post_z_ char *_Dstbuf,
1425 _In_ int _Radix);
1426
1427 onexit_t
1428 __cdecl
1429 onexit(
1430 _In_opt_ onexit_t _Func);
1431
1432 #endif /* _POSIX_ */
1433 #endif /* NO_OLDNAMES */
1434
1435 #if !defined __NO_ISOCEXT /* externs in static libmingwex.a */
1436
1437 __MINGW_EXTENSION typedef struct { long long quot, rem; } lldiv_t;
1438
1439 _Check_return_ __MINGW_EXTENSION lldiv_t __cdecl lldiv(_In_ long long, _In_ long long);
1440
1441 #ifndef _MSC_VER
1442 __MINGW_EXTENSION __CRT_INLINE long long __cdecl llabs(_In_ long long _j) { return (_j >= 0 ? _j : -_j); }
1443 #endif
1444
1445 __MINGW_EXTENSION long long __cdecl strtoll(const char* __restrict__, char** __restrict, int);
1446 __MINGW_EXTENSION unsigned long long __cdecl strtoull(const char* __restrict__, char** __restrict__, int);
1447
1448 /* these are stubs for MS _i64 versions */
1449 __MINGW_EXTENSION long long __cdecl atoll (const char *);
1450
1451 #ifndef __STRICT_ANSI__
1452 __MINGW_EXTENSION long long __cdecl wtoll (const wchar_t *);
1453 __MINGW_EXTENSION char *__cdecl lltoa (long long, char *, int);
1454 __MINGW_EXTENSION char *__cdecl ulltoa (unsigned long long , char *, int);
1455 __MINGW_EXTENSION wchar_t *__cdecl lltow (long long, wchar_t *, int);
1456 __MINGW_EXTENSION wchar_t *__cdecl ulltow (unsigned long long, wchar_t *, int);
1457
1458 /* __CRT_INLINE using non-ansi functions */
1459 __MINGW_EXTENSION __CRT_INLINE long long __cdecl atoll (const char * _c) { return _atoi64 (_c); }
1460 __MINGW_EXTENSION __CRT_INLINE char *__cdecl lltoa (long long _n, char * _c, int _i) { return _i64toa (_n, _c, _i); }
1461 __MINGW_EXTENSION __CRT_INLINE char *__cdecl ulltoa (unsigned long long _n, char * _c, int _i) { return _ui64toa (_n, _c, _i); }
1462 __MINGW_EXTENSION __CRT_INLINE long long __cdecl wtoll (const wchar_t * _w) { return _wtoi64 (_w); }
1463 __MINGW_EXTENSION __CRT_INLINE wchar_t *__cdecl lltow (long long _n, wchar_t * _w, int _i) { return _i64tow (_n, _w, _i); }
1464 __MINGW_EXTENSION __CRT_INLINE wchar_t *__cdecl ulltow (unsigned long long _n, wchar_t * _w, int _i) { return _ui64tow (_n, _w, _i); }
1465 #endif /* (__STRICT_ANSI__) */
1466
1467 #endif /* !__NO_ISOCEXT */
1468
1469 #ifdef __cplusplus
1470 }
1471 #endif
1472
1473 #pragma pack(pop)
1474
1475 #include <sec_api/stdlib_s.h>
1476 #endif