From d80a05927330b7148b3b13c9dc56b07024c4202d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 28 Dec 2015 18:34:57 +0300 Subject: [PATCH] Allow GC_FAST_MALLOC_GRANS() multiple use in a function Avoid goto statement in gc_inline.h public header (to fix 'duplicate label' compiler error in GC_FAST_MALLOC_GRANS if the macro is used multiple times in a function). * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Replace goto with break --- include/gc_inline.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/include/gc_inline.h b/include/gc_inline.h index 90a7a761..01d4b058 100644 --- a/include/gc_inline.h +++ b/include/gc_inline.h @@ -76,14 +76,24 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t /* lb */, int /* k */, void *my_entry=*my_fl; \ void *next; \ \ - while (GC_EXPECT((GC_word)my_entry \ - <= (num_direct) + GC_TINY_FREELISTS + 1, 0)) { \ + for (;;) { \ + if (GC_EXPECT((GC_word)my_entry \ + > (num_direct) + GC_TINY_FREELISTS + 1, 1)) { \ + next = *(void **)(my_entry); \ + result = (void *)my_entry; \ + *my_fl = next; \ + init; \ + PREFETCH_FOR_WRITE(next); \ + GC_ASSERT(GC_size(result) >= (granules)*GC_GRANULE_BYTES); \ + GC_ASSERT((kind) == PTRFREE || ((GC_word *)result)[1] == 0); \ + break; \ + } \ /* Entry contains counter or NULL */ \ if ((GC_word)my_entry <= (num_direct) && my_entry != 0) { \ /* Small counter value, not NULL */ \ *my_fl = (char *)my_entry + (granules) + 1; \ result = (default_expr); \ - goto out; \ + break; \ } else { \ /* Large counter or NULL */ \ GC_generic_malloc_many(((granules) == 0? GC_GRANULE_BYTES : \ @@ -92,18 +102,10 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t /* lb */, int /* k */, my_entry = *my_fl; \ if (my_entry == 0) { \ result = (*GC_get_oom_fn())((granules)*GC_GRANULE_BYTES); \ - goto out; \ + break; \ } \ } \ } \ - next = *(void **)(my_entry); \ - result = (void *)my_entry; \ - *my_fl = next; \ - init; \ - PREFETCH_FOR_WRITE(next); \ - GC_ASSERT(GC_size(result) >= (granules)*GC_GRANULE_BYTES); \ - GC_ASSERT((kind) == PTRFREE || ((GC_word *)result)[1] == 0); \ - out: ; \ } \ } while (0) -- 2.40.0