Allow disabling signal handling, turn signal handling off by default.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-10-18 17:18:27 +02:00
parent c445536aed
commit 09bc55ec94
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 9 additions and 2 deletions

View File

@ -7,7 +7,7 @@ std::string ExceptionHandler::_ArbutilsLastException = "";
/// @brief Returns a null-terminated C string to the last exception found.
export const char* Arbutils_C_GetLastException() { return ExceptionHandler::GetLastException(); }
#if !WINDOWS
#if !WINDOWS && SIGNAL_HANDLING
static ArbUt::SignalHandling sh;
/// @brief Sets a callback to a function to run when a signal occurs.
export void Arbutils_C_SetSignalCallback(void (*callback)(const char*)) { sh.SetCallback(callback); }

View File

@ -11,6 +11,7 @@ option(SHARED "Whether we should build a shared library, instead of a static one
option(TESTS "Whether the test executable should be build as well." OFF)
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
option(PRETTYTRACES "Whether full stacktraces should be included. Note that this adds a dependency to libdw." ON)
option(SIGNAL_HANDLING "whether to include signal handling." OFF)
# Set whether we want a static or shared library.
set(LIBTYPE STATIC)
@ -46,6 +47,10 @@ if (NOT WINDOWS AND PRETTYTRACES)
set(LINKS ${LINKS} -ldw)
ADD_DEFINITIONS(-DPRETTYTRACES=1)
endif()
if (SIGNAL_HANDLING)
ADD_DEFINITIONS(-DSIGNAL_HANDLING=1)
endif()
# If we want to link the C and C++ library statically, link those as well.
if (STATICC)
set(LINKS ${LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)

View File

@ -1,6 +1,6 @@
#include "SignalHandling.hpp"
#if !WINDOWS
#if !WINDOWS && SIGNAL_HANDLING
/// \cond SKIP
void (*ArbUt::SignalHandling::_callback)(const char*) = nullptr;
/// \endcond

View File

@ -1,5 +1,6 @@
#ifndef ARBUTILS_SIGNALHANDLING_HPP
#define ARBUTILS_SIGNALHANDLING_HPP
#if SIGNAL_HANDLING
#if PRETTYTRACES && !WINDOWS
#define BACKWARD_HAS_DW 1
#include "../extern/backward.hpp"
@ -176,4 +177,5 @@ namespace ArbUt {
/// @fn ArbUt::SignalHandling::loaded()
/// @brief Whether or not the signal handler is loaded
#endif // SIGNAL_HANDLING
#endif // ARBUTILS_SIGNALHANDLING_HPP