From 0d4d41f1e2b12c1321cb37e2bcbe07c8bb089a2d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 1 May 2016 01:07:53 +0300 Subject: [PATCH] Fix GC_new_kind in case of client-defined PREDEFINED_KINDS There are 2 types of kinds - "pre-allocated" ones (with the number less than PREDEFINED_KINDS) which have pre-allocated free lists and object allocation for these kinds is dealt by GC_malloc_kind typically, and "custom" kinds which require the client to supply the free list (e.g., allocated by GC_new_free_list[_inner]) and arrange own object allocation procedure. By design, GC_new_kind[_inner] creates new "custom" kind. * mark.c (GC_N_KINDS_INITIAL_VALUE): Simplify and comment out (for now). * mark.c (GC_n_kinds): Initialize to PREDEFINED_KINDS (instead of GC_N_KINDS_INITIAL_VALUE); add TODO item. --- mark.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/mark.c b/mark.c index deac1b95..8faae042 100644 --- a/mark.c +++ b/mark.c @@ -69,21 +69,18 @@ GC_INNER struct obj_kind GC_obj_kinds[MAXOBJKINDS] = { # endif }; -# ifdef GC_ATOMIC_UNCOLLECTABLE -# ifdef STUBBORN_ALLOC -# define GC_N_KINDS_INITIAL_VALUE 5 -# else -# define GC_N_KINDS_INITIAL_VALUE 4 -# endif +#if 0 +# ifdef STUBBORN_ALLOC +# define GC_N_KINDS_INITIAL_VALUE (STUBBORN+1) # else -# ifdef STUBBORN_ALLOC -# define GC_N_KINDS_INITIAL_VALUE 4 -# else -# define GC_N_KINDS_INITIAL_VALUE 3 -# endif -# endif /* !GC_ATOMIC_UNCOLLECTABLE */ +# define GC_N_KINDS_INITIAL_VALUE STUBBORN +# endif +#endif +/* TODO: Add new API function to allocate kinds in range */ +/* GC_N_KINDS_INITIAL_VALUE .. PREDEFINED_KINDS-1 (if any) */ +/* which do not need allocation of a free list. */ -GC_INNER unsigned GC_n_kinds = GC_N_KINDS_INITIAL_VALUE; +GC_INNER unsigned GC_n_kinds = PREDEFINED_KINDS; # ifndef INITIAL_MARK_STACK_SIZE # define INITIAL_MARK_STACK_SIZE (1*HBLKSIZE) -- 2.40.0