xref: /reactos/sdk/include/crt/stdlib.h (revision e1605243)
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   _Check_return_
1199   unsigned int
1200   __cdecl
1201   _rotl(
1202     _In_ unsigned int _Val,
1203     _In_ int _Shift);
1204 
1205 #if _INTEGRAL_MAX_BITS >= 64
1206   _Check_return_
1207   __MINGW_EXTENSION
1208   unsigned __int64
1209   __cdecl
1210   _rotl64(
1211     _In_ unsigned __int64 _Val,
1212     _In_ int _Shift);
1213 #endif
1214 
1215   _Check_return_
1216   unsigned int
1217   __cdecl
1218   _rotr(
1219     _In_ unsigned int _Val,
1220     _In_ int _Shift);
1221 
1222 #if _INTEGRAL_MAX_BITS >= 64
1223   _Check_return_
1224   __MINGW_EXTENSION
1225   unsigned __int64
1226   __cdecl
1227   _rotr64(
1228     _In_ unsigned __int64 _Val,
1229     _In_ int _Shift);
1230 #endif
1231 
1232 #endif /* !defined(__GNUC__) && !defined(__clang__) */
1233 
1234   _CRTIMP
1235   void
1236   __cdecl
1237   _searchenv(
1238     _In_z_ const char *_Filename,
1239     _In_z_ const char *_EnvVar,
1240     _Pre_notnull_ _Post_z_ char *_ResultPath);
1241 
1242   _CRTIMP
1243   void
1244   __cdecl
1245   _splitpath(
1246     _In_z_ const char *_FullPath,
1247     _Pre_maybenull_ _Post_z_ char *_Drive,
1248     _Pre_maybenull_ _Post_z_ char *_Dir,
1249     _Pre_maybenull_ _Post_z_ char *_Filename,
1250     _Pre_maybenull_ _Post_z_ char *_Ext);
1251 
1252   _CRTIMP
1253   void
1254   __cdecl
1255   _swab(
1256     _Inout_updates_(_SizeInBytes) _Post_readable_size_(_SizeInBytes) char *_Buf1,
1257     _Inout_updates_(_SizeInBytes) _Post_readable_size_(_SizeInBytes) char *_Buf2,
1258     int _SizeInBytes);
1259 
1260 #ifndef _WSTDLIBP_DEFINED
1261 #define _WSTDLIBP_DEFINED
1262 
1263   _Check_return_
1264   _CRTIMP
1265   wchar_t*
1266   __cdecl
1267   _wfullpath(
1268     _Out_writes_opt_z_(_SizeInWords) wchar_t *_FullPath,
1269     _In_z_ const wchar_t *_Path,
1270     _In_ size_t _SizeInWords);
1271 
1272   _CRTIMP
1273   void
1274   __cdecl
1275   _wmakepath(
1276     _Pre_notnull_ _Post_z_ wchar_t *_ResultPath,
1277     _In_opt_z_ const wchar_t *_Drive,
1278     _In_opt_z_ const wchar_t *_Dir,
1279     _In_opt_z_ const wchar_t *_Filename,
1280     _In_opt_z_ const wchar_t *_Ext);
1281 
1282 #ifndef _CRT_WPERROR_DEFINED
1283 #define _CRT_WPERROR_DEFINED
1284   _CRTIMP
1285   void
1286   __cdecl
1287   _wperror(
1288     _In_opt_z_ const wchar_t *_ErrMsg);
1289 #endif
1290 
1291   _Check_return_
1292   _CRTIMP
1293   int
1294   __cdecl
1295   _wputenv(
1296     _In_z_ const wchar_t *_EnvString);
1297 
1298   _CRTIMP
1299   void
1300   __cdecl
1301   _wsearchenv(
1302     _In_z_ const wchar_t *_Filename,
1303     _In_z_ const wchar_t *_EnvVar,
1304     _Pre_notnull_ _Post_z_ wchar_t *_ResultPath);
1305 
1306   _CRTIMP
1307   void
1308   __cdecl
1309   _wsplitpath(
1310     _In_z_ const wchar_t *_FullPath,
1311     _Pre_maybenull_ _Post_z_ wchar_t *_Drive,
1312     _Pre_maybenull_ _Post_z_ wchar_t *_Dir,
1313     _Pre_maybenull_ _Post_z_ wchar_t *_Filename,
1314     _Pre_maybenull_ _Post_z_ wchar_t *_Ext);
1315 
1316 #endif /* _WSTDLIBP_DEFINED */
1317 
1318   _CRTIMP
1319   __MINGW_ATTRIB_DEPRECATED
1320   void
1321   __cdecl
1322   _beep(
1323     _In_ unsigned _Frequency,
1324     _In_ unsigned _Duration);
1325 
1326   /* Not to be confused with  _set_error_mode (int).  */
1327   _CRTIMP
1328   __MINGW_ATTRIB_DEPRECATED
1329   void
1330   __cdecl
1331   _seterrormode(
1332     _In_ int _Mode);
1333 
1334   _CRTIMP
1335   __MINGW_ATTRIB_DEPRECATED
1336   void
1337   __cdecl
1338   _sleep(
1339     _In_ unsigned long _Duration);
1340 
1341 #endif /* _POSIX_ */
1342 
1343 #ifndef NO_OLDNAMES
1344 #ifndef _POSIX_
1345 #if 0
1346 #ifndef __cplusplus
1347 #ifndef NOMINMAX
1348 #ifndef max
1349 #define max(a,b) (((a) > (b)) ? (a) : (b))
1350 #endif
1351 #ifndef min
1352 #define min(a,b) (((a) < (b)) ? (a) : (b))
1353 #endif
1354 #endif /* NOMINMAX */
1355 #endif /* __cplusplus */
1356 #endif
1357 
1358 #define sys_errlist _sys_errlist
1359 #define sys_nerr _sys_nerr
1360 #define environ _environ
1361 
1362   _Check_return_
1363   _CRTIMP
1364   char*
1365   __cdecl
1366   ecvt(
1367     _In_ double _Val,
1368     _In_ int _NumOfDigits,
1369     _Out_ int *_PtDec,
1370     _Out_ int *_PtSign);
1371 
1372   _Check_return_
1373   _CRTIMP
1374   char*
1375   __cdecl
1376   fcvt(
1377     _In_ double _Val,
1378     _In_ int _NumOfDec,
1379     _Out_ int *_PtDec,
1380     _Out_ int *_PtSign);
1381 
1382   _CRTIMP
1383   char*
1384   __cdecl
1385   gcvt(
1386     _In_ double _Val,
1387     _In_ int _NumOfDigits,
1388     _Pre_notnull_ _Post_z_ char *_DstBuf);
1389 
1390   _CRTIMP
1391   char*
1392   __cdecl
1393   itoa(
1394     _In_ int _Val,
1395     _Pre_notnull_ _Post_z_ char *_DstBuf,
1396     _In_ int _Radix);
1397 
1398   _CRTIMP
1399   char*
1400   __cdecl
1401   ltoa(
1402     _In_ long _Val,
1403     _Pre_notnull_ _Post_z_ char *_DstBuf,
1404     _In_ int _Radix);
1405 
1406   _Check_return_
1407   _CRTIMP
1408   int
1409   __cdecl
1410   putenv(
1411     _In_z_ const char *_EnvString);
1412 
1413   _CRTIMP
1414   void
1415   __cdecl
1416   swab(
1417     _Inout_updates_z_(_SizeInBytes) char *_Buf1,
1418     _Inout_updates_z_(_SizeInBytes) char *_Buf2,
1419     _In_ int _SizeInBytes);
1420 
1421   _CRTIMP
1422   char*
1423   __cdecl
1424   ultoa(
1425     _In_ unsigned long _Val,
1426     _Pre_notnull_ _Post_z_ char *_Dstbuf,
1427     _In_ int _Radix);
1428 
1429   onexit_t
1430   __cdecl
1431   onexit(
1432     _In_opt_ onexit_t _Func);
1433 
1434 #endif /* _POSIX_ */
1435 #endif /* NO_OLDNAMES */
1436 
1437 #if !defined __NO_ISOCEXT /* externs in static libmingwex.a */
1438 
1439   __MINGW_EXTENSION typedef struct { long long quot, rem; } lldiv_t;
1440 
1441   _Check_return_ __MINGW_EXTENSION lldiv_t __cdecl lldiv(_In_ long long, _In_ long long);
1442 
1443   __MINGW_EXTENSION __CRT_INLINE long long __cdecl llabs(_In_ long long _j) { return (_j >= 0 ? _j : -_j); }
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
1477