diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-05-20 21:26:00 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-05-20 21:26:00 +0000 |
commit | b074e2826f90a56a99d22c320b75ebb5dd7c6fdf (patch) | |
tree | 1aa69e75c47c822b46f5f455f56fdd32c5f0b5d7 | |
parent | f77c43d1f362f817c7801f48c59b715eae726613 (diff) |
Add a configure-time check for the existence of sigaltstack. It seems that some
systems provide a <signal.h> that doesn't declare it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270278 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-x | cmake/config-ix.cmake | 3 | ||||
-rw-r--r-- | include/llvm/Config/config.h.cmake | 3 | ||||
-rw-r--r-- | lib/Support/Unix/Signals.inc | 6 |
3 files changed, 10 insertions, 2 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index b3f225f0740..7149e13b07e 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -157,6 +157,9 @@ if( HAVE_SETJMP_H ) check_symbol_exists(siglongjmp setjmp.h HAVE_SIGLONGJMP) check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP) endif() +if( HAVE_SIGNAL_H ) + check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK) +endif() if( HAVE_SYS_UIO_H ) check_symbol_exists(writev sys/uio.h HAVE_WRITEV) endif() diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index c876583f037..f6b7d386fd9 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -248,6 +248,9 @@ /* Define if you have the shl_load function. */ #undef HAVE_SHL_LOAD +/* Define to 1 if you have the `sigaltstack' function. */ +#cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK} + /* Define to 1 if you have the `siglongjmp' function. */ #cmakedefine HAVE_SIGLONGJMP ${HAVE_SIGLONGJMP} diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc index cf621c0cf76..5d4a07a0a52 100644 --- a/lib/Support/Unix/Signals.inc +++ b/lib/Support/Unix/Signals.inc @@ -28,8 +28,6 @@ # include <execinfo.h> // For backtrace(). #endif #if HAVE_SIGNAL_H -// FIXME: We unconditionally use symbols from this header below. Do we really -// need a configure-time check for a POSIX-mandated header in lib/Support/Unix? #include <signal.h> #endif #if HAVE_SYS_STAT_H @@ -119,6 +117,7 @@ static void RegisterHandler(int Signal) { ++NumRegisteredSignals; } +#if defined(HAVE_SIGALTSTACK) // Hold onto the old alternate signal stack so that it's not reported as a leak. // We don't make any attempt to remove our alt signal stack if we remove our // signal handlers; that can't be done reliably if someone else is also trying @@ -143,6 +142,9 @@ static void CreateSigAltStack() { if (sigaltstack(&AltStack, &OldAltStack) != 0) free(AltStack.ss_sp); } +#else +static void CreateSigAltStack() {} +#endif static void RegisterHandlers() { // We need to dereference the signals mutex during handler registration so |