summaryrefslogtreecommitdiff
path: root/dbg_mlc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-07-26 18:09:54 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 18:09:54 +0200
commite35a4171fe47dfbf847e08988ea6cec4dfc8d124 (patch)
tree25f3501669fbf24a4b370c4f8b0c0701b1da4062 /dbg_mlc.c
parentffa0c9ea38b3dd87e91b5ed2118c74002fed6782 (diff)
gc7.0alpha1 tarball importgc7_0alpha1
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r--dbg_mlc.c484
1 files changed, 159 insertions, 325 deletions
diff --git a/dbg_mlc.c b/dbg_mlc.c
index aacbb7a..643f0e2 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -18,8 +18,8 @@
void GC_default_print_heap_obj_proc();
GC_API void GC_register_finalizer_no_order
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
+ (void * obj, GC_finalization_proc fn, void * cd,
+ GC_finalization_proc *ofn, void * *ocd);
#ifndef SHORT_DBG_HDRS
@@ -32,8 +32,7 @@ GC_API void GC_register_finalizer_no_order
/* on free lists may not have debug information set. Thus it's */
/* not always safe to return TRUE, even if the client does */
/* its part. */
-GC_bool GC_has_other_debug_info(p)
-ptr_t p;
+GC_bool GC_has_other_debug_info(ptr_t p)
{
register oh * ohdr = (oh *)p;
register ptr_t body = (ptr_t)(ohdr + 1);
@@ -59,7 +58,7 @@ ptr_t p;
# include <stdlib.h>
-# if defined(LINUX) || defined(SUNOS4) || defined(SUNOS5) \
+# if defined(LINUX) || defined(SUNOS5) \
|| defined(HPUX) || defined(IRIX5) || defined(OSF1)
# define RANDOM() random()
# else
@@ -180,34 +179,34 @@ ptr_t p;
void *base;
GC_print_heap_obj(GC_base(current));
- GC_err_printf0("\n");
+ GC_err_printf("\n");
for (i = 0; ; ++i) {
source = GC_get_back_ptr_info(current, &base, &offset);
if (GC_UNREFERENCED == source) {
- GC_err_printf0("Reference could not be found\n");
+ GC_err_printf("Reference could not be found\n");
goto out;
}
if (GC_NO_SPACE == source) {
- GC_err_printf0("No debug info in object: Can't find reference\n");
+ GC_err_printf("No debug info in object: Can't find reference\n");
goto out;
}
- GC_err_printf1("Reachable via %d levels of pointers from ",
+ GC_err_printf("Reachable via %d levels of pointers from ",
(unsigned long)i);
switch(source) {
case GC_REFD_FROM_ROOT:
- GC_err_printf1("root at 0x%lx\n\n", (unsigned long)base);
+ GC_err_printf("root at %p\n\n", base);
goto out;
case GC_REFD_FROM_REG:
- GC_err_printf0("root in register\n\n");
+ GC_err_printf("root in register\n\n");
goto out;
case GC_FINALIZER_REFD:
- GC_err_printf0("list of finalizable objects\n\n");
+ GC_err_printf("list of finalizable objects\n\n");
goto out;
case GC_REFD_FROM_HEAP:
- GC_err_printf1("offset %ld in object:\n", (unsigned long)offset);
+ GC_err_printf("offset %ld in object:\n", (unsigned long)offset);
/* Take GC_base(base) to get real base, i.e. header. */
GC_print_heap_obj(GC_base(base));
- GC_err_printf0("\n");
+ GC_err_printf("\n");
break;
}
current = base;
@@ -221,7 +220,7 @@ ptr_t p;
{
void * current;
current = GC_generate_random_valid_address();
- GC_printf1("\n****Chose address 0x%lx in object\n", (unsigned long)current);
+ GC_printf("\n****Chose address %p in object\n", current);
GC_print_backtrace(current);
}
@@ -237,11 +236,7 @@ ptr_t p;
(((word)(p + sizeof(oh) + sz - 1) ^ (word)p) >= HBLKSIZE)
/* Store debugging info into p. Return displaced pointer. */
/* Assumes we don't hold allocation lock. */
-ptr_t GC_store_debug_info(p, sz, string, integer)
-register ptr_t p; /* base pointer */
-word sz; /* bytes */
-GC_CONST char * string;
-word integer;
+ptr_t GC_store_debug_info(ptr_t p, word sz, const char *string, word integer)
{
register word * result = (word *)((oh *)p + 1);
DCL_LOCK_STATE;
@@ -273,11 +268,7 @@ word integer;
#ifdef DBG_HDRS_ALL
/* Store debugging info into p. Return displaced pointer. */
/* This version assumes we do hold the allocation lock. */
-ptr_t GC_store_debug_info_inner(p, sz, string, integer)
-register ptr_t p; /* base pointer */
-word sz; /* bytes */
-char * string;
-word integer;
+ptr_t GC_store_debug_info_inner(ptr_t p, word sz, char *string, word integer)
{
register word * result = (word *)((oh *)p + 1);
@@ -375,7 +366,8 @@ ptr_t p;
GC_err_puts("STUBBORN");
break;
default:
- GC_err_printf2("kind %ld, descr 0x%lx", kind, hhdr -> hb_descr);
+ GC_err_printf("kind %d, descr 0x%lx", kind,
+ (unsigned long)(hhdr -> hb_descr));
}
}
}
@@ -388,12 +380,12 @@ ptr_t p;
register oh * ohdr = (oh *)GC_base(p);
GC_ASSERT(!I_HOLD_LOCK());
- GC_err_printf1("0x%lx (", ((unsigned long)ohdr + sizeof(oh)));
+ GC_err_printf("%p (", ((ptr_t)ohdr + sizeof(oh)));
GC_err_puts(ohdr -> oh_string);
# ifdef SHORT_DBG_HDRS
- GC_err_printf1(":%ld, ", (unsigned long)(ohdr -> oh_int));
+ GC_err_printf(":%ld, ", (unsigned long)(ohdr -> oh_int));
# else
- GC_err_printf2(":%ld, sz=%ld, ", (unsigned long)(ohdr -> oh_int),
+ GC_err_printf(":%ld, sz=%ld, ", (unsigned long)(ohdr -> oh_int),
(unsigned long)(ohdr -> oh_sz));
# endif
GC_print_type((ptr_t)(ohdr + 1));
@@ -401,12 +393,7 @@ ptr_t p;
PRINT_CALL_CHAIN(ohdr);
}
-# if defined(__STDC__) || defined(__cplusplus)
- void GC_debug_print_heap_obj_proc(ptr_t p)
-# else
- void GC_debug_print_heap_obj_proc(p)
- ptr_t p;
-# endif
+void GC_debug_print_heap_obj_proc(ptr_t p)
{
GC_ASSERT(!I_HOLD_LOCK());
if (GC_HAS_DEBUG_INFO(p)) {
@@ -417,17 +404,15 @@ ptr_t p;
}
#ifndef SHORT_DBG_HDRS
-void GC_print_smashed_obj(p, clobbered_addr)
-ptr_t p, clobbered_addr;
+void GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr)
{
register oh * ohdr = (oh *)GC_base(p);
GC_ASSERT(!I_HOLD_LOCK());
- GC_err_printf2("0x%lx in object at 0x%lx(", (unsigned long)clobbered_addr,
- (unsigned long)p);
+ GC_err_printf("%p in object at %p(", clobbered_addr, p);
if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))
|| ohdr -> oh_string == 0) {
- GC_err_printf1("<smashed>, appr. sz = %ld)\n",
+ GC_err_printf("<smashed>, appr. sz = %ld)\n",
(GC_size((ptr_t)ohdr) - DEBUG_BYTES));
} else {
if (ohdr -> oh_string[0] == '\0') {
@@ -435,20 +420,20 @@ ptr_t p, clobbered_addr;
} else {
GC_err_puts(ohdr -> oh_string);
}
- GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
+ GC_err_printf(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
(unsigned long)(ohdr -> oh_sz));
PRINT_CALL_CHAIN(ohdr);
}
}
#endif
-void GC_check_heap_proc GC_PROTO((void));
+void GC_check_heap_proc (void);
-void GC_print_all_smashed_proc GC_PROTO((void));
+void GC_print_all_smashed_proc (void);
-void GC_do_nothing() {}
+void GC_do_nothing(void) {}
-void GC_start_debugging()
+void GC_start_debugging(void)
{
# ifndef SHORT_DBG_HDRS
GC_check_heap = GC_check_heap_proc;
@@ -464,36 +449,21 @@ void GC_start_debugging()
size_t GC_debug_header_size = sizeof(oh);
-# if defined(__STDC__) || defined(__cplusplus)
- void GC_debug_register_displacement(GC_word offset)
-# else
- void GC_debug_register_displacement(offset)
- GC_word offset;
-# endif
+void GC_debug_register_displacement(size_t offset)
{
GC_register_displacement(offset);
GC_register_displacement((word)sizeof(oh) + offset);
}
-# ifdef __STDC__
- GC_PTR GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# ifdef GC_ADD_CALLER
- --> GC_ADD_CALLER not implemented for K&R C
-# endif
-# endif
+void * GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result = GC_malloc(lb + DEBUG_BYTES);
+ void * result = GC_malloc(lb + DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1("GC_debug_malloc(%ld) returning NIL (",
- (unsigned long) lb);
+ GC_err_printf("GC_debug_malloc(%lu) returning NIL (",
+ (unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%ld)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -503,25 +473,15 @@ size_t GC_debug_header_size = sizeof(oh);
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_ignore_off_page(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_ignore_off_page(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# ifdef GC_ADD_CALLER
- --> GC_ADD_CALLER not implemented for K&R C
-# endif
-# endif
+void * GC_debug_malloc_ignore_off_page(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES);
+ void * result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1("GC_debug_malloc_ignore_off_page(%ld) returning NIL (",
+ GC_err_printf("GC_debug_malloc_ignore_off_page(%lu) returning NIL (",
(unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%lu)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -531,25 +491,15 @@ size_t GC_debug_header_size = sizeof(oh);
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_atomic_ignore_off_page(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# ifdef GC_ADD_CALLER
- --> GC_ADD_CALLER not implemented for K&R C
-# endif
-# endif
+void * GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES);
+ void * result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1("GC_debug_malloc_atomic_ignore_off_page(%ld)"
+ GC_err_printf("GC_debug_malloc_atomic_ignore_off_page(%lu)"
" returning NIL (", (unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%lu)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -568,12 +518,12 @@ size_t GC_debug_header_size = sizeof(oh);
* We assume debugging was started in collector initialization,
* and we already hold the GC lock.
*/
- GC_PTR GC_debug_generic_malloc_inner(size_t lb, int k)
+ void * GC_debug_generic_malloc_inner(size_t lb, int k)
{
- GC_PTR result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k);
+ void * result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k);
if (result == 0) {
- GC_err_printf1("GC internal allocation (%ld bytes) returning NIL\n",
+ GC_err_printf("GC internal allocation (%lu bytes) returning NIL\n",
(unsigned long) lb);
return(0);
}
@@ -581,13 +531,13 @@ size_t GC_debug_header_size = sizeof(oh);
return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));
}
- GC_PTR GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k)
+ void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k)
{
- GC_PTR result = GC_generic_malloc_inner_ignore_off_page(
+ void * result = GC_generic_malloc_inner_ignore_off_page(
lb + DEBUG_BYTES, k);
if (result == 0) {
- GC_err_printf1("GC internal allocation (%ld bytes) returning NIL\n",
+ GC_err_printf("GC internal allocation (%lu bytes) returning NIL\n",
(unsigned long) lb);
return(0);
}
@@ -597,22 +547,15 @@ size_t GC_debug_header_size = sizeof(oh);
# endif
#ifdef STUBBORN_ALLOC
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_stubborn(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# endif
+void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result = GC_malloc_stubborn(lb + DEBUG_BYTES);
+ void * result = GC_malloc_stubborn(lb + DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1("GC_debug_malloc(%ld) returning NIL (",
- (unsigned long) lb);
+ GC_err_printf("GC_debug_malloc(%lu) returning NIL (",
+ (unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%lu)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -622,41 +565,35 @@ size_t GC_debug_header_size = sizeof(oh);
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
-void GC_debug_change_stubborn(p)
-GC_PTR p;
+void GC_debug_change_stubborn(void *p)
{
- register GC_PTR q = GC_base(p);
- register hdr * hhdr;
+ void * q = GC_base(p);
+ hdr * hhdr;
if (q == 0) {
- GC_err_printf1("Bad argument: 0x%lx to GC_debug_change_stubborn\n",
- (unsigned long) p);
+ GC_err_printf("Bad argument: %p to GC_debug_change_stubborn\n", p);
ABORT("GC_debug_change_stubborn: bad arg");
}
hhdr = HDR(q);
if (hhdr -> hb_obj_kind != STUBBORN) {
- GC_err_printf1("GC_debug_change_stubborn arg not stubborn: 0x%lx\n",
- (unsigned long) p);
+ GC_err_printf("GC_debug_change_stubborn arg not stubborn: %p\n", p);
ABORT("GC_debug_change_stubborn: arg not stubborn");
}
GC_change_stubborn(q);
}
-void GC_debug_end_stubborn_change(p)
-GC_PTR p;
+void GC_debug_end_stubborn_change(void *p)
{
- register GC_PTR q = GC_base(p);
+ register void * q = GC_base(p);
register hdr * hhdr;
if (q == 0) {
- GC_err_printf1("Bad argument: 0x%lx to GC_debug_end_stubborn_change\n",
- (unsigned long) p);
+ GC_err_printf("Bad argument: %p to GC_debug_end_stubborn_change\n", p);
ABORT("GC_debug_end_stubborn_change: bad arg");
}
hhdr = HDR(q);
if (hhdr -> hb_obj_kind != STUBBORN) {
- GC_err_printf1("debug_end_stubborn_change arg not stubborn: 0x%lx\n",
- (unsigned long) p);
+ GC_err_printf("debug_end_stubborn_change arg not stubborn: %p\n", p);
ABORT("GC_debug_end_stubborn_change: arg not stubborn");
}
GC_end_stubborn_change(q);
@@ -664,46 +601,32 @@ GC_PTR p;
#else /* !STUBBORN_ALLOC */
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_stubborn(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# endif
+void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
{
return GC_debug_malloc(lb, OPT_RA s, i);
}
void GC_debug_change_stubborn(p)
-GC_PTR p;
+void * p;
{
}
void GC_debug_end_stubborn_change(p)
-GC_PTR p;
+void * p;
{
}
#endif /* !STUBBORN_ALLOC */
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_atomic(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# endif
+void * GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result = GC_malloc_atomic(lb + DEBUG_BYTES);
+ void * result = GC_malloc_atomic(lb + DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1("GC_debug_malloc_atomic(%ld) returning NIL (",
+ GC_err_printf("GC_debug_malloc_atomic(%lu) returning NIL (",
(unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%lu)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -713,22 +636,15 @@ GC_PTR p;
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_uncollectable(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_uncollectable(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# endif
+void * GC_debug_malloc_uncollectable(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result = GC_malloc_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);
+ void * result = GC_malloc_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1("GC_debug_malloc_uncollectable(%ld) returning NIL (",
+ GC_err_printf("GC_debug_malloc_uncollectable(%lu) returning NIL (",
(unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%lu)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -739,24 +655,17 @@ GC_PTR p;
}
#ifdef ATOMIC_UNCOLLECTABLE
-# ifdef __STDC__
- GC_PTR GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_malloc_atomic_uncollectable(lb, s, i)
- size_t lb;
- char * s;
- int i;
-# endif
+void * GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS)
{
- GC_PTR result =
+ void * result =
GC_malloc_atomic_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);
if (result == 0) {
- GC_err_printf1(
- "GC_debug_malloc_atomic_uncollectable(%ld) returning NIL (",
+ GC_err_printf(
+ "GC_debug_malloc_atomic_uncollectable(%lu) returning NIL (",
(unsigned long) lb);
GC_err_puts(s);
- GC_err_printf1(":%ld)\n", (unsigned long)i);
+ GC_err_printf(":%lu)\n", (unsigned long)i);
return(0);
}
if (!GC_debugging_started) {
@@ -767,36 +676,29 @@ GC_PTR p;
}
#endif /* ATOMIC_UNCOLLECTABLE */
-# ifdef __STDC__
- void GC_debug_free(GC_PTR p)
-# else
- void GC_debug_free(p)
- GC_PTR p;
-# endif
+void GC_debug_free(void * p)
{
- register GC_PTR base;
- register ptr_t clobbered;
+ ptr_t base;
+ ptr_t clobbered;
if (0 == p) return;
base = GC_base(p);
if (base == 0) {
- GC_err_printf1("Attempt to free invalid pointer %lx\n",
- (unsigned long)p);
+ GC_err_printf("Attempt to free invalid pointer %p\n", p);
ABORT("free(invalid pointer)");
}
if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
- GC_err_printf1(
- "GC_debug_free called on pointer %lx wo debugging info\n",
- (unsigned long)p);
+ GC_err_printf(
+ "GC_debug_free called on pointer %p wo debugging info\n", p);
} else {
# ifndef SHORT_DBG_HDRS
clobbered = GC_check_annotated_obj((oh *)base);
if (clobbered != 0) {
if (((oh *)base) -> oh_sz == GC_size(base)) {
- GC_err_printf0(
+ GC_err_printf(
"GC_debug_free: found previously deallocated (?) object at ");
} else {
- GC_err_printf0("GC_debug_free: found smashed location at ");
+ GC_err_printf("GC_debug_free: found smashed location at ");
}
GC_print_smashed_obj(p, clobbered);
}
@@ -807,7 +709,7 @@ GC_PTR p;
if (GC_find_leak) {
GC_free(base);
} else {
- register hdr * hhdr = HDR(p);
+ hdr * hhdr = HDR(p);
GC_bool uncollectable = FALSE;
if (hhdr -> hb_obj_kind == UNCOLLECTABLE) {
@@ -822,52 +724,42 @@ GC_PTR p;
GC_free(base);
} else {
size_t i;
- size_t obj_sz = hhdr -> hb_sz - BYTES_TO_WORDS(sizeof(oh));
+ size_t obj_sz = BYTES_TO_WORDS(hhdr -> hb_sz - sizeof(oh));
for (i = 0; i < obj_sz; ++i) ((word *)p)[i] = 0xdeadbeef;
- GC_ASSERT((word *)p + i == (word *)base + hhdr -> hb_sz);
+ GC_ASSERT((word *)p + i == (word *)(base + hhdr -> hb_sz));
}
} /* !GC_find_leak */
}
#ifdef THREADS
-extern void GC_free_inner(GC_PTR p);
+extern void GC_free_inner(void * p);
/* Used internally; we assume it's called correctly. */
-void GC_debug_free_inner(GC_PTR p)
+void GC_debug_free_inner(void * p)
{
GC_free_inner(GC_base(p));
}
#endif
-# ifdef __STDC__
- GC_PTR GC_debug_realloc(GC_PTR p, size_t lb, GC_EXTRA_PARAMS)
-# else
- GC_PTR GC_debug_realloc(p, lb, s, i)
- GC_PTR p;
- size_t lb;
- char *s;
- int i;
-# endif
+void * GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
{
- register GC_PTR base = GC_base(p);
- register ptr_t clobbered;
- register GC_PTR result;
- register size_t copy_sz = lb;
- register size_t old_sz;
- register hdr * hhdr;
+ void * base = GC_base(p);
+ ptr_t clobbered;
+ void * result;
+ size_t copy_sz = lb;
+ size_t old_sz;
+ hdr * hhdr;
if (p == 0) return(GC_debug_malloc(lb, OPT_RA s, i));
if (base == 0) {
- GC_err_printf1(
- "Attempt to reallocate invalid pointer %lx\n", (unsigned long)p);
+ GC_err_printf("Attempt to reallocate invalid pointer %p\n", p);
ABORT("realloc(invalid pointer)");
}
if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
- GC_err_printf1(
- "GC_debug_realloc called on pointer %lx wo debugging info\n",
- (unsigned long)p);
+ GC_err_printf(
+ "GC_debug_realloc called on pointer %p wo debugging info\n", p);
return(GC_realloc(p, lb));
}
hhdr = HDR(base);
@@ -892,7 +784,7 @@ void GC_debug_free_inner(GC_PTR p)
break;
# endif
default:
- GC_err_printf0("GC_debug_realloc: encountered bad kind\n");
+ GC_err_printf("GC_debug_realloc: encountered bad kind\n");
ABORT("bad kind");
}
# ifdef SHORT_DBG_HDRS
@@ -900,7 +792,7 @@ void GC_debug_free_inner(GC_PTR p)
# else
clobbered = GC_check_annotated_obj((oh *)base);
if (clobbered != 0) {
- GC_err_printf0("GC_debug_realloc: found smashed location at ");
+ GC_err_printf("GC_debug_realloc: found smashed location at ");
GC_print_smashed_obj(p, clobbered);
}
old_sz = ((oh *)base) -> oh_sz;
@@ -922,12 +814,7 @@ void GC_debug_free_inner(GC_PTR p)
ptr_t GC_smashed[MAX_SMASHED];
unsigned GC_n_smashed = 0;
-# if defined(__STDC__) || defined(__cplusplus)
- void GC_add_smashed(ptr_t smashed)
-# else
- void GC_add_smashed(smashed)
- ptr_t smashed;
-#endif
+void GC_add_smashed(ptr_t smashed)
{
GC_ASSERT(GC_is_marked(GC_base(smashed)));
GC_smashed[GC_n_smashed] = smashed;
@@ -938,13 +825,13 @@ unsigned GC_n_smashed = 0;
}
/* Print all objects on the list. Clear the list. */
-void GC_print_all_smashed_proc ()
+void GC_print_all_smashed_proc(void)
{
unsigned i;
GC_ASSERT(!I_HOLD_LOCK());
if (GC_n_smashed == 0) return;
- GC_err_printf0("GC_check_heap_block: found smashed heap objects:\n");
+ GC_err_printf("GC_check_heap_block: found smashed heap objects:\n");
for (i = 0; i < GC_n_smashed; ++i) {
GC_print_smashed_obj(GC_base(GC_smashed[i]), GC_smashed[i]);
GC_smashed[i] = 0;
@@ -952,37 +839,32 @@ void GC_print_all_smashed_proc ()
GC_n_smashed = 0;
}
-/* Check all marked objects in the given block for validity */
+/* Check all marked objects in the given block for validity */
+/* Avoid GC_apply_to_each_object for performance reasons. */
/*ARGSUSED*/
-# if defined(__STDC__) || defined(__cplusplus)
- void GC_check_heap_block(register struct hblk *hbp, word dummy)
-# else
- void GC_check_heap_block(hbp, dummy)
- register struct hblk *hbp; /* ptr to current heap block */
- word dummy;
-# endif
+void GC_check_heap_block(struct hblk *hbp, word dummy)
{
- register struct hblkhdr * hhdr = HDR(hbp);
- register word sz = hhdr -> hb_sz;
- register int word_no;
- register word *p, *plim;
+ struct hblkhdr * hhdr = HDR(hbp);
+ size_t sz = hhdr -> hb_sz;
+ int bit_no;
+ unsigned char *p, *plim;
- p = (word *)(hbp->hb_body);
- word_no = 0;
- if (sz > MAXOBJSZ) {
+ p = hbp->hb_body;
+ bit_no = 0;
+ if (sz > MAXOBJBYTES) {
plim = p;
} else {
- plim = (word *)((((word)hbp) + HBLKSIZE) - WORDS_TO_BYTES(sz));
+ plim = hbp->hb_body + HBLKSIZE - sz;
}
/* go through all words in block */
while( p <= plim ) {
- if( mark_bit_from_hdr(hhdr, word_no)
+ if( mark_bit_from_hdr(hhdr, bit_no)
&& GC_HAS_DEBUG_INFO((ptr_t)p)) {
ptr_t clobbered = GC_check_annotated_obj((oh *)p);
if (clobbered != 0) GC_add_smashed(clobbered);
}
- word_no += sz;
+ bit_no += MARK_BIT_OFFSET(sz);
p += sz;
}
}
@@ -990,14 +872,12 @@ void GC_print_all_smashed_proc ()
/* This assumes that all accessible objects are marked, and that */
/* I hold the allocation lock. Normally called by collector. */
-void GC_check_heap_proc()
+void GC_check_heap_proc(void)
{
# ifndef SMALL_CONFIG
-# ifdef ALIGN_DOUBLE
- GC_STATIC_ASSERT((sizeof(oh) & (2 * sizeof(word) - 1)) == 0);
-# else
- GC_STATIC_ASSERT((sizeof(oh) & (sizeof(word) - 1)) == 0);
-# endif
+ /* Ignore gcc no effect warning on the following. */
+ GC_STATIC_ASSERT((sizeof(oh) & (GRANULE_BYTES - 1)) == 0);
+ /* FIXME: Should we check for twice that alignment? */
# endif
GC_apply_to_all_blocks(GC_check_heap_block, (word)0);
}
@@ -1006,16 +886,10 @@ void GC_check_heap_proc()
struct closure {
GC_finalization_proc cl_fn;
- GC_PTR cl_data;
+ void * cl_data;
};
-# ifdef __STDC__
- void * GC_make_closure(GC_finalization_proc fn, void * data)
-# else
- GC_PTR GC_make_closure(fn, data)
- GC_finalization_proc fn;
- GC_PTR data;
-# endif
+void * GC_make_closure(GC_finalization_proc fn, void * data)
{
struct closure * result =
# ifdef DBG_HDRS_ALL
@@ -1027,34 +901,25 @@ struct closure {
result -> cl_fn = fn;
result -> cl_data = data;
- return((GC_PTR)result);
+ return((void *)result);
}
-# ifdef __STDC__
- void GC_debug_invoke_finalizer(void * obj, void * data)
-# else
- void GC_debug_invoke_finalizer(obj, data)
- char * obj;
- char * data;
-# endif
+void GC_debug_invoke_finalizer(void * obj, void * data)
{
register struct closure * cl = (struct closure *) data;
- (*(cl -> cl_fn))((GC_PTR)((char *)obj + sizeof(oh)), cl -> cl_data);
+ (*(cl -> cl_fn))((void *)((char *)obj + sizeof(oh)), cl -> cl_data);
}
/* Set ofn and ocd to reflect the values we got back. */
-static void store_old (obj, my_old_fn, my_old_cd, ofn, ocd)
-GC_PTR obj;
-GC_finalization_proc my_old_fn;
-struct closure * my_old_cd;
-GC_finalization_proc *ofn;
-GC_PTR *ocd;
+static void store_old (void *obj, GC_finalization_proc my_old_fn,
+ struct closure *my_old_cd, GC_finalization_proc *ofn,
+ void **ocd)
{
if (0 != my_old_fn) {
if (my_old_fn != GC_debug_invoke_finalizer) {
- GC_err_printf1("Debuggable object at 0x%lx had non-debug finalizer.\n",
- obj);
+ GC_err_printf("Debuggable object at %p had non-debug finalizer.\n",
+ obj);
/* This should probably be fatal. */
} else {
if (ofn) *ofn = my_old_cd -> cl_fn;
@@ -1066,26 +931,17 @@ GC_PTR *ocd;
}
}
-# ifdef __STDC__
- void GC_debug_register_finalizer(GC_PTR obj, GC_finalization_proc fn,
- GC_PTR cd, GC_finalization_proc *ofn,
- GC_PTR *ocd)
-# else
- void GC_debug_register_finalizer(obj, fn, cd, ofn, ocd)
- GC_PTR obj;
- GC_finalization_proc fn;
- GC_PTR cd;
- GC_finalization_proc *ofn;
- GC_PTR *ocd;
-# endif
+void GC_debug_register_finalizer(void * obj, GC_finalization_proc fn,
+ void * cd, GC_finalization_proc *ofn,
+ void * *ocd)
{
GC_finalization_proc my_old_fn;
- GC_PTR my_old_cd;
+ void * my_old_cd;
ptr_t base = GC_base(obj);
if (0 == base) return;
if ((ptr_t)obj - base != sizeof(oh)) {
- GC_err_printf1(
- "GC_debug_register_finalizer called with non-base-pointer 0x%lx\n",
+ GC_err_printf(
+ "GC_debug_register_finalizer called with non-base-pointer %p\n",
obj);
}
if (0 == fn) {
@@ -1097,28 +953,19 @@ GC_PTR *ocd;
store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd);
}
-# ifdef __STDC__
- void GC_debug_register_finalizer_no_order
- (GC_PTR obj, GC_finalization_proc fn,
- GC_PTR cd, GC_finalization_proc *ofn,
- GC_PTR *ocd)
-# else
- void GC_debug_register_finalizer_no_order
- (obj, fn, cd, ofn, ocd)
- GC_PTR obj;
- GC_finalization_proc fn;
- GC_PTR cd;
- GC_finalization_proc *ofn;
- GC_PTR *ocd;
-# endif
+void GC_debug_register_finalizer_no_order
+ (void * obj, GC_finalization_proc fn,
+ void * cd, GC_finalization_proc *ofn,
+ void * *ocd)
{
GC_finalization_proc my_old_fn;
- GC_PTR my_old_cd;
+ void * my_old_cd;
ptr_t base = GC_base(obj);
if (0 == base) return;
if ((ptr_t)obj - base != sizeof(oh)) {
- GC_err_printf1(
- "GC_debug_register_finalizer_no_order called with non-base-pointer 0x%lx\n",
+ GC_err_printf(
+ "GC_debug_register_finalizer_no_order called with "
+ "non-base-pointer %p\n",
obj);
}
if (0 == fn) {
@@ -1131,29 +978,19 @@ GC_PTR *ocd;
store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd);
}
-# ifdef __STDC__
- void GC_debug_register_finalizer_ignore_self
- (GC_PTR obj, GC_finalization_proc fn,
- GC_PTR cd, GC_finalization_proc *ofn,
- GC_PTR *ocd)
-# else
- void GC_debug_register_finalizer_ignore_self
- (obj, fn, cd, ofn, ocd)
- GC_PTR obj;
- GC_finalization_proc fn;
- GC_PTR cd;
- GC_finalization_proc *ofn;
- GC_PTR *ocd;
-# endif
+void GC_debug_register_finalizer_ignore_self
+ (void * obj, GC_finalization_proc fn,
+ void * cd, GC_finalization_proc *ofn,
+ void * *ocd)
{
GC_finalization_proc my_old_fn;
- GC_PTR my_old_cd;
+ void * my_old_cd;
ptr_t base = GC_base(obj);
if (0 == base) return;
if ((ptr_t)obj - base != sizeof(oh)) {
- GC_err_printf1(
- "GC_debug_register_finalizer_ignore_self called with non-base-pointer 0x%lx\n",
- obj);
+ GC_err_printf(
+ "GC_debug_register_finalizer_ignore_self called with "
+ "non-base-pointer %p\n", obj);
}
if (0 == fn) {
GC_register_finalizer_ignore_self(base, 0, 0, &my_old_fn, &my_old_cd);
@@ -1171,15 +1008,12 @@ GC_PTR *ocd;
# define RA
#endif
-GC_PTR GC_debug_malloc_replacement(lb)
-size_t lb;
+void * GC_debug_malloc_replacement(size_t lb)
{
return GC_debug_malloc(lb, RA "unknown", 0);
}
-GC_PTR GC_debug_realloc_replacement(p, lb)
-GC_PTR p;
-size_t lb;
+void * GC_debug_realloc_replacement(void *p, size_t lb)
{
return GC_debug_realloc(p, lb, RA "unknown", 0);
}