diff options
Diffstat (limited to 'winsup/mingw/include/stdlib.h')
-rw-r--r-- | winsup/mingw/include/stdlib.h | 114 |
1 files changed, 93 insertions, 21 deletions
diff --git a/winsup/mingw/include/stdlib.h b/winsup/mingw/include/stdlib.h index 153e6483c..bc5884278 100644 --- a/winsup/mingw/include/stdlib.h +++ b/winsup/mingw/include/stdlib.h @@ -101,10 +101,10 @@ extern wchar_t*** __p___wargv(void); #ifndef __DECLSPEC_SUPPORTED -extern int* __imp___argc_dll; -extern char*** __imp___argv_dll; -#define __argc (*__imp___argc_dll) -#define __argv (*__imp___argv_dll) +extern int* _imp____argc_dll; +extern char*** _imp____argv_dll; +#define __argc (*_imp____argc_dll) +#define __argv (*_imp____argv_dll) #else /* __DECLSPEC_SUPPORTED */ @@ -121,16 +121,27 @@ __MINGW_IMPORT char** __argv_dll; * Also defined in ctype.h. */ +/* Also defined in stdlib.h */ #ifndef MB_CUR_MAX +#ifdef __DECLSPEC_SUPPORTED # ifdef __MSVCRT__ # define MB_CUR_MAX __mb_cur_max __MINGW_IMPORT int __mb_cur_max; -# else /* not __MSVCRT */ +# else /* not __MSVCRT */ # define MB_CUR_MAX __mb_cur_max_dll __MINGW_IMPORT int __mb_cur_max_dll; -# endif /* not __MSVCRT */ -#endif /* MB_CUR_MAX */ +# endif /* not __MSVCRT */ +#else /* ! __DECLSPEC_SUPPORTED */ +# ifdef __MSVCRT__ + extern int* _imp____mbcur_max +# define MB_CUR_MAX (*_imp____mb_cur_max) +# else /* not __MSVCRT */ + extern int* _imp____mbcur_max_dll +# define MB_CUR_MAX (*_imp____mb_cur_max_dll) +# endif /* not __MSVCRT */ +#endif /* __DECLSPEC_SUPPORTED */ +#endif /* MB_CUR_MAX */ /* * MS likes to declare errno in stdlib.h as well. */ @@ -156,8 +167,8 @@ int* __doserrno(void); # define _wenviron (*__p__wenviron()) #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED - extern char *** __imp__environ_dll; -# define _environ (*__imp__environ_dll) + extern char *** _imp___environ_dll; +# define _environ (*_imp___environ_dll) # else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char ** _environ_dll; # define _environ _environ_dll @@ -170,8 +181,8 @@ int* __doserrno(void); /* One of the MSVCRTxx libraries */ #ifndef __DECLSPEC_SUPPORTED - extern int* __imp__sys_nerr; -# define sys_nerr (*__imp__sys_nerr) + extern int* _imp___sys_nerr; +# define sys_nerr (*_imp___sys_nerr) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT int _sys_nerr; # ifndef _UWIN @@ -184,8 +195,8 @@ int* __doserrno(void); /* CRTDLL run time library */ #ifndef __DECLSPEC_SUPPORTED - extern int* __imp__sys_nerr_dll; -# define sys_nerr (*__imp__sys_nerr_dll) + extern int* _imp___sys_nerr_dll; +# define sys_nerr (*_imp___sys_nerr_dll) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT int _sys_nerr_dll; # define sys_nerr _sys_nerr_dll @@ -194,8 +205,8 @@ int* __doserrno(void); #endif /* ! __MSVCRT__ */ #ifndef __DECLSPEC_SUPPORTED -extern char*** __imp__sys_errlist; -#define sys_errlist (*__imp__sys_errlist) +extern char*** _imp__sys_errlist; +#define sys_errlist (*_imp___sys_errlist) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char* _sys_errlist[]; #ifndef _UWIN @@ -262,7 +273,7 @@ wchar_t** __p__wpgmptr(void); #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED extern char** __imp__pgmptr_dll; -# define _pgmptr (*__imp__pgmptr_dll) +# define _pgmptr (*_imp___pgmptr_dll) # else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char* _pgmptr_dll; # define _pgmptr _pgmptr_dll @@ -285,12 +296,26 @@ int _wtoi (const wchar_t *); long _wtol (const wchar_t *); double strtod (const char*, char**); -double wcstod (const wchar_t*, wchar_t**); -long strtol (const char*, char**, int); -long wcstol (const wchar_t*, wchar_t**, int); +#if !defined __NO_ISOCEXT /* extern stubs in static libmingwex.a */ +extern __inline__ float strtof (const char *nptr, char **endptr) + { return (strtod (nptr, endptr));} +#endif /* __NO_ISOCEXT */ +long strtol (const char*, char**, int); unsigned long strtoul (const char*, char**, int); + +#ifndef _WSTDLIB_DEFINED +/* also declared in wchar.h */ +double wcstod (const wchar_t*, wchar_t**); +#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */ +extern __inline__ float wcstof( const wchar_t *nptr, wchar_t **endptr) +{ return (wcstod(nptr, endptr)); } +#endif /* __NO_ISOCEXT */ + +long wcstol (const wchar_t*, wchar_t**, int); unsigned long wcstoul (const wchar_t*, wchar_t**, int); +#define _WSTDLIB_DEFINED +#endif size_t wcstombs (char*, const wchar_t*, size_t); int wctomb (char*, wchar_t); @@ -336,7 +361,6 @@ typedef struct { long quot, rem; } ldiv_t; div_t div (int, int); ldiv_t ldiv (long, long); - #ifndef __STRICT_ANSI__ /* @@ -348,7 +372,12 @@ void _seterrormode (int); void _sleep (unsigned long); void _exit (int) _ATTRIB_NORETURN; - +#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */ +/* C99 function name */ +void _Exit(int) _ATTRIB_NORETURN; /* Declare to get noreturn attribute. */ +extern __inline__ void _Exit(int status) + { _exit(status); } +#endif /* _onexit is MS extension. Use atexit for portability. */ typedef int (* _onexit_t)(void); _onexit_t _onexit( _onexit_t ); @@ -406,6 +435,49 @@ char* gcvt (double, int, char*); #endif /* Not __STRICT_ANSI__ */ +/* C99 names */ + +#if !defined __NO_ISOCEXT /* externs in static libmingwex.a */ + +typedef struct { long long quot, rem; } lldiv_t; + +lldiv_t lldiv (long long, long long); + +extern __inline__ long long llabs(long long _j) + {return (_j >= 0 ? _j : -_j);} + +long long strtoll (const char* __restrict__, char** __restrict, int); +unsigned long long strtoull (const char* __restrict__, char** __restrict__, int); + +#if defined (__MSVCRT__) /* these are stubs for MS _i64 versions */ +long long atoll (const char *); + +#if !defined (__STRICT_ANSI__) +long long wtoll(const wchar_t *); +char* lltoa(long long, char *, int); +char* ulltoa(unsigned long long , char *, int); +wchar_t* lltow(long long, wchar_t *, int); +wchar_t* ulltow(unsigned long long, wchar_t *, int); + + /* inline using non-ansi functions */ +extern __inline__ long long atoll (const char * _c) + { return _atoi64 (_c); } +extern __inline__ char* lltoa(long long _n, char * _c, int _i) + { return _i64toa (_n, _c, _i); } +extern __inline__ char* ulltoa(unsigned long long _n, char * _c, int _i) + { return _ui64toa (_n, _c, _i); } +extern __inline__ long long wtoll(const wchar_t * _w) + { return _wtoi64 (_w); } +extern __inline__ wchar_t* lltow(long long _n, wchar_t * _w, int _i) + { return _i64tow (_n, _w, _i); } +extern __inline__ wchar_t* ulltow(unsigned long long _n, wchar_t * _w, int _i) + { return _ui64tow (_n, _w, _i); } +#endif /* (__STRICT_ANSI__) */ + +#endif /* __MSVCRT__ */ + +#endif /* !__NO_ISOCEXT */ + /* * Undefine the no return attribute used in some function definitions */ |