Fix 'ISO C90 forbids mixed declarations and code' compiler warning
authorIvan Maidanski <ivmai@mail.ru>
Fri, 21 Oct 2016 08:42:26 +0000 (11:42 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 21 Oct 2016 08:42:26 +0000 (11:42 +0300)
* 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
thread_local_alloc.c

index d62d356..538f0d9 100644 (file)
@@ -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);
index 26b7699..ae1286d 100644 (file)
@@ -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