Fix 'attribute declaration must precede definition' warning (clang-3.1)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 18 Dec 2013 19:33:50 +0000 (23:33 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 18 Dec 2013 19:33:50 +0000 (23:33 +0400)
* extra/gc.c: Include gc_inline.h explicitly before including mallocx.c
(to workaround "attribute declaration must precede definition" warning
reported by clang-3.1 for GC_generic_malloc_many); define
GC_PTHREAD_REDIRECTS_ONLY before including gc_pthread_redirects.h.
* include/gc_pthread_redirects.h (GC_dlopen, GC_pthread_sigmask,
GC_PTHREAD_CREATE_CONST, GC_pthread_create, GC_pthread_join,
GC_pthread_detach, GC_pthread_cancel, GC_pthread_exit): Do not declare
if GC_PTHREAD_REDIRECTS_ONLY defined (to workaround
"attribute declaration must precede definition" warning reported by
clang-3.1).

extra/gc.c
include/gc_pthread_redirects.h

index fa70a0a..a77fba6 100644 (file)
@@ -44,6 +44,7 @@
 #include "../ptr_chck.c"
 #include "../stubborn.c"
 
+#include "gc_inline.h"
 #include "../allchblk.c"
 #include "../alloc.c"
 #include "../dbg_mlc.c"
@@ -79,6 +80,7 @@
 /* This is only useful if directly included from application    */
 /* (instead of linking gc).                                     */
 #ifndef GC_NO_THREAD_REDIRECTS
+# define GC_PTHREAD_REDIRECTS_ONLY
 # include "gc_pthread_redirects.h"
 #endif
 
index f0ab25e..0d571e9 100644 (file)
 /* facility in thr_keycreate.  Alternatively, keep a redundant pointer  */
 /* to thread specific data on the thread stack.                         */
 
-#include <pthread.h>
+#ifndef GC_PTHREAD_REDIRECTS_ONLY
+# include <pthread.h>
 
-#ifndef GC_NO_DLOPEN
-# include <dlfcn.h>
-  GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
-#endif /* !GC_NO_DLOPEN */
+# ifndef GC_NO_DLOPEN
+#   include <dlfcn.h>
+    GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
+# endif /* !GC_NO_DLOPEN */
 
-#ifndef GC_NO_PTHREAD_SIGMASK
-# include <signal.h>
-  GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
-                                sigset_t * /* oset */);
-#endif /* !GC_NO_PTHREAD_SIGMASK */
+# ifndef GC_NO_PTHREAD_SIGMASK
+#   include <signal.h>
+    GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
+                                  sigset_t * /* oset */);
+# endif /* !GC_NO_PTHREAD_SIGMASK */
 
-#ifndef GC_PTHREAD_CREATE_CONST
-  /* This is used for pthread_create() only.    */
-# define GC_PTHREAD_CREATE_CONST const
-#endif
+# ifndef GC_PTHREAD_CREATE_CONST
+    /* This is used for pthread_create() only.    */
+#   define GC_PTHREAD_CREATE_CONST const
+# endif
 
-GC_API int GC_pthread_create(pthread_t *,
-                             GC_PTHREAD_CREATE_CONST pthread_attr_t *,
-                             void *(*)(void *), void * /* arg */);
-GC_API int GC_pthread_join(pthread_t, void ** /* retval */);
-GC_API int GC_pthread_detach(pthread_t);
+  GC_API int GC_pthread_create(pthread_t *,
+                               GC_PTHREAD_CREATE_CONST pthread_attr_t *,
+                               void *(*)(void *), void * /* arg */);
+  GC_API int GC_pthread_join(pthread_t, void ** /* retval */);
+  GC_API int GC_pthread_detach(pthread_t);
 
-#ifndef GC_NO_PTHREAD_CANCEL
-  GC_API int GC_pthread_cancel(pthread_t);
-#endif
+# ifndef GC_NO_PTHREAD_CANCEL
+    GC_API int GC_pthread_cancel(pthread_t);
+# endif
 
-#if defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(GC_PTHREAD_EXIT_DECLARED)
-# define GC_PTHREAD_EXIT_DECLARED
-  GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE;
-#endif
+# if defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(GC_PTHREAD_EXIT_DECLARED)
+#   define GC_PTHREAD_EXIT_DECLARED
+    GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE;
+# endif
+#endif /* !GC_PTHREAD_REDIRECTS_ONLY */
 
 #if !defined(GC_NO_THREAD_REDIRECTS) && !defined(GC_USE_LD_WRAP)
   /* Unless the compiler supports #pragma extern_prefix, the Tru64      */