(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.
# 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 */);
+# 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
# 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"