X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=m4%2Fnocrash.m4;h=49140074d08596e3388c42fbfd9a27005e3e3ab5;hb=92249085071a973e2c0621b0415b93d2e48bb00d;hp=efbcfa6af837fb04179bda45880611045e32fcda;hpb=dc0ab95dbae38577efebe2283fc9b76e92ef4233;p=debian%2Fgzip diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 index efbcfa6..4914007 100644 --- a/m4/nocrash.m4 +++ b/m4/nocrash.m4 @@ -1,5 +1,5 @@ -# nocrash.m4 serial 2 -dnl Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. +# nocrash.m4 serial 5 +dnl Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -18,7 +18,7 @@ dnl int main() { nocrash_init(); ... } AC_DEFUN([GL_NOCRASH],[[ #include #if defined __MACH__ && defined __APPLE__ -/* Avoid a crash on MacOS X. */ +/* Avoid a crash on Mac OS X. */ #include #include #include @@ -79,14 +79,43 @@ nocrash_init (void) } } } +#elif 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 +#include /* A POSIX signal handler. */ static void exception_handler (int sig) { - exit (1); + _exit (1); } static void nocrash_init (void)