Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _INC_STDLIB
      7 #define _INC_STDLIB
      8 
      9 #include <crtdefs.h>
     10 #include <limits.h>
     11 
     12 #if defined (__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) && !defined (__USE_MINGW_STRTOX)
     13 #define __USE_MINGW_STRTOX 1
     14 #endif
     15 
     16 #pragma pack(push,_CRT_PACKING)
     17 
     18 #ifdef __cplusplus
     19 extern "C" {
     20 #endif
     21 
     22 #ifndef NULL
     23 #ifdef __cplusplus
     24 #ifndef _WIN64
     25 #define NULL 0
     26 #else
     27 #define NULL 0LL
     28 #endif  /* W64 */
     29 #else
     30 #define NULL ((void *)0)
     31 #endif
     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 
     80 #pragma push_macro("long")
     81 #undef long
     82 
     83   typedef struct {
     84     long double x;
     85   } _LONGDOUBLE;
     86 
     87 #pragma pop_macro("long")
     88 
     89 #pragma pack(4)
     90   typedef struct {
     91     unsigned char ld12[12];
     92   } _LDBL12;
     93 #pragma pack()
     94 #endif
     95 
     96 #define RAND_MAX 0x7fff
     97 
     98 #ifndef MB_CUR_MAX
     99 #define MB_CUR_MAX ___mb_cur_max_func()
    100 #ifndef __mb_cur_max
    101 #ifdef _MSVCRT_
    102   extern int __mb_cur_max;
    103 #define __mb_cur_max	__mb_cur_max
    104 #else
    105   extern int * __MINGW_IMP_SYMBOL(__mb_cur_max);
    106 #define __mb_cur_max	(* __MINGW_IMP_SYMBOL(__mb_cur_max))
    107 #endif
    108 #endif
    109 #define ___mb_cur_max_func() (__mb_cur_max)
    110 #endif
    111 
    112 #define __max(a,b) (((a) > (b)) ? (a) : (b))
    113 #define __min(a,b) (((a) < (b)) ? (a) : (b))
    114 
    115 #define _MAX_PATH 260
    116 #define _MAX_DRIVE 3
    117 #define _MAX_DIR 256
    118 #define _MAX_FNAME 256
    119 #define _MAX_EXT 256
    120 
    121 #define _OUT_TO_DEFAULT 0
    122 #define _OUT_TO_STDERR 1
    123 #define _OUT_TO_MSGBOX 2
    124 #define _REPORT_ERRMODE 3
    125 
    126 #define _WRITE_ABORT_MSG 0x1
    127 #define _CALL_REPORTFAULT 0x2
    128 
    129 #define _MAX_ENV 32767
    130 
    131   typedef void (__cdecl *_purecall_handler)(void);
    132 
    133   _CRTIMP _purecall_handler __cdecl _set_purecall_handler(_purecall_handler _Handler);
    134   _CRTIMP _purecall_handler __cdecl _get_purecall_handler(void);
    135 
    136   typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t *,const wchar_t *,const wchar_t *,unsigned int,uintptr_t);
    137   _CRTIMP _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_invalid_parameter_handler _Handler);
    138   _CRTIMP _invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
    139 
    140 #ifndef _CRT_ERRNO_DEFINED
    141 #define _CRT_ERRNO_DEFINED
    142   _CRTIMP extern int *__cdecl _errno(void);
    143 #define errno (*_errno())
    144   errno_t __cdecl _set_errno(int _Value);
    145   errno_t __cdecl _get_errno(int *_Value);
    146 #endif
    147   _CRTIMP unsigned long *__cdecl __doserrno(void);
    148 #define _doserrno (*__doserrno())
    149   errno_t __cdecl _set_doserrno(unsigned long _Value);
    150   errno_t __cdecl _get_doserrno(unsigned long *_Value);
    151 #ifdef _MSVCRT_
    152   extern char *_sys_errlist[];
    153   extern int _sys_nerr;
    154 #else
    155   extern _CRTIMP char *_sys_errlist[1];
    156   extern _CRTIMP int _sys_nerr;
    157 #endif
    158 #if (defined(_X86_) && !defined(__x86_64))
    159   _CRTIMP int *__cdecl __p___argc(void);
    160   _CRTIMP char ***__cdecl __p___argv(void);
    161   _CRTIMP wchar_t ***__cdecl __p___wargv(void);
    162   _CRTIMP char ***__cdecl __p__environ(void);
    163   _CRTIMP wchar_t ***__cdecl __p__wenviron(void);
    164   _CRTIMP char **__cdecl __p__pgmptr(void);
    165   _CRTIMP wchar_t **__cdecl __p__wpgmptr(void);
    166 #endif
    167 #ifndef __argc
    168 #ifdef _MSVCRT_
    169   extern int __argc;
    170 #else
    171   extern int * __MINGW_IMP_SYMBOL(__argc);
    172 #define __argc (* __MINGW_IMP_SYMBOL(__argc))
    173 #endif
    174 #endif
    175 #ifndef __argv
    176 #ifdef _MSVCRT_
    177   extern char **__argv;
    178 #else
    179   extern char *** __MINGW_IMP_SYMBOL(__argv);
    180 #define __argv	(* __MINGW_IMP_SYMBOL(__argv))
    181 #endif
    182 #endif
    183 #ifndef __wargv
    184 #ifdef _MSVCRT_
    185   extern wchar_t **__wargv;
    186 #else
    187   extern wchar_t *** __MINGW_IMP_SYMBOL(__wargv);
    188 #define __wargv (* __MINGW_IMP_SYMBOL(__wargv))
    189 #endif
    190 #endif
    191 
    192 #ifdef _POSIX_
    193   extern char **environ;
    194 #else
    195 #ifndef _environ
    196 #ifdef _MSVCRT_
    197   extern char **_environ;
    198 #else
    199   extern char *** __MINGW_IMP_SYMBOL(_environ);
    200 #define _environ (* __MINGW_IMP_SYMBOL(_environ))
    201 #endif
    202 #endif
    203 
    204 #ifndef _wenviron
    205 #ifdef _MSVCRT_
    206   extern wchar_t **_wenviron;
    207 #else
    208   extern wchar_t *** __MINGW_IMP_SYMBOL(_wenviron);
    209 #define _wenviron (* __MINGW_IMP_SYMBOL(_wenviron))
    210 #endif
    211 #endif
    212 #endif
    213 #ifndef _pgmptr
    214 #ifdef _MSVCRT_
    215   extern char *_pgmptr;
    216 #else
    217   extern char ** __MINGW_IMP_SYMBOL(_pgmptr);
    218 #define _pgmptr	(* __MINGW_IMP_SYMBOL(_pgmptr))
    219 #endif
    220 #endif
    221 
    222 #ifndef _wpgmptr
    223 #ifdef _MSVCRT_
    224   extern wchar_t *_wpgmptr;
    225 #else
    226   extern wchar_t ** __MINGW_IMP_SYMBOL(_wpgmptr);
    227 #define _wpgmptr (* __MINGW_IMP_SYMBOL(_wpgmptr))
    228 #endif
    229 #endif
    230   errno_t __cdecl _get_pgmptr(char **_Value);
    231   errno_t __cdecl _get_wpgmptr(wchar_t **_Value);
    232 #ifndef _fmode
    233 #ifdef _MSVCRT_
    234   extern int _fmode;
    235 #else
    236   extern int * __MINGW_IMP_SYMBOL(_fmode);
    237 #define _fmode	(* __MINGW_IMP_SYMBOL(_fmode))
    238 #endif
    239 #endif
    240   _CRTIMP errno_t __cdecl _set_fmode(int _Mode);
    241   _CRTIMP errno_t __cdecl _get_fmode(int *_PMode);
    242 
    243 #ifndef _osplatform
    244 #ifdef _MSVCRT_
    245   extern unsigned int _osplatform;
    246 #else
    247   extern unsigned int * __MINGW_IMP_SYMBOL(_osplatform);
    248 #define _osplatform (* __MINGW_IMP_SYMBOL(_osplatform))
    249 #endif
    250 #endif
    251 
    252 #ifndef _osver
    253 #ifdef _MSVCRT_
    254   extern unsigned int _osver;
    255 #else
    256   extern unsigned int * __MINGW_IMP_SYMBOL(_osver);
    257 #define _osver	(* __MINGW_IMP_SYMBOL(_osver))
    258 #endif
    259 #endif
    260 
    261 #ifndef _winver
    262 #ifdef _MSVCRT_
    263   extern unsigned int _winver;
    264 #else
    265   extern unsigned int * __MINGW_IMP_SYMBOL(_winver);
    266 #define _winver	(* __MINGW_IMP_SYMBOL(_winver))
    267 #endif
    268 #endif
    269 
    270 #ifndef _winmajor
    271 #ifdef _MSVCRT_
    272   extern unsigned int _winmajor;
    273 #else
    274   extern unsigned int * __MINGW_IMP_SYMBOL(_winmajor);
    275 #define _winmajor (* __MINGW_IMP_SYMBOL(_winmajor))
    276 #endif
    277 #endif
    278 
    279 #ifndef _winminor
    280 #ifdef _MSVCRT_
    281   extern unsigned int _winminor;
    282 #else
    283   extern unsigned int * __MINGW_IMP_SYMBOL(_winminor);
    284 #define _winminor (* __MINGW_IMP_SYMBOL(_winminor))
    285 #endif
    286 #endif
    287 
    288   errno_t __cdecl _get_osplatform(unsigned int *_Value);
    289   errno_t __cdecl _get_osver(unsigned int *_Value);
    290   errno_t __cdecl _get_winver(unsigned int *_Value);
    291   errno_t __cdecl _get_winmajor(unsigned int *_Value);
    292   errno_t __cdecl _get_winminor(unsigned int *_Value);
    293 #ifndef _countof
    294 #ifndef __cplusplus
    295 #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
    296 #else
    297   extern "C++" {
    298     template <typename _CountofType,size_t _SizeOfArray> char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
    299 #define _countof(_Array) sizeof(*__countof_helper(_Array))
    300   }
    301 #endif
    302 #endif
    303 
    304 #ifndef _CRT_TERMINATE_DEFINED
    305 #define _CRT_TERMINATE_DEFINED
    306   void __cdecl __MINGW_NOTHROW exit(int _Code) __MINGW_ATTRIB_NORETURN;
    307   void __cdecl __MINGW_NOTHROW _exit(int _Code) __MINGW_ATTRIB_NORETURN;
    308 
    309 #if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
    310   /* C99 function name */
    311   void __cdecl _Exit(int) __MINGW_ATTRIB_NORETURN;
    312 #ifndef __CRT__NO_INLINE
    313   __CRT_INLINE __MINGW_ATTRIB_NORETURN void  __cdecl _Exit(int status)
    314   {  _exit(status); }
    315 #endif /* !__CRT__NO_INLINE */
    316 #endif /* Not  __NO_ISOCEXT */
    317 
    318 #pragma push_macro("abort")
    319 #undef abort
    320   void __cdecl __declspec(noreturn) abort(void);
    321 #pragma pop_macro("abort")
    322 
    323 #endif /* _CRT_TERMINATE_DEFINED */
    324 
    325   _CRTIMP unsigned int __cdecl _set_abort_behavior(unsigned int _Flags,unsigned int _Mask);
    326 
    327 #ifndef _CRT_ABS_DEFINED
    328 #define _CRT_ABS_DEFINED
    329   int __cdecl abs(int _X);
    330   long __cdecl labs(long _X);
    331 #endif
    332 
    333   __MINGW_EXTENSION __int64 __cdecl _abs64(__int64);
    334 #ifdef __MINGW_INTRIN_INLINE
    335   __MINGW_INTRIN_INLINE __int64 __cdecl _abs64(__int64 x) {
    336     return __builtin_llabs(x);
    337   }
    338 #endif
    339 
    340   int __cdecl atexit(void (__cdecl *)(void));
    341 #ifndef _CRT_ATOF_DEFINED
    342 #define _CRT_ATOF_DEFINED
    343   double __cdecl atof(const char *_String);
    344   double __cdecl _atof_l(const char *_String,_locale_t _Locale);
    345 #endif
    346   int __cdecl atoi(const char *_Str);
    347   _CRTIMP int __cdecl _atoi_l(const char *_Str,_locale_t _Locale);
    348   long __cdecl atol(const char *_Str);
    349   _CRTIMP long __cdecl _atol_l(const char *_Str,_locale_t _Locale);
    350 #ifndef _CRT_ALGO_DEFINED
    351 #define _CRT_ALGO_DEFINED
    352   void *__cdecl bsearch(const void *_Key,const void *_Base,size_t _NumOfElements,size_t _SizeOfElements,int (__cdecl *_PtFuncCompare)(const void *,const void *));
    353   void __cdecl qsort(void *_Base,size_t _NumOfElements,size_t _SizeOfElements,int (__cdecl *_PtFuncCompare)(const void *,const void *));
    354 #endif
    355   unsigned short __cdecl _byteswap_ushort(unsigned short _Short);
    356   unsigned long __cdecl _byteswap_ulong (unsigned long _Long);
    357   __MINGW_EXTENSION unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 _Int64);
    358   div_t __cdecl div(int _Numerator,int _Denominator);
    359   char *__cdecl getenv(const char *_VarName) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    360   _CRTIMP char *__cdecl _itoa(int _Value,char *_Dest,int _Radix);
    361   __MINGW_EXTENSION _CRTIMP char *__cdecl _i64toa(__int64 _Val,char *_DstBuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    362   __MINGW_EXTENSION _CRTIMP char *__cdecl _ui64toa(unsigned __int64 _Val,char *_DstBuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    363   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _atoi64(const char *_String);
    364   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _atoi64_l(const char *_String,_locale_t _Locale);
    365   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _strtoi64(const char *_String,char **_EndPtr,int _Radix);
    366   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _strtoi64_l(const char *_String,char **_EndPtr,int _Radix,_locale_t _Locale);
    367   __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _strtoui64(const char *_String,char **_EndPtr,int _Radix);
    368   __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _strtoui64_l(const char *_String,char **_EndPtr,int _Radix,_locale_t _Locale);
    369   ldiv_t __cdecl ldiv(long _Numerator,long _Denominator);
    370   _CRTIMP char *__cdecl _ltoa(long _Value,char *_Dest,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    371   int __cdecl mblen(const char *_Ch,size_t _MaxCount);
    372   _CRTIMP int __cdecl _mblen_l(const char *_Ch,size_t _MaxCount,_locale_t _Locale);
    373   _CRTIMP size_t __cdecl _mbstrlen(const char *_Str);
    374   _CRTIMP size_t __cdecl _mbstrlen_l(const char *_Str,_locale_t _Locale);
    375   _CRTIMP size_t __cdecl _mbstrnlen(const char *_Str,size_t _MaxCount);
    376   _CRTIMP size_t __cdecl _mbstrnlen_l(const char *_Str,size_t _MaxCount,_locale_t _Locale);
    377   int __cdecl mbtowc(wchar_t * __restrict__ _DstCh,const char * __restrict__ _SrcCh,size_t _SrcSizeInBytes);
    378   _CRTIMP int __cdecl _mbtowc_l(wchar_t * __restrict__ _DstCh,const char * __restrict__ _SrcCh,size_t _SrcSizeInBytes,_locale_t _Locale);
    379   size_t __cdecl mbstowcs(wchar_t * __restrict__ _Dest,const char * __restrict__ _Source,size_t _MaxCount);
    380   _CRTIMP size_t __cdecl _mbstowcs_l(wchar_t * __restrict__ _Dest,const char * __restrict__ _Source,size_t _MaxCount,_locale_t _Locale);
    381   int __cdecl mkstemp(char *template_name);
    382   int __cdecl rand(void);
    383   _CRTIMP int __cdecl _set_error_mode(int _Mode);
    384   void __cdecl srand(unsigned int _Seed);
    385 #if defined(_POSIX) || defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    386   #ifndef rand_r
    387   #define rand_r(__seed) (__seed == __seed ? rand () : rand ())
    388   #endif
    389 #endif
    390 #ifdef _CRT_RAND_S
    391   _CRTIMP errno_t __cdecl rand_s(unsigned int *randomValue);
    392 #endif
    393 
    394 #if defined(__USE_MINGW_STRTOX)
    395 __mingw_ovr
    396 double __cdecl __MINGW_NOTHROW strtod(const char * __restrict__ _Str,char ** __restrict__ _EndPtr)
    397 {
    398   double __cdecl __mingw_strtod (const char * __restrict__, char ** __restrict__);
    399   return __mingw_strtod( _Str, _EndPtr);
    400 }
    401 
    402 __mingw_ovr
    403 float __cdecl __MINGW_NOTHROW strtof(const char * __restrict__ _Str,char ** __restrict__ _EndPtr)
    404 {
    405   float __cdecl __mingw_strtof (const char * __restrict__, char ** __restrict__);
    406   return __mingw_strtof( _Str, _EndPtr);
    407 }
    408 
    409 /* strtold is already an alias to __mingw_strtold */
    410 #else
    411   double __cdecl __MINGW_NOTHROW strtod(const char * __restrict__ _Str,char ** __restrict__ _EndPtr);
    412   float __cdecl __MINGW_NOTHROW strtof(const char * __restrict__ nptr, char ** __restrict__ endptr);
    413 #endif /* defined(__USE_MINGW_STRTOX) */
    414   long double __cdecl __MINGW_NOTHROW strtold(const char * __restrict__ , char ** __restrict__ );
    415 #if !defined __NO_ISOCEXT
    416   /* libmingwex.a provides a c99-compliant strtod() exported as __strtod() */
    417   extern double __cdecl __MINGW_NOTHROW
    418   __strtod (const char * __restrict__ , char ** __restrict__);
    419 #if !defined(__USE_MINGW_STRTOX)
    420 #define strtod __strtod
    421 #endif /* !defined(__USE_MINGW_STRTOX) */
    422 #endif /* __NO_ISOCEXT */
    423 
    424 #if !defined __NO_ISOCEXT  /* in libmingwex.a */
    425   float __cdecl __mingw_strtof (const char * __restrict__, char ** __restrict__);
    426   double __cdecl __mingw_strtod (const char * __restrict__, char ** __restrict__);
    427   long double __cdecl __mingw_strtold(const char * __restrict__, char ** __restrict__);
    428 #endif /* __NO_ISOCEXT */
    429   _CRTIMP double __cdecl _strtod_l(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,_locale_t _Locale);
    430   long __cdecl strtol(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix);
    431   _CRTIMP long __cdecl _strtol_l(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
    432   unsigned long __cdecl strtoul(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix);
    433   _CRTIMP unsigned long __cdecl _strtoul_l(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
    434 #ifndef _CRT_SYSTEM_DEFINED
    435 #define _CRT_SYSTEM_DEFINED
    436   int __cdecl system(const char *_Command);
    437 #endif
    438   _CRTIMP char *__cdecl _ultoa(unsigned long _Value,char *_Dest,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    439   int __cdecl wctomb(char *_MbCh,wchar_t _WCh) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    440   _CRTIMP int __cdecl _wctomb_l(char *_MbCh,wchar_t _WCh,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    441   size_t __cdecl wcstombs(char * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    442   _CRTIMP size_t __cdecl _wcstombs_l(char * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _MaxCount,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    443 
    444 #ifndef _CRT_ALLOCATION_DEFINED
    445 #define _CRT_ALLOCATION_DEFINED
    446   void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements);
    447   void __cdecl free(void *_Memory);
    448   void *__cdecl malloc(size_t _Size);
    449   void *__cdecl realloc(void *_Memory,size_t _NewSize);
    450   _CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size);
    451 /* Make sure that X86intrin.h doesn't produce here collisions.  */
    452 #if (!defined (_XMMINTRIN_H_INCLUDED) && !defined (_MM_MALLOC_H_INCLUDED)) || defined(_aligned_malloc)
    453 #pragma push_macro("_aligned_free")
    454 #pragma push_macro("_aligned_malloc")
    455 #undef _aligned_free
    456 #undef _aligned_malloc
    457   _CRTIMP void __cdecl _aligned_free(void *_Memory);
    458   _CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment);
    459 #pragma pop_macro("_aligned_free")
    460 #pragma pop_macro("_aligned_malloc")
    461 #endif
    462   _CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset);
    463   _CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment);
    464   _CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment);
    465   _CRTIMP void *__cdecl _aligned_offset_realloc(void *_Memory,size_t _Size,size_t _Alignment,size_t _Offset);
    466   _CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset);
    467 #endif
    468 
    469 #ifndef _WSTDLIB_DEFINED
    470 #define _WSTDLIB_DEFINED
    471 
    472   _CRTIMP wchar_t *__cdecl _itow(int _Value,wchar_t *_Dest,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    473   _CRTIMP wchar_t *__cdecl _ltow(long _Value,wchar_t *_Dest,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    474   _CRTIMP wchar_t *__cdecl _ultow(unsigned long _Value,wchar_t *_Dest,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    475 
    476   double __cdecl __mingw_wcstod(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr);
    477   float __cdecl __mingw_wcstof(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr);
    478   long double __cdecl __mingw_wcstold(const wchar_t * __restrict__, wchar_t ** __restrict__);
    479 
    480 #if defined(__USE_MINGW_STRTOX)
    481   __mingw_ovr
    482   double __cdecl wcstod(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr){
    483     return __mingw_wcstod(_Str,_EndPtr);
    484   }
    485   __mingw_ovr
    486   float __cdecl wcstof(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr){
    487     return __mingw_wcstof(_Str,_EndPtr);
    488   }
    489   /* wcstold is already a mingw implementation */
    490 #else
    491   double __cdecl wcstod(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr);
    492   float __cdecl wcstof(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr);
    493 #endif /* defined(__USE_MINGW_STRTOX) */
    494 #if !defined __NO_ISOCEXT /* in libmingwex.a */
    495   long double __cdecl wcstold(const wchar_t * __restrict__, wchar_t ** __restrict__);
    496 #endif /* __NO_ISOCEXT */
    497   _CRTIMP double __cdecl _wcstod_l(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,_locale_t _Locale);
    498   long __cdecl wcstol(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix);
    499   _CRTIMP long __cdecl _wcstol_l(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
    500   unsigned long __cdecl wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix);
    501   _CRTIMP unsigned long __cdecl _wcstoul_l(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
    502   _CRTIMP wchar_t *__cdecl _wgetenv(const wchar_t *_VarName) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    503 #ifndef _CRT_WSYSTEM_DEFINED
    504 #define _CRT_WSYSTEM_DEFINED
    505   _CRTIMP int __cdecl _wsystem(const wchar_t *_Command);
    506 #endif
    507   _CRTIMP double __cdecl _wtof(const wchar_t *_Str);
    508   _CRTIMP double __cdecl _wtof_l(const wchar_t *_Str,_locale_t _Locale);
    509   _CRTIMP int __cdecl _wtoi(const wchar_t *_Str);
    510   _CRTIMP int __cdecl _wtoi_l(const wchar_t *_Str,_locale_t _Locale);
    511   _CRTIMP long __cdecl _wtol(const wchar_t *_Str);
    512   _CRTIMP long __cdecl _wtol_l(const wchar_t *_Str,_locale_t _Locale);
    513 
    514   __MINGW_EXTENSION _CRTIMP wchar_t *__cdecl _i64tow(__int64 _Val,wchar_t *_DstBuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    515   __MINGW_EXTENSION _CRTIMP wchar_t *__cdecl _ui64tow(unsigned __int64 _Val,wchar_t *_DstBuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    516   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _wtoi64(const wchar_t *_Str);
    517   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _wtoi64_l(const wchar_t *_Str,_locale_t _Locale);
    518   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _wcstoi64(const wchar_t *_Str,wchar_t **_EndPtr,int _Radix);
    519   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _wcstoi64_l(const wchar_t *_Str,wchar_t **_EndPtr,int _Radix,_locale_t _Locale);
    520   __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _wcstoui64(const wchar_t *_Str,wchar_t **_EndPtr,int _Radix);
    521   __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _wcstoui64_l(const wchar_t *_Str ,wchar_t **_EndPtr,int _Radix,_locale_t _Locale);
    522 #endif
    523 
    524   _CRTIMP int __cdecl _putenv(const char *_EnvString);
    525   _CRTIMP int __cdecl _wputenv(const wchar_t *_EnvString);
    526 
    527 #ifndef _POSIX_
    528 #define _CVTBUFSIZE (309+40)
    529   _CRTIMP char *__cdecl _fullpath(char *_FullPath,const char *_Path,size_t _SizeInBytes);
    530   _CRTIMP char *__cdecl _ecvt(double _Val,int _NumOfDigits,int *_PtDec,int *_PtSign) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    531   _CRTIMP char *__cdecl _fcvt(double _Val,int _NumOfDec,int *_PtDec,int *_PtSign) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    532   _CRTIMP char *__cdecl _gcvt(double _Val,int _NumOfDigits,char *_DstBuf) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    533   _CRTIMP int __cdecl _atodbl(_CRT_DOUBLE *_Result,char *_Str);
    534   _CRTIMP int __cdecl _atoldbl(_LDOUBLE *_Result,char *_Str);
    535   _CRTIMP int __cdecl _atoflt(_CRT_FLOAT *_Result,char *_Str);
    536   _CRTIMP int __cdecl _atodbl_l(_CRT_DOUBLE *_Result,char *_Str,_locale_t _Locale);
    537   _CRTIMP int __cdecl _atoldbl_l(_LDOUBLE *_Result,char *_Str,_locale_t _Locale);
    538   _CRTIMP int __cdecl _atoflt_l(_CRT_FLOAT *_Result,char *_Str,_locale_t _Locale);
    539 
    540 #if defined(__INTRIN_H_) || \
    541    (defined(_X86INTRIN_H_INCLUDED) && \
    542      ((__MINGW_GCC_VERSION >= 40902) || defined(__LP64__) || defined(_X86_)))
    543 
    544 /* We already have bug-free prototypes and inline definitions for _lrotl
    545    and _lrotr from either intrin.h or x86intrin.h. */
    546 
    547 #else
    548 
    549 /* Remove buggy x86intrin.h definitions if present (see gcc bug 61662). */
    550 #undef _lrotr
    551 #undef _lrotl
    552 
    553 /* These prototypes work for x86, x64 (native Windows), and cyginwin64. */
    554 unsigned long __cdecl _lrotl(unsigned long,int);
    555 unsigned long __cdecl _lrotr(unsigned long,int);
    556 
    557 #endif /* defined(__INTRIN_H_) || \
    558     (defined(_X86INTRIN_H_INCLUDED) && \
    559        ((__MINGW_GCC_VERSION >= 40902) || defined(__LP64__))) */
    560 
    561   _CRTIMP void __cdecl _makepath(char *_Path,const char *_Drive,const char *_Dir,const char *_Filename,const char *_Ext);
    562   _onexit_t __cdecl _onexit(_onexit_t _Func);
    563 
    564 #ifndef _CRT_PERROR_DEFINED
    565 #define _CRT_PERROR_DEFINED
    566   void __cdecl perror(const char *_ErrMsg);
    567 #endif
    568 #pragma push_macro ("_rotr64")
    569 #pragma push_macro ("_rotl64")
    570 #undef _rotl64
    571 #undef _rotr64
    572   __MINGW_EXTENSION unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val,int _Shift);
    573   __MINGW_EXTENSION unsigned __int64 __cdecl _rotr64(unsigned __int64 Value,int Shift);
    574 #pragma pop_macro ("_rotl64")
    575 #pragma pop_macro ("_rotr64")
    576 #pragma push_macro ("_rotr")
    577 #pragma push_macro ("_rotl")
    578 #undef _rotr
    579 #undef _rotl
    580   unsigned int __cdecl _rotr(unsigned int _Val,int _Shift);
    581   unsigned int __cdecl _rotl(unsigned int _Val,int _Shift);
    582 #pragma pop_macro ("_rotl")
    583 #pragma pop_macro ("_rotr")
    584   __MINGW_EXTENSION unsigned __int64 __cdecl _rotr64(unsigned __int64 _Val,int _Shift);
    585   _CRTIMP void __cdecl _searchenv(const char *_Filename,const char *_EnvVar,char *_ResultPath) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    586   _CRTIMP void __cdecl _splitpath(const char *_FullPath,char *_Drive,char *_Dir,char *_Filename,char *_Ext) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    587   _CRTIMP void __cdecl _swab(char *_Buf1,char *_Buf2,int _SizeInBytes);
    588 
    589 #ifndef _WSTDLIBP_DEFINED
    590 #define _WSTDLIBP_DEFINED
    591   _CRTIMP wchar_t *__cdecl _wfullpath(wchar_t *_FullPath,const wchar_t *_Path,size_t _SizeInWords);
    592   _CRTIMP void __cdecl _wmakepath(wchar_t *_ResultPath,const wchar_t *_Drive,const wchar_t *_Dir,const wchar_t *_Filename,const wchar_t *_Ext);
    593 #ifndef _CRT_WPERROR_DEFINED
    594 #define _CRT_WPERROR_DEFINED
    595   _CRTIMP void __cdecl _wperror(const wchar_t *_ErrMsg);
    596 #endif
    597   _CRTIMP void __cdecl _wsearchenv(const wchar_t *_Filename,const wchar_t *_EnvVar,wchar_t *_ResultPath) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    598   _CRTIMP void __cdecl _wsplitpath(const wchar_t *_FullPath,wchar_t *_Drive,wchar_t *_Dir,wchar_t *_Filename,wchar_t *_Ext) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
    599 #endif
    600 
    601   _CRTIMP void __cdecl _beep(unsigned _Frequency,unsigned _Duration) __MINGW_ATTRIB_DEPRECATED;
    602   /* Not to be confused with  _set_error_mode (int).  */
    603   _CRTIMP void __cdecl _seterrormode(int _Mode) __MINGW_ATTRIB_DEPRECATED;
    604   _CRTIMP void __cdecl _sleep(unsigned long _Duration) __MINGW_ATTRIB_DEPRECATED;
    605 #endif
    606 
    607 #ifndef	NO_OLDNAMES
    608 #ifndef _POSIX_
    609 #if 0
    610 #ifndef __cplusplus
    611 #ifndef NOMINMAX
    612 #ifndef max
    613 #define max(a,b) (((a) > (b)) ? (a) : (b))
    614 #endif
    615 #ifndef min
    616 #define min(a,b) (((a) < (b)) ? (a) : (b))
    617 #endif
    618 #endif
    619 #endif
    620 #endif
    621 
    622 #define sys_errlist _sys_errlist
    623 #define sys_nerr _sys_nerr
    624 #define environ _environ
    625   char *__cdecl ecvt(double _Val,int _NumOfDigits,int *_PtDec,int *_PtSign) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    626   char *__cdecl fcvt(double _Val,int _NumOfDec,int *_PtDec,int *_PtSign) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    627   char *__cdecl gcvt(double _Val,int _NumOfDigits,char *_DstBuf) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    628   char *__cdecl itoa(int _Val,char *_DstBuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    629   char *__cdecl ltoa(long _Val,char *_DstBuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    630   int __cdecl putenv(const char *_EnvString) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    631 
    632 #ifndef _CRT_SWAB_DEFINED
    633 #define _CRT_SWAB_DEFINED  /* Also in unistd.h */
    634   void __cdecl swab(char *_Buf1,char *_Buf2,int _SizeInBytes) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    635 #endif
    636 
    637   char *__cdecl ultoa(unsigned long _Val,char *_Dstbuf,int _Radix) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    638   onexit_t __cdecl onexit(onexit_t _Func);
    639 #endif
    640 #endif
    641 
    642 #if !defined __NO_ISOCEXT /* externs in static libmingwex.a */
    643 
    644   typedef struct { __MINGW_EXTENSION long long quot, rem; } lldiv_t;
    645 
    646   __MINGW_EXTENSION lldiv_t __cdecl lldiv(long long, long long);
    647 
    648   __MINGW_EXTENSION long long __cdecl llabs(long long);
    649 #ifndef __CRT__NO_INLINE
    650   __MINGW_EXTENSION __CRT_INLINE long long __cdecl llabs(long long _j) { return (_j >= 0 ? _j : -_j); }
    651 #endif
    652 
    653   __MINGW_EXTENSION long long  __cdecl strtoll(const char * __restrict__, char ** __restrict, int);
    654   __MINGW_EXTENSION unsigned long long  __cdecl strtoull(const char * __restrict__, char ** __restrict__, int);
    655 
    656   /* these are stubs for MS _i64 versions */
    657   __MINGW_EXTENSION long long  __cdecl atoll (const char *);
    658 
    659 #ifndef __STRICT_ANSI__
    660   __MINGW_EXTENSION long long  __cdecl wtoll (const wchar_t *);
    661   __MINGW_EXTENSION char *__cdecl lltoa (long long, char *, int);
    662   __MINGW_EXTENSION char *__cdecl ulltoa (unsigned long long , char *, int);
    663   __MINGW_EXTENSION wchar_t *__cdecl lltow (long long, wchar_t *, int);
    664   __MINGW_EXTENSION wchar_t *__cdecl ulltow (unsigned long long, wchar_t *, int);
    665 
    666   /* __CRT_INLINE using non-ansi functions */
    667 #ifndef __CRT__NO_INLINE
    668   __MINGW_EXTENSION __CRT_INLINE long long  __cdecl atoll (const char * _c) { return _atoi64 (_c); }
    669   __MINGW_EXTENSION __CRT_INLINE char *__cdecl lltoa (long long _n, char * _c, int _i) { return _i64toa (_n, _c, _i); }
    670   __MINGW_EXTENSION __CRT_INLINE char *__cdecl ulltoa (unsigned long long _n, char * _c, int _i) { return _ui64toa (_n, _c, _i); }
    671   __MINGW_EXTENSION __CRT_INLINE long long  __cdecl wtoll (const wchar_t * _w) { return _wtoi64 (_w); }
    672   __MINGW_EXTENSION __CRT_INLINE wchar_t *__cdecl lltow (long long _n, wchar_t * _w, int _i) { return _i64tow (_n, _w, _i); }
    673   __MINGW_EXTENSION __CRT_INLINE wchar_t *__cdecl ulltow (unsigned long long _n, wchar_t * _w, int _i) { return _ui64tow (_n, _w, _i); }
    674 #endif /* !__CRT__NO_INLINE */
    675 #endif /* (__STRICT_ANSI__)  */
    676 
    677 #endif /* !__NO_ISOCEXT */
    678 
    679 #ifdef __cplusplus
    680 }
    681 #endif
    682 
    683 #pragma pack(pop)
    684 
    685 #include <sec_api/stdlib_s.h>
    686 #include <malloc.h>
    687 
    688 #endif
    689