Re[2]: [Gc] Determining if pointer GC allocated

Ivan Maidanski ivmai at mail.ru
Sat Dec 31 00:55:17 PST 2011


Hi,

31 12 2011, 01:55 Hans Aberg <haberg-1 at telia.com>:
> On 30 Dec 2011, at 21:12, Ivan Maidanski wrote:
> 
> >>> I've implemented GC_is_heap_ptr (C, not C++) - see commit dcf6f52 (master branch).
> >>> Does it work for you?
> >>
> >> I made some simple timings. It is significantly faster than using GC_base(), and overhead is less than 70% relative a function f() that just returns an integer. It means that, unless one can optimize away the function call, there is little point in caching the value.
> >
> > If your test case were written in C then it would be possible to define GC_API=static and include extra/gc.c directly from your code thus resulting everything to be compiled as a single module with GC_is_heap_ptr inlined (at some level of -O).
> 
> It might be possible from C++ using:
> extern "C" {
> #define GC_API static
> #include "extra/gc.c"
> }
> but I get the error:
> In file included from ./extra/gc.c:38:
> ./extra/../backgraph.c:15:10: fatal error: 'private/dbg_mlc.h' file not found
> #include "private/dbg_mlc.h"
>          ^
> 1 error generated.

This error is caused by missing -I include option (as private/dbg_mlc.h in in include folder), also you might need to include -I libatomic_ops/src (if you set -D GC_THREADS).

The real problem with including C code from C++ is that "extern C" only influences name mangling (AFAIK) but not the semantics. 

Regards,

> 
> Hans
> 
> 



More information about the Gc mailing list