[llvm] r270278 - Add a configure-time check for the existence of sigaltstack. It seems that some

Richard Smith via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 14:26:00 PDT 2016


Author: rsmith
Date: Fri May 20 16:26:00 2016
New Revision: 270278

URL: http://llvm.org/viewvc/llvm-project?rev=270278&view=rev
Log:
Add a configure-time check for the existence of sigaltstack. It seems that some
systems provide a <signal.h> that doesn't declare it.

Modified:
    llvm/trunk/cmake/config-ix.cmake
    llvm/trunk/include/llvm/Config/config.h.cmake
    llvm/trunk/lib/Support/Unix/Signals.inc

Modified: llvm/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=270278&r1=270277&r2=270278&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Fri May 20 16:26:00 2016
@@ -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()

Modified: llvm/trunk/include/llvm/Config/config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=270278&r1=270277&r2=270278&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Config/config.h.cmake (original)
+++ llvm/trunk/include/llvm/Config/config.h.cmake Fri May 20 16:26:00 2016
@@ -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}
 

Modified: llvm/trunk/lib/Support/Unix/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=270278&r1=270277&r2=270278&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Signals.inc (original)
+++ llvm/trunk/lib/Support/Unix/Signals.inc Fri May 20 16:26:00 2016
@@ -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




More information about the llvm-commits mailing list