This is the mail archive of the
pthreads-win32@sourceware.org
mailing list for the pthreas-win32 project.
Pthreads-win32 and static linking
- From: Martin Lambers <marlam at marlam dot de>
- To: pthreads-win32 at sourceware dot org, ross dot johnson at homemail dot com dot au
- Date: Mon, 10 May 2010 21:50:37 +0200
- Subject: Pthreads-win32 and static linking
- Openpgp: id=15BC348B; url=http://www.marlam.de/key.txt
Hello!
The Mingw-cross-env project provides a MinGW cross-compiling environment
for POSIX systems. For various reasons, all included libraries are
static, including the pthreads-win32 library.
This means that all pthreads users need to call
pthread_win32_thread_attach_np() and pthread_win32_thread_detach_np() in
each thread function.
We would like to avoid patching all libraries that use pthread, and
instead change pthreads-win32: instead of using a thread main function
given to pthread_create() directly, pthreads-win32 could use an internal
wrapper that calls the thread main function and also calls the
attach/detach functions if necessary.
To avoid the pthread_win32_process_attach() function, pthreads-win32
could check on each function call whether the library was initialized,
and if not, call pthread_win32_process_attach() itself.
This would induce some overhead, but would allow us to use a large
number of existing libraries unchanged.
Before we start to work on a patch, we would like to know if this
approach has a chance to work. Do you know any technical reasons why
this might fail?
Best regards,
Martin