bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nocrash: support Windows


From: Bruno Haible
Subject: nocrash: support Windows
Date: Sat, 10 Sep 2011 20:55:47 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

This patch add support for native Windows to the 'nocrash' module.


2011-09-10  Bruno Haible  <address@hidden>

        nocrash: Add support for native Windows.
        * m4/nocrash.m4 (GL_NOCRASH): Avoid a crash also on native Windows.

--- m4/nocrash.m4.orig  Sat Sep 10 20:52:11 2011
+++ m4/nocrash.m4       Sat Sep 10 19:59:22 2011
@@ -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 @@
     }
   }
 }
+#elif (defined _WIN32 || 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
 /* Avoid a crash on POSIX systems.  */
 #include <signal.h>

-- 
In memoriam Sergei Tretyakov <http://en.wikipedia.org/wiki/Sergei_Tretyakov>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]