Skip to content

Commit

Permalink
Fix 'attribute declaration must precede definition' warning (clang-3.1)
Browse files Browse the repository at this point in the history
* 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).
  • Loading branch information
ivmai committed Dec 18, 2013
1 parent 09304d1 commit 7635570
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
2 changes: 2 additions & 0 deletions extra/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
54 changes: 28 additions & 26 deletions include/gc_pthread_redirects.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,40 @@
/* 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 */
Expand Down

0 comments on commit 7635570

Please sign in to comment.