From: Ivan Maidanski Date: Sat, 30 Apr 2016 22:07:53 +0000 (+0300) Subject: Fix GC_new_kind in case of client-defined PREDEFINED_KINDS X-Git-Tag: gc7_6_0~25^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d4d41f1e2b12c1321cb37e2bcbe07c8bb089a2d;p=gc 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. --- 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)