Skip to content

Commit

Permalink
Fix tag collision between ENABLE_DISCLAIM and KEEP_BACK_PTRS
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
ivmai committed Jul 28, 2016
1 parent b5d5c43 commit 012da3f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fnlz_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 012da3f

Please sign in to comment.