diff --git a/reactos/include/crt/stdlib.h b/reactos/include/crt/stdlib.h index 0efd5cc4321..cf40425ff29 100644 --- a/reactos/include/crt/stdlib.h +++ b/reactos/include/crt/stdlib.h @@ -92,22 +92,15 @@ extern "C" { #ifndef MB_CUR_MAX #define MB_CUR_MAX ___mb_cur_max_func() -#ifndef __mb_cur_max -#ifdef _MSVCRT_ - extern int __mb_cur_max; -#else -#define __mb_cur_max (*_imp____mb_cur_max) - extern int *_imp____mb_cur_max; -#endif -#endif -#ifdef _MSVCRT_ - extern int __mbcur_max; -#define ___mb_cur_max_func() (__mb_cur_max) -#else - extern int* _imp____mbcur_max; -#define ___mb_cur_max_func() (*_imp____mb_cur_max) -#endif -#endif +#ifdef _M_CEE_PURE + _CRTIMP int* __cdecl __p___mb_cur_max(); + #define __mb_cur_max (*__p___mb_cur_max()) +#else /* !_M_CEE_PURE */ + _CRTIMP extern int __mb_cur_max; +#endif /* !_M_CEE_PURE */ + _CRTIMP int __cdecl ___mb_cur_max_func(void); + _CRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t); +#endif /* !MB_CUR_MAX */ #define __max(a,b) (((a) > (b)) ? (a) : (b)) #define __min(a,b) (((a) < (b)) ? (a) : (b)) @@ -152,7 +145,7 @@ extern "C" { _CRTIMP extern char *_sys_errlist[]; _CRTIMP extern int _sys_nerr; -//#if !defined(__x86_64) +#if defined(_DLL) && defined(_M_IX86) _CRTIMP int *__cdecl __p___argc(void); _CRTIMP char ***__cdecl __p___argv(void); _CRTIMP wchar_t ***__cdecl __p___wargv(void); @@ -160,133 +153,74 @@ extern "C" { _CRTIMP wchar_t ***__cdecl __p__wenviron(void); _CRTIMP char **__cdecl __p__pgmptr(void); _CRTIMP wchar_t **__cdecl __p__wpgmptr(void); -//#endif -#ifndef __argc -#ifdef _MSVCRT_ - extern int __argc; -#else -#define __argc (*_imp____argc) - extern int *_imp____argc; -#endif -#endif -#ifndef __argv -#ifdef _MSVCRT_ - extern char **__argv; -#else -#define __argv (*_imp____argv) - extern char ***_imp____argv; -#endif -#endif -#ifndef __wargv -#ifdef _MSVCRT_ - extern wchar_t **__wargv; -#else -#define __wargv (*_imp____wargv) - extern wchar_t ***_imp____wargv; -#endif #endif -#ifdef _POSIX_ - extern char **environ; -#else -#ifndef _environ -#ifdef _MSVCRT_ - extern char **_environ; -#else -#define _environ (*_imp___environ) - extern char ***_imp___environ; -#endif -#endif +// FIXME: move inside _M_CEE_PURE section + _CRTIMP int *__cdecl __p___argc(); + _CRTIMP char ***__cdecl __p___argv(); + _CRTIMP wchar_t ***__cdecl __p___wargv(); + _CRTIMP char ***__cdecl __p__environ(); + _CRTIMP wchar_t ***__cdecl __p__wenviron(); + _CRTIMP char **__cdecl __p__pgmptr(); + _CRTIMP wchar_t **__cdecl __p__wpgmptr(); -#ifndef _wenviron -#ifdef _MSVCRT_ - extern wchar_t **_wenviron; -#else -#define _wenviron (*_imp___wenviron) - extern wchar_t ***_imp___wenviron; -#endif -#endif -#endif -#ifndef _pgmptr -#ifdef _MSVCRT_ - extern char *_pgmptr; -#else -#define _pgmptr (*_imp___pgmptr) - extern char **_imp___pgmptr; -#endif -#endif +#ifdef _M_CEE_PURE + #define __argv (*__p___argv()) + #define __argc (*__p___argc()) + #define __wargv (*__p___wargv()) + #define _environ (*__p__environ()) + #define _wenviron (*__p__wenviron()) + #define _pgmptr (*__p__pgmptr()) + #define _wpgmptr (*__p__wpgmptr()) +#else /* !_M_CEE_PURE */ + _CRTIMP extern int __argc; + _CRTIMP extern char **__argv; + _CRTIMP extern wchar_t **__wargv; + _CRTIMP extern char **_environ; + _CRTIMP extern wchar_t **_wenviron; + _CRTIMP extern char *_pgmptr; + _CRTIMP extern wchar_t *_wpgmptr; +#endif /* !_M_CEE_PURE */ -#ifndef _wpgmptr -#ifdef _MSVCRT_ - extern wchar_t *_wpgmptr; + _CRTIMP errno_t __cdecl _get_environ(char***); + _CRTIMP errno_t __cdecl _get_wenviron(wchar_t***); + _CRTIMP errno_t __cdecl _get_pgmptr(char **_Value); + _CRTIMP errno_t __cdecl _get_wpgmptr(wchar_t **_Value); + +#ifdef _M_CEE_PURE + _CRTIMP int* __cdecl __p__fmode(); + #define _fmode (*__p__fmode()) #else -#define _wpgmptr (*_imp___wpgmptr) - extern wchar_t **_imp___wpgmptr; -#endif -#endif - errno_t __cdecl _get_pgmptr(char **_Value); - errno_t __cdecl _get_wpgmptr(wchar_t **_Value); -#ifndef _fmode -#ifdef _MSVCRT_ - extern int _fmode; -#else -#define _fmode (*_imp___fmode) - extern int *_imp___fmode; -#endif -#endif + _CRTIMP extern int _fmode; +#endif /* !_M_CEE_PURE */ _CRTIMP errno_t __cdecl _set_fmode(int _Mode); _CRTIMP errno_t __cdecl _get_fmode(int *_PMode); -#ifndef _osplatform -#ifdef _MSVCRT_ - extern unsigned int _osplatform; -#else -#define _osplatform (*_imp___osplatform) - extern unsigned int *_imp___osplatform; -#endif -#endif - -#ifndef _osver -#ifdef _MSVCRT_ - extern unsigned int _osver; -#else -#define _osver (*_imp___osver) - extern unsigned int *_imp___osver; -#endif -#endif - -#ifndef _winver -#ifdef _MSVCRT_ - extern unsigned int _winver; -#else -#define _winver (*_imp___winver) - extern unsigned int *_imp___winver; -#endif -#endif - -#ifndef _winmajor -#ifdef _MSVCRT_ - extern unsigned int _winmajor; -#else -#define _winmajor (*_imp___winmajor) - extern unsigned int *_imp___winmajor; -#endif -#endif - -#ifndef _winminor -#ifdef _MSVCRT_ - extern unsigned int _winminor; -#else -#define _winminor (*_imp___winminor) - extern unsigned int *_imp___winminor; -#endif -#endif +#ifdef _M_CEE_PURE + _CRTIMP unsigned int* __cdecl __p__osplatform(); + _CRTIMP unsigned int* __cdecl __p__osver(); + _CRTIMP unsigned int* __cdecl __p__winver(); + _CRTIMP unsigned int* __cdecl __p__winmajor(); + _CRTIMP unsigned int* __cdecl __p__winminor(); +#define _osplatform (*__p__osplatform()) +#define _osver (*__p__osver()) +#define _winver (*__p__winver()) +#define _winmajor (*__p__winmajor()) +#define _winminor (*__p__winminor()) +#else /* !_M_CEE_PURE */ + _CRTIMP extern unsigned int _osplatform; + _CRTIMP extern unsigned int _osver; + _CRTIMP extern unsigned int _winver; + _CRTIMP extern unsigned int _winmajor; + _CRTIMP extern unsigned int _winminor; +#endif /* !_M_CEE_PURE */ errno_t __cdecl _get_osplatform(unsigned int *_Value); errno_t __cdecl _get_osver(unsigned int *_Value); errno_t __cdecl _get_winver(unsigned int *_Value); errno_t __cdecl _get_winmajor(unsigned int *_Value); errno_t __cdecl _get_winminor(unsigned int *_Value); + #ifndef _countof #ifndef __cplusplus #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))