Support building Boehm GC with Winpthreads.

Winpthreads is a pthreads implementation from the MinGW-w64 project,
different from pthreads-win32.  A similar patch to this should make its
way into Boehm GC upstream.  As we will not be upgrading Boehm GC on the
14.01 branch, apply this small change to our copy of the library for now.

boehm_gc/include/private/gc_locks.h:
	Winpthreads uses scalar thread IDs.

boehm_gc/win32_threads.c:
	Winpthread thread IDs should be practically unique but make the
	conservative assumption anyway.
This commit is contained in:
Peter Wang
2014-08-13 13:53:44 +10:00
parent 03f90b6ada
commit d77dfad3ba
2 changed files with 7 additions and 3 deletions

View File

@@ -98,7 +98,8 @@
/* integers for each thread, though that should be true as much */
/* as possible. */
/* Refine to exclude platforms on which pthread_t is struct */
# if !defined(GC_WIN32_PTHREADS)
/* Mercury-specific: Winpthreads has numeric thread ids */
# if !defined(GC_WIN32_PTHREADS) || defined(__WINPTHREADS_VERSION_MAJOR)
# define NUMERIC_THREAD_ID(id) ((unsigned long)(id))
# define THREAD_EQUAL(id1, id2) ((id1) == (id2))
# define NUMERIC_THREAD_ID_UNIQUE

View File

@@ -2510,14 +2510,17 @@ GC_INNER void GC_thr_init(void)
/* After the join,thread id may have been recycled. */
/* FIXME: It would be better if this worked more like */
/* pthread_support.c. */
# ifndef GC_WIN32_PTHREADS
/* Mercury-specific: Winpthreads allocates threads ids */
/* incrementally (with wraparound) so should be practically */
/* unique, but let's make the conservative assumption. --pw */
# if !defined(GC_WIN32_PTHREADS) || defined(__WINPTHREADS_VERSION_MAJOR)
while ((t = GC_lookup_pthread(pthread_id)) == 0)
Sleep(10);
# endif
result = pthread_join(pthread_id, retval);
# ifdef GC_WIN32_PTHREADS
# if defined(GC_WIN32_PTHREADS) && !defined(__WINPTHREADS_VERSION_MAJOR)
/* win32_pthreads id are unique */
t = GC_lookup_pthread(pthread_id);
# endif