Alexandre Julliard wrote:
> David Elliott <[EMAIL PROTECTED]> writes:
>
> > Now that I have that figured out I'll fix all of those
> > problems and ditch the libwinemsvcrt because the way it is linking now is
> > actually exactly how I want it to link anyway without needing to do stupid
> > hacks.
>
> But the way it will link in the future is not the same as it is now,
> and is closer to what you thought it was doing now (confused yet? ;-)
>
No, not at all confused. I think what I thought it was doing is almost exactly
what it will do in the future.
>
> Basically now Winelib linking completely bypasses the spec file and
> links directly to the internal functions (the MSVCRT_* in your
> case). In the future it will link to the names as exported from the
> spec file.
>
Yup, I figured that out too after trying to see what would happen if I tried
using a function that wasn't implemented in libmsvcrt.so but was forwarded in
libwinemsvcrt.so. It then dawned on me that it was really grabbing the symbols
from libmsvcrt.so like a normal UNIX program.
>
> This doesn't mean however that you should export MSVCRT_* like you did
> in your libwinemsvcrt; it means that the Winelib app should be
> compiled perfectly normally, using standard C functions, and all the
> magic will happen at link time. So once the new mechanism is in place,
> you should no longer need any #define xxx MSVCRT_xxx, or any MSVCRT_xxx
> prototype in the header files.
>
Well for now it seems like this is the best way to do things (which you seem to
agree with). However, I don't really want to have to change a bunch of headers
when winebuild is fixed, and I doubt that you do either, so I propose the
following:
#define MSVCRT_SYMBOL(s) MSVCRT_##s
PVOID __cdecl MSVCRT_SYMBOL(malloc) (MSVCRT_size_t size);
I think it would be reasonable to keep naming the structures with the
MSVCRT_ prefix and using a bunch of typedefs to get rid of the prefix when
compiling a winelib program. Not doing so would make the headers get
REALLY messy with MSVCRT_SYMBOL all over the damn place.
Eventually when the MSVCRT_ prefix is no longer needed it can easily be
redefined. However, when compiling the MSVCRT source itself (which #include's
these header files with #include "msvcrt/header.h") we still want the MSVCRT_
prefix and therefore we can use the define as shown above in this case.
I will put that #define into a seperate header and #include it from all of the
headers. Then when the change is needed I can change the one header file and
it'll be good to go. I think I could probably put that in windef.h as I think
most of the headers are including that anyway.
The only other thing that would be needed is to remove all of the #define magic
for the functions, which will be a very simple task, of course I could always
put these in an #ifndef FINALLY_FIXED_WINEBUILD or something. Actually,
I could do that anyway for clarity whether or not it ever got used it would at
least mark which lines to remove.
Does this sound reasonable to you? I have actually thought of several
different ways of tackling this problem, but this seems to be the easiest to me
and I don't want to bother you and others with 20 different ways to do
something when this appears to be the best way to do it.
----------------------------------------------------------------------
Okay, now onto what I actually have done so far. Attached are the new versions
of things (same filenames as before). I now simply have a libmsvcrt and a
winelib program to test it. It is against the now current CVS.
As before you will need to run autoconf and tools/make_debug unless you want to
be lazy and attempt to apply the lazy patch (which is really only included
because it was part of the cvs diff anyway). The tar should be extracted into
the toplevel sourcedir as before.
In the programs/msvcrttest/Makefile.in I have hardcoded the path to my
compiler's include files (like stdarg.h).
One way I have come up with to find your compilers include directory looks like
this:
echo "#include <stdarg.h>" | cpp -M | sed 's/^-: *\([^ ]*\)\/stdarg.h.*/\1/'
That actually works on my system, but I am not sure how portable that is or
maybe there is a better way to do things other than using -nostdinc on the
compiler's commandline.
Right now I am of the opinion that in a winelib program things like stdarg.h
should work with the compiler's conventions and not MSes. Therefore I am not
including a stdarg.h because the winelib program should use the compiler's
include file. This is especially true if the program implements and calls
varargs functions within itself. It *MUST* use the compilers definition to
work right.
Of course, all this is a non-issue for most winelib developers since GNU C on
ix86 is binary compatible with MS AFAIK.
I need a bit of input on how to deal with this. vprintf and friends comes to
mind as a potentially major problem. Right now I think the best thing to do is
to put some FIXME's in the code to at least mark the places where there could
be porting problems.
Anyway, this version should be a lot better than the last, and after
I incorporate some of the changes from the first part of this mail (assuming
that's how it should be done) it should be ready to go into CVS. Actually, I'd
say it wouldn't hurt to put it in CVS now and I can then just immediately send
in a diff to the header files assuming no-one finds anything else wrong with
it.
Pay no attention to printf stuff in programs/msvcrttest/msvcrttest_main.c. It
was part of what I was doing to figure out how the linking worked, and then
I figured I'd just leave it in there.
-Dave
? dlls/msvcrt
? include/msvcrt
? programs/msvcrttest
Index: Make.rules.in
===================================================================
RCS file: /home/wine/wine/Make.rules.in,v
retrieving revision 1.69
diff -u -r1.69 Make.rules.in
--- Make.rules.in 2000/10/31 00:20:51 1.69
+++ Make.rules.in 2000/11/02 07:24:42
@@ -121,6 +121,7 @@
msacm.drv \
msacm32 \
msnet32 \
+ msvcrt \
msvfw32 \
odbc32 \
ole32 \
Index: configure.in
===================================================================
RCS file: /home/wine/wine/configure.in,v
retrieving revision 1.155
diff -u -r1.155 configure.in
--- configure.in 2000/10/23 21:32:05 1.155
+++ configure.in 2000/11/02 07:24:58
@@ -1065,6 +1065,7 @@
dlls/mpr/Makefile
dlls/msacm/Makefile
dlls/msnet32/Makefile
+dlls/msvcrt/Makefile
dlls/msvideo/Makefile
dlls/ntdll/Makefile
dlls/odbc32/Makefile
@@ -1135,6 +1136,7 @@
programs/clock/Makefile
programs/cmdlgtst/Makefile
programs/control/Makefile
+programs/msvcrttest/Makefile
programs/notepad/Makefile
programs/osversioncheck/Makefile
programs/progman/Makefile
Index: dlls/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/Makefile.in,v
retrieving revision 1.71
diff -u -r1.71 Makefile.in
--- dlls/Makefile.in 2000/10/31 00:20:51 1.71
+++ dlls/Makefile.in 2000/11/02 07:24:59
@@ -32,6 +32,7 @@
mpr/libmpr.@LIBEXT@ \
msacm/libmsacm32.@LIBEXT@ \
msnet32/libmsnet32.@LIBEXT@ \
+ msvcrt/libmsvcrt.@LIBEXT@ \
msvideo/libmsvfw32.@LIBEXT@ \
ntdll/libntdll.@LIBEXT@ \
odbc32/libodbc32.@LIBEXT@ \
@@ -141,6 +142,7 @@
mpr \
msacm \
msnet32 \
+ msvcrt \
msvideo \
ntdll \
odbc32 \
@@ -268,6 +270,9 @@
libmsnet32.@LIBEXT@: msnet32/libmsnet32.@LIBEXT@
$(RM) $@ && $(LN_S) msnet32/libmsnet32.@LIBEXT@ $@
+libmsvcrt.@LIBEXT@: msvcrt/libmsvcrt.@LIBEXT@
+ $(RM) $@ && $(LN_S) msvcrt/libmsvcrt.@LIBEXT@ $@
+
libmsvfw32.@LIBEXT@ libmsvideo.@LIBEXT@: msvideo/libmsvfw32.@LIBEXT@
$(RM) $@ && $(LN_S) msvideo/libmsvfw32.@LIBEXT@ $@
@@ -396,6 +401,7 @@
lzexpand/liblz32.so: libkernel32.so
mpr/libmpr.so: libkernel32.so
msacm/libmsacm32.so: libwinmm.so libuser32.so libkernel32.so
+msvcrt/libmsvcrt.so: libkernel32.so libntdll.so
msnet32/libmsnet32.so: libntdll.so
msvideo/libmsvfw32.so: libwinmm.so libuser32.so libgdi32.so libkernel32.so
odbc32/libodbc32.so: libntdll.so
Index: include/Makefile.in
===================================================================
RCS file: /home/wine/wine/include/Makefile.in,v
retrieving revision 1.12
diff -u -r1.12 Makefile.in
--- include/Makefile.in 2000/10/13 23:16:46 1.12
+++ include/Makefile.in 2000/11/02 07:25:03
@@ -38,6 +38,12 @@
mmreg.h \
mmsystem.h \
msacm.h \
+ msvcrt/errno.h \
+ msvcrt/math.h \
+ msvcrt/process.h \
+ msvcrt/stdio.h \
+ msvcrt/stdlib.h \
+ msvcrt/string.h \
ntsecapi.h \
oaidl.h \
objbase.h \
@@ -138,12 +144,13 @@
wtypes.h \
zmouse.h
-EXTRASUBDIRS = bitmaps wine
+EXTRASUBDIRS = bitmaps msvcrt wine
@MAKE_RULES@
install::
[ -d $(includedir) ] || $(MKDIR) $(includedir)
+ [ -d $(includedir)/msvcrt ] || $(MKDIR) $(includedir)/msvcrt
[ -d $(includedir)/wine ] || $(MKDIR) $(includedir)/wine
for f in $(INSTALLED_INCLUDES); do $(INSTALL_DATA) $(SRCDIR)/$$f
$(includedir)/$$f; done
Index: programs/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/Makefile.in,v
retrieving revision 1.10
diff -u -r1.10 Makefile.in
--- programs/Makefile.in 2000/10/31 00:22:42 1.10
+++ programs/Makefile.in 2000/11/02 07:25:05
@@ -9,6 +9,7 @@
clock \
cmdlgtst \
control \
+ msvcrttest \
notepad \
osversioncheck \
progman \
Index: configure
===================================================================
RCS file: /home/wine/wine/configure,v
retrieving revision 1.155
diff -u -r1.155 configure
--- configure 2000/10/23 21:32:05 1.155
+++ configure 2000/11/02 07:24:56
@@ -5139,7 +5139,7 @@
#include "confdefs.h"
#include <alloca.h>
int main() {
-void *p = alloca(2 * sizeof(int));
+char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
if { (eval echo configure:5146: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test
-s conftest${ac_exeext}; then
@@ -5603,7 +5603,7 @@
int main() {
/* Ultrix mips cc rejects this. */
-typedef int charset[2]; const charset x = {0,0};
+typedef int charset[2]; const charset x;
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
@@ -5678,7 +5678,7 @@
#include "confdefs.h"
int main() {
-} int $ac_kw foo() {
+} $ac_kw foo() {
; return 0; }
EOF
if { (eval echo configure:5685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; };
then
@@ -6495,6 +6495,7 @@
dlls/mpr/Makefile
dlls/msacm/Makefile
dlls/msnet32/Makefile
+dlls/msvcrt/Makefile
dlls/msvideo/Makefile
dlls/ntdll/Makefile
dlls/odbc32/Makefile
@@ -6565,6 +6566,7 @@
programs/clock/Makefile
programs/cmdlgtst/Makefile
programs/control/Makefile
+programs/msvcrttest/Makefile
programs/notepad/Makefile
programs/osversioncheck/Makefile
programs/progman/Makefile
@@ -6728,6 +6730,7 @@
dlls/mpr/Makefile
dlls/msacm/Makefile
dlls/msnet32/Makefile
+dlls/msvcrt/Makefile
dlls/msvideo/Makefile
dlls/ntdll/Makefile
dlls/odbc32/Makefile
@@ -6798,6 +6801,7 @@
programs/clock/Makefile
programs/cmdlgtst/Makefile
programs/control/Makefile
+programs/msvcrttest/Makefile
programs/notepad/Makefile
programs/osversioncheck/Makefile
programs/progman/Makefile
Index: include/debugdefs.h
===================================================================
RCS file: /home/wine/wine/include/debugdefs.h,v
retrieving revision 1.39
diff -u -r1.39 debugdefs.h
--- include/debugdefs.h 2000/07/08 18:27:03 1.39
+++ include/debugdefs.h 2000/11/02 07:25:03
@@ -98,6 +98,7 @@
char dbch_mpr[] = "\003mpr";
char dbch_msacm[] = "\003msacm";
char dbch_msg[] = "\003msg";
+char dbch_msvcrt[] = "\003msvcrt";
char dbch_msvideo[] = "\003msvideo";
char dbch_nativefont[] = "\003nativefont";
char dbch_nonclient[] = "\003nonclient";
@@ -173,7 +174,7 @@
char dbch_x11[] = "\003x11";
char dbch_x11drv[] = "\003x11drv";
-#define DEBUG_CHANNEL_COUNT 166
+#define DEBUG_CHANNEL_COUNT 167
static char * const debug_channels[DEBUG_CHANNEL_COUNT] = {
dbch_accel,
@@ -268,6 +269,7 @@
dbch_mpr,
dbch_msacm,
dbch_msg,
+ dbch_msvcrt,
dbch_msvideo,
dbch_nativefont,
dbch_nonclient,
msvcrt-dfe-20001102.tar.gz