[xml] Windows Threads Revisited



Hi all,

Inspired by a recent mailing, I have revisited the thread code in libxml. I
would like to modify few things. All that is relevant only to the Windows
platform.

The configuration script for the MSVC build will now allow you to specify
the kind of thread code which is to be used, if any. There is a parameter
named 'threads' which previously could have the value of either 'yes or
'no'. Now it can have the following values:

  no      No thread-safety code compiled.
  ctls    Use Windows Threads with compiler-supported TLS
  native  Use Windows Threads without compiler-suported TLS
  posix   Use pthreads library.

The test-program testThreads or testThreadsWin32 will be compiled
accordingly to what is chosen.

The Windows Threads versions both work. The pthreads version compiles, but
the pthreads library trashes on me soon after I run the test program. I'll
investigate this later.

Making all that compiler-independent, I removed compiler-specific macros and
used custom ones, which can be defined or undefined at the compilation time.
The details are handled automagically with the MSVC build. The following is
a rough explanation for those who use different compilers.

* If macro HAVE_PTHREAD_H is defined, pthreads will be used. In order to use
this, you will need a pthreads library for Windows. The one I used can be
found at:
http://sources.redhat.com/pthreads-win32/

* If HAVE_WIN32_THREADS is defined, then the Windows Threads will be used.
This macro is therefore mutually exclusive with the previous one. If
HAVE_COMPILER_TLS is also defined, then the compiler-supported TLS will be
used. If it is not defined, then the API-based TLS will be used. So far,
Microsoft and Borland are the only compilers with this TLS feature.

Of course, none of these has any effect if LIBXML_THREAD_ENABLED in
xmlversion.h is not defined. That remains the main on/off switch.

Borland users are affected. They will have to define HAVE_COMPILER_TLS
through their project files to get the same behaviour they had so far, they
don't get the compiler-supported TLS by default. The code will by default
behave the same as before for others.

Any objections? Questions?

Ciao
Igor





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]