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