X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fnocrash.m4;h=60aad952956a8543599133a0865a6fab0f7ed16c;hb=f55bb4f13cc783805ac42d4ecf6e75999902b879;hp=1f92c26d909ab08cb3c29d3b09aa267407934037;hpb=b908e23481452834d238421cfa4dc3ec396ea62b;p=gnulib.git diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 index 1f92c26d9..60aad9529 100644 --- a/m4/nocrash.m4 +++ b/m4/nocrash.m4 @@ -1,12 +1,12 @@ -# nocrash.m4 serial 1 -dnl Copyright (C) 2005 Free Software Foundation, Inc. +# 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, dnl with or without modifications, as long as this notice is preserved. dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini. -AC_PREREQ(2.13) +AC_PREREQ([2.13]) dnl Expands to some code for use in .c programs that will cause the configure dnl test to exit instead of crashing. This is useful to avoid triggering @@ -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