GNOME Bugzilla – Bug 588352
Threading mess when building in MSys
Last modified: 2009-08-18 21:39:08 UTC
It is not possible to force a particular type of threading support (pthreads, win32threads etc) in configure script, and configure script does not think threading support to be mutually exclusive. That is, in MSys it would pick pthread.h and define HAVE_PTHREAD_H, and (seeing that mingw is being used) defines HAVE_WIN32_THREADS too (but not in config.h, though this is irrelevent). As a result some parts of the threads.c (such as xmlOnceInit()) will have two mutually exclusive sections of the code enabled (one for win32 threads and one for pthread). How to fix: A) Use #else in xmlOnceInit() and other places (not sure if there are more of such places) to make sure that only one section of code is enabled B) Improve configure.in to enable only one threading model Solution (A) has one implication - it requires some fixes in threads.c, such as not assigning 0 to tok->tid (because tid is not int, it's a struct with pthread-win32) and not comparing tid with "==" operator (have to use pthread_equal() instead). Solution (B) is better in this regard, because libxml2 supports win32 threading, so that model is the one that should be used exclusively, and it is not necessary to fix the code to accommodate for pthread-win32 quirks. Other information:
Created attachment 138265 [details] [review] Changes configure.in to enable either pthreads or win32-threads
Patch looks fine and the idea sounds correct too, so applied and commited, thanks ! Daniel
Well, patch is not so fine. Maybe ti would have been better to just remove THREAD_LIBS="-lpthread" and WITH_THREADS="1" from pthread.h check and copy them to cygwin and linux section of the case. That would not have allowed to enforce a particular threading system, but i doubt that such feature is really required (and if it is, an additional 'if test "$with_threads" = "something" ; then' condition inside a particular case would have made it available).