From bf828ba79277bca2c8b145f4379a4da0a1b6423e Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 1 Feb 2012 20:49:25 +0400 Subject: [PATCH] gctest: Avoid use of deprecated GC_dont_gc and GC_stackbottom * tests/test.c (GC_amiga_gctest_malloc_explicitly_typed, GC_amiga_gctest_calloc_explicitly_typed): Do not unnecessarily check GC_dont_gc value. * tests/test.c (check_heap_stats): Get stack base via GC_get_stack_base() (report error if failed) instead of accessing GC_stackbottom. --- tests/test.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/test.c b/tests/test.c index cbbee258..cf6c383d 100644 --- a/tests/test.c +++ b/tests/test.c @@ -121,10 +121,8 @@ int realloc_count = 0; void *GC_amiga_gctest_malloc_explicitly_typed(size_t lb, GC_descr d){ void *ret=GC_malloc_explicitly_typed(lb,d); if(ret==NULL){ - if(!GC_dont_gc){ GC_gcollect(); ret=GC_malloc_explicitly_typed(lb,d); - } if(ret==NULL){ GC_printf("Out of memory, (typed allocations are not directly " "supported with the GC_AMIGA_FASTALLOC option.)\n"); @@ -136,10 +134,8 @@ int realloc_count = 0; void *GC_amiga_gctest_calloc_explicitly_typed(size_t a,size_t lb, GC_descr d){ void *ret=GC_calloc_explicitly_typed(a,lb,d); if(ret==NULL){ - if(!GC_dont_gc){ GC_gcollect(); ret=GC_calloc_explicitly_typed(a,lb,d); - } if(ret==NULL){ GC_printf("Out of memory, (typed allocations are not directly " "supported with the GC_AMIGA_FASTALLOC option.)\n"); @@ -1332,8 +1328,17 @@ void check_heap_stats(void) GC_invoke_finalizers(); } if (GC_print_stats) { - GC_log_printf("Primordial thread stack bottom: %p\n", - (void *)GC_stackbottom); + struct GC_stack_base sb; + int res = GC_get_stack_base(&sb); + + if (res == GC_SUCCESS) { + GC_log_printf("Primordial thread stack bottom: %p\n", sb.mem_base); + } else if (res == GC_UNIMPLEMENTED) { + GC_log_printf("GC_get_stack_base() unimplemented\n"); + } else { + GC_printf("GC_get_stack_base() failed: %d\n", res); + FAIL; + } } GC_printf("Completed %u tests\n", n_tests); GC_printf("Allocated %d collectable objects\n", collectable_count); -- 2.40.0