From: Ivan Maidanski Date: Fri, 13 Jan 2012 15:53:47 +0000 (+0400) Subject: Fix extra/gc.c to enable GC source inclusion from multi-threaded app X-Git-Tag: gc7_2~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cab08ec1a863515de17affebe82257bcbd94ece;p=gc Fix extra/gc.c to enable GC source inclusion from multi-threaded app * extra/gc.c: Include gc_pthread_redirects.h (unless GC_NO_THREAD_REDIRECTS) to restore thread calls macro-based redirection after the corresponding undef's in pthread_support.c. * win32_threads.c: Restore thread calls macro-based redirection (unless GC_NO_THREAD_REDIRECTS) at the file end. * extra/gc.c: Remove "file not well tested" comment. --- diff --git a/extra/gc.c b/extra/gc.c index 7ad1b019..d660433b 100644 --- a/extra/gc.c +++ b/extra/gc.c @@ -27,8 +27,6 @@ /* for GC and the client otherwise GC_thread_exit_proc() is not */ /* guaranteed to be invoked (see the comments in pthread_start.c). */ -/* This file is not well tested (for now). */ - #define GC_INNER STATIC #define GC_EXTERN GC_INNER @@ -73,4 +71,12 @@ #include "../pthread_start.c" +/* Restore pthread calls redirection (if altered in */ +/* pthread_stop_world.c, pthread_support.c or win32_threads.c). */ +/* This is only useful if directly included from application */ +/* (instead of linking gc). */ +#ifndef GC_NO_THREAD_REDIRECTS +# include "gc_pthread_redirects.h" +#endif + /* real_malloc.c, extra/MacOS.c, extra/msvc_dbg.c are not included. */ diff --git a/win32_threads.c b/win32_threads.c index 69817c85..ca9976e6 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2737,4 +2737,14 @@ GC_INNER void GC_init_parallel(void) #endif /* THREAD_LOCAL_ALLOC ... */ +# ifndef GC_NO_THREAD_REDIRECTS + /* Restore thread calls redirection. */ +# define CreateThread GC_CreateThread +# define ExitThread GC_ExitThread +# undef _beginthreadex +# define _beginthreadex GC_beginthreadex +# undef _endthreadex +# define _endthreadex GC_endthreadex +# endif /* !GC_NO_THREAD_REDIRECTS */ + #endif /* GC_WIN32_THREADS */