From 5bfdba67a938900c046b8e4c1ba56653c6058146 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 23 Dec 2016 00:39:10 +0300 Subject: [PATCH] Fix bm_huge initialization for 64-bit targets (gctest) * tests/test.c (bm_huge): Make array size depend on word size (5 elements for 64-bit targets); initialize elements (except the last one) to -1 instead of 0xffffffff (so that all bits are ones even on a 64-bit target); initialize last element to ((word)-1)>>8 instead of 0x00ffffff value. * tests/test.c (typed_test): Fail if bm_huge descriptor contains wrong bit values at certain positions (as it had before this fix). --- tests/test.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/test.c b/tests/test.c index a06df7ec..9b582fac 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1008,17 +1008,19 @@ void tree_test(void) unsigned n_tests = 0; -const GC_word bm_huge[10] = { +const GC_word bm_huge[320 / CPP_WORDSZ] = { +# if CPP_WORDSZ == 32 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0x00ffffff, +# endif + (GC_signed_word)-1, + (GC_signed_word)-1, + (GC_signed_word)-1, + (GC_signed_word)-1, + ((GC_word)((GC_signed_word)-1)) >> 8 /* highest byte is zero */ }; /* A very simple test of explicitly typed allocation */ @@ -1039,6 +1041,11 @@ void typed_test(void) (void)GC_make_descriptor(&bm_large, 32); # endif collectable_count++; + if (GC_get_bit(bm_huge, 32) == 0 || GC_get_bit(bm_huge, 311) == 0 + || GC_get_bit(bm_huge, 319) != 0) { + GC_printf("Bad GC_get_bit() or bm_huge initialization\n"); + FAIL; + } old = 0; for (i = 0; i < 4000; i++) { collectable_count++; -- 2.40.0