Possible code simplifications using gnulib's pthread modules
Two days ago, Bruno Haible announced a bunch of new modules for gnulib, which look very promising. It means, we could get rid off our own thread checking/compat code (configure.ac, lib/locks.h).
Bruno's message from the gnulib ML:
I'm committing a set of gnulib modules that support the essential portion of POSIX <pthread.h> and its functions.
- pthread-h: A POSIX-like <pthread.h>.
- pthread-thread: Creating and controlling POSIX threads.
- pthread-once: POSIX once-only control.
- pthread-mutex: POSIX mutexes (locks).
- pthread-rwlock: POSIX read-write locks.
- pthread-cond: POSIX condition variables.
- pthread-tss: POSIX thread-specific storage.
- pthread-spin: POSIX spin locks.
- pthread: Now merely a convenience wrapper for all of the above.
This has been tested on all customary platforms, from glibc systems up to native Windows with MSVC, and Android.
Like for the older 'thread', 'lock', 'cond', 'tls' modules, on mingw systems the installing user can choose among --enable-threads=posix (which uses the mingw winpthreads library) and --enable-threads=windows (which uses native Windows code, like on MSVC). The default currently is --enable-threads=posix. The package developer can change the default by placing an invocation to gl_AVOID_WINPTHREAD in the configure.ac file. Why is this useful? Because the pthread-tss test hangs with --enable-threads=posix but works fine with --enable-threads=windows