Browse Source

Reworked SIGALRM handling to work under windows

Former-commit-id: 9073af2e28
tempestpy_adaptions
PBerger 11 years ago
parent
commit
fcc17b800b
  1. 2
      src/storm.cpp
  2. 27
      src/utility/ErrorHandling.h

2
src/storm.cpp

@ -408,7 +408,7 @@ int main(const int argc, const char* argv[]) {
storm::settings::Settings* s = storm::settings::Settings::getInstance();
uint_fast64_t timeout = s->getOptionByLongName("timeout").getArgument(0).getValueAsUnsignedInteger();
if (timeout != 0) {
alarm(timeout);
stormSetAlarm(timeout);
}
// Now, the settings are received and the specified model is parsed. The actual actions taken depend on whether

27
src/utility/ErrorHandling.h

@ -17,9 +17,7 @@
*
* @param symbol The name of the symbol that is to be demangled.
*/
std::string demangle(char const* symbol) {
int status;
std::string demangle(char const* symbol) {
// Attention: sscanf format strings rely on the size being 128.
char temp[128];
@ -28,6 +26,7 @@ std::string demangle(char const* symbol) {
#ifdef WINDOWS
scanResult = sscanf_s(symbol, "%*[^(]%*[^_]%127[^)+]", temp, sizeof(temp));
#else
int status;
scanResult = sscanf(symbol, "%*[^(]%*[^_]%127[^)+]", temp);
#endif
@ -150,5 +149,27 @@ void installSignalHandler() {
#endif
}
#ifdef WINDOWS
// This defines a placeholder-function to be called from SetTimer() which in turn calls the Signal Handler
VOID CALLBACK stormWindowsSetTimerCallBack(
HWND hwnd, // handle to window for timer messages
UINT message, // WM_TIMER message
UINT_PTR idEvent,
DWORD dwTime) // current system time
{
// I believe that SIGALRM translates to 14, but it could be wrong!
signalHandler(14);
}
#endif
void stormSetAlarm(uint_fast64_t timeoutSeconds) {
#ifndef WINDOWS
alarm(timeout);
#else
// This needs more research (http://msdn.microsoft.com/en-us/library/windows/desktop/ms644906(v=vs.85).aspx)
UINT_PTR retVal = SetTimer(NULL, 0, static_cast<UINT>(timeoutSeconds * 1000), static_cast<TIMERPROC>(&stormWindowsSetTimerCallBack));
#endif
}
#endif /* ERRORHANDLING_H */
Loading…
Cancel
Save