]> granicus.if.org Git - gc/commitdiff
Fix GC_new_kind in case of client-defined PREDEFINED_KINDS
authorIvan Maidanski <ivmai@mail.ru>
Sat, 30 Apr 2016 22:07:53 +0000 (01:07 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 30 Apr 2016 22:07:53 +0000 (01:07 +0300)
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

diff --git a/mark.c b/mark.c
index 37de535d4556dc24df7af2d25b72a1307299955c..71aa14ba4f318609fb6861919bcfe7ea50a1453b 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -70,21 +70,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)