Re: [Gc]: Problems with GC settings

Ivan Maidanski ivmai at mail.ru
Thu Oct 1 03:50:00 PDT 2009


Hi!

Juan Jose Garcia-Ripoll <juanjose.garciaripoll at googlemail.com> wrote:
> To make a long story short:
>  - ECL uses the gc library, configuring it to use --enable-threads=posix
>  - Before building our environment, we build the library and install
> it in a temporary directory
>  - When building ECL we include gc.h but the headers have no clue that
> they were built with support for threads.
>
> I discovered this because the headers do not overwrite the
> pthread_create() routine.
>
> On a closer inspection, gc_config_macros.h does not seem to be
> generated, as it is the case in ordinary autoconfed libraries.
> Currently I am being forced to define explicitly GC_PTHREADS or
> GC_WIN32_THREADS before including gc.h and I do not like this -- seems
> very fragile under change of environment or platform.
>
> This is with v7.1, which is also the one available in most
> distributions. Have things changed in CVS?
>
> Juanjo

The things that are changed since 7.1:
- GC_PTHREADS/GC_xxx_THREADS are no deprecated for external usage (GC_THREADS should be used instead);
- now we have config.h (but it's only for building GC).

The things that you should care in your product:
- if you are going to use GC in a shared lib (has effect only for Win32/WinCE platforms, may be omitted on all GnuWin toolchains with auto-import), you should define GC_DLL before including "gc.h" (this could be done in the source file including gc.h or in config.h for your product, or in a Makefile at your choice);
- if you are going to have multiple threads (manipulating pointers to the GC heap) in your product, you have to define GC_THREADS before including "cg.h";
- if you know better which thread and when should be registered to GC, you should define GC_NO_THREAD_REDIRECTS (and call GC_allow_register_threads() before going multi-threaded) along with GC_THREADS.

All the above macros are platform-independent.

Bye.


More information about the Gc mailing list