Fix 'implicit declaration of pthread_sigmask' compiler warning
authorIvan Maidanski <ivmai@mail.ru>
Fri, 31 Mar 2017 15:46:43 +0000 (18:46 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 31 Mar 2017 15:53:16 +0000 (18:53 +0300)
(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
tests/test.c

index 4e7964b..8dcf7eb 100644 (file)
     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 <signal.h>
-    GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
-                                  sigset_t * /* oset */);
+# ifndef GC_NO_PTHREAD_SIGMASK
+#   include <signal.h>  /* 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
index c6a9e86..87574aa 100644 (file)
 #  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"