msvcrt/ removal

Dimitrie O. Paun dpaun at rogers.com
Fri Dec 13 01:29:14 CST 2002


OK,

Here is the problem:
  A. The msvcrt files include other msvcrt files, but they should
     do so *without* explicitly asking for them. That is, they should
	#include "stdio.h"
     instead of:
	#include "msvcrt/stdio.h"

     Rationale: among other things, this should allow Winelib apps to
	easily choose between msvcrt and glibc by modifying their path.

  B. There are some places (particularly in the msvcrt implementation)
     where we *need* to mix msvcrt and glibc so we can implement
     the former on top of the latter. To this end, we define a macro
	     USE_MSVCRT_PREFIX
     which signals the msvcrt headers that they need to rename symbols
     and do stuff so they can coexist with glibc in the same namespace.

Obviously, in the (B) case, we can not include the msvcrt/ dir in the
include path, because we would not be able to include glibc headers,
which is a big NO-NO. So mu _have_ to include them explicitly:
  #include "msvcrt/stdio.h"
But by (A), the msvcrt/stdio.h file must have all includes of the form:
  #include "stdio.h"
which can not work because they are not in the path!

The solution is simply. In the pathological case where we need to mix
the two libc implementations (which is signaled by USE_MSVCRT_PREFIX),
so NOT include any files from msvcrt headers, and leave the responsability
of explicitly including all the needed files to the caller.

Which is exactly what this patch does, and it works beautifully.

ChangeLog
  Do not explicitly include msvcrt files from msvcrt headers.

Index: dlls/msvcrt/msvcrt.h
===================================================================
RCS file: /var/cvs/wine/dlls/msvcrt/msvcrt.h,v
retrieving revision 1.17
diff -u -r1.17 msvcrt.h
--- dlls/msvcrt/msvcrt.h	31 Oct 2002 02:10:15 -0000	1.17
+++ dlls/msvcrt/msvcrt.h	13 Dec 2002 07:04:32 -0000
@@ -29,6 +29,11 @@
 #include "winnls.h"
 
 #include "msvcrt/eh.h"
+#include "msvcrt/wctype.h"
+#include "msvcrt/malloc.h"
+#include "msvcrt/sys/types.h"
+#include "msvcrt/stdio.h"
+#include "msvcrt/search.h"
 
 /* TLS data */
 extern DWORD MSVCRT_tls_index;
Index: include/msvcrt/ctype.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/ctype.h,v
retrieving revision 1.2
diff -u -r1.2 ctype.h
--- include/msvcrt/ctype.h	22 Oct 2001 18:59:23 -0000	1.2
+++ include/msvcrt/ctype.h	13 Dec 2002 06:45:40 -0000
@@ -9,8 +9,9 @@
 #define __WINE_CTYPE_H
 #define __WINE_USE_MSVCRT
 
-#include "msvcrt/wctype.h"
-
+#ifndef USE_MSVCRT_PREFIX
+# include "wctype.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
Index: include/msvcrt/direct.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/direct.h,v
retrieving revision 1.2
diff -u -r1.2 direct.h
--- include/msvcrt/direct.h	22 Oct 2001 18:59:23 -0000	1.2
+++ include/msvcrt/direct.h	13 Dec 2002 06:45:58 -0000
@@ -9,9 +9,10 @@
 #define __WINE_DIRECT_H
 #define __WINE_USE_MSVCRT
 
-#include "winnt.h"
-#include "msvcrt/dos.h"            /* For _getdiskfree & co */
-
+#ifndef USE_MSVCRT_PREFIX
+# include "winnt.h"
+# include "dos.h"            /* For _getdiskfree & co */
+#endif
 
 #ifdef __cplusplus
 extern "C" {
Index: include/msvcrt/io.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/io.h,v
retrieving revision 1.2
diff -u -r1.2 io.h
--- include/msvcrt/io.h	22 Oct 2001 18:59:23 -0000	1.2
+++ include/msvcrt/io.h	13 Dec 2002 06:46:13 -0000
@@ -9,8 +9,10 @@
 #define __WINE_IO_H
 #define __WINE_USE_MSVCRT
 
-#include "msvcrt/stdio.h"          /* For FILENAME_MAX */
-#include "msvcrt/sys/types.h"      /* For time_t */
+#ifndef USE_MSVCRT_PREFIX
+# include "stdio.h"          /* For FILENAME_MAX */
+# include "sys/types.h"      /* For time_t */
+#endif
 
 /* The following are also defined in dos.h */
 #define _A_NORMAL 0x00000000
Index: include/msvcrt/mbstring.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/mbstring.h,v
retrieving revision 1.2
diff -u -r1.2 mbstring.h
--- include/msvcrt/mbstring.h	10 Mar 2002 00:02:38 -0000	1.2
+++ include/msvcrt/mbstring.h	13 Dec 2002 06:46:26 -0000
@@ -21,7 +21,9 @@
 #define __WINE_MBSTRING_H
 #define __WINE_USE_MSVCRT
 
-#include "msvcrt/mbctype.h"
+#ifndef USE_MSVCRT_PREFIX
+# include "mbctype.h"
+#endif
 
 #ifdef USE_MSVCRT_PREFIX
 #define MSVCRT(x)    MSVCRT_##x
Index: include/msvcrt/stdio.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/stdio.h,v
retrieving revision 1.7
diff -u -r1.7 stdio.h
--- include/msvcrt/stdio.h	17 Aug 2002 01:22:00 -0000	1.7
+++ include/msvcrt/stdio.h	13 Dec 2002 06:47:11 -0000
@@ -9,11 +9,12 @@
 #define __WINE_STDIO_H
 #define __WINE_USE_MSVCRT
 
-#ifndef RC_INVOKED
-#include <stdarg.h>
+#ifndef USE_MSVCRT_PREFIX
+# ifndef RC_INVOKED
+#  include <stdarg.h>
+# endif
+# include "wctype.h"         /* For wint_t */
 #endif
-#include "msvcrt/wctype.h"         /* For wint_t */
-
 
 /* file._flag flags */
 #ifndef USE_MSVCRT_PREFIX
Index: include/msvcrt/stdlib.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/stdlib.h,v
retrieving revision 1.7
diff -u -r1.7 stdlib.h
--- include/msvcrt/stdlib.h	10 Dec 2002 22:56:44 -0000	1.7
+++ include/msvcrt/stdlib.h	13 Dec 2002 06:47:39 -0000
@@ -9,10 +9,11 @@
 #define __WINE_STDLIB_H
 #define __WINE_USE_MSVCRT
 
-#include "basetsd.h"
-#include "msvcrt/malloc.h"                /* For size_t, malloc & co */
-#include "msvcrt/search.h"                /* For bsearch and qsort */
-
+#ifndef USE_MSVCRT_PREFIX
+# include "basetsd.h"
+# include "malloc.h"                /* For size_t, malloc & co */
+# include "search.h"                /* For bsearch and qsort */
+#endif
 
 #ifndef USE_MSVCRT_PREFIX
 #define EXIT_SUCCESS        0
Index: include/msvcrt/time.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/time.h,v
retrieving revision 1.3
diff -u -r1.3 time.h
--- include/msvcrt/time.h	10 Mar 2002 00:02:38 -0000	1.3
+++ include/msvcrt/time.h	13 Dec 2002 06:47:51 -0000
@@ -21,8 +21,10 @@
 #define __WINE_TIME_H
 #define __WINE_USE_MSVCRT
 
-#include "winnt.h"
-#include "msvcrt/sys/types.h"      /* For time_t */
+#ifndef USE_MSVCRT_PREFIX
+# include "winnt.h"
+# include "sys/types.h"      /* For time_t */
+#endif
 
 
 #ifndef MSVCRT_SIZE_T_DEFINED
Index: include/msvcrt/wchar.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/wchar.h,v
retrieving revision 1.3
diff -u -r1.3 wchar.h
--- include/msvcrt/wchar.h	22 Oct 2001 18:59:23 -0000	1.3
+++ include/msvcrt/wchar.h	13 Dec 2002 06:48:13 -0000
@@ -9,17 +9,18 @@
 #define __WINE_WCHAR_H
 #define __WINE_USE_MSVCRT
 
-#include "msvcrt/io.h"
-#include "msvcrt/locale.h"
-#include "msvcrt/process.h"
-#include "msvcrt/stdio.h"
-#include "msvcrt/stdlib.h"
-#include "msvcrt/string.h"
-#include "msvcrt/sys/stat.h"
-#include "msvcrt/sys/types.h"
-#include "msvcrt/time.h"
-#include "msvcrt/wctype.h"
-
+#ifndef USE_MSVCRT_PREFIX
+# include "io.h"
+# include "locale.h"
+# include "process.h"
+# include "stdio.h"
+# include "stdlib.h"
+# include "string.h"
+# include "sys/stat.h"
+# include "sys/types.h"
+# include "time.h"
+# include "wctype.h"
+#endif
 
 #define WCHAR_MIN 0
 #define WCHAR_MAX ((WCHAR)-1)
Index: include/msvcrt/sys/stat.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/sys/stat.h,v
retrieving revision 1.5
diff -u -r1.5 stat.h
--- include/msvcrt/sys/stat.h	31 Jul 2002 20:04:20 -0000	1.5
+++ include/msvcrt/sys/stat.h	13 Dec 2002 06:48:29 -0000
@@ -9,7 +9,9 @@
 #define __WINE_SYS_STAT_H
 #define __WINE_USE_MSVCRT
 
-#include "msvcrt/sys/types.h"
+#ifndef USE_MSVCRT_PREFIX
+# include "sys/types.h"
+#endif
 
 
 #define _S_IEXEC  0x0040
Index: include/msvcrt/sys/timeb.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/sys/timeb.h,v
retrieving revision 1.3
diff -u -r1.3 timeb.h
--- include/msvcrt/sys/timeb.h	10 Mar 2002 00:02:38 -0000	1.3
+++ include/msvcrt/sys/timeb.h	13 Dec 2002 06:48:43 -0000
@@ -21,7 +21,9 @@
 #define __WINE_SYS_TIMEB_H
 #define __WINE_USE_MSVCRT
 
-#include "msvcrt/sys/types.h"      /* For time_t */
+#ifndef USE_MSVCRT_PREFIX
+# include "sys/types.h"      /* For time_t */
+#endif
 
 
 struct _timeb
Index: include/msvcrt/sys/utime.h
===================================================================
RCS file: /var/cvs/wine/include/msvcrt/sys/utime.h,v
retrieving revision 1.3
diff -u -r1.3 utime.h
--- include/msvcrt/sys/utime.h	10 Mar 2002 00:02:38 -0000	1.3
+++ include/msvcrt/sys/utime.h	13 Dec 2002 06:49:19 -0000
@@ -21,9 +21,10 @@
 #define __WINE_SYS_UTIME_H
 #define __WINE_USE_MSVCRT
 
-#include "winnt.h"
-#include "msvcrt/sys/types.h"      /* For time_t */
-
+#ifndef USE_MSVCRT_PREFIX
+# include "winnt.h"
+# include "sys/types.h"      /* For time_t */
+#endif
 
 struct _utimbuf
 {



-- 
Dimi.




More information about the wine-patches mailing list