From 1a8c7c0e8952ce552be0956b45bcb93cc3dd3637 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 21 Oct 2016 11:42:26 +0300 Subject: [PATCH] Fix 'ISO C90 forbids mixed declarations and code' compiler warning * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_thread_exit_proc): Move GC_log_printf() call down to be after local variables declarations. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && USE_PTHREAD_SPECIFIC && !USE_WIN32_SPECIFIC]: Add {} to have "k" local variable declaration before any statement in a block. --- pthread_support.c | 6 +++--- thread_local_alloc.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pthread_support.c b/pthread_support.c index d62d356..538f0d9 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1434,13 +1434,13 @@ GC_API int GC_CALL GC_unregister_my_thread(void) /* resources or id anyway. */ GC_INNER_PTHRSTART void GC_thread_exit_proc(void *arg) { + IF_CANCEL(int cancel_state;) + DCL_LOCK_STATE; + # ifdef DEBUG_THREADS GC_log_printf("Called GC_thread_exit_proc on %p, gc_thread = %p\n", (void *)((GC_thread)arg)->id, arg); # endif - IF_CANCEL(int cancel_state;) - DCL_LOCK_STATE; - LOCK(); DISABLE_CANCEL(cancel_state); GC_wait_for_gc_completion(FALSE); diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 26b7699..ae1286d 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -157,13 +157,16 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_kind(size_t bytes, int knd) } # endif # if !defined(USE_PTHREAD_SPECIFIC) && !defined(USE_WIN32_SPECIFIC) + { GC_key_t k = GC_thread_key; + if (EXPECT(0 == k, FALSE)) { /* We haven't yet run GC_init_parallel. That means */ /* we also aren't locking, so this is fairly cheap. */ return GC_malloc_kind_global(bytes, knd); } tsd = GC_getspecific(k); + } # else tsd = GC_getspecific(GC_thread_key); # endif -- 2.7.4