diff options
author | hboehm <hboehm> | 2008-07-26 00:51:33 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 21:06:43 +0400 |
commit | 68b9f2740e77bfae2b94392140608d952114b199 (patch) | |
tree | 492d095c29a2cfc5cbbc4a49b41fa1f5b06bc6ff /ptr_chck.c | |
parent | 1867d249698c81214418b2cf9752a987abb7b4f2 (diff) | |
download | bdwgc-68b9f2740e77bfae2b94392140608d952114b199.tar.gz |
2008-07-25 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Ivan Maidanski)
Ivan's description of the patch follows. Note that a few pieces like
the GC_malloc(0) patch, were not applied since an alternate had been
previously applied. A few differed stylistically from the rest of
the code (mostly casts to void * instead of target type),
or were classified as too minor to bother. Note that
all of Ivan's static declarations which did not correct outright
naming bugs (as a few did), where replaced by STATIC, which is
ignored by default.
- minor bug fixing (for FreeBSD, for THREAD_LOCAL_ALLOC and for
GC_malloc(0));
- addition of missing getter/setter functions for public variables
(may be useful if compiled as Win32 DLL);
- addition of missing GC_API for some exported functions;
- addition of missing "static" declarator for internal functions
and variables (where possible);
- replacement of all remaining K&R-style definitions with ANSI
C ones (__STDC__ macro is not used anymore);
- addition of some Win32 macro definitions (that may be missing in
the standard headers supplied with a compiler) for GWW_VDB mode;
- elimination of most compiler warnings (except for
"uninitialized data" warning);
- several typos correction;
- missing parenthesis addition in macros in some header files of
"libatomic_ops" module.
My highlights based on reading the patch:
* allchblk.c: Remove GC_freehblk_ptr decl.
Make free_list_index_of() static.
* include/gc.h: Use __int64 on win64, define GC_oom_func,
GC_finalizer_notifier_proc, GC_finalizer_notifier_proc,
add getter and setters: GC_get_gc_no, GC_get_parallel,
GC_set_oom_fn, GC_set_finalize_on_demand,
GC_set_java_finalization, GC_set_dont_expand,
GC_set_no_dls, GC_set_max_retries, GC_set_dont_precollect,
GC_set_finalizer_notifier. Always define GC_win32_free_heap.
gc_config_macros.h: Define _REENTRANT after processing
GC_THREADS.
* include/gc_cpp.h: Improve GC_PLACEMENT_DELETE test,
handling of operator new[] for old Windows compilers.
* include/gc_inline.h (GC_MALLOC_FAST_GRANS): Add parentheses
around arguments.
* dbg_mlc.c, malloc.c, misc.c: Add many GC_API specs.
* mark.c (GC_mark_and_push_stack): Fix source argument for
blacklist printing.
* misc.c: Fix log file naming based on environment variable
for Windows. Make GC_set_warn_proc and GC_set_free_space_divisor
just return current value with 0 argument. Add DONT_USER_USER32_DLL.
Add various getters and setters as in gc.h.
* os_dep.c: Remove no longer used GC_disable/enable_signals
implementations. (GC_get_stack_base): Add pthread_attr_destroy
call. No longer set GC_old_bus_handler in DARWIN workaround.
* pthread_support.c: GC_register_my_thread must also
call GC_init_thread_local.
Diffstat (limited to 'ptr_chck.c')
-rw-r--r-- | ptr_chck.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -18,7 +18,7 @@ #include "private/gc_pmark.h" -void GC_default_same_obj_print_proc(void * p, void * q) +STATIC void GC_default_same_obj_print_proc(void * p, void * q) { GC_err_printf("%p and %p are not in the same object\n", p, q); ABORT("GC_same_obj test failed"); @@ -36,7 +36,7 @@ void (*GC_same_obj_print_proc) (void *, void *) /* We assume this is performance critical. (It shouldn't */ /* be called by production code, but this can easily make */ /* debugging intolerably slow.) */ -void * GC_same_obj(void *p, void *q) +GC_API void * GC_same_obj(void *p, void *q) { struct hblk *h; hdr *hhdr; @@ -99,7 +99,7 @@ fail: return(p); } -void GC_default_is_valid_displacement_print_proc (void *p) +STATIC void GC_default_is_valid_displacement_print_proc (void *p) { GC_err_printf("%p does not point to valid object displacement\n", p); ABORT("GC_is_valid_displacement test failed"); @@ -114,7 +114,7 @@ void (*GC_is_valid_displacement_print_proc)(void *) = /* Always returns its argument. */ /* Note that we don't lock, since nothing relevant about the header */ /* should change while we have a valid object pointer to the block. */ -void * GC_is_valid_displacement(void *p) +GC_API void * GC_is_valid_displacement(void *p) { hdr *hhdr; word pdispl; @@ -149,7 +149,7 @@ fail: return(p); } -void GC_default_is_visible_print_proc(void * p) +STATIC void GC_default_is_visible_print_proc(void * p) { GC_err_printf("%p is not a GC visible pointer location\n", p); ABORT("GC_is_visible test failed"); @@ -157,12 +157,10 @@ void GC_default_is_visible_print_proc(void * p) void (*GC_is_visible_print_proc)(void * p) = GC_default_is_visible_print_proc; +#ifndef THREADS /* Could p be a stack address? */ -GC_bool GC_on_stack(ptr_t p) -{ -# ifdef THREADS - return(TRUE); -# else + STATIC GC_bool GC_on_stack(ptr_t p) + { int dummy; # ifdef STACK_GROWS_DOWN if ((ptr_t)p >= (ptr_t)(&dummy) && (ptr_t)p < GC_stackbottom ) { @@ -174,8 +172,8 @@ GC_bool GC_on_stack(ptr_t p) } # endif return(FALSE); -# endif -} + } +#endif /* Check that p is visible */ /* to the collector as a possibly pointer containing location. */ @@ -185,7 +183,7 @@ GC_bool GC_on_stack(ptr_t p) /* untyped allocations. The idea is that it should be possible, though */ /* slow, to add such a call to all indirect pointer stores.) */ /* Currently useless for multithreaded worlds. */ -void * GC_is_visible(void *p) +GC_API void * GC_is_visible(void *p) { hdr *hhdr; @@ -204,15 +202,13 @@ void * GC_is_visible(void *p) if (GC_on_stack(p)) return(p); hhdr = HDR((word)p); if (hhdr == 0) { - GC_bool result; - if (GC_is_static_root(p)) return(p); /* Else do it again correctly: */ # if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || \ defined(MSWINCE) || defined(PCR)) GC_register_dynamic_libraries(); - result = GC_is_static_root(p); - if (result) return(p); + if (GC_is_static_root(p)) + return(p); # endif goto fail; } else { @@ -259,7 +255,7 @@ fail: } -void * GC_pre_incr (void **p, size_t how_much) +GC_API void * GC_pre_incr (void **p, size_t how_much) { void * initial = *p; void * result = GC_same_obj((void *)((word)initial + how_much), initial); @@ -270,7 +266,7 @@ void * GC_pre_incr (void **p, size_t how_much) return (*p = result); } -void * GC_post_incr (void **p, size_t how_much) +GC_API void * GC_post_incr (void **p, size_t how_much) { void * initial = *p; void * result = GC_same_obj((void *)((word)initial + how_much), initial); |