diff --git a/ChangeLog b/ChangeLog index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 67a39a2b1..9d57690ef 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,22 @@ +1999-04-24 Tor Lillqvist + + Support added for building using a GNU toolchain on Win32, + i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). + + * README.win32: Updated. + * build-dll makefile.cygwin tests/makefile.cygwin: New files. + * glib.h glib.def glibconfig.h.win32: Slight updates. + * gmain.c: No need to include and on Win32. + * gmain.c gutils.c testglib.c tests/string-test.c: Test for + NATIVE_WIN32, not _MSC_VER. + * gmutex.c: Must declare g_thread_functions_for_glib_use as + exported (using the GUTILS_C_VAR macro). + * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. + * gmodule/gmoduleconf.h.win32: Need underscore with gcc. + * gthread/gthread.c: With gcc on Win32, must use memcpy to assign + value of g_thread_functions_for_glib_use (?). + * makefile.msc tests/makefile.msc: Cosmetics. + Fri Apr 23 14:29:25 BST 1999 Tony Gale * glib.h: Fix typo in g_string_ncasecmp macro (by me). diff --git a/README.win32 b/README.win32 index 212163c1b..178c0737a 100644 --- a/README.win32 +++ b/README.win32 @@ -5,32 +5,35 @@ Win32 API only, and not any POSIX emulation layer except that provided by the Microsoft runtime C library. Additionally, a pthreads emulation library is used. -As for now, to build GLib on Win32, you need the Microsoft compiler -and tools. Both the compiler from MSVC 5.0 and from MSVC 6.0 have been -used successfully. +To build GLib on Win32, you can use either the Microsoft compiler and +tools, or egcs-1.1.2 running under cygwin-b20.1. Both the compiler +from MSVC 5.0 and from MSVC 6.0 have been used successfully. If you +build with egcs, note that the produced executables and DLLs do *not* +require the cygwin dll ("mingw32"). That's the whole point of this +porting effort, more or less. + +The egcs support was added quite recently, but seems to work in all +respects. Debugging with gdk works. Before building you must get the pthreads library for Windows from http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32 -snapshot from 1999-03-16 is mostly OK. Edit the location of the -pthreads library and include files in makefile.msc. Also edit the BIN -definition in makefile.msc. +snapshot from 1999-04-07 is the one that should be used. Edit the +location of the pthreads library and include files in +makefile.msc. -Build with `nmake -f makefile.msc`. Install with `nmake -f -makefile.msc install`. +If using the Microsoft toolchain, build with `nmake -f +makefile.msc`. Install with `nmake -f makefile.msc install`. +If using egcs, build using `make -f makefile.cygwin`. To test the GLib functions, go to the tests subdirectory and enter `nmake -f makefile.msc check`. -Support for building using the cygwin tools (without depending on the -cygwin runtime, i.e. "mingw32"), and maybe LCC-Win32 might be added -later. When using the cygwin tools *with* the cygwin runtime the -normal Unix configuration method should work as if on Unix (knock on -wood). +If you would want to use the cygwin tools to generate executables that +*do* usethe cygwin runtime the normal Unix configuration method should +work as if on Unix (knock on wood). With a little work, it might be possible to use the ./configure -mechanism also with a "mingw32" configuration. I.e. building GLib for -Win32 would use the cygwin tools (and runtime), but the produced -libraries would not depend on the cygwin runtime being present. +mechanism also with a "mingw32" configuration. The following preprocessor macros are used for conditional compilation related to Win32: @@ -42,17 +45,20 @@ related to Win32: - NATIVE_WIN32 is defined when compiling for Win32, *and* without any POSIX emulation, other that to the extent provided by the - (Microsoft) C library, or the pthreads-win32 library. For instance, - pathnames use the native Windows syntax. + bundled Microsoft C library and the pthreads-win32 library. For + instance, pathnames are in the native Windows syntax. -- _MSC_VER is defined when using the Microsoft compiler. +The Win32 port uses the combination with both of those on. -Currently the Win32 port uses the combination with all three of those -on, but eventually "gcc -mno-cygwin" will be supported also, and in -that case _MSC_VER wouldn't be defined. +Additionally, there are the compiler-specific macros: +- _MSC_VER is defined when using the Microsoft compiler +- __GNUC__ is defined when using GCC (i.e. egcs) -Some of the usage of these macros is probably a bit mixed up, and will -have to be straightened out when actually trying other combinations. +Some of the usage of these macros was a bit mixed up, and had to be +straightened out when adding the gcc support. In particular, I used to +check for _MSC_VER in some places where I really wanted to check for +the Microsoft C library, and those checks has now been changed to +NATIVE_WIN32. The pthreads for Win32 package that the thread support uses isn't quite ready yet, and thus threads really should not be relied upon. diff --git a/build-dll b/build-dll new file mode 100644 index 000000000..a02d644b8 --- /dev/null +++ b/build-dll @@ -0,0 +1,33 @@ +#!/bin/sh + +# Temporary hack until building dlls with gcc -mno-cygwin is easier + +LD=ld +DLLTOOL=dlltool +AS=as + +library=$1; shift +version=$1; shift; +def=$1; shift +ldargs="$*" + +defswitch="" +[ -n "$def" -a "$def" != '-' ] && defswitch="--def $def" + +libname=$library +[ $version != '-' ] && libname=$library-$version +dllfile=$libname.dll + +for F in $ldargs; do + case $F in + *.o) objs="$objs $F";; + esac +done + +$LD -s --base-file $library.base --dll -o $dllfile $ldargs -e _DllMain@12 -lmingw32 +$DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs +$LD -s --base-file $library.base $library.exp --dll -o $dllfile $ldargs -e _DllMain@12 -lmingw32 +$DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs +$LD $library.exp --dll -o $dllfile $ldargs -e _DllMain@12 -lmingw32 +$DLLTOOL --as=$AS --dllname $dllfile $defswitch --output-lib lib$libname.a $objs +rm $library.base $library.exp diff --git a/glib.def b/glib.def index 833827b7f..03d196207 100644 --- a/glib.def +++ b/glib.def @@ -56,7 +56,6 @@ EXPORTS g_date_is_last_of_month g_date_is_leap_year g_date_julian - g_date_julian g_date_monday_week_of_year g_date_monday_weeks_in_year g_date_new @@ -377,9 +376,13 @@ EXPORTS g_string_new g_string_prepend g_string_prepend_c + g_string_readline + g_string_readline_buffered g_string_sized_new g_string_sprintf g_string_sprintfa + g_string_tokenise + g_string_tokenise_free g_string_truncate g_string_up g_strjoinv diff --git a/glib.h b/glib.h index da110059a..ae8084520 100644 --- a/glib.h +++ b/glib.h @@ -2750,8 +2750,10 @@ GIOChannel *g_io_channel_win32_new_stream_socket (int socket); */ #ifdef NATIVE_WIN32 # define MAXPATHLEN 1024 -# ifdef _MSC_VER + +#ifdef _MSC_VER typedef int pid_t; +#endif /* These POSIXish functions are available in the Microsoft C library * prefixed with underscore (which of course technically speaking is @@ -2768,6 +2770,9 @@ typedef int pid_t; # define getcwd _getcwd # define getpid _getpid # define access _access +#ifdef __GNUC__ +# define stat _stat +#endif # define open _open # define read _read # define write _write @@ -2802,7 +2807,6 @@ DIR* gwin_opendir (const gchar *dirname); struct dirent* gwin_readdir (DIR *dir); void gwin_rewinddir (DIR *dir); gint gwin_closedir (DIR *dir); -# endif /* _MSC_VER */ #endif /* NATIVE_WIN32 */ diff --git a/glib/glib.def b/glib/glib.def index 833827b7f..03d196207 100644 --- a/glib/glib.def +++ b/glib/glib.def @@ -56,7 +56,6 @@ EXPORTS g_date_is_last_of_month g_date_is_leap_year g_date_julian - g_date_julian g_date_monday_week_of_year g_date_monday_weeks_in_year g_date_new @@ -377,9 +376,13 @@ EXPORTS g_string_new g_string_prepend g_string_prepend_c + g_string_readline + g_string_readline_buffered g_string_sized_new g_string_sprintf g_string_sprintfa + g_string_tokenise + g_string_tokenise_free g_string_truncate g_string_up g_strjoinv diff --git a/glib/glib.h b/glib/glib.h index da110059a..ae8084520 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -2750,8 +2750,10 @@ GIOChannel *g_io_channel_win32_new_stream_socket (int socket); */ #ifdef NATIVE_WIN32 # define MAXPATHLEN 1024 -# ifdef _MSC_VER + +#ifdef _MSC_VER typedef int pid_t; +#endif /* These POSIXish functions are available in the Microsoft C library * prefixed with underscore (which of course technically speaking is @@ -2768,6 +2770,9 @@ typedef int pid_t; # define getcwd _getcwd # define getpid _getpid # define access _access +#ifdef __GNUC__ +# define stat _stat +#endif # define open _open # define read _read # define write _write @@ -2802,7 +2807,6 @@ DIR* gwin_opendir (const gchar *dirname); struct dirent* gwin_readdir (DIR *dir); void gwin_rewinddir (DIR *dir); gint gwin_closedir (DIR *dir); -# endif /* _MSC_VER */ #endif /* NATIVE_WIN32 */ diff --git a/glib/gmain.c b/glib/gmain.c index 4976ceb8d..bab33b69b 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -54,11 +54,6 @@ #include #endif /* NATIVE_WIN32 */ -#ifdef _MSC_VER -#include -#include -#endif /* _MSC_VER */ - /* Types */ typedef struct _GTimeoutData GTimeoutData; @@ -576,7 +571,7 @@ g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, void g_get_current_time (GTimeVal *result) { -#ifndef _MSC_VER +#ifndef NATIVE_WIN32 struct timeval r; g_return_if_fail (result != NULL); diff --git a/glib/gutils.c b/glib/gutils.c index ff202f710..c9362cc5b 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -81,16 +81,6 @@ const guint glib_micro_version = GLIB_MICRO_VERSION; const guint glib_interface_age = GLIB_INTERFACE_AGE; const guint glib_binary_age = GLIB_BINARY_AGE; -#if defined (NATIVE_WIN32) && defined (__LCC__) -int __stdcall -LibMain (void *hinstDll, - unsigned long dwReason, - void *reserved) -{ - return 1; -} -#endif /* NATIVE_WIN32 && __LCC__ */ - void g_atexit (GVoidFunc func) { @@ -736,7 +726,6 @@ g_iochannel_wakeup_peer (GIOChannel *channel) #endif /* Old IO Channels */ #ifdef NATIVE_WIN32 -#ifdef _MSC_VER int gwin_ftruncate (gint fd, @@ -898,6 +887,4 @@ gwin_closedir (DIR *dir) return 0; } -#endif /* _MSC_VER */ - #endif /* NATIVE_WIN32 */ diff --git a/glibconfig.h.win32 b/glibconfig.h.win32 index 23334f03c..97f3ff9d5 100644 --- a/glibconfig.h.win32 +++ b/glibconfig.h.win32 @@ -1,5 +1,5 @@ /* glibconfig.h.win32 */ -/* Handcrafted for Microsoft C. */ +/* Handcrafted for Microsoft C and gcc -mno-cygwin ("mingw32"). */ #ifndef GLIBCONFIG_H #define GLIBCONFIG_H @@ -65,11 +65,22 @@ typedef unsigned int guint32; #define G_HAVE_GINT64 1 +/* These are compiler specific */ +#ifdef _MSC_VER typedef __int64 gint64; typedef unsigned __int64 guint64; +#define G_GINT64_CONSTANT(val) (val##i64) +#elif __GNUC__ +typedef long long gint64; +typedef unsigned long long guint64; +#define G_GINT64_CONSTANT(val) (val##LL) +#endif + +/* These depend on the C library. Using this file means the we + * use the (bundled) Microsoft msvcrt.dll. + */ #define G_GINT64_FORMAT "I64i" #define G_GUINT64_FORMAT "I64u" -#define G_GINT64_CONSTANT(val) (val##i64) #define GPOINTER_TO_INT(p) ((gint)(p)) #define GPOINTER_TO_UINT(p) ((guint)(p)) @@ -82,7 +93,9 @@ typedef unsigned __int64 guint64; #define g_memmove(d,s,n) G_STMT_START { memmove ((d), (s), (n)); } G_STMT_END #define G_HAVE_ALLOCA 1 +#ifdef _MSC_VER #define alloca _alloca +#endif #define GLIB_MAJOR_VERSION 1 #define GLIB_MINOR_VERSION 3 @@ -106,7 +119,7 @@ typedef unsigned __int64 guint64; * printf ("sizeof (pthread_mutex_t) = %d\n", sizeof (pthread_mutex_t)); * printf ("PTHREAD_MUTEX_INITIALIZER = "); * for (i = 0; i < sizeof (pthread_mutex_t); i++) - * printf ("%u, ", (unsigned) ((char *) &m)[i]); + * printf ("%u, ", (unsigned) ((unsigned char *) &m)[i]); * printf ("\n"); * exit(0); * } @@ -119,7 +132,7 @@ struct _GStaticMutex struct _GMutex *runtime_mutex; union { /* The size of the pad array should be sizeof (pthread_mutext_t) */ - /* This value corresponds to the 1999-03-16 version of pthreads-win32 */ + /* This value corresponds to the 1999-04-07 version of pthreads-win32 */ char pad[4]; double dummy_double; void *dummy_pointer; @@ -127,7 +140,7 @@ struct _GStaticMutex } aligned_pad_u; }; /* This should be NULL followed by the bytes in PTHREAD_MUTEX_INITIALIZER */ -#define G_STATIC_MUTEX_INIT { NULL, { { 1, 0, 0, 0 } } } +#define G_STATIC_MUTEX_INIT { NULL, { { 255, 255, 255, 255 } } } #define g_static_mutex_get_mutex(mutex) \ (g_thread_use_default_impl ? ((GMutex*) &((mutex)->aligned_pad_u)) : \ g_static_mutex_get_mutex_impl (&((mutex)->runtime_mutex))) @@ -172,7 +185,7 @@ struct _GStaticMutex /* Define if this is Win32, possibly using the Cygwin emulation layer. */ #define WIN32 1 -/* Define if this is Win32 without Cygwin. */ +/* Define if this is Win32 using the Microsoft C runtime. */ #define NATIVE_WIN32 1 #ifdef __cplusplus diff --git a/gmain.c b/gmain.c index 4976ceb8d..bab33b69b 100644 --- a/gmain.c +++ b/gmain.c @@ -54,11 +54,6 @@ #include #endif /* NATIVE_WIN32 */ -#ifdef _MSC_VER -#include -#include -#endif /* _MSC_VER */ - /* Types */ typedef struct _GTimeoutData GTimeoutData; @@ -576,7 +571,7 @@ g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, void g_get_current_time (GTimeVal *result) { -#ifndef _MSC_VER +#ifndef NATIVE_WIN32 struct timeval r; g_return_if_fail (result != NULL); diff --git a/gmodule/libgplugin_a.c b/gmodule/libgplugin_a.c index 91b928d0d..d6f5bb514 100644 --- a/gmodule/libgplugin_a.c +++ b/gmodule/libgplugin_a.c @@ -27,16 +27,6 @@ #include #include -#if defined (NATIVE_WIN32) && defined (__LCC__) -int __stdcall -LibMain(void *hinstDll, - unsigned long dwReason, - void *reserved) -{ - return 1; -} -#endif /* NATIVE_WIN32 && __LCC__ */ - G_MODULE_EXPORT void gplugin_a_func (void) { diff --git a/gmodule/libgplugin_b.c b/gmodule/libgplugin_b.c index 109e04853..be2795b66 100644 --- a/gmodule/libgplugin_b.c +++ b/gmodule/libgplugin_b.c @@ -26,16 +26,6 @@ #include -#if defined (NATIVE_WIN32) && defined (__LCC__) -int __stdcall -LibMain(void *hinstDll, - unsigned long dwReason, - void *reserved) -{ - return 1; -} -#endif /* NATIVE_WIN32 && __LCC__ */ - G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module) { diff --git a/gmutex.c b/gmutex.c index a6e7934f5..d2fe57ae6 100644 --- a/gmutex.c +++ b/gmutex.c @@ -50,7 +50,7 @@ static void g_thread_fail (void); gboolean g_thread_use_default_impl = TRUE; gboolean g_threads_got_initialized = FALSE; -GThreadFunctions g_thread_functions_for_glib_use = { +GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use = { (GMutex*(*)())g_thread_fail, /* mutex_new */ NULL, /* mutex_lock */ NULL, /* mutex_trylock */ diff --git a/gthread/gthread.c b/gthread/gthread.c index f7d76bed8..57b75aa19 100644 --- a/gthread/gthread.c +++ b/gthread/gthread.c @@ -64,8 +64,11 @@ g_thread_init (GThreadFunctions* init) else g_thread_use_default_impl = FALSE; +#if defined (WIN32) && defined (__GNUC__) + memcpy(&g_thread_functions_for_glib_use, init, sizeof (*init)); +#else g_thread_functions_for_glib_use = *init; - +#endif /* It is important, that g_threads_got_initialized is not set before the * thread initialization functions of the different modules are called */ diff --git a/gutils.c b/gutils.c index ff202f710..c9362cc5b 100644 --- a/gutils.c +++ b/gutils.c @@ -81,16 +81,6 @@ const guint glib_micro_version = GLIB_MICRO_VERSION; const guint glib_interface_age = GLIB_INTERFACE_AGE; const guint glib_binary_age = GLIB_BINARY_AGE; -#if defined (NATIVE_WIN32) && defined (__LCC__) -int __stdcall -LibMain (void *hinstDll, - unsigned long dwReason, - void *reserved) -{ - return 1; -} -#endif /* NATIVE_WIN32 && __LCC__ */ - void g_atexit (GVoidFunc func) { @@ -736,7 +726,6 @@ g_iochannel_wakeup_peer (GIOChannel *channel) #endif /* Old IO Channels */ #ifdef NATIVE_WIN32 -#ifdef _MSC_VER int gwin_ftruncate (gint fd, @@ -898,6 +887,4 @@ gwin_closedir (DIR *dir) return 0; } -#endif /* _MSC_VER */ - #endif /* NATIVE_WIN32 */ diff --git a/makefile.cygwin b/makefile.cygwin new file mode 100644 index 000000000..ec312b138 --- /dev/null +++ b/makefile.cygwin @@ -0,0 +1,169 @@ +## Makefile for building the GLib, gmodule and gthread DLLs with +## egcs on cygwin. +## Use: make -f makefile.cygwin install + +# Change this to wherever you want to install the DLLs. This directory +# should be in your PATH. +BIN = /bin + +# This is the location of pthreads for Win32, +# see http://sourceware.cygnus.com/pthreads-win32/ +PTHREADS = ../pthreads-snap-1999-04-07 +PTHREAD_LIB = -L$(PTHREADS) -lpthread +PTHREAD_INC = -I $(PTHREADS) + +################################################################ + +# Nothing much configurable below + +CC = gcc -mno-cygwin -mpentium + +CP = cp +LD = ld +DLLTOOL = dlltool +INSTALL = install + +GLIB_VER = 1.3 + +CFLAGS = -g -O2 -I. -DHAVE_CONFIG_H + +all : \ + glibconfig.h \ + config.h \ + glib-$(GLIB_VER).dll \ + gthread-$(GLIB_VER).dll \ + gmodule/gmoduleconf.h \ + gmodule-$(GLIB_VER).dll \ + testglib.exe \ + testgmodule.exe \ + testgdate.exe \ + testgdateparser.exe \ + testgthread.exe + +install : all + $(INSTALL) glib-$(GLIB_VER).dll $(BIN) + $(INSTALL) gmodule-$(GLIB_VER).dll $(BIN) + $(INSTALL) gthread-$(GLIB_VER).dll $(BIN) + +glib_OBJECTS = \ + garray.o \ + gcache.o \ + gcompletion.o \ + gdataset.o \ + gdate.o \ + gerror.o \ + ghook.o \ + ghash.o \ + giochannel.o \ + giowin32.o \ + glist.o \ + gmain.o \ + gmem.o \ + gmessages.o \ + gmutex.o \ + gnode.o \ + gprimes.o \ + gqueue.o \ + grand.o \ + gslist.o \ + gstack.o \ + gtimer.o \ + gtree.o \ + grel.o \ + gstring.o \ + gstrfuncs.o \ + gscanner.o \ + gutils.o + +glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def + ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -lmsvcrt -lkernel32 -luser32 -ladvapi32 -lwsock32 + +glibconfig.h: glibconfig.h.win32 + $(CP) glibconfig.h.win32 glibconfig.h + +config.h: config.h.win32 + $(CP) config.h.win32 config.h + +.c.o : + $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< + +gmodule_OBJECTS = \ + gmodule.o + +gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) gmodule/gmodule.def + ./build-dll gmodule $(GLIB_VER) gmodule/gmodule.def $(gmodule_OBJECTS) -L. -lglib-$(GLIB_VER) -lmsvcrt -lkernel32 -luser32 -ladvapi32 -lwsock32 + +gmodule.o : gmodule/gmodule.c gmodule/gmodule-win32.c + $(CC) $(CFLAGS) -Igmodule -c -DG_LOG_DOMAIN=g_log_domain_gmodule gmodule/gmodule.c + +gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32 + $(CP) gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h + +gthread_OBJECTS = \ + gthread.o + +gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) glib-$(GLIB_VER).dll gthread/gthread.def + ./build-dll gthread $(GLIB_VER) gthread/gthread.def $(gthread_OBJECTS) -L. -lglib-$(GLIB_VER) $(PTHREAD_LIB) -lmsvcrt -lkernel32 -luser32 -ladvapi32 -lwsock32 + +gthread.o : gthread/gthread.c gthread/gthread-posix.c + $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread.c + +testglib.exe : glib-$(GLIB_VER).dll testglib.o + $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) -lmsvcrt $(LDFLAGS) + +testglib.o : testglib.c + $(CC) -c $(CFLAGS) testglib.c + +testgdate.exe : glib-$(GLIB_VER).dll testgdate.o + $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) -lmsvcrt $(LDFLAGS) + +testgdate.o : testgdate.c + $(CC) -c $(CFLAGS) testgdate.c + +testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o + $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) -lmsvcrt $(LDFLAGS) + +testgdateparser.o : testgdateparser.c + $(CC) -c $(CFLAGS) testgdateparser.c + +testgmodule.exe : glib-$(GLIB_VER).dll gmodule-$(GLIB_VER).dll testgmodule.o libgplugin_a.dll libgplugin_b.dll +# Wow, do we really have to do it like this to get some symbols +# exported from a .exe? Apparently yes. Does the __declspec(dllexport) +# actually do anything in egcs-1.1.2? + $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt $(LDFLAGS) + $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o + $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt $(LDFLAGS) + $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o + $(CC) $(CFLAGS) -Wl,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt $(LDFLAGS) + +testgmodule.o : gmodule/testgmodule.c + $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c + +libgplugin_a.dll : libgplugin_a.o + ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt + +libgplugin_a.o : gmodule/libgplugin_a.c + $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c + +libgplugin_b.dll : libgplugin_b.o + ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt + +libgplugin_b.o : gmodule/libgplugin_b.c + $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c + +testgthread.exe : glib-$(GLIB_VER).dll gthread-$(GLIB_VER).dll testgthread.o + $(CC) $(CFLAGS) -o testgthread.exe testgthread.o -L. -lglib-$(GLIB_VER) -lgthread-$(GLIB_VER) $(PTHREAD_LIB) $(LDFLAGS) + +testgthread.o : gthread/testgthread.c + $(CC) $(CFLAGS) $(PTHREAD_INC) -c gthread/testgthread.c + +clean: + -rm config.h + -rm glibconfig.h + -rm gmodule/gmoduleconf.h + -rm *.exe + -rm *.o + -rm *.dll + -rm *.a + -rm *.base + -rm *.exp diff --git a/makefile.msc b/makefile.msc index 4edac218d..885bd80c8 100644 --- a/makefile.msc +++ b/makefile.msc @@ -7,8 +7,9 @@ BIN = C:\bin # This is the location of pthreads for Win32, # see http://sourceware.cygnus.com/pthreads-win32/ -PTHREAD_LIB = ..\lib\pthread.lib -PTHREAD_INC = ..\include +PTHREADS = ..\pthreads-snap-1999-04-07 +PTHREAD_LIB = $(PTHREADS)\pthread.lib +PTHREAD_INC = -I $(PTHREADS) ################################################################ @@ -18,7 +19,7 @@ PTHREAD_INC = ..\include CC = cl -G5 -GF -Ox -W3 -MD -nologo # No general LDFLAGS needes -LDFLAGS = /link +LDFLAGS = /link INSTALL = copy GLIB_VER = 1.3 @@ -88,7 +89,7 @@ config.h: config.h.win32 gmodule_OBJECTS = \ gmodule.obj -gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) +gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) gmodule\gmodule.def $(CC) $(CFLAGS) -LD -Fegmodule-$(GLIB_VER).dll $(gmodule_OBJECTS) glib-$(GLIB_VER).lib $(LDFLAGS) /def:gmodule\gmodule.def gmodule.obj : gmodule\gmodule.c gmodule\gmodule-win32.c @@ -100,11 +101,11 @@ gmodule\gmoduleconf.h: gmodule\gmoduleconf.h.win32 gthread_OBJECTS = \ gthread.obj -gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) - $(CC) $(CFLAGS) -LD -Fegthread-$(GLIB_VER).dll $(gthread_OBJECTS) glib-$(GLIB_VER).lib $(PTHREAD_LIB) glib-$(GLIB_VER).lib $(LDFLAGS) /def:gthread\gthread.def +gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) gthread\gthread.def + $(CC) $(CFLAGS) -LD -Fegthread-$(GLIB_VER).dll $(gthread_OBJECTS) glib-$(GLIB_VER).lib $(PTHREAD_LIB) $(LDFLAGS) /def:gthread\gthread.def gthread.obj : gthread\gthread.c gthread\gthread-posix.c - $(CC) $(CFLAGS) -GD -I$(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread\gthread.c + $(CC) $(CFLAGS) -GD $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread\gthread.c testglib.exe : glib-$(GLIB_VER).dll testglib.obj $(CC) $(CFLAGS) -Fetestglib.exe testglib.obj glib-$(GLIB_VER).lib $(LDFLAGS) /subsystem:console @@ -146,7 +147,7 @@ testgthread.exe : glib-$(GLIB_VER).dll gthread-$(GLIB_VER).dll testgthread.obj $(CC) $(CFLAGS) testgthread.obj glib-$(GLIB_VER).lib gthread-$(GLIB_VER).lib $(PTHREAD_LIB) $(LDFLAGS) /subsystem:console testgthread.obj : gthread\testgthread.c - $(CC) $(CFLAGS) -I$(PTHREAD_INC) -c gthread\testgthread.c + $(CC) $(CFLAGS) $(PTHREAD_INC) -c gthread\testgthread.c clean: del config.h diff --git a/testglib.c b/testglib.c index 843b49ede..54d621406 100644 --- a/testglib.c +++ b/testglib.c @@ -699,8 +699,8 @@ main (int argc, for (i = 0; i < 10000; i++) g_string_append_c (string1, 'a'+(i%26)); -#if !(defined (_MSC_VER) || defined (__LCC__)) - /* MSVC and LCC use the same run-time C library, which doesn't like +#ifndef NATIVE_WIN32 + /* MSVC, mingw32 and LCC use the same run-time C library, which doesn't like the %10000.10000f format... */ g_string_sprintf (string2, "%s|%0100d|%s|%s|%0*d|%*.*f|%10000.10000f", "this pete guy sure is a wuss, like he's the number ", diff --git a/tests/makefile.cygwin b/tests/makefile.cygwin new file mode 100644 index 000000000..62c4b290c --- /dev/null +++ b/tests/makefile.cygwin @@ -0,0 +1,50 @@ +## Makefile for building the GLib test programs with egcs on cygwin. +## Use: make -f makefile.cygwin check + +################################################################ + +# Nothing much configurable below + +# cl -? described the options +CC = gcc -mno-cygwin -mpentium + +# No general LDFLAGS needes +LDFLAGS = /link + +GLIB_VER = 1.3 + +CFLAGS = -I.. -DHAVE_CONFIG_H + +TESTS = \ + array-test.exe \ + date-test.exe \ + dirname-test.exe\ + hash-test.exe \ + list-test.exe \ + node-test.exe \ + queue-test.exe \ + rand-test.exe \ + relation-test.exe\ + slist-test.exe \ + stack-test.exe \ + string-test.exe \ + strfunc-test.exe\ + tree-test.exe \ + type-test.exe + +all : $(TESTS) + +.SUFFIXES: .c .exe + +.c.exe : + $(CC) $(CFLAGS) -c $< + $(CC) $(CFLAGS) -o $@ $< -L.. -lglib-$(GLIB_VER) -lmsvcrt + +check: all + @for P in $(TESTS) ; do echo $$P; ./$$P; done + +clean: + rm *.exe + rm *.o + rm *.dll + rm *.exp diff --git a/tests/makefile.msc b/tests/makefile.msc index 56a9210de..ff484e10e 100644 --- a/tests/makefile.msc +++ b/tests/makefile.msc @@ -1,5 +1,5 @@ ## Makefile for building the GLib test programs with Microsoft C -## Use: nmake -f makefile.msc all +## Use: nmake -f makefile.msc check ################################################################ @@ -10,7 +10,6 @@ CC = cl -G5 -GF -Ox -W3 -MD -nologo # No general LDFLAGS needes LDFLAGS = /link -INSTALL = copy GLIB_VER = 1.3 diff --git a/tests/string-test.c b/tests/string-test.c index bc5b7dbca..b2c7c1d1e 100644 --- a/tests/string-test.c +++ b/tests/string-test.c @@ -103,8 +103,8 @@ main (int argc, g_assert((strlen("hi pete!") + 10000) == string1->len); g_assert((strlen("hi pete!") + 10000) == strlen(string1->str)); -#if !(defined (_MSC_VER) || defined (__LCC__)) - /* MSVC and LCC use the same run-time C library, which doesn't like +#ifndef NATIVE_WIN32 + /* MSVC and mingw32 use the same run-time C library, which doesn't like the %10000.10000f format... */ g_string_sprintf (string2, "%s|%0100d|%s|%s|%0*d|%*.*f|%10000.10000f", "this pete guy sure is a wuss, like he's the number ", diff --git a/tests/testglib.c b/tests/testglib.c index 843b49ede..54d621406 100644 --- a/tests/testglib.c +++ b/tests/testglib.c @@ -699,8 +699,8 @@ main (int argc, for (i = 0; i < 10000; i++) g_string_append_c (string1, 'a'+(i%26)); -#if !(defined (_MSC_VER) || defined (__LCC__)) - /* MSVC and LCC use the same run-time C library, which doesn't like +#ifndef NATIVE_WIN32 + /* MSVC, mingw32 and LCC use the same run-time C library, which doesn't like the %10000.10000f format... */ g_string_sprintf (string2, "%s|%0100d|%s|%s|%0*d|%*.*f|%10000.10000f", "this pete guy sure is a wuss, like he's the number ",