From 7635570ffa95f64f8d225f3c39a618c288d1c9f1 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 18 Dec 2013 23:33:50 +0400 Subject: [PATCH] Fix 'attribute declaration must precede definition' warning (clang-3.1) * 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 | 2 ++ include/gc_pthread_redirects.h | 54 ++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/extra/gc.c b/extra/gc.c index fa70a0a8..a77fba65 100644 --- a/extra/gc.c +++ b/extra/gc.c @@ -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 diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index f0ab25e7..0d571e91 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -30,38 +30,40 @@ /* facility in thr_keycreate. Alternatively, keep a redundant pointer */ /* to thread specific data on the thread stack. */ -#include +#ifndef GC_PTHREAD_REDIRECTS_ONLY +# include -#ifndef GC_NO_DLOPEN -# include - GC_API void *GC_dlopen(const char * /* path */, int /* mode */); -#endif /* !GC_NO_DLOPEN */ +# ifndef GC_NO_DLOPEN +# include + GC_API void *GC_dlopen(const char * /* path */, int /* mode */); +# endif /* !GC_NO_DLOPEN */ -#ifndef GC_NO_PTHREAD_SIGMASK -# include - 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 + 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 */ -- 2.40.0