version 1.1.1.1, 2012/05/29 09:29:44
|
version 1.1.1.2, 2021/03/17 13:38:46
|
Line 1
|
Line 1
|
# nocrash.m4 serial 2 | # nocrash.m4 serial 5 |
dnl Copyright (C) 2005, 2009-2011 Free Software Foundation, Inc. | dnl Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc. |
dnl This file is free software; the Free Software Foundation |
dnl This file is free software; the Free Software Foundation |
dnl gives unlimited permission to copy and/or distribute it, |
dnl gives unlimited permission to copy and/or distribute it, |
dnl with or without modifications, as long as this notice is preserved. |
dnl with or without modifications, as long as this notice is preserved. |
Line 18 dnl int main() { nocrash_init(); ... }
|
Line 18 dnl int main() { nocrash_init(); ... }
|
AC_DEFUN([GL_NOCRASH],[[ |
AC_DEFUN([GL_NOCRASH],[[ |
#include <stdlib.h> |
#include <stdlib.h> |
#if defined __MACH__ && defined __APPLE__ |
#if defined __MACH__ && defined __APPLE__ |
/* Avoid a crash on MacOS X. */ | /* Avoid a crash on Mac OS X. */ |
#include <mach/mach.h> |
#include <mach/mach.h> |
#include <mach/mach_error.h> |
#include <mach/mach_error.h> |
#include <mach/thread_status.h> |
#include <mach/thread_status.h> |
Line 79 nocrash_init (void)
|
Line 79 nocrash_init (void)
|
} |
} |
} |
} |
} |
} |
|
#elif defined _WIN32 && ! defined __CYGWIN__ |
|
/* Avoid a crash on native Windows. */ |
|
#define WIN32_LEAN_AND_MEAN |
|
#include <windows.h> |
|
#include <winerror.h> |
|
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 |
#else |
/* Avoid a crash on POSIX systems. */ |
/* Avoid a crash on POSIX systems. */ |
#include <signal.h> |
#include <signal.h> |
|
#include <unistd.h> |
/* A POSIX signal handler. */ |
/* A POSIX signal handler. */ |
static void |
static void |
exception_handler (int sig) |
exception_handler (int sig) |
{ |
{ |
exit (1); | _exit (1); |
} |
} |
static void |
static void |
nocrash_init (void) |
nocrash_init (void) |