From be80f9a106b1560447a7312480045960e521e728 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 20 Jun 1999 22:20:43 +0000 Subject: [PATCH] Update the pthreads snapshot version we want. Advice how to hand-expand * README.win32: Update the pthreads snapshot version we want. Advice how to hand-expand the makefile.*.in files. * config.h.win32.in: Define values needed by Sebastian Wilhelmi's new thread stuff. * glib.def: Add new functions. * glibconfig.h.win32.in: Update the pthreads snapshot version. Fix typo. * gthread.c: Include config.h, guard inclusion of unistd.h. When using gcc on Win32, g_thread_functions_for_glib_use must be marked for export here, too. * gtimer.c: Implement g_usleep on native Win32 using Sleep (which only has millisecond granularity, though). * makefile.cygwin.in * makefile.msc.in: Update pthreads snapshot version. File name changes. Remove testgthread. * tests/makefile.cygwin.in * tests/makefile.msc.in: Add thread-test. Link with gthread lib. * gthread-posix.c: Guard pthread_attr_setscope call with test for _POSIX_THREAD_PRIORITY_SCHEDULING, which should be defined in a that supports that feature. --- ChangeLog | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-0 | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-10 | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-12 | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-2 | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-4 | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-6 | 27 +++++++++++++++++++++++++++ ChangeLog.pre-2-8 | 27 +++++++++++++++++++++++++++ README.win32 | 44 +++++++++++++++++++++++++++++--------------- config.h.win32.in | 5 +++++ glib.def | 15 +++++++++++++++ glib/glib.def | 15 +++++++++++++++ glib/gthread.c | 7 +++++++ glib/gtimer.c | 4 ++++ glib/makefile.msc.in | 21 +++++++-------------- glibconfig.h.win32.in | 5 +++-- gthread.c | 7 +++++++ gthread/ChangeLog | 6 ++++++ gthread/gthread-posix.c | 3 +++ gtimer.c | 4 ++++ makefile.cygwin.in | 23 ++++++++--------------- makefile.msc.in | 21 +++++++-------------- tests/makefile.cygwin.in | 3 ++- tests/makefile.msc.in | 3 ++- 24 files changed, 340 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index bcbd74c..51c3320 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index bcbd74c..51c3320 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,30 @@ +1999-06-21 Tor Lillqvist + + * README.win32: Update the pthreads snapshot version we want. + Advice how to hand-expand the makefile.*.in files. + + * config.h.win32.in: Define values needed by Sebastian Wilhelmi's + new thread stuff. + + * glib.def: Add new functions. + + * glibconfig.h.win32.in: Update the pthreads snapshot version. + Fix typo. + + * gthread.c: Include config.h, guard inclusion of unistd.h. When + using gcc on Win32, g_thread_functions_for_glib_use must be marked + for export here, too. + + * gtimer.c: Implement g_usleep on native Win32 using Sleep (which + only has millisecond granularity, though). + + * makefile.cygwin.in + * makefile.msc.in: Update pthreads snapshot version. File + name changes. Remove testgthread. + + * tests/makefile.cygwin.in + * tests/makefile.msc.in: Add thread-test. Link with gthread lib. + 1999-06-18 Jeff Garzik * tests/Makefile.am: Re-order tests in alpha order. diff --git a/README.win32 b/README.win32 index fefc509..8d83009 100644 --- a/README.win32 +++ b/README.win32 @@ -12,9 +12,9 @@ To build GLib on Win32, you can use either the Microsoft compiler and tools, or gcc. Both the compiler from MSVC 5.0 and from MSVC 6.0 have been used successfully. With gcc I mean egcs-1.1.2 (as distributed by Mumit Khan), running under cygwin-b20.1. To successfully use gcc, -follow the instructions below. I use gcc -mno-cygwin, i.e. the -produced executables (.exe and .dll files) do *not* require the cygwin -runtime library. +follow the instructions below. We want to use gcc -mno-cygwin, +i.e. produce executables (.exe and .dll files) that do *not* require +the cygwin runtime library. This is sometimes called "mingw32". To test the GLib functions, go to the tests subdirectory and enter `nmake -f makefile.msc check` or `make -f makefile.cygwin check`. @@ -27,8 +27,8 @@ haven't succeeded in that. With a little work, it might be possible to use the ./configure mechanism also with a "mingw32" configuration. -The following preprocessor macros are used for conditional compilation -related to Win32: +The following preprocessor macros are defined in glibconfig.h and used +for conditional compilation related to Win32: - WIN32 is defined when compiling for the Win32 platform, regardless if using the X11 or Win32 windowing API (in the case of GLib, this @@ -40,32 +40,46 @@ related to Win32: bundled Microsoft C library (msvcrt.dll) and the pthreads-win32 library. For instance, pathnames are in the native Windows syntax. -The Win32 port uses the combination with both of those on. +The Win32 port uses the combination with both of those on. As these +are in glibconfig.h, they are available to all source files that use +GLib (or GTk+, which uses GLib). 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 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. NATIVE_WIN32 ought to be renamed to USE_MSVCRT. +Some of the usage of these macros used to be 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. NATIVE_WIN32 ought to be renamed to +USE_MSVCRT. Pthreads library ================ Before building you must get the pthreads library for Win32 from http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32 -snapshot from 1999-04-07 is the one that should be used. Edit the +snapshot from 1999-05-30 is the one that should be used. Edit the location of the pthreads library and include files in makefile.msc or -makefile.cygwin. The ptreads distribution includes the precompiled dll +makefile.cygwin. The pthreads distribution includes the precompiled dll and import libraries both for MSVC and gcc. The pthreads for Win32 package that the thread support uses supposedly isn't quite ready yet, and thus threads stuff should not be relied upon for anything serious. +Where are the makefiles? +======================== + +If you are building from a CVS snapshot, you will not have any +makefile.msc or makefile.cygwin file. You should copy the +corresponding makefile.msc.in or makefile.cygwin.in file to that name, +and edit the line that sets GLIB_VER to the correct version number. + +This is done automatically when an official distribution package is +built. + Building with MSVC ================== @@ -85,8 +99,8 @@ C:\cygnus\cygwin-b20\H-i586-cygwin32\lib\gcc-lib\i586-cygwin32\egcs-2.91.66\spec Sorry for the illegibility of this diff, but the specs file is like that... This patch replaces -lcrtdll with -lmsvcrt, replaces crt1 with -crt2, removes -lmoldname (because that might pull in crtdll.dll), and -defines __MSVCRT__. +crt2, removes -lmoldname (because using functions from it would pull +in crtdll.dll), and defines __MSVCRT__. --- specs.ORIG Sun Apr 25 00:40:40 1999 +++ specs Sun Apr 25 00:48:04 1999 diff --git a/config.h.win32.in b/config.h.win32.in index 8dc0ff4..2a07737 100644 --- a/config.h.win32.in +++ b/config.h.win32.in @@ -60,6 +60,11 @@ #define GLIB_INTERFACE_AGE @GLIB_INTERFACE_AGE@ #define GLIB_BINARY_AGE @GLIB_BINARY_AGE@ +#define GLIB_SIZEOF_PTHREAD_T 4 +#define POSIX_MIN_PRIORITY -2 +#define POSIX_MAX_PRIORITY 2 +#define POSIX_YIELD_FUNC Sleep(0) + #define G_THREAD_SOURCE "gthread-posix.c" /* The number of bytes in a char. */ diff --git a/glib.def b/glib.def index d6220cb..cd86fd5 100644 --- a/glib.def +++ b/glib.def @@ -350,6 +350,16 @@ EXPORTS g_static_mutex_get_mutex_impl g_static_private_get g_static_private_set + g_static_rec_mutex_lock + g_static_rec_mutex_trylock + g_static_rec_mutex_unlock + g_static_rw_lock_free + g_static_rw_lock_reader_lock + g_static_rw_lock_reader_trylock + g_static_rw_lock_reader_unlock + g_static_rw_lock_writer_lock + g_static_rw_lock_writer_trylock + g_static_rw_lock_writer_unlock g_str_equal g_str_hash g_strcasecmp @@ -396,6 +406,10 @@ EXPORTS g_strsplit g_strtod g_strup + g_thread_create + g_thread_join + g_thread_self + g_thread_set_priority g_timeout_add g_timeout_add_full g_timer_destroy @@ -415,6 +429,7 @@ EXPORTS g_tree_traverse g_tuples_destroy g_tuples_index + g_usleep g_vsnprintf glib_binary_age glib_interface_age diff --git a/glib/glib.def b/glib/glib.def index d6220cb..cd86fd5 100644 --- a/glib/glib.def +++ b/glib/glib.def @@ -350,6 +350,16 @@ EXPORTS g_static_mutex_get_mutex_impl g_static_private_get g_static_private_set + g_static_rec_mutex_lock + g_static_rec_mutex_trylock + g_static_rec_mutex_unlock + g_static_rw_lock_free + g_static_rw_lock_reader_lock + g_static_rw_lock_reader_trylock + g_static_rw_lock_reader_unlock + g_static_rw_lock_writer_lock + g_static_rw_lock_writer_trylock + g_static_rw_lock_writer_unlock g_str_equal g_str_hash g_strcasecmp @@ -396,6 +406,10 @@ EXPORTS g_strsplit g_strtod g_strup + g_thread_create + g_thread_join + g_thread_self + g_thread_set_priority g_timeout_add g_timeout_add_full g_timer_destroy @@ -415,6 +429,7 @@ EXPORTS g_tree_traverse g_tuples_destroy g_tuples_index + g_usleep g_vsnprintf glib_binary_age glib_interface_age diff --git a/glib/gthread.c b/glib/gthread.c index 0aaef25..f893a97 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -32,8 +32,12 @@ * MT safe */ +#include "config.h" #include "glib.h" + +#ifdef HAVE_UNISTD_H #include +#endif typedef struct _GRealThread GRealThread; @@ -62,6 +66,9 @@ static void g_thread_fail (void); gboolean g_thread_use_default_impl = TRUE; gboolean g_threads_got_initialized = FALSE; +#if defined(NATIVE_WIN32) && defined(__GNUC__) +__declspec(dllexport) +#endif GThreadFunctions g_thread_functions_for_glib_use = { (GMutex*(*)())g_thread_fail, /* mutex_new */ NULL, /* mutex_lock */ diff --git a/glib/gtimer.c b/glib/gtimer.c index 0e61f63..f4b02c1 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -195,9 +195,13 @@ g_timer_elapsed (GTimer *timer, void g_usleep (gulong microseconds) { +#ifdef NATIVE_WIN32 + Sleep (microseconds / 1000); +#else struct timeval tv; tv.tv_sec = microseconds / G_MICROSEC; tv.tv_usec = microseconds % G_MICROSEC; select(0, NULL, NULL, NULL, &tv); +#endif } diff --git a/glib/makefile.msc.in b/glib/makefile.msc.in index 6c8febb..61b1e43 100644 --- a/glib/makefile.msc.in +++ b/glib/makefile.msc.in @@ -7,8 +7,8 @@ BIN = C:\bin # This is the location of pthreads for Win32, # see http://sourceware.cygnus.com/pthreads-win32/ -# We want the 1999-04-07 snapshot. -PTHREADS = ..\pthreads-snap-1999-04-07 +# We want the 1999-05-30 snapshot. +PTHREADS = ..\pthreads-snap-1999-05-30 PTHREAD_LIB = $(PTHREADS)\pthread.lib PTHREAD_INC = -I $(PTHREADS) @@ -42,8 +42,7 @@ all : \ testglib.exe \ testgmodule.exe \ testgdate.exe \ - testgdateparser.exe \ - testgthread.exe + testgdateparser.exe install : all $(INSTALL) glib-$(GLIB_VER).dll $(BIN) @@ -65,13 +64,13 @@ glib_OBJECTS = \ gmain.obj \ gmem.obj \ gmessages.obj \ - gmutex.obj \ gnode.obj \ gprimes.obj \ gqueue.obj \ grand.obj \ gslist.obj \ gstack.obj \ + gthread.obj \ gtimer.obj \ gtree.obj \ grel.obj \ @@ -105,13 +104,13 @@ gmodule\gmoduleconf.h: gmodule\gmoduleconf.h.win32 copy gmodule\gmoduleconf.h.win32 gmodule\gmoduleconf.h gthread_OBJECTS = \ - gthread.obj + gthread-impl.obj 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 $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread\gthread.c +gthread-impl.obj : gthread\gthread-impl.c gthread\gthread-posix.c + $(CC) $(CFLAGS) -GD $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread\gthread-impl.c testglib.exe : glib-$(GLIB_VER).dll testglib.obj $(CC) $(CFLAGS) -Fetestglib.exe testglib.obj glib-$(GLIB_VER).lib $(LDFLAGS) /subsystem:console @@ -149,12 +148,6 @@ libgplugin_b.dll : libgplugin_b.obj libgplugin_b.obj : gmodule\libgplugin_b.c $(CC) $(CFLAGS) -Igmodule -c gmodule\libgplugin_b.c -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) $(PTHREAD_INC) -c gthread\testgthread.c - clean: del config.h del glibconfig.h diff --git a/glibconfig.h.win32.in b/glibconfig.h.win32.in index a4aa9c1..a9bf191 100644 --- a/glibconfig.h.win32.in +++ b/glibconfig.h.win32.in @@ -117,6 +117,7 @@ typedef unsigned long long guint64; * int i; * pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; * printf ("sizeof (pthread_mutex_t) = %d\n", sizeof (pthread_mutex_t)); + * printf ("sizeof (pthread_t) = %d\n", sizeof (pthread_t)); * printf ("PTHREAD_MUTEX_INITIALIZER = "); * for (i = 0; i < sizeof (pthread_mutex_t); i++) * printf ("%u, ", ((unsigned char *) &m)[i]); @@ -131,8 +132,8 @@ 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-04-07 version of pthreads-win32 */ + /* The size of the pad array should be sizeof (pthread_mutex_t) */ + /* This value corresponds to the 1999-05-30 version of pthreads-win32 */ char pad[4]; double dummy_double; void *dummy_pointer; diff --git a/gthread.c b/gthread.c index 0aaef25..f893a97 100644 --- a/gthread.c +++ b/gthread.c @@ -32,8 +32,12 @@ * MT safe */ +#include "config.h" #include "glib.h" + +#ifdef HAVE_UNISTD_H #include +#endif typedef struct _GRealThread GRealThread; @@ -62,6 +66,9 @@ static void g_thread_fail (void); gboolean g_thread_use_default_impl = TRUE; gboolean g_threads_got_initialized = FALSE; +#if defined(NATIVE_WIN32) && defined(__GNUC__) +__declspec(dllexport) +#endif GThreadFunctions g_thread_functions_for_glib_use = { (GMutex*(*)())g_thread_fail, /* mutex_new */ NULL, /* mutex_lock */ diff --git a/gthread/ChangeLog b/gthread/ChangeLog index 51075f5..be3bb0f 100644 --- a/gthread/ChangeLog +++ b/gthread/ChangeLog @@ -1,3 +1,9 @@ +1999-06-21 Tor Lillqvist + + * gthread-posix.c: Guard pthread_attr_setscope call with test + for _POSIX_THREAD_PRIORITY_SCHEDULING, which should be defined + in a that supports that feature. + 1999-06-17 Sebastian Wilhelmi * gthread-posix.c, gthread-solaris.c: Added the native diff --git a/gthread/gthread-posix.c b/gthread/gthread-posix.c index e7c9462..079f05b 100644 --- a/gthread/gthread-posix.c +++ b/gthread/gthread-posix.c @@ -245,9 +245,12 @@ g_thread_create_posix_impl (GThreadFunc thread_func, posix_check_for_error (pthread_attr_setstacksize (&attr, stack_size)); #endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */ +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (bound) posix_check_for_error (pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM)); +#endif + posix_check_for_error( pthread_attr_setdetachstate( &attr, joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED ) ); diff --git a/gtimer.c b/gtimer.c index 0e61f63..f4b02c1 100644 --- a/gtimer.c +++ b/gtimer.c @@ -195,9 +195,13 @@ g_timer_elapsed (GTimer *timer, void g_usleep (gulong microseconds) { +#ifdef NATIVE_WIN32 + Sleep (microseconds / 1000); +#else struct timeval tv; tv.tv_sec = microseconds / G_MICROSEC; tv.tv_usec = microseconds % G_MICROSEC; select(0, NULL, NULL, NULL, &tv); +#endif } diff --git a/makefile.cygwin.in b/makefile.cygwin.in index 2a8761a..1012957 100644 --- a/makefile.cygwin.in +++ b/makefile.cygwin.in @@ -8,9 +8,9 @@ BIN = /bin # This is the location of pthreads for Win32, # see http://sourceware.cygnus.com/pthreads-win32/ -# We want the 1999-04-07 snapshot. -PTHREADS = ../pthreads-snap-1999-04-07 -PTHREAD_LIB = -L$(PTHREADS) -lpthread +# We want the 1999-05-30 snapshot. +PTHREADS = ../pthreads-snap-1999-05-30 +PTHREAD_LIB = -L$(PTHREADS) -lpthread32 PTHREAD_INC = -I $(PTHREADS) OPTIMIZE = -g -O @@ -40,8 +40,7 @@ all : \ testglib.exe \ testgmodule.exe \ testgdate.exe \ - testgdateparser.exe \ - testgthread.exe + testgdateparser.exe install : all $(INSTALL) glib-$(GLIB_VER).dll $(BIN) @@ -63,13 +62,13 @@ glib_OBJECTS = \ gmain.o \ gmem.o \ gmessages.o \ - gmutex.o \ gnode.o \ gprimes.o \ gqueue.o \ grand.o \ gslist.o \ gstack.o \ + gthread.o \ gtimer.o \ gtree.o \ grel.o \ @@ -103,13 +102,13 @@ gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32 $(CP) gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h gthread_OBJECTS = \ - gthread.o + gthread-impl.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) -lwsock32 -gthread.o : gthread/gthread.c gthread/gthread-posix.c - $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread.c +gthread-impl.o : gthread/gthread-impl.c gthread/gthread-posix.c + $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread-impl.c testglib.exe : glib-$(GLIB_VER).dll testglib.o $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS) @@ -154,12 +153,6 @@ libgplugin_b.dll : libgplugin_b.o 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 glibconfig.h gmodule/gmoduleconf.h -rm *.exe *.o *.dll *.a *.base *.exp diff --git a/makefile.msc.in b/makefile.msc.in index 6c8febb..61b1e43 100644 --- a/makefile.msc.in +++ b/makefile.msc.in @@ -7,8 +7,8 @@ BIN = C:\bin # This is the location of pthreads for Win32, # see http://sourceware.cygnus.com/pthreads-win32/ -# We want the 1999-04-07 snapshot. -PTHREADS = ..\pthreads-snap-1999-04-07 +# We want the 1999-05-30 snapshot. +PTHREADS = ..\pthreads-snap-1999-05-30 PTHREAD_LIB = $(PTHREADS)\pthread.lib PTHREAD_INC = -I $(PTHREADS) @@ -42,8 +42,7 @@ all : \ testglib.exe \ testgmodule.exe \ testgdate.exe \ - testgdateparser.exe \ - testgthread.exe + testgdateparser.exe install : all $(INSTALL) glib-$(GLIB_VER).dll $(BIN) @@ -65,13 +64,13 @@ glib_OBJECTS = \ gmain.obj \ gmem.obj \ gmessages.obj \ - gmutex.obj \ gnode.obj \ gprimes.obj \ gqueue.obj \ grand.obj \ gslist.obj \ gstack.obj \ + gthread.obj \ gtimer.obj \ gtree.obj \ grel.obj \ @@ -105,13 +104,13 @@ gmodule\gmoduleconf.h: gmodule\gmoduleconf.h.win32 copy gmodule\gmoduleconf.h.win32 gmodule\gmoduleconf.h gthread_OBJECTS = \ - gthread.obj + gthread-impl.obj 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 $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread\gthread.c +gthread-impl.obj : gthread\gthread-impl.c gthread\gthread-posix.c + $(CC) $(CFLAGS) -GD $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread\gthread-impl.c testglib.exe : glib-$(GLIB_VER).dll testglib.obj $(CC) $(CFLAGS) -Fetestglib.exe testglib.obj glib-$(GLIB_VER).lib $(LDFLAGS) /subsystem:console @@ -149,12 +148,6 @@ libgplugin_b.dll : libgplugin_b.obj libgplugin_b.obj : gmodule\libgplugin_b.c $(CC) $(CFLAGS) -Igmodule -c gmodule\libgplugin_b.c -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) $(PTHREAD_INC) -c gthread\testgthread.c - clean: del config.h del glibconfig.h diff --git a/tests/makefile.cygwin.in b/tests/makefile.cygwin.in index 6db6bc9..5e944a1 100644 --- a/tests/makefile.cygwin.in +++ b/tests/makefile.cygwin.in @@ -27,6 +27,7 @@ TESTS = \ stack-test.exe \ string-test.exe \ strfunc-test.exe\ + thread-test.exe \ tree-test.exe \ type-test.exe @@ -36,7 +37,7 @@ all : $(TESTS) .c.exe : $(CC) $(CFLAGS) -c $< - $(CC) $(CFLAGS) -o $@ $< -L.. -lglib-$(GLIB_VER) + $(CC) $(CFLAGS) -o $@ $< -L.. -lglib-$(GLIB_VER) -lgthread-$(GLIB_VER) check: all @for P in $(TESTS) ; do echo $$P; ./$$P; done diff --git a/tests/makefile.msc.in b/tests/makefile.msc.in index 8cbf3e3..1a91929 100644 --- a/tests/makefile.msc.in +++ b/tests/makefile.msc.in @@ -29,6 +29,7 @@ TESTS = \ stack-test.exe \ string-test.exe \ strfunc-test.exe\ + thread-test.exe \ tree-test.exe \ type-test.exe @@ -36,7 +37,7 @@ all : $(TESTS) .c.exe : $(CC) $(CFLAGS) -c $< - $(CC) $(CFLAGS) -Fe$@ $< ..\glib-$(GLIB_VER).lib $(LDFLAGS) /subsystem:console + $(CC) $(CFLAGS) -Fe$@ $< ..\glib-$(GLIB_VER).lib ..\gthread-$(GLIB_VER).lib $(LDFLAGS) /subsystem:console check: all for %p in ($(TESTS)) do %p -- 2.7.4