Add _MSVCRT_ support for rosbe global data of msvcrt.
git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@460 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/mingw-w64-headers/include/ChangeLog b/mingw-w64-headers/include/ChangeLog
index 86838e9..df51f43 100644
--- a/mingw-w64-headers/include/ChangeLog
+++ b/mingw-w64-headers/include/ChangeLog
@@ -1,6 +1,13 @@
2008-08-27 Kai Tietz <kai.tietz@onevision.com>
* fcntl.h (_O_ACCMODE): New.
+ * math.h (_HUGE): Special handling if _MSVCRT_ is defined.
+ * ctype.h (_imp__...): Likewise.
+ * mbctype.h (_imp__...): Likewise.
+ * stdio.h (_imp__...): Likewise.
+ * stdlib.h (_imp__...): Likewise.
+ * wchar.h (_imp__...): Likewise.
+ * wctype.h (_imp__...): Likewise.
2008-08-07 Kai Tietz <kai.tietz@onevision.com>
diff --git a/mingw-w64-headers/include/ctype.h b/mingw-w64-headers/include/ctype.h
index 4420ee3..7e90100 100644
--- a/mingw-w64-headers/include/ctype.h
+++ b/mingw-w64-headers/include/ctype.h
@@ -22,13 +22,21 @@
#ifndef __PCTYPE_FUNC
#define __PCTYPE_FUNC __pctype_func()
+#ifdef _MSVCRT_
+#define __pctype_func() (_pctype)
+#else
#define __pctype_func() (*_imp___pctype)
#endif
+#endif
#ifndef _pctype
+#ifdef _MSVCRT_
+ extern unsigned short *_pctype;
+#else
extern unsigned short **_imp___pctype;
#define _pctype (*_imp___pctype)
#endif
+#endif
#endif
#endif
@@ -37,15 +45,25 @@
#define _CRT_WCTYPEDATA_DEFINED
#ifndef _CTYPE_DISABLE_MACROS
#ifndef _wctype
+#ifdef _MSVCRT_
+ extern unsigned short *_wctype;
+#else
extern unsigned short **_imp___wctype;
#define _wctype (*_imp___wctype)
#endif
+#endif
+#ifdef _MSVCRT_
+#define __pwctype_func() (_pwctype)
+#ifndef _pwctype
+ extern unsigned short *_pwctype;
+#endif
+#else
#define __pwctype_func() (*_imp___pwctype)
#ifndef _pwctype
extern unsigned short **_imp___pwctype;
#define _pwctype (*_imp___pwctype)
#endif
-
+#endif
#endif
#endif
@@ -169,11 +187,19 @@
#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_
+#define ___mb_cur_max_func() (__mb_cur_max)
+#else
#define ___mb_cur_max_func() (*_imp____mb_cur_max)
#endif
+#endif
#define __chvalidchk(a,b) (__PCTYPE_FUNC[(a)] & (b))
#define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? __chvalidchk(_Char,_Flag) : ((_locale_t)_Locale)->locinfo->pctype[_Char] & (_Flag))
diff --git a/mingw-w64-headers/include/math.h b/mingw-w64-headers/include/math.h
index beb8156..fd8a3b3 100644
--- a/mingw-w64-headers/include/math.h
+++ b/mingw-w64-headers/include/math.h
@@ -49,9 +49,13 @@
#define ERANGE 34
#ifndef _HUGE
+#ifdef _MSVCRT_
+ extern double *_HUGE;
+#else
extern double *_imp___HUGE;
#define _HUGE (*_imp___HUGE)
#endif
+#endif
#define HUGE_VAL _HUGE
diff --git a/mingw-w64-headers/include/mbctype.h b/mingw-w64-headers/include/mbctype.h
index 111c2aa..d8dd366 100644
--- a/mingw-w64-headers/include/mbctype.h
+++ b/mingw-w64-headers/include/mbctype.h
@@ -22,13 +22,21 @@
#endif /* defined (_DLL) && defined (_M_IX86) */
#endif
#ifndef _mbctype
+#ifdef _MSVCRT_
+ extern unsigned char *_mbctype;
+#else
#define _mbctype (*_imp___mbctype)
extern unsigned char **_imp___mbctype;
#endif
+#endif
#ifndef _mbcasemap
+#ifdef _MSVCRT_
+ extern unsigned char *_mbcasemap;
+#else
#define _mbcasemap (*_imp___mbcasemap)
extern unsigned char **_imp___mbcasemap;
#endif
+#endif
/* CRT stuff */
#if 1
diff --git a/mingw-w64-headers/include/stdio.h b/mingw-w64-headers/include/stdio.h
index ae0cba4..ba9393d 100644
--- a/mingw-w64-headers/include/stdio.h
+++ b/mingw-w64-headers/include/stdio.h
@@ -94,11 +94,16 @@
#ifdef _WIN64
_CRTIMP FILE *__cdecl __iob_func(void);
#else
+#ifdef _MSVCRT_
+extern FILE _iob[]; /* A pointer to an array of FILE */
+#define __iob_func() (_iob)
+#else
extern FILE (*_imp___iob)[]; /* A pointer to an array of FILE */
#define __iob_func() (*_imp___iob)
-#endif
#define _iob __iob_func()
#endif
+#endif
+#endif
#ifndef _FPOS_T_DEFINED
#define _FPOS_T_DEFINED
diff --git a/mingw-w64-headers/include/stdlib.h b/mingw-w64-headers/include/stdlib.h
index 2e708e3..68c75a3 100644
--- a/mingw-w64-headers/include/stdlib.h
+++ b/mingw-w64-headers/include/stdlib.h
@@ -90,12 +90,21 @@
#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
#define __max(a,b) (((a) > (b)) ? (a) : (b))
#define __min(a,b) (((a) < (b)) ? (a) : (b))
@@ -148,67 +157,126 @@
_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
+
#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
+
#ifndef _wpgmptr
+#ifdef _MSVCRT_
+ extern wchar_t *_wpgmptr;
+#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 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
+
errno_t __cdecl _get_osplatform(unsigned int *_Value);
errno_t __cdecl _get_osver(unsigned int *_Value);
errno_t __cdecl _get_winver(unsigned int *_Value);
diff --git a/mingw-w64-headers/include/wchar.h b/mingw-w64-headers/include/wchar.h
index 14c81d9..86bbbef 100644
--- a/mingw-w64-headers/include/wchar.h
+++ b/mingw-w64-headers/include/wchar.h
@@ -50,9 +50,16 @@
#ifdef _WIN64
_CRTIMP FILE *__cdecl __iob_func(void);
#else
+#ifdef _MSVCRT_
+extern FILE _iob[]; /* A pointer to an array of FILE */
+#define __iob_func() (_iob)
+#else
extern FILE (*_imp___iob)[]; /* A pointer to an array of FILE */
#define __iob_func() (*_imp___iob)
+#define _iob __iob_func()
#endif
+#endif
+
#define _iob __iob_func()
#endif
@@ -148,30 +155,50 @@
#ifndef __PCTYPE_FUNC
#define __PCTYPE_FUNC __pctype_func()
+#ifdef _MSVCRT_
+#define __pctype_func() (_pctype)
+#else
#define __pctype_func() (*_imp___pctype)
#endif
+#endif
#ifndef _pctype
+#ifdef _MSVCRT_
+ extern unsigned short *_pctype;
+#else
extern unsigned short **_imp___pctype;
#define _pctype (*_imp___pctype)
#endif
#endif
#endif
+#endif
#ifndef _CRT_WCTYPEDATA_DEFINED
#define _CRT_WCTYPEDATA_DEFINED
#ifndef _CTYPE_DISABLE_MACROS
#ifndef _wctype
+#ifdef _MSVCRT_
+ extern unsigned short *_wctype;
+#else
extern unsigned short **_imp___wctype;
#define _wctype (*_imp___wctype)
#endif
+#endif
+#ifdef _MSVCRT_
+#define __pwctype_func() (_pwctype)
+#else
#define __pwctype_func() (*_imp___pwctype)
+#endif
#ifndef _pwctype
+#ifdef _MSVCRT_
+ extern unsigned short *_pwctype;
+#else
extern unsigned short **_imp___pwctype;
#define _pwctype (*_imp___pwctype)
#endif
+#endif
#endif
#endif
diff --git a/mingw-w64-headers/include/wctype.h b/mingw-w64-headers/include/wctype.h
index ae19d9e..a44cb38 100644
--- a/mingw-w64-headers/include/wctype.h
+++ b/mingw-w64-headers/include/wctype.h
@@ -43,13 +43,21 @@
#ifndef __PCTYPE_FUNC
#define __PCTYPE_FUNC __pctype_func()
+#ifdef _MSVCRT_
+#define __pctype_func() (_pctype)
+#else
#define __pctype_func() (*_imp___pctype)
#endif
+#endif
#ifndef _pctype
+#ifdef _MSVCRT_
+ extern unsigned short *_pctype;
+#else
extern unsigned short **_imp___pctype;
#define _pctype (*_imp___pctype)
#endif
+#endif
#endif
#endif
@@ -58,17 +66,25 @@
#define _CRT_WCTYPEDATA_DEFINED
#ifndef _CTYPE_DISABLE_MACROS
#ifndef _wctype
+#ifdef _MSVCRT_
+ extern unsigned short *_wctype;
+#else
extern unsigned short **_imp___wctype;
#define _wctype (*_imp___wctype)
#endif
+#endif
#ifndef _pwctype
+#ifdef _MSVCRT_
+ extern unsigned short *_pwctype;
+#else
extern unsigned short **_imp___pwctype;
#define _pwctype (*_imp___pwctype)
#define __pwctype_func() (*_imp___pwctype)
#endif
#endif
#endif
+#endif
#define _UPPER 0x1
#define _LOWER 0x2