From 012da3f159076fadf828a023786c41aea8537fd4 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 28 Jul 2016 12:06:42 +0300 Subject: Fix tag collision between ENABLE_DISCLAIM and KEEP_BACK_PTRS * fnlz_mlc.c (FINALIZER_CLOSURE_FLAG): New macro (defined to 0x2 in case KEEP_BACK_PTRS or MAKE_BACK_GRAPH, otherwise to 0x1). * fnlz_mlc.c (GC_finalized_disclaim, GC_finalized_malloc): Use FINALIZER_CLOSURE_FLAG instead of 0x1. --- fnlz_mlc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fnlz_mlc.c b/fnlz_mlc.c index 15b234b9..c6ba7aca 100644 --- a/fnlz_mlc.c +++ b/fnlz_mlc.c @@ -21,11 +21,18 @@ STATIC int GC_finalized_kind = 0; +#if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH) + /* The first bit is already used for a debug purpose. */ +# define FINALIZER_CLOSURE_FLAG 0x2 +#else +# define FINALIZER_CLOSURE_FLAG 0x1 +#endif + STATIC int GC_CALLBACK GC_finalized_disclaim(void *obj) { word fc_word = *(word *)obj; - if ((fc_word & 1) != 0) { + if ((fc_word & FINALIZER_CLOSURE_FLAG) != 0) { /* The disclaim function may be passed fragments from the */ /* free-list, on which it should not run finalization. */ /* To recognize this case, we use the fact that the first word */ @@ -34,7 +41,8 @@ STATIC int GC_CALLBACK GC_finalized_disclaim(void *obj) /* which does not use the first word for storing finalization */ /* info, GC_reclaim_with_finalization must be extended to clear */ /* fragments so that the assumption holds for the selected word. */ - const struct GC_finalizer_closure *fc = (void *)(fc_word & ~(word)1); + const struct GC_finalizer_closure *fc + = (void *)(fc_word & ~(word)FINALIZER_CLOSURE_FLAG); (*fc->proc)((word *)obj + 1, fc->cd); } return 0; @@ -84,7 +92,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_finalized_malloc(size_t lb, op = GC_malloc_kind(lb + sizeof(word), GC_finalized_kind); if (EXPECT(NULL == op, FALSE)) return NULL; - *op = (word)fclos | 1; + *op = (word)fclos | FINALIZER_CLOSURE_FLAG; return op + 1; } -- cgit v1.2.1