From 097011075ccc0a238e938bc548c07f09a773e6c6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 31 Mar 2017 18:46:43 +0300 Subject: [PATCH] Fix 'implicit declaration of pthread_sigmask' compiler warning (fix commit 1554297) * include/gc_pthread_redirects.h [GC_NO_PTHREAD_SIGMASK]: Include signal.h even GC_pthread_sigmask is not declared (otherwise pthread_sigmask is redefined to GC_pthread_sigmask first and then signal.h is included thus causing REAL(pthread_sigmask) to stay undefined). * include/gc_pthread_redirects.h [GC_NO_PTHREAD_SIGMASK] (GC_pthread_sigmask): Define it also if _BSD_SOURCE or _GNU_SOURCE. * tests/test.c [CPPCHECK] (GC_PTHREAD_SIGMASK_NEEDED): Do not define (because defining _GNU_SOURCE is sufficient to have GC_pthread_sigmask declared). * tests/test.c [CPPCHECK] (_GNU_SOURCE): Do not define unless GC_PTHREADS. --- include/gc_pthread_redirects.h | 14 ++++++++------ tests/test.c | 7 ++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index 4e7964bd..8dcf7ebf 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -42,12 +42,14 @@ GC_API void *GC_dlopen(const char * /* path */, int /* mode */); # endif /* !GC_NO_DLOPEN */ -# if !defined(GC_NO_PTHREAD_SIGMASK) \ - && (defined(GC_PTHREAD_SIGMASK_NEEDED) \ - || _POSIX_C_SOURCE >= 199506L || _XOPEN_SOURCE >= 500) -# include - GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *, - sigset_t * /* oset */); +# ifndef GC_NO_PTHREAD_SIGMASK +# include /* needed anyway for proper redirection */ +# if defined(GC_PTHREAD_SIGMASK_NEEDED) \ + || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) \ + || (_POSIX_C_SOURCE >= 199506L) || (_XOPEN_SOURCE >= 500) + GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *, + sigset_t * /* oset */); +# endif # endif /* !GC_NO_PTHREAD_SIGMASK */ # ifndef GC_PTHREAD_CREATE_CONST diff --git a/tests/test.c b/tests/test.c index c6a9e860..87574aad 100644 --- a/tests/test.c +++ b/tests/test.c @@ -29,11 +29,8 @@ # define GC_DEBUG #endif -#ifdef CPPCHECK -# define GC_PTHREAD_SIGMASK_NEEDED -# ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -# endif +#if defined(CPPCHECK) && defined(GC_PTHREADS) && !defined(_GNU_SOURCE) +# define _GNU_SOURCE 1 #endif #undef GC_NO_THREAD_REDIRECTS #include "gc.h" -- 2.40.0