From: Ivan Maidanski Date: Sat, 8 Dec 2012 08:39:07 +0000 (+0400) Subject: Make GC_generic_malloc_ignore_off_page() public X-Git-Tag: gc7_4_0~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bd92c91f5712ff6723eb2479d0442cd6154a10e;p=gc Make GC_generic_malloc_ignore_off_page() public * include/gc_mark.h (GC_generic_malloc): Refine comment. * include/gc_mark.h (GC_generic_malloc_ignore_off_page): Move prototype from gc_priv.h and make it public; add GC_ATTR_MALLOC attribute. * include/private/gc_priv.h (GC_generic_malloc): Move comment to gc_mark.h. * include/private/gc_priv.h (GC_generic_malloc_ignore_off_page): Remove GC-inner prototype. * include/private/gc_priv.h (GC_generic_malloc_inner): Update comment. * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * mallocx.c (GC_generic_malloc_ignore_off_page): Make public. --- diff --git a/include/gc_mark.h b/include/gc_mark.h index 508fb2cc..4c003c03 100644 --- a/include/gc_mark.h +++ b/include/gc_mark.h @@ -183,14 +183,24 @@ GC_API unsigned GC_CALL GC_new_kind_inner(void ** /* free_list */, GC_API unsigned GC_CALL GC_new_proc(GC_mark_proc); GC_API unsigned GC_CALL GC_new_proc_inner(GC_mark_proc); -/* Allocate an object of a given kind. Note that in multithreaded */ +/* Allocate an object of a given kind. By default, there are only */ +/* a few kinds: composite (pointer-free), atomic, uncollectable, etc. */ +/* We claim it is possible for clever client code that understands the */ +/* GC internals to add more, e.g. to communicate object layout */ +/* information to the collector. Note that in the multi-threaded */ /* contexts, this is usually unsafe for kinds that have the descriptor */ /* in the object itself, since there is otherwise a window in which */ /* the descriptor is not correct. Even in the single-threaded case, */ /* we need to be sure that cleared objects on a free list don't */ /* cause a GC crash if they are accidentally traced. */ -GC_API GC_ATTR_MALLOC void * GC_CALL - GC_generic_malloc(size_t /* lb */, int /* k */); +GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc(size_t /* lb */, + int /* k */); + +GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc_ignore_off_page( + size_t /* lb */, int /* k */); + /* As above, but pointers to past the */ + /* first page of the resulting object */ + /* are ignored. */ typedef void (GC_CALLBACK * GC_describe_type_fn)(void * /* p */, char * /* out_buf */); diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index fb0d9644..c3125170 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1769,23 +1769,10 @@ GC_INNER void GC_collect_a_little_inner(int n); /* collection work, if appropriate. */ /* A unit is an amount appropriate for */ /* HBLKSIZE bytes of allocation. */ -/* void * GC_generic_malloc(size_t lb, int k); */ - /* Allocate an object of the given */ - /* kind. By default, there are only */ - /* a few kinds: composite(pointerfree), */ - /* atomic, uncollectable, etc. */ - /* We claim it's possible for clever */ - /* client code that understands GC */ - /* internals to add more, e.g. to */ - /* communicate object layout info */ - /* to the collector. */ - /* The actual decl is in gc_mark.h. */ -GC_INNER void * GC_generic_malloc_ignore_off_page(size_t b, int k); - /* As above, but pointers past the */ - /* first page of the resulting object */ - /* are ignored. */ + GC_INNER void * GC_generic_malloc_inner(size_t lb, int k); - /* Ditto, but I already hold lock, etc. */ + /* Allocate an object of the given */ + /* kind but assuming lock already held. */ GC_INNER void * GC_generic_malloc_inner_ignore_off_page(size_t lb, int k); /* Allocate an object, where */ /* the client guarantees that there */ diff --git a/mallocx.c b/mallocx.c index bf7f9f06..db265103 100644 --- a/mallocx.c +++ b/mallocx.c @@ -165,11 +165,10 @@ void * realloc(void * p, size_t lb) # undef GC_debug_realloc_replacement # endif /* REDIRECT_REALLOC */ - /* Allocate memory such that only pointers to near the */ /* beginning of the object are considered. */ -/* We avoid holding allocation lock while we clear memory. */ -GC_INNER void * GC_generic_malloc_ignore_off_page(size_t lb, int k) +/* We avoid holding allocation lock while we clear the memory. */ +GC_API void * GC_CALL GC_generic_malloc_ignore_off_page(size_t lb, int k) { void *result; size_t lg;