summaryrefslogtreecommitdiff
path: root/mallocx.c
diff options
context:
space:
mode:
authorAlessandro Bruni <alessandro.bruni@gmail.com>2016-01-28 00:03:49 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-01-28 00:03:49 +0300
commit989056833ff24691cc26c8bc8b9ba951a08b4a66 (patch)
tree9c8309a5b911a2a7cae1580aeb35e543203c49c3 /mallocx.c
parent283e7fded73a8428f94fa0e0baa24e5ed2a1f78b (diff)
downloadbdwgc-989056833ff24691cc26c8bc8b9ba951a08b4a66.tar.gz
GC_malloc[_atomic] global and thread-local generalization with kind
* include/gc_inline.h (GC_malloc_kind, GC_malloc_kind_global): New public function declaration. * include/gc_inline.h (GC_MALLOC_WORDS_KIND): New public macro. * include/gc_inline.h (GC_MALLOC_WORDS, GC_MALLOC_ATOMIC_WORDS): Use GC_MALLOC_WORDS_KIND. * include/gc_inline.h (GC_CONS): Use GC_malloc_kind (instead of GC_malloc); reformat code. * include/private/gc_priv.h (MAXOBJKINDS): Allow user-defined values. * include/private/gc_priv.h (GC_core_malloc, GC_core_malloc_atomic): Remove prototype. * malloc.c: Include gc_inline.h (to get GC_malloc_kind prototype). * mallocx.c: Likewise. * malloc.c (GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc): Add assertion on "k" (kind) argument (should be less than MAXOBJKINDS). * mallocx.c (GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * malloc.c (GC_generic_malloc_uncollectable): Add assertion on "k" argument (should be less than PREDEFINED_KINDS). * malloc.c (GC_core_malloc_atomic, GC_core_malloc): Replace with GC_malloc_kind_global. * malloc.c (GC_malloc_atomic, GC_malloc): Define as a wrapper around GC_malloc_kind_global. * malloc.c (GC_malloc_kind): Redirect to GC_malloc_kind_global if not defined in gc_inline.h (as a macro) or in thread_local_alloc.c. * mallocx.c (GC_generic_or_special_malloc): Call GC_malloc_kind instead of GC_malloc_kind and GC_malloc. * thread_local_alloc.c (GC_malloc, GC_malloc_atomic): Replace with GC_malloc_kind; remove tiny_fl local variable; call GC_malloc_kind_global instead of GC_core_malloc and GC_core_malloc_atomic. * thread_local_alloc.c (GC_destroy_thread_local): Adjust static assert to guard against global _freelists overrun.
Diffstat (limited to 'mallocx.c')
-rw-r--r--mallocx.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mallocx.c b/mallocx.c
index f84b0b60..75147486 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -15,6 +15,7 @@
*/
#include "private/gc_priv.h"
+#include "gc_inline.h" /* for GC_malloc_kind */
/*
* These are extra allocation routines which are likely to be less
@@ -65,9 +66,8 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_or_special_malloc(size_t lb,
return GC_malloc_stubborn(lb);
# endif
case PTRFREE:
- return GC_malloc_atomic(lb);
case NORMAL:
- return GC_malloc(lb);
+ return GC_malloc_kind(lb, knd);
case UNCOLLECTABLE:
# ifdef GC_ATOMIC_UNCOLLECTABLE
case AUNCOLLECTABLE:
@@ -189,6 +189,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL
if (SMALL_OBJ(lb))
return GC_generic_malloc(lb, k);
+ GC_ASSERT(k < MAXOBJKINDS);
lg = ROUNDED_UP_GRANULES(lb);
lb_rounded = GRANULES_TO_BYTES(lg);
if (lb_rounded < lb)
@@ -300,6 +301,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result)
*result = op;
return;
}
+ GC_ASSERT(k < MAXOBJKINDS);
lw = BYTES_TO_WORDS(lb);
lg = BYTES_TO_GRANULES(lb);
if (EXPECT(GC_have_errors, FALSE))