From: Ivan Maidanski Date: Fri, 30 Sep 2011 09:30:16 +0000 (+0400) Subject: Merge branch 'remotes/paurkedal/t/disclaim-pullreq' plus some minor fixes X-Git-Tag: gc7_3alpha2~320^2^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a28cfb78ac3abf4e59161ce8ee9c128e8377fd81;p=gc Merge branch 'remotes/paurkedal/t/disclaim-pullreq' plus some minor fixes --- a28cfb78ac3abf4e59161ce8ee9c128e8377fd81 diff --cc include/gc_disclaim.h index 0437f724,44b29d49..2e8013d2 --- a/include/gc_disclaim.h +++ b/include/gc_disclaim.h @@@ -20,9 -20,6 +20,11 @@@ /* This API is defined only if the library has been suitably compiled */ /* (i.e. with ENABLE_DISCLAIM defined). */ - /* Prepare the object kind used for GC_finalized_malloc. */ ++/* Prepare the object kind used by GC_finalized_malloc. Call it from */ ++/* your initialization code or, at least, at some point before using */ ++/* finalized allocations. The function is thread-safe. */ +GC_API void GC_CALL GC_init_finalized_malloc(void); + /* Type of a disclaim call-back, always stored along with closure data */ /* passed as the second argument. */ typedef int (GC_CALLBACK * GC_disclaim_proc)(void * /*obj*/, void * /*cd*/); diff --cc tests/disclaim_bench.c index fb75d0d5,cee0a3ec..4dab169e --- a/tests/disclaim_bench.c +++ b/tests/disclaim_bench.c @@@ -17,32 -17,24 +17,23 @@@ #include #include -#include // FIXME: It would be good not to use timing API by - // default (is it is not quite portable). - #include "atomic_ops.h" -#include "private/gc_priv.h" #include "gc_disclaim.h" - #ifndef AO_HAVE_fetch_and_add1 ++#include "private/gc_priv.h" + - int main(void) - { - printf("Skipping disclaim_bench test\n"); - return 0; - } - - #else + static int free_count = 0; - #include - - static AO_t free_count = 0; - --typedef struct testobj_s *testobj_t; struct testobj_s { -- testobj_t keep_link; ++ struct testobj_s *keep_link; int i; }; ++typedef struct testobj_s *testobj_t; ++ void GC_CALLBACK testobj_finalize(void *obj, void *carg) { - AO_fetch_and_add1((AO_t *)carg); + ++*(int *)carg; assert(((testobj_t)obj)->i++ == 109); }