From: Ivan Maidanski Date: Thu, 30 Mar 2017 21:11:04 +0000 (+0300) Subject: Fix gc.h compliance to strict ANSI (pthreads) X-Git-Tag: v7.4.6~139 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41d537144522bc6cbd2bff3289bc6e369c7245c9;p=gc Fix gc.h compliance to strict ANSI (pthreads) (Cherry-pick commits 1554297, 0970110 from 'master' branch.) If -std=cXX option is passed to gcc/clang then sigset_t is undefined, thus GC_pthread_sigmask declaration should be omitted. However, this symbol should be available during GC source code audit by cppcheck. * include/gc_pthread_redirects.h [!GC_NO_PTHREAD_SIGMASK] (GC_pthread_sigmask): Declare only if GC_PTHREAD_SIGMASK_NEEDED or _POSIX_C_SOURCE >= 199506 or _XOPEN_SOURCE >= 500, or _BSD_SOURCE or _GNU_SOURCE. * tests/test.c [CPPCHECK && !_GNU_SOURCE && GC_PTHREADS] (_GNU_SOURCE): Likewise. --- diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index 0d571e91..534d6c90 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -39,9 +39,13 @@ # endif /* !GC_NO_DLOPEN */ # ifndef GC_NO_PTHREAD_SIGMASK -# include - GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *, - sigset_t * /* oset */); +# 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 6ca22e05..37c65ccc 100644 --- a/tests/test.c +++ b/tests/test.c @@ -28,6 +28,9 @@ # define GC_DEBUG #endif +#if defined(CPPCHECK) && defined(GC_PTHREADS) && !defined(_GNU_SOURCE) +# define _GNU_SOURCE 1 +#endif #undef GC_NO_THREAD_REDIRECTS #include "gc.h"