1 /***
2 *stdlib.h - declarations/definitions for commonly used library functions
3 *
4 *           Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 *Purpose:
7 *           This include file contains the function declarations for commonly
8 *           used library functions which either don't fit somewhere else, or,
9 *           cannot be declared in the normal place for other reasons.
10 *           [ANSI]
11 *
12 *           [Public]
13 *
14 ****/
15
16 #if        _MSC_VER > 1000
17 #pragma once
18 #endif
19
20 #ifndef _INC_STDLIB
21 #define _INC_STDLIB
22
23 #include <crtdefs.h>
24 #include <limits.h>
25
26 #ifdef  _MSC_VER
27 /*
28  * Currently, all MS C compilers for Win32 platforms default to 8 byte
29  * alignment.
30  */
31 #pragma pack(push,_CRT_PACKING)
32 #endif  /* _MSC_VER */
33
34 #ifdef  __cplusplus
35 extern "C" {
36 #endif
37
38 /* Define NULL pointer value */
39 #ifndef NULL
40 #ifdef __cplusplus
41 #define NULL      0
42 #else
43 #define NULL      ((void *)0)
44 #endif
45 #endif
46
47 /* Definition of the argument values for the exit() function */
48
49 #define EXIT_SUCCESS      0
50 #define EXIT_FAILURE      1
51
52
53 #ifndef _ONEXIT_T_DEFINED
54
55 #if !defined (_M_CEE_PURE)
56 typedef int (__cdecl * _onexit_t)(void);
57 #else
58 typedef int (__clrcall * _onexit_t)(void);
59 typedef _onexit_t _onexit_m_t;
60 #endif
61
62 #if defined (_M_CEE_MIXED)
63 typedef int (__clrcall * _onexit_m_t)(void);
64 #endif
65
66 #if        !__STDC__
67 /* Non-ANSI name for compatibility */
68 #define onexit_t _onexit_t
69 #endif
70
71 #define _ONEXIT_T_DEFINED
72 #endif
73
74
75 /* Data structure definitions for div and ldiv runtimes. */
76
77 #ifndef _DIV_T_DEFINED
78
79 typedef struct _div_t {
80              int quot;
81              int rem;
82 } div_t;
83
84 typedef struct _ldiv_t {
85              long quot;
86              long rem;
87 } ldiv_t;
88
89 #define _DIV_T_DEFINED
90 #endif
91
92 /*
93  * structs used to fool the compiler into not generating floating point
94  * instructions when copying and pushing [long] double values
95  */
96
97 #ifndef _CRT_DOUBLE_DEC
98
99 #ifndef _LDSUPPORT
100
101 #pragma pack(4)
102 typedef struct {
103       unsigned char ld[10];
104 } _LDOUBLE;
105 #pragma pack()
106
107 #define _PTR_LD(x) ((unsigned char  *)(&(x)->ld))
108
109 #else
110
111 /* push and pop long, which is #defined as __int64 by a spec2k test */
112 #pragma push_macro("long")
113 #undef long
114 typedef long double _LDOUBLE;
115 #pragma pop_macro("long")
116
117 #define _PTR_LD(x) ((unsigned char  *)(x))
118
Lines 119 ... 128 are skipped.
129 /* push and pop long, which is #defined as __int64 by a spec2k test */
130 #pragma push_macro("long")
131 #undef long
132
133 typedef struct {
134              /*
135                * Assume there is a long double type
136                */
137              long double x;
138 } _LONGDOUBLE;
139
140 #pragma pop_macro("long")
141
142 #pragma pack(4)
143 typedef struct {
144       unsigned char ld12[12];
145 } _LDBL12;
146 #pragma pack()
147
148 #define _CRT_DOUBLE_DEC
149 #endif
150
151 /* Maximum value that can be returned by the rand function. */
152
153 #define RAND_MAX 0x7fff
154
155 /*
156  * Maximum number of bytes in multi-byte character in the current locale
157  * (also defined in ctype.h).
158  */
159 #ifndef MB_CUR_MAX
160 #ifdef _MT
161 #define MB_CUR_MAX ___mb_cur_max_func()
162 #else
163 #define MB_CUR_MAX __mb_cur_max
164 #endif
165 #if !defined(_M_CEE_PURE)
166 _CRTIMP extern int __mb_cur_max;
167 #else
168 _CRTIMP int* __cdecl __p___mb_cur_max();
169 #define __mb_cur_max (*__p___mb_cur_max())
170 #endif /* !defined(_M_CEE_PURE) */
171 _CRTIMP int __cdecl ___mb_cur_max_func(void);
172 _CRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t);
173 #endif  /* MB_CUR_MAX */
174
175 /* Minimum and maximum macros */
176
177 #define __max(a,b)  (((a) > (b)) ? (a) : (b))
178 #define __min(a,b)  (((a) < (b)) ? (a) : (b))
179
180 /*
181  * Sizes for buffers used by the _makepath() and _splitpath() functions.
182  * note that the sizes include space for 0-terminator
183  */
184 #define _MAX_PATH     260 /* max. length of full pathname */
185 #define _MAX_DRIVE  3     /* max. length of drive component */
186 #define _MAX_DIR      256 /* max. length of path component */
187 #define _MAX_FNAME  256 /* max. length of file name component */
188 #define _MAX_EXT      256 /* max. length of extension component */
189
190 /*
191  * Argument values for _set_error_mode().
192  */
193 #define _OUT_TO_DEFAULT 0
194 #define _OUT_TO_STDERR  1
195 #define _OUT_TO_MSGBOX  2
196 #define _REPORT_ERRMODE 3
197
198 /*
199  * Argument values for _set_abort_behavior().
200  */
201 #define _WRITE_ABORT_MSG      0x1
202 #define _CALL_REPORTFAULT     0x2
203
204 /*
205  * Sizes for buffers used by the getenv/putenv family of functions.
206  */
207 #define _MAX_ENV 32767     
208
209 #if !defined(_M_CEE_PURE)
210 /* a purecall handler procedure. Never returns normally */
211 typedef void (__cdecl *_purecall_handler)(void); 
212
213 /* establishes a purecall handler for the process */
214 _CRTIMP _purecall_handler __cdecl _set_purecall_handler(_In_opt_ _purecall_handler _Handler);
215 _CRTIMP _purecall_handler __cdecl _get_purecall_handler();
216 #endif
217
218 #if defined(__cplusplus)
219 extern "C++"
220 {
221 #if defined(_M_CEE_PURE)
222       typedef void (__clrcall *_purecall_handler)(void);
223       typedef _purecall_handler _purecall_handler_m;
224       _MRTIMP _purecall_handler __cdecl _set_purecall_handler(_In_opt_ _purecall_handler _Handler);
225 #endif
226
227 #if defined(_M_CEE_MIXED)
228       typedef void (__clrcall *_purecall_handler_m)(void);
229
230       _MRTIMP _purecall_handler_m __cdecl _set_purecall_handler(_In_opt_ _purecall_handler_m _Handler);
231
232       _MRTIMP _purecall_handler __cdecl _set_purecall_handler(_In_ int _Handler); /* To disambiguate NULL/0 */
233 #endif
234 }
235 #endif
236
237 #if !defined(_M_CEE_PURE)
238 /* a invalid_arg handler procedure. */
239 typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t *, const wchar_t *, const wchar_t *, unsigned int, uintptr_t); 
240
241 /* establishes a invalid_arg handler for the process */
242 _CRTIMP _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_In_opt_ _invalid_parameter_handler _Handler);
243 _CRTIMP _invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
244 #endif
245
246 #if defined(__cplusplus)
247 extern "C++"
248 {
249 #if defined(_M_CEE_PURE)
250       typedef void (__clrcall *_invalid_parameter_handler)(const wchar_t *, const wchar_t *, const wchar_t *, unsigned int, uintptr_t);
251       typedef _invalid_parameter_handler _invalid_parameter_handler_m;
252       _MRTIMP _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_In_opt_ _invalid_parameter_handler _Handlerh);
253 #endif
254
255 #if defined(_M_CEE_MIXED)
256       typedef void (__clrcall *_invalid_parameter_handler_m)(const wchar_t *, const wchar_t *, const wchar_t *, unsigned int, uintptr_t);
257       _MRTIMP _invalid_parameter_handler_m __cdecl _set_invalid_parameter_handler(_In_opt_ _invalid_parameter_handler_m _Handlerh);
258
259       _MRTIMP _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_In_ int _Handler); /* To disambiguate NULL/0, only when we have both */
260 #endif
261 }
262 #endif
263
264 /* External variable declarations */
265 #ifndef _CRT_ERRNO_DEFINED
266 #define _CRT_ERRNO_DEFINED
267 _CRTIMP extern int * __cdecl _errno(void);
268 #define errno     (*_errno())
269
270 errno_t __cdecl _set_errno(_In_ int _Value);
271 errno_t __cdecl _get_errno(_Out_ int * _Value);
272 #endif
273
274 _CRTIMP unsigned long * __cdecl __doserrno(void);
275 #define _doserrno     (*__doserrno())
276
277 errno_t __cdecl _set_doserrno(_In_ unsigned long _Value);
278 errno_t __cdecl _get_doserrno(_Out_ unsigned long * _Value);
279
280 /* you can't modify this, but it is non-const for backcompat */
281 _CRTIMP _CRT_INSECURE_DEPRECATE(strerror) char ** __cdecl __sys_errlist(void);
282 #define _sys_errlist (__sys_errlist())
283
284 _CRTIMP _CRT_INSECURE_DEPRECATE(strerror) int * __cdecl __sys_nerr(void);
285 #define _sys_nerr (*__sys_nerr())
286
287 #if        defined(_DLL) && defined(_M_IX86)
288
289 _CRTIMP int *                __cdecl __p___argc(void);
290 _CRTIMP char ***           __cdecl __p___argv(void);
291 _CRTIMP wchar_t ***      __cdecl __p___wargv(void);
292 _CRTIMP char ***           __cdecl __p__environ(void);
293 _CRTIMP wchar_t ***      __cdecl __p__wenviron(void);
294 _CRTIMP char **             __cdecl __p__pgmptr(void);
295 _CRTIMP wchar_t **        __cdecl __p__wpgmptr(void);
296
297
298 #endif  /* _M_IX86 && _DLL */
299
300 #if !defined(_M_CEE_PURE)
301 _CRTIMP extern int __argc;                /* count of cmd line args */
302 _CRTIMP extern char ** __argv;          /* pointer to table of cmd line args */
303 _CRTIMP extern wchar_t ** __wargv;  /* pointer to table of wide cmd line args */
304 #else
305 _CRTIMP int* __cdecl __p___argc();
306 _CRTIMP char*** __cdecl __p___argv();
307 _CRTIMP wchar_t*** __cdecl __p___wargv();
308 #define __argv (*__p___argv())
309 #define __argc (*__p___argc())
310 #define __wargv (*__p___wargv())
311 #endif
312
313 #if !defined(_M_CEE_PURE)
314 #ifdef  _POSIX_
315 extern char ** environ;                     /* pointer to environment table */
316 #else
317 _CRTIMP extern char ** _environ;      /* pointer to environment table */
318 _CRTIMP extern wchar_t ** _wenviron;      /* pointer to wide environment table */
319 #endif  /* _POSIX_ */
320
321 _CRT_INSECURE_DEPRECATE_GLOBALS(_get_pgmptr) _CRTIMP extern char * _pgmptr;          /* points to the module (EXE) name */
322 _CRT_INSECURE_DEPRECATE_GLOBALS(_get_wpgmptr) _CRTIMP extern wchar_t * _wpgmptr;  /* points to the module (EXE) wide name */
323
324
325 #else
326
327 _CRTIMP char*** __cdecl __p__environ();
328 _CRTIMP wchar_t*** __cdecl __p__wenviron();
329 _CRT_INSECURE_DEPRECATE_GLOBALS(_get_pgmptr) _CRTIMP char** __cdecl __p__pgmptr();
330 _CRT_INSECURE_DEPRECATE_GLOBALS(_get_wpgmptr) _CRTIMP wchar_t** __cdecl __p__wpgmptr();
331
332 #define _environ     (*__p__environ())
333 #define _wenviron  (*__p__wenviron())
334 #define _pgmptr      (*__p__pgmptr())
335 #define _wpgmptr     (*__p__wpgmptr())
336
337 #endif /* !defined(_M_CEE_PURE) */
338
339 errno_t __cdecl _get_pgmptr(_Deref_out_z_ char ** _Value);
340 errno_t __cdecl _get_wpgmptr(_Deref_out_z_ wchar_t ** _Value);
341
342
343 #if !defined(_M_CEE_PURE)
344 _CRT_INSECURE_DEPRECATE_GLOBALS(_get_fmode) _CRTIMP extern int _fmode;                /* default file translation mode */
345 #else
346 _CRTIMP int* __cdecl __p__fmode();
347 #define _fmode (*__p__fmode())
348 #endif /* !defined(_M_CEE_PURE) */
349
350 _CRTIMP errno_t __cdecl _set_fmode(_In_ int _Mode);
351 _CRTIMP errno_t __cdecl _get_fmode(_Out_ int * _PMode);
352
353 /* _countof helper */
354 #if !defined(_countof)
355 #if !defined(__cplusplus)
356 #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
357 #else
358 extern "C++"
359 {
360 template <typename _CountofType, size_t _SizeOfArray>
361 char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
362 #define _countof(_Array) sizeof(*__countof_helper(_Array))
363 }
364 #endif
365 #endif
366
367 /* function prototypes */
368
369 #ifndef _CRT_TERMINATE_DEFINED
370 #define _CRT_TERMINATE_DEFINED
371 _CRTIMP __declspec(noreturn) void __cdecl exit(_In_ int _Code);
372 _CRTIMP __declspec(noreturn) void __cdecl _exit(_In_ int _Code);
373 _CRTIMP void __cdecl abort(void);
374 #endif
375
376 _CRTIMP unsigned int __cdecl _set_abort_behavior(_In_ unsigned int _Flags, _In_ unsigned int _Mask);
377
378 #ifndef _CRT_ABS_DEFINED
379 #define _CRT_ABS_DEFINED
380              int        __cdecl abs(_In_ int _X);
381              long      __cdecl labs(_In_ long _X);
382 #endif
383
384              __int64      __cdecl _abs64(__int64);
385 #if _MSC_VER >= 1400 && defined(_M_CEE)
386 #pragma warning (suppress: 4985)
387              _Check_return_ int      __clrcall _atexit_m_appdomain(_In_opt_ void (__clrcall * _Func)(void));
388 #if defined(_M_CEE_MIXED)
389 #pragma warning (suppress: 4985)
390              _Check_return_ int      __clrcall _atexit_m(_In_opt_ void (__clrcall * _Func)(void));
391 #else
392              _Check_return_ inline int __clrcall _atexit_m(_In_opt_ void (__clrcall *_Function)(void))
393 #pragma warning (suppress: 4985)
394              {
395                     return _atexit_m_appdomain(_Function);
396              }
397 #endif
398 #endif
399 #if defined(_M_CEE_PURE)
400              /* In pure mode, atexit is the same as atexit_m_appdomain */
401 extern "C++"
402 {
403 inline  int      __clrcall atexit
404 (
405       void (__clrcall *_Function)(void)
406 )
407 {
408       return _atexit_m_appdomain(_Function);
409 }
410 }
411 #else
412              int      __cdecl atexit(void (__cdecl *)(void));
413 #endif
414 #ifndef _CRT_ATOF_DEFINED
415 #define _CRT_ATOF_DEFINED
416 _Check_return_ _CRTIMP double  __cdecl atof(_In_z_ const char *_String);
417 _Check_return_ _CRTIMP double  __cdecl _atof_l(_In_z_ const char *_String, _In_opt_ _locale_t _Locale);
418 #endif
419 _Check_return_ _CRTIMP _CRT_JIT_INTRINSIC int      __cdecl atoi(_In_z_ const char *_Str);
420 _Check_return_ _CRTIMP int      __cdecl _atoi_l(_In_z_ const char *_Str, _In_opt_ _locale_t _Locale);
421 _Check_return_ _CRTIMP long     __cdecl atol(_In_z_ const char *_Str);
422 _Check_return_ _CRTIMP long     __cdecl _atol_l(_In_z_ const char *_Str, _In_opt_ _locale_t _Locale);
423 #ifndef _CRT_ALGO_DEFINED
424 #define _CRT_ALGO_DEFINED
425 #if __STDC_WANT_SECURE_LIB__
426 _Check_return_ _CRTIMP void * __cdecl bsearch_s(_In_ const void * _Key, _In_bytecount_x_(_NumOfElements * _SizeOfElements) const void * _Base, 
427              _In_ rsize_t _NumOfElements, _In_ rsize_t _SizeOfElements,
428              _In_ int (__cdecl * _PtFuncCompare)(void *, const void *, const void *), void * _Context);
429 #endif
430 _Check_return_ _CRTIMP void * __cdecl bsearch(_In_ const void * _Key, _In_bytecount_x_(_NumOfElements * _SizeOfElements) const void * _Base, 
431              _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements,
432              _In_ int (__cdecl * _PtFuncCompare)(const void *, const void *));
433
434 #if __STDC_WANT_SECURE_LIB__
435 _CRTIMP void __cdecl qsort_s(_Inout_bytecap_x_(_NumOfElements* _SizeOfElements) void * _Base, 
436              _In_ rsize_t _NumOfElements, _In_ rsize_t _SizeOfElements,
437              _In_ int (__cdecl * _PtFuncCompare)(void *, const void *, const void *), void *_Context);
438 #endif
439 _CRTIMP void __cdecl qsort(_Inout_bytecap_x_(_NumOfElements * _SizeOfElements) void * _Base, 
440     _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, 
441              _In_ int (__cdecl * _PtFuncCompare)(const void *, const void *));
442 #endif
443              _Check_return_ unsigned short __cdecl _byteswap_ushort(_In_ unsigned short _Short);
444              _Check_return_ unsigned long  __cdecl _byteswap_ulong (_In_ unsigned long _Long);
445              _Check_return_ unsigned __int64 __cdecl _byteswap_uint64(_In_ unsigned __int64 _Int64);
446 _Check_return_ _CRTIMP div_t  __cdecl div(_In_ int _Numerator, _In_ int _Denominator);
447 _Check_return_ _CRTIMP _CRT_INSECURE_DEPRECATE(_dupenv_s) char * __cdecl getenv(_In_z_ const char * _VarName);
448 #if __STDC_WANT_SECURE_LIB__
449 _Check_return_opt_ _CRTIMP errno_t __cdecl getenv_s(_Out_ size_t * _ReturnSize, _Out_z_cap_(_DstSize) char * _DstBuf, _In_ rsize_t _DstSize, _In_z_ const char * _VarName);
450 #endif
451 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, getenv_s, _Out_ size_t *, _ReturnSize, char, _Dest, _In_z_ const char *, _VarName)
452 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
453 #pragma push_macro("_dupenv_s")
454 #undef _dupenv_s
455 #endif
456
457 _Check_return_opt_ _CRTIMP errno_t __cdecl _dupenv_s(_Out_ _Deref_post_opt_z_cap_(*_PBufferSizeInBytes) char **_PBuffer, _Out_opt_ size_t * _PBufferSizeInBytes, _In_z_ const char * _VarName);
458
459 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
460 #pragma pop_macro("_dupenv_s")
461 #endif
462
463 _Check_return_opt_ _CRTIMP errno_t __cdecl _itoa_s(_In_ int _Value, _Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ int _Radix);
464 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _itoa_s, _In_ int, _Value, char, _Dest, _In_ int, _Radix)
465 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(char *, __RETURN_POLICY_DST, _CRTIMP, _itoa, _In_ int, _Value, _Pre_notnull_ _Post_z_, char, _Dest, _In_ int, _Radix)
466 _Check_return_opt_ _CRTIMP errno_t __cdecl _i64toa_s(_In_ __int64 _Val, _Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ int _Radix);
467 _CRTIMP _CRT_INSECURE_DEPRECATE(_i64toa_s) char * __cdecl _i64toa(_In_ __int64 _Val, _Pre_notnull_ _Post_z_ char * _DstBuf, _In_ int _Radix);
468 _Check_return_opt_ _CRTIMP errno_t __cdecl _ui64toa_s(_In_ unsigned __int64 _Val, _Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ int _Radix);
469 _CRTIMP _CRT_INSECURE_DEPRECATE(_ui64toa_s) char * __cdecl _ui64toa(_In_ unsigned __int64 _Val, _Pre_notnull_ _Post_z_ char * _DstBuf, _In_ int _Radix);
470 _Check_return_ _CRTIMP __int64 __cdecl _atoi64(_In_z_ const char * _String);
471 _Check_return_ _CRTIMP __int64 __cdecl _atoi64_l(_In_z_ const char * _String, _In_opt_ _locale_t _Locale);
472 _Check_return_ _CRTIMP __int64 __cdecl _strtoi64(_In_z_ const char * _String, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_ int _Radix);
473 _Check_return_ _CRTIMP __int64 __cdecl _strtoi64_l(_In_z_ const char * _String, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_ int _Radix, _In_opt_ _locale_t _Locale);
474 _Check_return_ _CRTIMP unsigned __int64 __cdecl _strtoui64(_In_z_ const char * _String, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_ int _Radix);
475 _Check_return_ _CRTIMP unsigned __int64 __cdecl _strtoui64_l(_In_z_ const char * _String, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_ int  _Radix, _In_opt_ _locale_t _Locale);
476 _Check_return_ _CRTIMP ldiv_t __cdecl ldiv(_In_ long _Numerator, _In_ long _Denominator);
477 #ifdef __cplusplus
478 extern "C++"
479 {
480       inline ldiv_t  div(_In_ long _A1, _In_ long _A2)
481       {
482              return ldiv(_A1, _A2);
483       }
484 }
485 #endif
486 _Check_return_opt_ _CRTIMP errno_t __cdecl _ltoa_s(_In_ long _Val, _Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ int _Radix);
487 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _ltoa_s, _In_ long, _Value, char, _Dest, _In_ int, _Radix)
488 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(char *, __RETURN_POLICY_DST, _CRTIMP, _ltoa, _In_ long, _Value, _Pre_notnull_ _Post_z_, char, _Dest, _In_ int, _Radix)
489 _Check_return_ _CRTIMP int      __cdecl mblen(_In_opt_bytecount_(_MaxCount) _Pre_opt_z_ const char * _Ch, _In_ size_t _MaxCount);
490 _Check_return_ _CRTIMP int      __cdecl _mblen_l(_In_opt_bytecount_(_MaxCount) _Pre_opt_z_ const char * _Ch, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
491 _Check_return_ _CRTIMP size_t __cdecl _mbstrlen(_In_z_ const char * _Str);
492 _Check_return_ _CRTIMP size_t __cdecl _mbstrlen_l(_In_z_ const char *_Str, _In_opt_ _locale_t _Locale);
493 _Check_return_ _CRTIMP size_t __cdecl _mbstrnlen(_In_z_ const char *_Str, _In_ size_t _MaxCount);
494 _Check_return_ _CRTIMP size_t __cdecl _mbstrnlen_l(_In_z_ const char *_Str, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
495 _CRTIMP int      __cdecl mbtowc(_Pre_notnull_ _Post_z_ wchar_t * _DstCh, _In_opt_bytecount_(_SrcSizeInBytes) _Pre_opt_z_ const char * _SrcCh, _In_ size_t _SrcSizeInBytes);
496 _CRTIMP int      __cdecl _mbtowc_l(_Pre_notnull_ _Post_z_ wchar_t * _DstCh, _In_opt_bytecount_(_SrcSizeInBytes) _Pre_opt_z_ const char * _SrcCh, _In_ size_t _SrcSizeInBytes, _In_opt_ _locale_t _Locale);
497 _Check_return_opt_ _CRTIMP errno_t __cdecl mbstowcs_s(_Out_opt_ size_t * _PtNumOfCharConverted, _Out_opt_cap_post_count_(_SizeInWords, *_PtNumOfCharConverted) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_count_(_MaxCount) _Pre_z_ const char * _SrcBuf, _In_ size_t _MaxCount );
498 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(errno_t, mbstowcs_s, _Out_opt_ size_t *, _PtNumOfCharConverted, _Deref_post_z_ wchar_t, _Dest, _In_z_ const char *, _Source, _In_ size_t, _MaxCount)
499 __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE(_CRTIMP, mbstowcs, _Out_opt_z_cap_(_MaxCount), wchar_t, _Dest, _In_z_ const char *, _Source, _In_ size_t, _MaxCount)
500
501 _Check_return_opt_ _CRTIMP errno_t __cdecl _mbstowcs_s_l(_Out_opt_ size_t * _PtNumOfCharConverted, _Out_opt_cap_post_count_(_SizeInWords, *_PtNumOfCharConverted) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_count_(_MaxCount) _Pre_z_ const char * _SrcBuf, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
502 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(errno_t, _mbstowcs_s_l, _Out_opt_ size_t *, _PtNumOfCharConverted, wchar_t, _Dest, _In_z_ const char *, _Source, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
503 __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE_EX(_CRTIMP, _mbstowcs_l, _mbstowcs_s_l, _Out_opt_z_cap_(_Size) wchar_t, _Out_z_cap_(_MaxCount), wchar_t, _Dest, _In_z_ const char *, _Source, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
504
505 _Check_return_ _CRTIMP int      __cdecl rand(void);
506 #if defined(_CRT_RAND_S)
507 _CRTIMP errno_t __cdecl rand_s ( _Out_ unsigned int *_RandomValue);
508 #endif
509
510 _Check_return_opt_ _CRTIMP int      __cdecl _set_error_mode(_In_ int _Mode);
511
512 _CRTIMP void     __cdecl srand(_In_ unsigned int _Seed);
513 _Check_return_ _CRTIMP double __cdecl strtod(_In_z_ const char * _Str, _Out_opt_ _Deref_post_z_ char ** _EndPtr);
514 _Check_return_ _CRTIMP double __cdecl _strtod_l(_In_z_ const char * _Str, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_opt_ _locale_t _Locale);
515 _Check_return_ _CRTIMP long     __cdecl strtol(_In_z_ const char * _Str, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_ int _Radix );
516 _Check_return_ _CRTIMP long     __cdecl _strtol_l(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix, _In_opt_ _locale_t _Locale);
517 _Check_return_ _CRTIMP unsigned long __cdecl strtoul(_In_z_ const char * _Str, _Out_opt_ _Deref_post_z_ char ** _EndPtr, _In_ int _Radix);
518 _Check_return_ _CRTIMP unsigned long __cdecl _strtoul_l(const char * _Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix, _In_opt_ _locale_t _Locale);
519 #ifndef _CRT_SYSTEM_DEFINED
520 #define _CRT_SYSTEM_DEFINED
521 _CRTIMP int __cdecl system(_In_opt_z_ const char * _Command);
522 #endif
523 _Check_return_opt_ _CRTIMP errno_t __cdecl _ultoa_s(_In_ unsigned long _Val, _Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ int _Radix);
524 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _ultoa_s, _In_ unsigned long, _Value, char, _Dest, _In_ int, _Radix)
525 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(char *, __RETURN_POLICY_DST, _CRTIMP, _ultoa, _In_ unsigned long, _Value, _Pre_notnull_ _Post_z_, char, _Dest, _In_ int, _Radix)
526 _CRTIMP _CRT_INSECURE_DEPRECATE(wctomb_s) int      __cdecl wctomb(_Out_opt_z_bytecap_c_(MB_LEN_MAX) char * _MbCh, _In_ wchar_t _WCh);
527 _CRTIMP _CRT_INSECURE_DEPRECATE(_wctomb_s_l) int      __cdecl _wctomb_l(_Pre_maybenull_ _Post_z_ char * _MbCh, _In_ wchar_t _WCh, _In_opt_ _locale_t _Locale);
528 #if __STDC_WANT_SECURE_LIB__
529 _Check_return_wat_ _CRTIMP errno_t __cdecl wctomb_s(_Out_opt_ int * _SizeConverted, _Out_opt_bytecap_post_bytecount_(_SizeInBytes, *_SizeConverted) char * _MbCh, _In_ rsize_t _SizeInBytes, _In_ wchar_t _WCh);
530 #endif
531 _Check_return_wat_ _CRTIMP errno_t __cdecl _wctomb_s_l(_Out_opt_ int * _SizeConverted, _Out_opt_z_bytecap_(_SizeInBytes) char * _MbCh, _In_ size_t _SizeInBytes, _In_ wchar_t _WCh, _In_opt_ _locale_t _Locale);
532 _Check_return_wat_ _CRTIMP errno_t __cdecl wcstombs_s(_Out_opt_ size_t * _PtNumOfCharConverted, _Out_opt_bytecap_post_bytecount_(_DstSizeInBytes, *_PtNumOfCharConverted) char * _Dst, _In_ size_t _DstSizeInBytes, _In_z_ const wchar_t * _Src, _In_ size_t _MaxCountInBytes);
533 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(errno_t, wcstombs_s, _Out_opt_ size_t *, _PtNumOfCharConverted, _Out_opt_bytecap_(_Size) char, _Dest, _In_z_ const wchar_t *, _Source, _In_ size_t, _MaxCount)
534 __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE(_CRTIMP, wcstombs, _Out_opt_z_cap_(_MaxCount), char, _Dest, _In_z_ const wchar_t *, _Source, _In_ size_t, _MaxCount)
535 _Check_return_wat_ _CRTIMP errno_t __cdecl _wcstombs_s_l(_Out_opt_ size_t * _PtNumOfCharConverted, _Out_opt_bytecap_post_bytecount_(_DstSizeInBytes, *_PtNumOfCharConverted) char * _Dst, _In_ size_t _DstSizeInBytes, _In_z_ const wchar_t * _Src, _In_ size_t _MaxCountInBytes, _In_opt_ _locale_t _Locale);
536 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(errno_t, _wcstombs_s_l, _Out_opt_ size_t *,_PtNumOfCharConverted, _Out_opt_cap_(_Size) char, _Dest, _In_z_ const wchar_t *, _Source, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
537 __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE_EX(_CRTIMP, _wcstombs_l, _wcstombs_s_l, _Out_opt_z_cap_(_Size) char, _Out_z_cap_(_MaxCount), char, _Dest, _In_z_ const wchar_t *, _Source, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
538
539 #if _MSC_VER >= 1400 && defined(__cplusplus) && defined(_M_CEE)
540 /*
541  * Managed search routines. Note __cplusplus, this is because we only support
542  * managed C++.
543  */
544 extern "C++"
545 {
546 #if __STDC_WANT_SECURE_LIB__
547 _Check_return_ void * __clrcall bsearch_s(_In_ const void * _Key, _In_bytecount_x_(_NumOfElements*_SizeOfElements) const void * _Base, _In_ rsize_t _NumOfElements, _In_ rsize_t _SizeOfElements, 
548              _In_ int (__clrcall * _PtFuncCompare)(void *, const void *, const void *), void * _Context);
549 #endif
550 _Check_return_ void * __clrcall bsearch  (_In_ const void * _Key, _In_bytecount_x_(_NumOfElements*_SizeOfElements) const void * _Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements,
551              _In_ int (__clrcall * _PtFuncCompare)(const void *, const void *));
552
553 #if __STDC_WANT_SECURE_LIB__
554 void __clrcall qsort_s(_Inout_bytecap_x_(_NumOfElements*_SizeOfElements) _Post_bytecount_x_(_NumOfElements*_SizeOfElements) void * _Base, 
555              _In_ rsize_t _NumOfElements, _In_ rsize_t _SizeOfElment, 
556              _In_ int (__clrcall * _PtFuncCompare)(void *, const void *, const void *), void * _Context);
557 #endif
558 void __clrcall qsort(_Inout_bytecap_x_(_NumOfElements*_SizeOfElements) _Post_bytecount_x_(_NumOfElements*_SizeOfElements) void * _Base, 
559              _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, 
560              _In_ int (__clrcall * _PtFuncCompare)(const void *, const void *));
561
562 }
563 #endif
564
565 #ifndef _CRT_ALLOCATION_DEFINED
566 #define _CRT_ALLOCATION_DEFINED
567
568 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
569
570 #pragma push_macro("calloc")
571 #pragma push_macro("free")
572 #pragma push_macro("malloc")
573 #pragma push_macro("realloc")
574 #pragma push_macro("_recalloc")
575 #pragma push_macro("_aligned_free")
576 #pragma push_macro("_aligned_malloc")
577 #pragma push_macro("_aligned_offset_malloc")
578 #pragma push_macro("_aligned_realloc")
579 #pragma push_macro("_aligned_recalloc")
580 #pragma push_macro("_aligned_offset_realloc")
581 #pragma push_macro("_aligned_offset_recalloc")
582 #pragma push_macro("_aligned_msize")
583
584 #undef calloc
585 #undef free
586 #undef malloc
587 #undef realloc
588 #undef _recalloc
589 #undef _aligned_free
590 #undef _aligned_malloc
591 #undef _aligned_offset_malloc
592 #undef _aligned_realloc
593 #undef _aligned_recalloc
594 #undef _aligned_offset_realloc
595 #undef _aligned_offset_recalloc
596 #undef _aligned_msize
597
598 #endif
599 _Check_return_ _Ret_opt_bytecap_x_(_NumOfElements* _SizeOfElements) _CRTIMP _CRT_JIT_INTRINSIC _CRTNOALIAS _CRTRESTRICT      void * __cdecl calloc(_In_ size_t _NumOfElements, _In_ size_t _SizeOfElements);
600 _CRTIMP                                   _CRTNOALIAS                                                                                                                                void     __cdecl free(_Inout_opt_ void * _Memory);
601 _Check_return_ _Ret_opt_bytecap_(_Size) _CRTIMP _CRT_JIT_INTRINSIC _CRTNOALIAS _CRTRESTRICT                                                  void * __cdecl malloc(_In_ size_t _Size);
602 _Check_return_ _Ret_opt_bytecap_(_NewSize) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                             void * __cdecl realloc(_In_opt_ void * _Memory, _In_ size_t _NewSize);
603 _Check_return_ _Ret_opt_bytecap_x_(_Count*_Size) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                      void * __cdecl _recalloc(_In_opt_ void * _Memory, _In_ size_t _Count, _In_ size_t _Size);
604 _CRTIMP                                   _CRTNOALIAS                                                                                                                                void     __cdecl _aligned_free(_Inout_opt_ void * _Memory);
605 _Check_return_ _Ret_opt_bytecap_(_Size) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                                  void * __cdecl _aligned_malloc(_In_ size_t _Size, _In_ size_t _Alignment);
606 _Check_return_ _Ret_opt_bytecap_(_Size) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                                  void * __cdecl _aligned_offset_malloc(_In_ size_t _Size, _In_ size_t _Alignment, _In_ size_t _Offset);
607 _Check_return_ _Ret_opt_bytecap_(_NewSize) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                                  void * __cdecl _aligned_realloc(_In_opt_ void * _Memory, _In_ size_t _NewSize, _In_ size_t _Alignment);
608 _Check_return_ _Ret_opt_bytecap_x_(_Count*_Size) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                      void * __cdecl _aligned_recalloc(_In_opt_ void * _Memory, _In_ size_t _Count, _In_ size_t _Size, _In_ size_t _Alignment);
609 _Check_return_ _Ret_opt_bytecap_(_NewSize) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                                  void * __cdecl _aligned_offset_realloc(_In_opt_ void * _Memory, _In_ size_t _NewSize, _In_ size_t _Alignment, _In_ size_t _Offset);
610 _Check_return_ _Ret_opt_bytecap_x_(_Count*_Size) _CRTIMP _CRTNOALIAS _CRTRESTRICT                                      void * __cdecl _aligned_offset_recalloc(_In_opt_ void * _Memory, _In_ size_t _Count, _In_ size_t _Size, _In_ size_t _Alignment, _In_ size_t _Offset);
611 _Check_return_ _CRTIMP                                                                                   size_t __cdecl _aligned_msize(_In_ void * _Memory, _In_ size_t _Alignment, _In_ size_t _Offset);
612
613
614 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
615
616 #pragma pop_macro("_aligned_msize")
617 #pragma pop_macro("_aligned_offset_recalloc")
618 #pragma pop_macro("_aligned_offset_realloc")
619 #pragma pop_macro("_aligned_recalloc")
620 #pragma pop_macro("_aligned_realloc")
621 #pragma pop_macro("_aligned_offset_malloc")
622 #pragma pop_macro("_aligned_malloc")
623 #pragma pop_macro("_aligned_free")
624 #pragma pop_macro("_recalloc")
625 #pragma pop_macro("realloc")
626 #pragma pop_macro("malloc")
627 #pragma pop_macro("free")
628 #pragma pop_macro("calloc")
629
630 #endif
631
632 #endif /*_CRT_ALLOCATION_DEFINED */
633
634 #ifndef _WSTDLIB_DEFINED
635
636 /* wide function prototypes, also declared in wchar.h  */
637
638 _Check_return_wat_ _CRTIMP errno_t __cdecl _itow_s (_In_ int _Val, _Out_z_cap_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ int _Radix);
639 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _itow_s, _In_ int, _Value, wchar_t, _Dest, _In_ int, _Radix)
640 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(wchar_t *, __RETURN_POLICY_DST, _CRTIMP, _itow, _In_ int, _Value, _Pre_notnull_ _Post_z_, wchar_t, _Dest, _In_ int, _Radix)
641 _Check_return_wat_ _CRTIMP errno_t __cdecl _ltow_s (_In_ long _Val, _Out_z_cap_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ int _Radix);
642 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _ltow_s, _In_ long, _Value, wchar_t, _Dest, _In_ int, _Radix)
643 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(wchar_t *, __RETURN_POLICY_DST, _CRTIMP, _ltow, _In_ long, _Value, _Pre_notnull_ _Post_z_, wchar_t, _Dest, _In_ int, _Radix)
644 _Check_return_wat_ _CRTIMP errno_t __cdecl _ultow_s (_In_ unsigned long _Val, _Out_z_cap_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ int _Radix);
645 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _ultow_s, _In_ unsigned long, _Value, wchar_t, _Dest, _In_ int, _Radix)
646 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(wchar_t *, __RETURN_POLICY_DST, _CRTIMP, _ultow, _In_ unsigned long, _Value, _Pre_notnull_ _Post_z_, wchar_t, _Dest, _In_ int, _Radix)
647 _Check_return_ _CRTIMP double __cdecl wcstod(_In_z_ const wchar_t * _Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr);
648 _Check_return_ _CRTIMP double __cdecl _wcstod_l(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, _In_opt_ _locale_t _Locale);
649 _Check_return_ _CRTIMP long     __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, int _Radix);
650 _Check_return_ _CRTIMP long     __cdecl _wcstol_l(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, int _Radix, _In_opt_ _locale_t _Locale);
651 _Check_return_ _CRTIMP unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, int _Radix);
652 _Check_return_ _CRTIMP unsigned long __cdecl _wcstoul_l(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, int _Radix, _In_opt_ _locale_t _Locale);
653 _Check_return_ _CRTIMP _CRT_INSECURE_DEPRECATE(_wdupenv_s) wchar_t * __cdecl _wgetenv(_In_z_ const wchar_t * _VarName);
654 _Check_return_wat_ _CRTIMP errno_t __cdecl _wgetenv_s(_Out_ size_t * _ReturnSize, _Out_z_cap_(_DstSizeInWords) wchar_t * _DstBuf, _In_ size_t _DstSizeInWords, _In_z_ const wchar_t * _VarName);
655 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, _wgetenv_s, _Out_ size_t *, _ReturnSize, wchar_t, _Dest, _In_z_ const wchar_t *, _VarName)
656
657 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
658 #pragma push_macro("_wdupenv_s")
659 #undef _wdupenv_s
660 #endif
661
662 _Check_return_wat_ _CRTIMP errno_t __cdecl _wdupenv_s(_Out_ _Deref_post_opt_z_cap_(*_BufferSizeInWords) wchar_t **_Buffer, _Out_opt_ size_t *_BufferSizeInWords, _In_z_ const wchar_t *_VarName);
663
664 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
665 #pragma pop_macro("_wdupenv_s")
666 #endif
667
668 #ifndef _CRT_WSYSTEM_DEFINED
669 #define _CRT_WSYSTEM_DEFINED
670 _CRTIMP int __cdecl _wsystem(_In_opt_z_ const wchar_t * _Command);
671 #endif
672 _Check_return_ _CRTIMP double __cdecl _wtof(_In_z_ const wchar_t *_Str);
673 _Check_return_ _CRTIMP double __cdecl _wtof_l(_In_z_ const wchar_t *_Str, _In_opt_ _locale_t _Locale);
674 _Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str);
675 _Check_return_ _CRTIMP int __cdecl _wtoi_l(_In_z_ const wchar_t *_Str, _In_opt_ _locale_t _Locale);
676 _Check_return_ _CRTIMP long __cdecl _wtol(_In_z_ const wchar_t *_Str);
677 _Check_return_ _CRTIMP long __cdecl _wtol_l(_In_z_ const wchar_t *_Str, _In_opt_ _locale_t _Locale);
678
679 _Check_return_wat_ _CRTIMP errno_t __cdecl _i64tow_s(_In_ __int64 _Val, _Out_z_cap_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ int _Radix);
680 _CRTIMP _CRT_INSECURE_DEPRECATE(_i64tow_s) wchar_t * __cdecl _i64tow(_In_ __int64 _Val, _Pre_notnull_ _Post_z_ wchar_t * _DstBuf, _In_ int _Radix);
681 _Check_return_wat_ _CRTIMP errno_t __cdecl _ui64tow_s(_In_ unsigned __int64 _Val, _Out_z_cap_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ int _Radix);
682 _CRTIMP _CRT_INSECURE_DEPRECATE(_ui64tow_s) wchar_t * __cdecl _ui64tow(_In_ unsigned __int64 _Val, _Pre_notnull_ _Post_z_ wchar_t * _DstBuf, _In_ int _Radix);
683 _Check_return_ _CRTIMP __int64     __cdecl _wtoi64(_In_z_ const wchar_t *_Str);
684 _Check_return_ _CRTIMP __int64     __cdecl _wtoi64_l(_In_z_ const wchar_t *_Str, _In_opt_ _locale_t _Locale);
685 _Check_return_ _CRTIMP __int64     __cdecl _wcstoi64(_In_z_ const wchar_t * _Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, _In_ int _Radix);
686 _Check_return_ _CRTIMP __int64     __cdecl _wcstoi64_l(_In_z_ const wchar_t * _Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, _In_ int _Radix, _In_opt_ _locale_t _Locale);
687 _Check_return_ _CRTIMP unsigned __int64  __cdecl _wcstoui64(_In_z_ const wchar_t * _Str, _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, _In_ int _Radix);
688 _Check_return_ _CRTIMP unsigned __int64  __cdecl _wcstoui64_l(_In_z_ const wchar_t *_Str , _Out_opt_ _Deref_post_z_ wchar_t ** _EndPtr, _In_ int _Radix, _In_opt_ _locale_t _Locale);
689
690 #define _WSTDLIB_DEFINED
691 #endif
692
693
694 #ifndef _POSIX_
695
696 /* 
697 Buffer size required to be passed to _gcvt, fcvt and other fp conversion routines
698 */
699 #define _CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop */
700
701 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
702
703 #pragma push_macro("_fullpath")
704 #undef _fullpath
705
706 #endif
707
708 _Check_return_ _CRTIMP char * __cdecl _fullpath(_Out_opt_z_cap_(_SizeInBytes) char * _FullPath, _In_z_ const char * _Path, _In_ size_t _SizeInBytes);
709
710 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
711
712 #pragma pop_macro("_fullpath")
713
714 #endif
715
716 _Check_return_wat_ _CRTIMP errno_t __cdecl _ecvt_s(_Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ double _Val, _In_ int _NumOfDights, _Out_ int * _PtDec, _Out_ int * _PtSign);
717 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(errno_t, _ecvt_s, char, _Dest, _In_ double, _Value, _In_ int, _NumOfDigits, _Out_ int *, _PtDec, _Out_ int *, _PtSign)
718 _Check_return_ _CRTIMP _CRT_INSECURE_DEPRECATE(_ecvt_s) char * __cdecl _ecvt(_In_ double _Val, _In_ int _NumOfDigits, _Out_ int * _PtDec, _Out_ int * _PtSign);
719 _Check_return_wat_ _CRTIMP errno_t __cdecl _fcvt_s(_Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ double _Val, _In_ int _NumOfDec, _Out_ int * _PtDec, _Out_ int * _PtSign);
720 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(errno_t, _fcvt_s, char, _Dest, _In_ double, _Value, _In_ int, _NumOfDigits, _Out_ int *, _PtDec, _Out_ int *, _PtSign)
721 _Check_return_ _CRTIMP _CRT_INSECURE_DEPRECATE(_fcvt_s) char * __cdecl _fcvt(_In_ double _Val, _In_ int _NumOfDec, _Out_ int * _PtDec, _Out_ int * _PtSign);
722 _CRTIMP errno_t __cdecl _gcvt_s(_Out_z_cap_(_Size) char * _DstBuf, _In_ size_t _Size, _In_ double _Val, _In_ int _NumOfDigits);
723 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(errno_t, _gcvt_s, char, _Dest, _In_ double, _Value, _In_ int, _NumOfDigits)
724 _CRTIMP _CRT_INSECURE_DEPRECATE(_gcvt_s) char * __cdecl _gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char * _DstBuf);
725
726 _Check_return_ _CRTIMP int __cdecl _atodbl(_Out_ _CRT_DOUBLE * _Result, _In_z_ char * _Str);
727 _Check_return_ _CRTIMP int __cdecl _atoldbl(_Out_ _LDOUBLE * _Result, _In_z_ char * _Str);
728 _Check_return_ _CRTIMP int __cdecl _atoflt(_Out_ _CRT_FLOAT * _Result, _In_z_ char * _Str);
729 _Check_return_ _CRTIMP int __cdecl _atodbl_l(_Out_ _CRT_DOUBLE * _Result, _In_z_ char * _Str, _In_opt_ _locale_t _Locale);
730 _Check_return_ _CRTIMP int __cdecl _atoldbl_l(_Out_ _LDOUBLE * _Result, _In_z_ char * _Str, _In_opt_ _locale_t _Locale);
731 _Check_return_ _CRTIMP int __cdecl _atoflt_l(_Out_ _CRT_FLOAT * _Result, _In_z_ char * _Str, _In_opt_ _locale_t _Locale);
732              _Check_return_ unsigned long __cdecl _lrotl(_In_ unsigned long _Val, _In_ int _Shift);
733              _Check_return_ unsigned long __cdecl _lrotr(_In_ unsigned long _Val, _In_ int _Shift);
734 _Check_return_wat_ _CRTIMP_ALTERNATIVE errno_t     __cdecl _makepath_s(_Out_z_cap_(_SizeInWords) char * _PathResult, _In_ size_t _SizeInWords, _In_opt_z_ const char * _Drive, _In_opt_z_ const char * _Dir, _In_opt_z_ const char * _Filename,
735              _In_opt_z_ const char * _Ext);
736 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(errno_t, _makepath_s, char, _Path, _In_opt_z_ const char *, _Drive, _In_opt_z_ const char *, _Dir, _In_opt_z_ const char *, _Filename, _In_opt_z_ const char *, _Ext)
737 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4(void, __RETURN_POLICY_VOID, _CRTIMP, _makepath, _Pre_notnull_ _Post_z_, char, _Path, _In_opt_z_ const char *, _Drive, _In_opt_z_ const char *, _Dir, _In_opt_z_ const char *, _Filename, _In_opt_z_ const char *, _Ext)
738
739 #if _MSC_VER >= 1400 && defined(_M_CEE)
740         _onexit_m_t      __clrcall _onexit_m_appdomain(_onexit_m_t _Function);
741     #if defined(_M_CEE_MIXED)
742         _onexit_m_t      __clrcall _onexit_m(_onexit_m_t _Function);
743     #else
744         inline _onexit_m_t      __clrcall _onexit_m(_onexit_t _Function)
745         {
746             return _onexit_m_appdomain(_Function);
747         }
748     #endif
749              
750 #endif
751 #if defined(_M_CEE_PURE)
752              /* In pure mode, _onexit is the same as _onexit_m_appdomain */
753 extern "C++"
754 {
755 inline  _onexit_t      __clrcall _onexit
756 (
757       _onexit_t _Function
758 )
759 {
760       return _onexit_m_appdomain(_Function);
761 }
762 }
763 #else
764              _onexit_t __cdecl _onexit(_In_opt_ _onexit_t _Func);
765 #endif
766              
767 #ifndef _CRT_PERROR_DEFINED
768 #define _CRT_PERROR_DEFINED
769 _CRTIMP void __cdecl perror(_In_opt_z_ const char * _ErrMsg);
770 #endif
771
772 #pragma warning (push)
773 #pragma warning (disable:6540) // the functions below have declspecs in their declarations in the windows headers, causing PREfast to fire 6540 here
774 _Check_return_ _CRTIMP int      __cdecl _putenv(_In_z_ const char * _EnvString);
775 _Check_return_wat_ _CRTIMP errno_t __cdecl _putenv_s(_In_z_ const char * _Name, _In_z_ const char * _Value);
776              _Check_return_ unsigned int __cdecl _rotl(_In_ unsigned int _Val, _In_ int _Shift);
777              _Check_return_ unsigned __int64 __cdecl _rotl64(_In_ unsigned __int64 _Val, _In_ int _Shift);
778              _Check_return_ unsigned int __cdecl _rotr(_In_ unsigned int _Val, _In_ int _Shift);
779              _Check_return_ unsigned __int64 __cdecl _rotr64(_In_ unsigned __int64 _Val, _In_ int _Shift);
780 #pragma warning (pop)
781
782 _CRTIMP errno_t __cdecl _searchenv_s(_In_z_ const char * _Filename, _In_z_ const char * _EnvVar, _Out_z_cap_(_SizeInBytes) char * _ResultPath, _In_ size_t _SizeInBytes);
783 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0(errno_t, _searchenv_s, _In_z_ const char *, _Filename, _In_z_ const char *, _EnvVar, char, _ResultPath)
784 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0(void, __RETURN_POLICY_VOID, _CRTIMP, _searchenv, _In_z_ const char *, _Filename, _In_z_ const char *, _EnvVar, _Pre_notnull_ _Post_z_, char, _ResultPath)
785
786 _CRT_INSECURE_DEPRECATE(_splitpath_s) _CRTIMP void     __cdecl _splitpath(_In_z_ const char * _FullPath, _Pre_maybenull_ _Post_z_ char * _Drive, _Pre_maybenull_ _Post_z_ char * _Dir, _Pre_maybenull_ _Post_z_ char * _Filename, _Pre_maybenull_ _Post_z_ char * _Ext);
787 _Check_return_wat_ _CRTIMP_ALTERNATIVE errno_t  __cdecl _splitpath_s(_In_z_ const char * _FullPath, 
788         _Out_opt_z_cap_(_DriveSize) char * _Drive, _In_ size_t _DriveSize, 
789         _Out_opt_z_cap_(_DirSize) char * _Dir, _In_ size_t _DirSize, 
790         _Out_opt_z_cap_(_FilenameSize) char * _Filename, _In_ size_t _FilenameSize, 
791         _Out_opt_z_cap_(_ExtSize) char * _Ext, _In_ size_t _ExtSize);
792 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t, _splitpath_s,  char, _Dest)
793
794 _CRTIMP void     __cdecl _swab(_Inout_cap_(_SizeInBytes) _Post_count_(_SizeInBytes) char * _Buf1, _Inout_cap_(_SizeInBytes) _Post_count_(_SizeInBytes) char * _Buf2, int _SizeInBytes);
795
796 #ifndef _WSTDLIBP_DEFINED
797
798 /* wide function prototypes, also declared in wchar.h  */
799
800 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
801 #pragma push_macro("_wfullpath")
802 #undef _wfullpath
803 #endif
804
805 _Check_return_ _CRTIMP wchar_t * __cdecl _wfullpath(_Out_opt_z_cap_(_SizeInWords) wchar_t * _FullPath, _In_z_ const wchar_t * _Path, _In_ size_t _SizeInWords);
806
807 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
808 #pragma pop_macro("_wfullpath")
809 #endif
810
811 _Check_return_wat_ _CRTIMP_ALTERNATIVE errno_t __cdecl _wmakepath_s(_Out_z_cap_(_SIZE) wchar_t * _PathResult, _In_ size_t _SIZE, _In_opt_z_ const wchar_t * _Drive, _In_opt_z_ const wchar_t * _Dir, _In_opt_z_ const wchar_t * _Filename,
812              _In_opt_z_ const wchar_t * _Ext);             
813 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(errno_t, _wmakepath_s, wchar_t, _ResultPath, _In_opt_z_ const wchar_t *, _Drive, _In_opt_z_ const wchar_t *, _Dir, _In_opt_z_ const wchar_t *, _Filename, _In_opt_z_ const wchar_t *, _Ext)
814 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4(void, __RETURN_POLICY_VOID, _CRTIMP, _wmakepath, _Pre_notnull_ _Post_z_, wchar_t, _ResultPath, _In_opt_z_ const wchar_t *, _Drive, _In_opt_z_ const wchar_t *, _Dir, _In_opt_z_ const wchar_t *, _Filename, _In_opt_z_ const wchar_t *, _Ext)
815 #ifndef _CRT_WPERROR_DEFINED
816 #define _CRT_WPERROR_DEFINED
817 _CRTIMP void __cdecl _wperror(_In_opt_z_ const wchar_t * _ErrMsg);
818 #endif 
819 _Check_return_ _CRTIMP int      __cdecl _wputenv(_In_z_ const wchar_t * _EnvString);
820 _Check_return_wat_ _CRTIMP errno_t __cdecl _wputenv_s(_In_z_ const wchar_t * _Name, _In_z_ const wchar_t * _Value);
821 _CRTIMP errno_t __cdecl _wsearchenv_s(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _EnvVar, _Out_z_cap_(_SizeInWords) wchar_t * _ResultPath, _In_ size_t _SizeInWords);
822 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0(errno_t, _wsearchenv_s, _In_z_ const wchar_t *, _Filename, _In_z_ const wchar_t *, _EnvVar, wchar_t, _ResultPath)
823 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0(void, __RETURN_POLICY_VOID, _CRTIMP, _wsearchenv, _In_z_ const wchar_t *, _Filename, _In_z_ const wchar_t *, _EnvVar, _Pre_notnull_ _Post_z_, wchar_t, _ResultPath)
824 _CRT_INSECURE_DEPRECATE(_wsplitpath_s) _CRTIMP void     __cdecl _wsplitpath(_In_z_ const wchar_t * _FullPath, _Pre_maybenull_ _Post_z_ wchar_t * _Drive, _Pre_maybenull_ _Post_z_ wchar_t * _Dir, _Pre_maybenull_ _Post_z_ wchar_t * _Filename, _Pre_maybenull_ _Post_z_ wchar_t * _Ext);
825 _CRTIMP_ALTERNATIVE errno_t __cdecl _wsplitpath_s(_In_z_ const wchar_t * _FullPath, 
826         _Out_opt_z_cap_(_DriveSize) wchar_t * _Drive, _In_ size_t _DriveSize, 
827         _Out_opt_z_cap_(_DirSize) wchar_t * _Dir, _In_ size_t _DirSize, 
828         _Out_opt_z_cap_(_FilenameSize) wchar_t * _Filename, _In_ size_t _FilenameSize, 
829         _Out_opt_z_cap_(_ExtSize) wchar_t * _Ext, _In_ size_t _ExtSize);
830 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t, _wsplitpath_s, wchar_t, _Path)
831
832 #define _WSTDLIBP_DEFINED
833 #endif
834
835 /* The Win32 API SetErrorMode, Beep and Sleep should be used instead. */
836 _CRT_OBSOLETE(SetErrorMode) _CRTIMP void __cdecl _seterrormode(_In_ int _Mode);
837 _CRT_OBSOLETE(Beep) _CRTIMP void __cdecl _beep(_In_ unsigned _Frequency, _In_ unsigned _Duration);
838 _CRT_OBSOLETE(Sleep) _CRTIMP void __cdecl _sleep(_In_ unsigned long _Duration);
839
840 #endif  /* _POSIX_ */
841
842 #if        !__STDC__
843
844 #ifndef _POSIX_
845
846 /* Non-ANSI names for compatibility */
847
848 #ifndef __cplusplus
849 #define max(a,b)      (((a) > (b)) ? (a) : (b))
850 #define min(a,b)      (((a) < (b)) ? (a) : (b))
851 #endif
852
853 #define sys_errlist _sys_errlist
854 #define sys_nerr      _sys_nerr
855 #define environ        _environ
856
857 #pragma warning(push)
858 #pragma warning(disable: 4141) /* Using deprecated twice */ 
859 _Check_return_ _CRT_NONSTDC_DEPRECATE(_ecvt) _CRT_INSECURE_DEPRECATE(_ecvt_s) _CRTIMP char * __cdecl ecvt(_In_ double _Val, _In_ int _NumOfDigits, _Out_ int * _PtDec, _Out_ int * _PtSign);
860 _Check_return_ _CRT_NONSTDC_DEPRECATE(_fcvt) _CRT_INSECURE_DEPRECATE(_fcvt_s) _CRTIMP char * __cdecl fcvt(_In_ double _Val, _In_ int _NumOfDec, _Out_ int * _PtDec, _Out_ int * _PtSign);
861 _CRT_NONSTDC_DEPRECATE(_gcvt) _CRT_INSECURE_DEPRECATE(_fcvt_s)        _CRTIMP char * __cdecl gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char * _DstBuf);
862 _CRT_NONSTDC_DEPRECATE(_itoa) _CRT_INSECURE_DEPRECATE(_itoa_s)        _CRTIMP char * __cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char * _DstBuf, _In_ int _Radix);
863 _CRT_NONSTDC_DEPRECATE(_ltoa) _CRT_INSECURE_DEPRECATE(_ltoa_s)        _CRTIMP char * __cdecl ltoa(_In_ long _Val, _Pre_notnull_ _Post_z_ char * _DstBuf, _In_ int _Radix);
864 _Check_return_ _CRT_NONSTDC_DEPRECATE(_putenv) _CRTIMP int      __cdecl putenv(_In_z_ const char * _EnvString);
865 _CRT_NONSTDC_DEPRECATE(_swab)                                        _CRTIMP void     __cdecl swab(_Inout_z_bytecap_(_SizeInBytes) char * _Buf1,_Inout_z_bytecap_(_SizeInBytes) char * _Buf2, _In_ int _SizeInBytes);
866 _CRT_NONSTDC_DEPRECATE(_ultoa) _CRT_INSECURE_DEPRECATE(_ultoa_s)    _CRTIMP char * __cdecl ultoa(_In_ unsigned long _Val, _Pre_notnull_ _Post_z_ char * _Dstbuf, _In_ int _Radix);
867 #pragma warning(pop)
868 onexit_t __cdecl onexit(_In_opt_ onexit_t _Func);
869
870 #endif  /* _POSIX_ */
871
872 #endif  /* __STDC__ */
873
874 #ifdef  __cplusplus
875 }
876
877 #endif
878
879 #ifdef  _MSC_VER
880 #pragma pack(pop)
881 #endif  /* _MSC_VER */
882
883 #endif  /* _INC_STDLIB */
884