summaryrefslogtreecommitdiff
path: root/libjava/prims.cc
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-03-15 22:03:19 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-03-15 22:03:19 +0000
commit648fb7469753f7d785415f596c2b250c635db9ad (patch)
tree6ff411e4ce4a6ce8717905d98f2d63b7479a6539 /libjava/prims.cc
parent74636a3e7b0c19f83026989b46a3712f7691b320 (diff)
downloadgcc-648fb7469753f7d785415f596c2b250c635db9ad.tar.gz
2000-03-15 Tom Tromey <tromey@cygnus.com>
* java/io/natFileDescriptorWin32.cc (winerr): Now static. * prims.cc (win32_exception_handler): Reformatted. * include/win32-threads.h (_Jv_HaveCondDestroy): New define. (_Jv_HaveMutexDestroy): Likewise. 2000-03-15 Jon Beniston <jb7216@bristol.ac.uk> * java/io/natFileDescriptorWin32.cc: New file. * java/io/natFileWin32.cc: New file. * java/net/natInetAddress.cc: Added conditional inclusion of Windows / Winsock headers. * java/net/natPlainDatagramSocketImpl.cc: Added conditional inclusion of Windows / Winsock headers. * java/net/natPlainSocketImpl.cc: Added conditional inclusion of Windows / Winsock headers. * include/win32-signal.h: New file. * include/win32-threads.h: New file. * win32-threads.cc: New file. * exception.cc (win32_get_restart_frame): New function. * prims.cc (win32_exception_handler): New function. (main_init) Performs Winsock initialisation. (main_init) Installs exeception handler. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32567 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r--libjava/prims.cc49
1 files changed, 48 insertions, 1 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc
index 8c08f86c2a3..81668a86c88 100644
--- a/libjava/prims.cc
+++ b/libjava/prims.cc
@@ -10,6 +10,15 @@ details. */
#include <config.h>
+#ifdef USE_WIN32_SIGNALLING
+#include <windows.h>
+#endif /* USE_WIN32_SIGNALLING */
+
+#ifdef USE_WINSOCK
+#undef __INSIDE_CYGWIN__
+#include <winsock.h>
+#endif /* USE_WINSOCK */
+
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
@@ -589,6 +598,32 @@ _Jv_ThisExecutable (const char *name)
}
}
+#ifdef USE_WIN32_SIGNALLING
+
+extern "C" int* win32_get_restart_frame (void *);
+
+LONG CALLBACK
+win32_exception_handler (LPEXCEPTION_POINTERS e)
+{
+ int* setjmp_buf;
+ if (e->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
+ setjmp_buf = win32_get_restart_frame (nullp);
+ else if (e->ExceptionRecord->ExceptionCode == EXCEPTION_INT_DIVIDE_BY_ZERO)
+ setjmp_buf = win32_get_restart_frame (arithexception);
+ else
+ return EXCEPTION_CONTINUE_SEARCH;
+
+ e->ContextRecord->Ebp = setjmp_buf[0];
+ // FIXME: Why does i386-signal.h increment the PC here, do we need to do it?
+ e->ContextRecord->Eip = setjmp_buf[1];
+ // FIXME: Is this the stack pointer? Do we need it?
+ e->ContextRecord->Esp = setjmp_buf[2];
+
+ return EXCEPTION_CONTINUE_EXECUTION;
+}
+
+#endif
+
static void
main_init ()
{
@@ -606,12 +641,24 @@ main_init ()
LTDL_SET_PRELOADED_SYMBOLS ();
#endif
- // FIXME: we only want this on POSIX systems.
+#ifdef USE_WINSOCK
+ // Initialise winsock for networking
+ WSADATA data;
+ if (WSAStartup (MAKEWORD (1, 1), &data))
+ MessageBox (NULL, "Error initialising winsock library.", "Error", MB_OK | MB_ICONEXCLAMATION);
+#endif /* USE_WINSOCK */
+
+#ifdef USE_WIN32_SIGNALLING
+ // Install exception handler
+ SetUnhandledExceptionFilter (win32_exception_handler);
+#else
+ // We only want this on POSIX systems.
struct sigaction act;
act.sa_handler = SIG_IGN;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
sigaction (SIGPIPE, &act, NULL);
+#endif /* USE_WIN32_SIGNALLING */
_Jv_JNI_Init ();
}