From 9a5654c9d319013848ccfb6c4f10d74a828b1ef5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 10 Sep 2011 20:54:24 +0200 Subject: [PATCH] nocrash: Add support for native Windows. * m4/nocrash.m4 (GL_NOCRASH): Avoid a crash also on native Windows. --- ChangeLog | 5 +++++ m4/nocrash.m4 | 30 +++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 42da00811..2f853ce27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-09-10 Bruno Haible + + nocrash: Add support for native Windows. + * m4/nocrash.m4 (GL_NOCRASH): Avoid a crash also on native Windows. + 2011-09-10 Michael Goffioul (tiny change) Bruno Haible diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 index 0cc0d53eb..60aad9529 100644 --- a/m4/nocrash.m4 +++ b/m4/nocrash.m4 @@ -1,4 +1,4 @@ -# nocrash.m4 serial 2 +# nocrash.m4 serial 3 dnl Copyright (C) 2005, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -79,6 +79,34 @@ nocrash_init (void) } } } +#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} #else /* Avoid a crash on POSIX systems. */ #include -- 2.11.0