Winpthreads is a different pthread implementation for MinGW-w64.
This patch redefines GC_WIN32_PTHREADS to mean either pthreads-win32
or winpthreads.
* configure.ac (GC_WIN32_PTHREADS): Improve description to cover
"winpthreads" library.
* doc/README.macros (GC_WIN32_PTHREADS): Likewise.
* doc/README.win32: Likewise.
* include/gc_config_macros.h (GC_WIN32_THREADS): Mention "winpthreads"
library in comment.
* win32_threads.c (GC_pthread_join): Likewise.
* include/private/gc_locks.h (NUMERIC_THREAD_ID, THREAD_EQUAL,
NUMERIC_THREAD_ID_UNIQUE): Define to support winpthreads properly (if
GC_WIN32_PTHREADS).
* win32_threads.c (GC_PTHREAD_PTRVAL): Likewise.
AH_TEMPLATE([GC_OSF1_THREADS], [Define to support Tru64 pthreads.])
AH_TEMPLATE([GC_SOLARIS_THREADS], [Define to support Solaris pthreads.])
AH_TEMPLATE([GC_WIN32_THREADS], [Define to support Win32 threads.])
-AH_TEMPLATE([GC_WIN32_PTHREADS], [Define to support pthreads-win32.])
+AH_TEMPLATE([GC_WIN32_PTHREADS],
+ [Define to support pthreads-win32 or winpthreads.])
AH_TEMPLATE([GC_RTEMS_PTHREADS], [Define to support rtems-pthreads.])
dnl System header feature requests.
;;
*-*-mingw*)
AC_DEFINE(GC_WIN32_PTHREADS)
- # Using pthreads-win32 library.
+ # Using pthreads-win32 (or other non-Cygwin pthreads) library.
if test "${enable_parallel_mark}" != no; then
AC_DEFINE(PARALLEL_MARK)
fi
GC_WIN32_THREADS Enables support for Win32 threads. That makes sense
for this Makefile only under Cygwin.
-GC_WIN32_PTHREADS Enables support for pthreads-win32. This cannot be
- enabled automatically by GC_THREADS, which would assume Win32 native
- threads.
+GC_WIN32_PTHREADS Enables support for pthreads-win32 (or other
+ non-Cygwin pthreads library for Windows). This cannot be enabled
+ automatically by GC_THREADS, which would assume Win32 native threads.
PTW32_STATIC_LIB Causes the static version of the Mingw pthreads
library to be used. Requires GC_WIN32_PTHREADS.
crash in the GC, since it makes it impossible for the collector to
correctly track threads.
-To build the collector for MinGW pthreads-win32,
-use Makefile.direct and explicitly set
+To build the collector for MinGW pthreads-win32 (or other non-Cygwin pthreads
+implementation for Windows), use Makefile.direct and explicitly set
GC_WIN32_PTHREADS (or pass --enable-threads=pthreads to configure).
Use -DPTW32_STATIC_LIB for the static threads library.
#endif
#if defined(GC_WIN32_PTHREADS) && !defined(GC_WIN32_THREADS)
- /* Using pthreads-win32 library. */
+ /* Using pthreads-win32 library (or other Win32 implementation). */
# define GC_WIN32_THREADS
#endif
# define NUMERIC_THREAD_ID(id) ((unsigned long)(id))
# define THREAD_EQUAL(id1, id2) ((id1) == (id2))
# define NUMERIC_THREAD_ID_UNIQUE
-# else
+# elif defined(__WINPTHREADS_VERSION_MAJOR) /* winpthreads */
+# define NUMERIC_THREAD_ID(id) ((unsigned long)(id))
+# define THREAD_EQUAL(id1, id2) ((id1) == (id2))
+# ifndef _WIN64
+ /* NUMERIC_THREAD_ID is 32-bit and not unique on Win64. */
+# define NUMERIC_THREAD_ID_UNIQUE
+# endif
+# else /* pthreads-win32 */
# define NUMERIC_THREAD_ID(id) ((unsigned long)(id.p))
/* Using documented internal details of pthreads-win32 library. */
/* Faster than pthread_equal(). Should not change with */
#ifdef CYGWIN32
# define GC_PTHREAD_PTRVAL(pthread_id) pthread_id
#elif defined(GC_WIN32_PTHREADS) || defined(GC_PTHREADS_PARAMARK)
-# define GC_PTHREAD_PTRVAL(pthread_id) pthread_id.p
+# include <pthread.h> /* to check for winpthreads */
+# if defined(__WINPTHREADS_VERSION_MAJOR)
+# define GC_PTHREAD_PTRVAL(pthread_id) pthread_id
+# else
+# define GC_PTHREAD_PTRVAL(pthread_id) pthread_id.p
+# endif
#endif
/* If a thread has been joined, but we have not yet */
result = pthread_join(pthread_id, retval);
# else
result = pthread_join(pthread_id, retval);
- /* pthreads-win32 id are unique (not recycled) */
+ /* pthreads-win32 and winpthreads id are unique (not recycled). */
t = GC_lookup_pthread(pthread_id);
if (NULL == t) ABORT("Thread not registered");
# endif