From e7f40b12c1ae51c2a67e90e67fc9a9d47e8a8690 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 22 Oct 2016 01:31:44 +0300 Subject: [PATCH] Eliminate 'value of GC_PTHREAD_EXIT_ATTRIBUTE unknown' cppcheck messages * include/gc_config_macros.h [GC_PTHREAD_EXIT_ATTRIBUTE] (GC_HAVE_PTHREAD_EXIT): New macro. * include/gc_config_macros.h: Replace defined(GC_PTHREAD_EXIT_ATTRIBUTE) with defined(GC_HAVE_PTHREAD_EXIT). * include/gc_pthread_redirects.h: Likewise. * pthread_support.c: Likewise. --- include/gc_config_macros.h | 8 +++++--- include/gc_pthread_redirects.h | 4 ++-- pthread_support.c | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index 9f7f7d7..5234910 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -363,14 +363,16 @@ # ifndef GC_PTHREAD_CREATE_CONST # define GC_PTHREAD_CREATE_CONST /* empty */ # endif -# ifndef GC_PTHREAD_EXIT_ATTRIBUTE +# ifndef GC_HAVE_PTHREAD_EXIT +# define GC_HAVE_PTHREAD_EXIT # define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */ # endif # endif -# if !defined(GC_PTHREAD_EXIT_ATTRIBUTE) \ +# if !defined(GC_HAVE_PTHREAD_EXIT) \ && !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) \ && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS)) +# define GC_HAVE_PTHREAD_EXIT /* Intercept pthread_exit on Linux and Solaris. */ # if defined(__GNUC__) /* since GCC v2.7 */ # define GC_PTHREAD_EXIT_ATTRIBUTE __attribute__((__noreturn__)) @@ -381,7 +383,7 @@ # endif # endif -# if (!defined(GC_PTHREAD_EXIT_ATTRIBUTE) || defined(__native_client__)) \ +# if (!defined(GC_HAVE_PTHREAD_EXIT) || defined(__native_client__)) \ && !defined(GC_NO_PTHREAD_CANCEL) /* Either there is no pthread_cancel() or no need to intercept it. */ # define GC_NO_PTHREAD_CANCEL diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index e069c57..21e2808 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -63,7 +63,7 @@ GC_API int GC_pthread_cancel(pthread_t); # endif -# if defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(GC_PTHREAD_EXIT_DECLARED) +# if defined(GC_HAVE_PTHREAD_EXIT) && !defined(GC_PTHREAD_EXIT_DECLARED) # define GC_PTHREAD_EXIT_DECLARED GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE; # endif @@ -92,7 +92,7 @@ # undef pthread_cancel # define pthread_cancel GC_pthread_cancel # endif -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT # undef pthread_exit # define pthread_exit GC_pthread_exit # endif diff --git a/pthread_support.c b/pthread_support.c index 538f0d9..1db9af6 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -86,7 +86,7 @@ # ifndef GC_NO_PTHREAD_CANCEL # undef pthread_cancel # endif -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT # undef pthread_exit # endif # undef pthread_join @@ -100,7 +100,7 @@ # ifndef GC_NO_PTHREAD_CANCEL # define pthread_cancel __pthread_cancel # endif -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT # define pthread_exit __pthread_exit # endif # endif @@ -119,7 +119,7 @@ # ifndef GC_NO_PTHREAD_CANCEL int REAL_FUNC(pthread_cancel)(pthread_t); # endif -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT void REAL_FUNC(pthread_exit)(void *) GC_PTHREAD_EXIT_ATTRIBUTE; # endif #else @@ -148,7 +148,7 @@ typedef int (* GC_pthread_cancel_t)(pthread_t); static GC_pthread_cancel_t REAL_FUNC(pthread_cancel); # endif -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT typedef void (* GC_pthread_exit_t)(void *) GC_PTHREAD_EXIT_ATTRIBUTE; static GC_pthread_exit_t REAL_FUNC(pthread_exit); # endif @@ -198,12 +198,12 @@ } # endif /* !GC_NO_PTHREAD_CANCEL */ -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT GC_API GC_PTHREAD_EXIT_ATTRIBUTE void GC_pthread_exit(void *retval) { pthread_exit(retval); } -# endif /* GC_PTHREAD_EXIT_ATTRIBUTE */ +# endif #endif /* Linker-based interception. */ #ifdef GC_USE_DLOPEN_WRAP @@ -242,7 +242,7 @@ REAL_FUNC(pthread_cancel) = (GC_pthread_cancel_t) dlsym(dl_handle, "pthread_cancel"); # endif -# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# ifdef GC_HAVE_PTHREAD_EXIT REAL_FUNC(pthread_exit) = (GC_pthread_exit_t) dlsym(dl_handle, "pthread_exit"); # endif @@ -1384,7 +1384,7 @@ STATIC void GC_unregister_my_thread_inner(GC_thread me) GC_ASSERT(GC_getspecific(GC_thread_key) == &me->tlfs); GC_destroy_thread_local(&(me->tlfs)); # endif -# if defined(GC_PTHREAD_EXIT_ATTRIBUTE) || !defined(GC_NO_PTHREAD_CANCEL) +# if defined(GC_HAVE_PTHREAD_EXIT) || !defined(GC_NO_PTHREAD_CANCEL) /* Handle DISABLED_GC flag which is set by the */ /* intercepted pthread_cancel or pthread_exit. */ if ((me -> flags & DISABLED_GC) != 0) { @@ -1540,7 +1540,7 @@ GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) } #endif /* !GC_NO_PTHREAD_CANCEL */ -#ifdef GC_PTHREAD_EXIT_ATTRIBUTE +#ifdef GC_HAVE_PTHREAD_EXIT GC_API GC_PTHREAD_EXIT_ATTRIBUTE void WRAP_FUNC(pthread_exit)(void *retval) { pthread_t self = pthread_self(); @@ -1560,7 +1560,7 @@ GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) REAL_FUNC(pthread_exit)(retval); } -#endif /* GC_PTHREAD_EXIT_ATTRIBUTE */ +#endif /* GC_HAVE_PTHREAD_EXIT */ GC_INNER GC_bool GC_in_thread_creation = FALSE; /* Protected by allocation lock. */ -- 2.7.4