summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorAleksas Pantechovskis <alex.pantec@gmail.com>2016-03-26 14:36:40 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-03-29 15:54:39 +0000
commit97858ca008fd8cf405e52795c8db415ef6c5afb3 (patch)
tree8a98170fec21faeafdf7b8fd0f1ad01ba7d4f7cf /sal
parent35313dead30ed869e9ebd5dbd8950bc5f6c714d6 (diff)
tdf#93548 Refactor sal signal to reduce code duplication
Change-Id: Iff331a48fadc23da8b24f9ca3a841000313a03dd Reviewed-on: https://gerrit.libreoffice.org/23477 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/Library_sal.mk1
-rw-r--r--sal/inc/internal/signalshared.hxx47
-rw-r--r--sal/osl/all/signalshared.cxx177
-rw-r--r--sal/osl/unx/signal.cxx209
-rw-r--r--sal/osl/w32/signal.cxx207
5 files changed, 302 insertions, 339 deletions
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index ed2e91459874..2eb4cb2e141e 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
sal/osl/all/filepath \
sal/osl/all/loadmodulerelative \
sal/osl/all/log \
+ sal/osl/all/signalshared \
sal/osl/all/utility \
sal/rtl/alloc_arena \
sal/rtl/alloc_cache \
diff --git a/sal/inc/internal/signalshared.hxx b/sal/inc/internal/signalshared.hxx
new file mode 100644
index 000000000000..07f997626e89
--- /dev/null
+++ b/sal/inc/internal/signalshared.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SAL_INC_INTERNAL_SIGNALSHARED_HXX
+#define INCLUDED_SAL_INC_INTERNAL_SIGNALSHARED_HXX
+
+#include <sal/config.h>
+#include <osl/signal.h>
+#include <osl/mutex.h>
+
+struct oslSignalHandlerImpl
+{
+ oslSignalHandlerFunction Handler;
+ void* pData;
+ oslSignalHandlerImpl* pNext;
+};
+
+typedef void (*ErrorReportingChangedHandler)(bool);
+
+extern bool bErrorReportingEnabled;
+extern bool bInitSignal;
+
+void setErrorReportingChangedHandler(ErrorReportingChangedHandler handler);
+
+oslSignalAction callSignalHandler(oslSignalInfo* pInfo);
+
+// platform-specific functions that need to be implemented
+bool onInitSignal();
+bool onDeInitSignal();
+
+#endif
+
diff --git a/sal/osl/all/signalshared.cxx b/sal/osl/all/signalshared.cxx
new file mode 100644
index 000000000000..fcafacdb78bf
--- /dev/null
+++ b/sal/osl/all/signalshared.cxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <internal/signalshared.hxx>
+
+#include <osl/diagnose.h>
+
+bool bErrorReportingEnabled = true;
+bool bInitSignal = false;
+
+namespace
+{
+oslSignalHandlerImpl* SignalList;
+oslMutex SignalListMutex;
+
+ErrorReportingChangedHandler errorReportingChangedHandler;
+
+bool initSignal()
+{
+ SignalListMutex = osl_createMutex();
+
+ return onInitSignal();
+}
+
+bool deInitSignal()
+{
+ bool bRet = onDeInitSignal();
+
+ osl_destroyMutex(SignalListMutex);
+
+ return bRet;
+}
+
+}
+
+void setErrorReportingChangedHandler(ErrorReportingChangedHandler handler)
+{
+ errorReportingChangedHandler = handler;
+}
+
+oslSignalAction callSignalHandler(oslSignalInfo* pInfo)
+{
+ oslSignalHandlerImpl* pHandler = SignalList;
+ oslSignalAction Action = osl_Signal_ActCallNextHdl;
+
+ while (pHandler != nullptr)
+ {
+ if ((Action = pHandler->Handler(pHandler->pData, pInfo))
+ != osl_Signal_ActCallNextHdl)
+ break;
+
+ pHandler = pHandler->pNext;
+ }
+
+ return Action;
+}
+
+oslSignalHandler SAL_CALL osl_addSignalHandler(oslSignalHandlerFunction handler, void* pData)
+{
+ OSL_ASSERT(handler != nullptr);
+ if (handler == nullptr)
+ {
+ return nullptr;
+ }
+
+ if (! bInitSignal)
+ bInitSignal = initSignal();
+
+ oslSignalHandlerImpl* pHandler = static_cast<oslSignalHandlerImpl*>(calloc(1, sizeof(oslSignalHandlerImpl)));
+
+ if (pHandler != nullptr)
+ {
+ pHandler->Handler = handler;
+ pHandler->pData = pData;
+
+ osl_acquireMutex(SignalListMutex);
+
+ pHandler->pNext = SignalList;
+ SignalList = pHandler;
+
+ osl_releaseMutex(SignalListMutex);
+
+ return pHandler;
+ }
+
+ return nullptr;
+}
+
+sal_Bool SAL_CALL osl_removeSignalHandler(oslSignalHandler handler)
+{
+ OSL_ASSERT(handler != nullptr);
+
+ if (! bInitSignal)
+ bInitSignal = initSignal();
+
+ osl_acquireMutex(SignalListMutex);
+
+ oslSignalHandlerImpl* pHandler = SignalList;
+ oslSignalHandlerImpl* pPrevious = nullptr;
+
+ while (pHandler != nullptr)
+ {
+ if (pHandler == handler)
+ {
+ if (pPrevious)
+ pPrevious->pNext = pHandler->pNext;
+ else
+ SignalList = pHandler->pNext;
+
+ osl_releaseMutex(SignalListMutex);
+
+ if (SignalList == nullptr)
+ bInitSignal = deInitSignal();
+
+ free(pHandler);
+
+ return sal_True;
+ }
+
+ pPrevious = pHandler;
+ pHandler = pHandler->pNext;
+ }
+
+ osl_releaseMutex(SignalListMutex);
+
+ return sal_False;
+}
+
+oslSignalAction SAL_CALL osl_raiseSignal(sal_Int32 userSignal, void* userData)
+{
+ if (! bInitSignal)
+ bInitSignal = initSignal();
+
+ osl_acquireMutex(SignalListMutex);
+
+ oslSignalInfo info;
+ info.Signal = osl_Signal_User;
+ info.UserSignal = userSignal;
+ info.UserData = userData;
+
+ oslSignalAction action = callSignalHandler(&info);
+
+ osl_releaseMutex(SignalListMutex);
+
+ return action;
+}
+
+sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable )
+{
+ bool bOld = bErrorReportingEnabled;
+ bErrorReportingEnabled = bEnable;
+
+ if (errorReportingChangedHandler)
+ errorReportingChangedHandler(bEnable);
+
+ return bOld;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx
index d5230f89135f..9f44d31d078b 100644
--- a/sal/osl/unx/signal.cxx
+++ b/sal/osl/unx/signal.cxx
@@ -19,6 +19,8 @@
#include <sal/config.h>
+#include <internal/signalshared.hxx>
+
#include <config_features.h>
/* system headers */
@@ -51,7 +53,6 @@
#endif
#include <osl/diagnose.h>
-#include <osl/mutex.h>
#include <osl/signal.h>
#include <osl/process.h>
#include <osl/thread.h>
@@ -60,7 +61,6 @@
#include <rtl/digest.h>
#include "file_path_helper.hxx"
-
#define ACT_IGNORE 1
#define ACT_EXIT 2
#define ACT_SYSTEM 3
@@ -71,14 +71,9 @@
#include <valgrind/memcheck.h>
#endif
-struct oslSignalHandlerImpl
+namespace
{
- oslSignalHandlerFunction Handler;
- void* pData;
- oslSignalHandlerImpl * pNext;
-};
-
-static struct SignalAction
+struct SignalAction
{
int Signal;
int Action;
@@ -138,19 +133,15 @@ what looks like a bug in the new handler*/
};
const int NoSignals = sizeof(Signals) / sizeof(struct SignalAction);
-static bool bErrorReportingEnabled = true;
-static bool bInitSignal = false;
-static oslMutex SignalListMutex;
-static oslSignalHandlerImpl* SignalList;
-static bool bSetSEGVHandler = false;
-static bool bSetWINCHHandler = false;
-static bool bSetILLHandler = false;
+bool bSetSEGVHandler = false;
+bool bSetWINCHHandler = false;
+bool bSetILLHandler = false;
-static void SignalHandlerFunction(int);
+void signalHandlerFunction(int);
-static void getExecutableName_Impl (rtl_String ** ppstrProgName)
+void getExecutableName_Impl (rtl_String ** ppstrProgName)
{
- rtl_uString * ustrProgFile = nullptr;
+ rtl_uString* ustrProgFile = nullptr;
osl_getExecutableFile (&ustrProgFile);
if (ustrProgFile)
{
@@ -169,10 +160,10 @@ static void getExecutableName_Impl (rtl_String ** ppstrProgName)
}
}
-static bool is_soffice_Impl()
+bool is_soffice_Impl()
{
- sal_Int32 idx = -1;
- rtl_String * strProgName = nullptr;
+ sal_Int32 idx = -1;
+ rtl_String* strProgName = nullptr;
getExecutableName_Impl (&strProgName);
if (strProgName)
@@ -183,13 +174,10 @@ static bool is_soffice_Impl()
return (idx != -1);
}
-static bool InitSignal()
-{
- int i;
- struct sigaction act;
- struct sigaction oact;
- sigset_t unset;
+}
+bool onInitSignal()
+{
if (is_soffice_Impl())
{
// WORKAROUND FOR SEGV HANDLER CONFLICT
@@ -213,15 +201,14 @@ static bool InitSignal()
bSetSEGVHandler = bSetWINCHHandler = bSetILLHandler = false;
#endif
- SignalListMutex = osl_createMutex();
-
- act.sa_handler = SignalHandlerFunction;
+ struct sigaction act;
+ act.sa_handler = signalHandlerFunction;
act.sa_flags = SA_RESTART;
sigfillset(&(act.sa_mask));
/* Initialize the rest of the signals */
- for (i = 0; i < NoSignals; ++i)
+ for (int i = 0; i < NoSignals; ++i)
{
#if defined HAVE_VALGRIND_HEADERS
if (Signals[i].Signal == SIGUSR2 && RUNNING_ON_VALGRIND)
@@ -243,6 +230,7 @@ static bool InitSignal()
ign.sa_flags = 0;
sigemptyset(&ign.sa_mask);
+ struct sigaction oact;
if (sigaction(Signals[i].Signal, &ign, &oact) == 0)
Signals[i].Handler = oact.sa_handler;
else
@@ -250,6 +238,7 @@ static bool InitSignal()
}
else
{
+ struct sigaction oact;
if (sigaction(Signals[i].Signal, &act, &oact) == 0)
Signals[i].Handler = oact.sa_handler;
else
@@ -263,6 +252,7 @@ static bool InitSignal()
crash soffice re-execs itself from within the signal handler, so the
second soffice would have the guilty signal blocked and would freeze upon
encountering a similar crash again): */
+ sigset_t unset;
if (sigemptyset(&unset) < 0 ||
pthread_sigmask(SIG_SETMASK, &unset, nullptr) < 0)
{
@@ -272,16 +262,15 @@ static bool InitSignal()
return true;
}
-static bool DeInitSignal()
+bool onDeInitSignal()
{
- int i;
struct sigaction act;
act.sa_flags = 0;
sigemptyset(&(act.sa_mask));
/* Initialize the rest of the signals */
- for (i = NoSignals - 1; i >= 0; i--)
+ for (int i = NoSignals - 1; i >= 0; i--)
if (Signals[i].Action != ACT_SYSTEM)
{
act.sa_handler = Signals[i].Handler;
@@ -289,12 +278,12 @@ static bool DeInitSignal()
sigaction(Signals[i].Signal, &act, nullptr);
}
- osl_destroyMutex(SignalListMutex);
-
return false;
}
-static void PrintStack( int sig )
+namespace
+{
+void printStack(int sig)
{
#ifdef INCLUDE_BACKTRACE
void *buffer[MAX_STACK_FRAMES];
@@ -316,31 +305,13 @@ static void PrintStack( int sig )
#endif
}
-static oslSignalAction CallSignalHandler(oslSignalInfo *pInfo)
-{
- oslSignalHandlerImpl* pHandler = SignalList;
- oslSignalAction Action = osl_Signal_ActCallNextHdl;
-
- while (pHandler != nullptr)
- {
- if ((Action = pHandler->Handler(pHandler->pData, pInfo))
- != osl_Signal_ActCallNextHdl)
- break;
-
- pHandler = pHandler->pNext;
- }
-
- return Action;
-}
-
-void CallSystemHandler(int Signal)
+void callSystemHandler(int signal)
{
int i;
- struct sigaction act;
for (i = 0; i < NoSignals; i++)
{
- if (Signals[i].Signal == Signal)
+ if (Signals[i].Signal == signal)
break;
}
@@ -359,11 +330,12 @@ void CallSystemHandler(int Signal)
break;
case ACT_ABORT: /* terminate witch core dump */
+ struct sigaction act;
act.sa_handler = SIG_DFL;
act.sa_flags = 0;
sigemptyset(&(act.sa_mask));
sigaction(SIGABRT, &act, nullptr);
- PrintStack( Signal );
+ printStack( signal );
abort();
break;
@@ -375,7 +347,7 @@ void CallSystemHandler(int Signal)
}
}
else
- (*Signals[i].Handler)(Signal);
+ (*Signals[i].Handler)(signal);
}
}
@@ -399,15 +371,14 @@ static void DUMPCURRENTALLOCS()
}
#endif
-void SignalHandlerFunction(int Signal)
+void signalHandlerFunction(int signal)
{
- oslSignalInfo Info;
- struct sigaction act;
+ oslSignalInfo Info;
- Info.UserSignal = Signal;
+ Info.UserSignal = signal;
Info.UserData = nullptr;
- switch (Signal)
+ switch (signal)
{
case SIGBUS:
case SIGILL:
@@ -446,18 +417,19 @@ void SignalHandlerFunction(int Signal)
break;
}
- switch (CallSignalHandler(&Info))
+ switch (callSignalHandler(&Info))
{
case osl_Signal_ActCallNextHdl:
- CallSystemHandler(Signal);
+ callSystemHandler(signal);
break;
case osl_Signal_ActAbortApp:
+ struct sigaction act;
act.sa_handler = SIG_DFL;
act.sa_flags = 0;
sigemptyset(&(act.sa_mask));
sigaction(SIGABRT, &act, nullptr);
- PrintStack( Signal );
+ printStack( signal );
abort();
break;
@@ -470,107 +442,6 @@ void SignalHandlerFunction(int Signal)
}
}
-oslSignalHandler SAL_CALL osl_addSignalHandler(oslSignalHandlerFunction Handler, void* pData)
-{
- oslSignalHandlerImpl* pHandler;
-
- OSL_ASSERT(Handler != nullptr);
- if ( Handler == nullptr )
- {
- return nullptr;
- }
-
- if (! bInitSignal)
- bInitSignal = InitSignal();
-
- pHandler = static_cast<oslSignalHandlerImpl*>(calloc(1, sizeof(oslSignalHandlerImpl)));
-
- if (pHandler != nullptr)
- {
- pHandler->Handler = Handler;
- pHandler->pData = pData;
-
- osl_acquireMutex(SignalListMutex);
-
- pHandler->pNext = SignalList;
- SignalList = pHandler;
-
- osl_releaseMutex(SignalListMutex);
-
- return (pHandler);
- }
-
- return nullptr;
-}
-
-sal_Bool SAL_CALL osl_removeSignalHandler(oslSignalHandler Handler)
-{
- oslSignalHandlerImpl *pHandler, *pPrevious = nullptr;
-
- OSL_ASSERT(Handler != nullptr);
-
- if (! bInitSignal)
- bInitSignal = InitSignal();
-
- osl_acquireMutex(SignalListMutex);
-
- pHandler = SignalList;
-
- while (pHandler != nullptr)
- {
- if (pHandler == Handler)
- {
- if (pPrevious)
- pPrevious->pNext = pHandler->pNext;
- else
- SignalList = pHandler->pNext;
-
- osl_releaseMutex(SignalListMutex);
-
- if (SignalList == nullptr)
- bInitSignal = DeInitSignal();
-
- free(pHandler);
-
- return sal_True;
- }
-
- pPrevious = pHandler;
- pHandler = pHandler->pNext;
- }
-
- osl_releaseMutex(SignalListMutex);
-
- return sal_False;
-}
-
-oslSignalAction SAL_CALL osl_raiseSignal(sal_Int32 UserSignal, void* UserData)
-{
- oslSignalInfo Info;
- oslSignalAction Action;
-
- if (! bInitSignal)
- bInitSignal = InitSignal();
-
- osl_acquireMutex(SignalListMutex);
-
- Info.Signal = osl_Signal_User;
- Info.UserSignal = UserSignal;
- Info.UserData = UserData;
-
- Action = CallSignalHandler(&Info);
-
- osl_releaseMutex(SignalListMutex);
-
- return (Action);
-}
-
-sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable )
-{
- bool bOld = bErrorReportingEnabled;
- bErrorReportingEnabled = bEnable;
-
- return bOld;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx
index 69c56838f3bb..3c7c47b35643 100644
--- a/sal/osl/w32/signal.cxx
+++ b/sal/osl/w32/signal.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <internal/signalshared.hxx>
+
/* system headers */
#include "system.h"
#include <tchar.h>
@@ -25,7 +29,6 @@
#include "path_helper.hxx"
#include <osl/diagnose.h>
-#include <osl/mutex.h>
#include <osl/signal.h>
#ifndef __MINGW32__
#include <DbgHelp.h>
@@ -36,80 +39,49 @@
#include <eh.h>
#include <stdexcept>
-typedef struct _oslSignalHandlerImpl
+namespace
{
- oslSignalHandlerFunction Handler;
- void* pData;
- struct _oslSignalHandlerImpl* pNext;
-} oslSignalHandlerImpl;
+long WINAPI signalHandlerFunction(LPEXCEPTION_POINTERS lpEP);
-static sal_Bool bErrorReportingEnabled = sal_True;
-static sal_Bool bInitSignal = sal_False;
-static oslMutex SignalListMutex;
-static oslSignalHandlerImpl* SignalList;
-
-static long WINAPI SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP);
+void onErrorReportingChanged(bool bEnable);
+}
-static sal_Bool InitSignal()
+bool onInitSignal()
{
- HMODULE hFaultRep;
+ SetUnhandledExceptionFilter(signalHandlerFunction);
- SignalListMutex = osl_createMutex();
-
- SetUnhandledExceptionFilter(SignalHandlerFunction);
-
- hFaultRep = LoadLibrary( "faultrep.dll" );
+ HMODULE hFaultRep = LoadLibrary( "faultrep.dll" );
if ( hFaultRep )
{
- pfn_ADDEREXCLUDEDAPPLICATIONW pfn = (pfn_ADDEREXCLUDEDAPPLICATIONW)GetProcAddress( hFaultRep, "AddERExcludedApplicationW" );
+ pfn_ADDEREXCLUDEDAPPLICATIONW pfn = (pfn_ADDEREXCLUDEDAPPLICATIONW)GetProcAddress( hFaultRep, "AddERExcludedApplicationW" );
if ( pfn )
pfn( L"SOFFICE.EXE" );
FreeLibrary( hFaultRep );
}
- return sal_True;
+ return true;
}
-static sal_Bool DeInitSignal()
+bool onDeInitSignal()
{
- SetUnhandledExceptionFilter(NULL);
+ SetUnhandledExceptionFilter(nullptr);
- osl_destroyMutex(SignalListMutex);
-
- return sal_False;
+ return false;
}
-static oslSignalAction CallSignalHandler(oslSignalInfo *pInfo)
+namespace
{
- oslSignalHandlerImpl* pHandler = SignalList;
- oslSignalAction Action = osl_Signal_ActCallNextHdl;
-
- while (pHandler != NULL)
- {
- if ((Action = pHandler->Handler(pHandler->pData, pInfo)) != osl_Signal_ActCallNextHdl)
- break;
-
- pHandler = pHandler->pNext;
- }
-
- return Action;
-}
-
-/*****************************************************************************/
-/* SignalHandlerFunction */
-/*****************************************************************************/
-
/* magic Microsoft C++ compiler exception constant */
#define EXCEPTION_MSC_CPP_EXCEPTION 0xe06d7363
-static long WINAPI SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
+long WINAPI signalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
{
- static sal_Bool bNested = sal_False;
- oslSignalInfo Info;
- oslSignalAction Action;
+ static bool bNested = false;
- Info.UserSignal = lpEP->ExceptionRecord->ExceptionCode;
- Info.UserData = NULL;
+ oslSignalInfo info;
+
+ info.UserSignal = lpEP->ExceptionRecord->ExceptionCode;
+ info.UserData = nullptr;
switch (lpEP->ExceptionRecord->ExceptionCode)
{
@@ -118,35 +90,37 @@ static long WINAPI SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
*/
case EXCEPTION_MSC_CPP_EXCEPTION:
case EXCEPTION_ACCESS_VIOLATION:
- Info.Signal = osl_Signal_AccessViolation;
+ info.Signal = osl_Signal_AccessViolation;
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
- Info.Signal = osl_Signal_IntegerDivideByZero;
+ info.Signal = osl_Signal_IntegerDivideByZero;
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- Info.Signal = osl_Signal_FloatDivideByZero;
+ info.Signal = osl_Signal_FloatDivideByZero;
break;
case EXCEPTION_BREAKPOINT:
- Info.Signal = osl_Signal_DebugBreak;
+ info.Signal = osl_Signal_DebugBreak;
break;
default:
- Info.Signal = osl_Signal_System;
+ info.Signal = osl_Signal_System;
break;
}
+ oslSignalAction action;
+
if ( !bNested )
{
- bNested = sal_True;
- Action = CallSignalHandler(&Info);
+ bNested = true;
+ action = callSignalHandler(&info);
}
else
- Action = osl_Signal_ActKillApp;
+ action = osl_Signal_ActKillApp;
- switch ( Action )
+ switch ( action )
{
case osl_Signal_ActCallNextHdl:
return EXCEPTION_CONTINUE_SEARCH;
@@ -165,113 +139,9 @@ static long WINAPI SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
return EXCEPTION_CONTINUE_EXECUTION;
}
-/*****************************************************************************/
-/* osl_addSignalHandler */
-/*****************************************************************************/
-oslSignalHandler SAL_CALL osl_addSignalHandler(oslSignalHandlerFunction Handler, void* pData)
-{
- oslSignalHandlerImpl* pHandler;
-
- OSL_ASSERT(Handler != NULL);
-
- if (! bInitSignal)
- bInitSignal = InitSignal();
-
- pHandler = reinterpret_cast< oslSignalHandlerImpl* >( calloc( 1, sizeof(oslSignalHandlerImpl) ) );
-
- if (pHandler != NULL)
- {
- pHandler->Handler = Handler;
- pHandler->pData = pData;
-
- osl_acquireMutex(SignalListMutex);
-
- pHandler->pNext = SignalList;
- SignalList = pHandler;
-
- osl_releaseMutex(SignalListMutex);
-
- return pHandler;
- }
-
- return NULL;
-}
-
-/*****************************************************************************/
-/* osl_removeSignalHandler */
-/*****************************************************************************/
-sal_Bool SAL_CALL osl_removeSignalHandler(oslSignalHandler Handler)
-{
- oslSignalHandlerImpl *pHandler, *pPrevious = NULL;
-
- OSL_ASSERT(Handler != NULL);
-
- if (! bInitSignal)
- bInitSignal = InitSignal();
-
- osl_acquireMutex(SignalListMutex);
-
- pHandler = SignalList;
-
- while (pHandler != NULL)
- {
- if (pHandler == Handler)
- {
- if (pPrevious)
- pPrevious->pNext = pHandler->pNext;
- else
- SignalList = pHandler->pNext;
-
- osl_releaseMutex(SignalListMutex);
-
- if (SignalList == NULL)
- bInitSignal = DeInitSignal();
-
- free(pHandler);
-
- return sal_True;
- }
-
- pPrevious = pHandler;
- pHandler = pHandler->pNext;
- }
-
- osl_releaseMutex(SignalListMutex);
-
- return sal_False;
-}
-
-/*****************************************************************************/
-/* osl_raiseSignal */
-/*****************************************************************************/
-oslSignalAction SAL_CALL osl_raiseSignal(sal_Int32 UserSignal, void* UserData)
-{
- oslSignalInfo Info;
- oslSignalAction Action;
-
- if (! bInitSignal)
- bInitSignal = InitSignal();
-
- osl_acquireMutex(SignalListMutex);
-
- Info.Signal = osl_Signal_User;
- Info.UserSignal = UserSignal;
- Info.UserData = UserData;
-
- Action = CallSignalHandler(&Info);
-
- osl_releaseMutex(SignalListMutex);
-
- return Action;
-}
-
-/*****************************************************************************/
-/* osl_setErrorReporting */
-/*****************************************************************************/
-
void win_seh_translator( unsigned nSEHCode, _EXCEPTION_POINTERS* /* pExcPtrs */)
{
- const char* pSEHName = NULL;
+ const char* pSEHName = nullptr;
switch( nSEHCode)
{
case EXCEPTION_ACCESS_VIOLATION: pSEHName = "SEH Exception: ACCESS VIOLATION"; break;
@@ -304,11 +174,8 @@ void win_seh_translator( unsigned nSEHCode, _EXCEPTION_POINTERS* /* pExcPtrs */)
throw std::runtime_error( pSEHName);
}
-sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable )
+void onErrorReportingChanged(bool bEnable)
{
- sal_Bool bOld = bErrorReportingEnabled;
- bErrorReportingEnabled = bEnable;
-
#if defined _MSC_VER
if( !bEnable) // if the crash reporter is disabled
{
@@ -316,8 +183,8 @@ sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable )
_set_se_translator( win_seh_translator);
}
#endif
+}
- return bOld;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */