summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wang <novalazy@gmail.com>2014-08-23 12:48:37 +0400
committerIvan Maidanski <ivmai@mail.ru>2014-08-23 12:48:37 +0400
commit94b85eea2e2713c7a6071f1965b1e98e645e65a7 (patch)
tree8e2a2fad8250230bf44624dd29ddfdd988b3b49e
parent8cdc86284ff3a7faf03d68e44707009b870221d8 (diff)
downloadbdwgc-94b85eea2e2713c7a6071f1965b1e98e645e65a7.tar.gz
Support winpthreads
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.
-rw-r--r--configure.ac5
-rw-r--r--doc/README.macros6
-rw-r--r--doc/README.win324
-rw-r--r--include/gc_config_macros.h2
-rw-r--r--include/private/gc_locks.h9
-rw-r--r--win32_threads.c9
6 files changed, 24 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index fac8edd3..45ab6932 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,7 +145,8 @@ AH_TEMPLATE([GC_OPENBSD_THREADS], [Define to support OpenBSD pthreads.])
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.
@@ -275,7 +276,7 @@ case "$THREADS" in
;;
*-*-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
diff --git a/doc/README.macros b/doc/README.macros
index 96a41c76..3cc302e7 100644
--- a/doc/README.macros
+++ b/doc/README.macros
@@ -149,9 +149,9 @@ GC_DGUX386_THREADS Enables support for DB/UX on I386 threads.
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.
diff --git a/doc/README.win32 b/doc/README.win32
index 134681cf..0a32c204 100644
--- a/doc/README.win32
+++ b/doc/README.win32
@@ -217,7 +217,7 @@ especially with the garbage collector. Any use is likely to provoke a
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.
diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h
index ae970e12..db8a40df 100644
--- a/include/gc_config_macros.h
+++ b/include/gc_config_macros.h
@@ -58,7 +58,7 @@
#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
diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h
index 964182af..6507609b 100644
--- a/include/private/gc_locks.h
+++ b/include/private/gc_locks.h
@@ -91,7 +91,14 @@
# 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 */
diff --git a/win32_threads.c b/win32_threads.c
index 2b783f4a..fc65743a 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -618,7 +618,12 @@ GC_API int GC_CALL GC_thread_is_registered(void)
#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 */
@@ -2469,7 +2474,7 @@ GC_INNER void GC_thr_init(void)
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