Commit 73272ce6 by Tom Tromey Committed by Tom Tromey

prims.cc (_Jv_CreateJavaVM): Call _Jv_platform_initialize.

	* prims.cc (_Jv_CreateJavaVM): Call _Jv_platform_initialize.
	* win32.cc (win32_exception_handler): Now static.
	* include/win32.h (_Jv_platform_initialize): Declare.
	(win32_exception_handler): Don't declare.
	* java/lang/natSystem.cc (currentTimeMillis): Use
	_Jv_platform_gettimeofday.
	* posix.cc (_Jv_platform_gettimeofday): Renamed.
	(_Jv_select): Use new name.
	(_Jv_platform_initialize): New function.
	* include/posix.h (_Jv_platform_gettimeofday): Renamed from
	_Jv_gettimeofday.
	(_Jv_platform_initialize): Declare.

From-SVN: r49583
parent 225909c3
2002-02-07 Tom Tromey <tromey@redhat.com> 2002-02-07 Tom Tromey <tromey@redhat.com>
* prims.cc (_Jv_CreateJavaVM): Call _Jv_platform_initialize.
* win32.cc (win32_exception_handler): Now static.
* include/win32.h (_Jv_platform_initialize): Declare.
(win32_exception_handler): Don't declare.
* java/lang/natSystem.cc (currentTimeMillis): Use
_Jv_platform_gettimeofday.
* posix.cc (_Jv_platform_gettimeofday): Renamed.
(_Jv_select): Use new name.
(_Jv_platform_initialize): New function.
* include/posix.h (_Jv_platform_gettimeofday): Renamed from
_Jv_gettimeofday.
(_Jv_platform_initialize): Declare.
* configure: Rebuilt. * configure: Rebuilt.
* configure.in: Removed unnecessary parens. * configure.in: Removed unnecessary parens.
......
// posix.h -- Helper functions for POSIX-flavored OSs. // posix.h -- Helper functions for POSIX-flavored OSs.
/* Copyright (C) 2000 Free Software Foundation /* Copyright (C) 2000, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -29,4 +29,5 @@ details. */ ...@@ -29,4 +29,5 @@ details. */
#endif #endif
extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *); extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
extern void _Jv_gettimeofday (struct timeval *); extern void _Jv_platform_gettimeofday (struct timeval *);
extern void _Jv_platform_initialize (void);
...@@ -17,6 +17,6 @@ details. */ ...@@ -17,6 +17,6 @@ details. */
#undef __INSIDE_CYGWIN__ #undef __INSIDE_CYGWIN__
#include <winsock.h> #include <winsock.h>
LONG CALLBACK win32_exception_handler (LPEXCEPTION_POINTERS e); extern void _Jv_platform_initialize (void);
#endif /* __JV_WIN32_H__ */ #endif /* __JV_WIN32_H__ */
...@@ -159,7 +159,7 @@ jlong ...@@ -159,7 +159,7 @@ jlong
java::lang::System::currentTimeMillis (void) java::lang::System::currentTimeMillis (void)
{ {
struct timeval tv; struct timeval tv;
_Jv_gettimeofday (&tv); _Jv_platform_gettimeofday (&tv);
return (jlong) tv.tv_sec * 1000 + tv.tv_usec / 1000; return (jlong) tv.tv_sec * 1000 + tv.tv_usec / 1000;
} }
......
// posix.cc -- Helper functions for POSIX-flavored OSs. // posix.cc -- Helper functions for POSIX-flavored OSs.
/* Copyright (C) 2000, 2001 Free Software Foundation /* Copyright (C) 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -13,6 +13,7 @@ details. */ ...@@ -13,6 +13,7 @@ details. */
#include "posix.h" #include "posix.h"
#include <errno.h> #include <errno.h>
#include <signal.h>
#include <jvm.h> #include <jvm.h>
#include <java/lang/Thread.h> #include <java/lang/Thread.h>
...@@ -24,7 +25,7 @@ extern "C" unsigned long long _clock (void); ...@@ -24,7 +25,7 @@ extern "C" unsigned long long _clock (void);
// gettimeofday implementation. // gettimeofday implementation.
void void
_Jv_gettimeofday (struct timeval *tv) _Jv_platform_gettimeofday (struct timeval *tv)
{ {
#if defined (HAVE_GETTIMEOFDAY) #if defined (HAVE_GETTIMEOFDAY)
gettimeofday (tv, NULL); gettimeofday (tv, NULL);
...@@ -47,6 +48,22 @@ _Jv_gettimeofday (struct timeval *tv) ...@@ -47,6 +48,22 @@ _Jv_gettimeofday (struct timeval *tv)
#endif #endif
} }
// Platform-specific VM initialization.
void
_Jv_platform_initialize (void)
{
#if defined (HAVE_SIGACTION)
// 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);
#else
signal (SIGPIPE, SIG_IGN);
#endif
}
// A wrapper for select() which ignores EINTR. // A wrapper for select() which ignores EINTR.
int int
_Jv_select (int n, fd_set *readfds, fd_set *writefds, _Jv_select (int n, fd_set *readfds, fd_set *writefds,
...@@ -57,7 +74,7 @@ _Jv_select (int n, fd_set *readfds, fd_set *writefds, ...@@ -57,7 +74,7 @@ _Jv_select (int n, fd_set *readfds, fd_set *writefds,
struct timeval end, delay; struct timeval end, delay;
if (timeout) if (timeout)
{ {
_Jv_gettimeofday (&end); _Jv_platform_gettimeofday (&end);
end.tv_usec += timeout->tv_usec; end.tv_usec += timeout->tv_usec;
if (end.tv_usec >= 1000000) if (end.tv_usec >= 1000000)
{ {
...@@ -87,7 +104,7 @@ _Jv_select (int n, fd_set *readfds, fd_set *writefds, ...@@ -87,7 +104,7 @@ _Jv_select (int n, fd_set *readfds, fd_set *writefds,
struct timeval after; struct timeval after;
if (timeout) if (timeout)
{ {
_Jv_gettimeofday (&after); _Jv_platform_gettimeofday (&after);
// Now compute new timeout argument. // Now compute new timeout argument.
delay.tv_usec = end.tv_usec - after.tv_usec; delay.tv_usec = end.tv_usec - after.tv_usec;
delay.tv_sec = end.tv_sec - after.tv_sec; delay.tv_sec = end.tv_sec - after.tv_sec;
......
// prims.cc - Code for core of runtime environment. // prims.cc - Code for core of runtime environment.
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -928,23 +928,7 @@ _Jv_CreateJavaVM (void* /*vm_args*/) ...@@ -928,23 +928,7 @@ _Jv_CreateJavaVM (void* /*vm_args*/)
LTDL_SET_PRELOADED_SYMBOLS (); LTDL_SET_PRELOADED_SYMBOLS ();
#endif #endif
#ifdef WIN32 _Jv_platform_initialize ();
// Initialise winsock for networking
WSADATA data;
if (WSAStartup (MAKEWORD (1, 1), &data))
MessageBox (NULL, "Error initialising winsock library.", "Error", MB_OK | MB_ICONEXCLAMATION);
// Install exception handler
SetUnhandledExceptionFilter (win32_exception_handler);
#elif defined(HAVE_SIGACTION)
// 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);
#else
signal (SIGPIPE, SIG_IGN);
#endif
_Jv_JNI_Init (); _Jv_JNI_Init ();
......
...@@ -9,9 +9,10 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for ...@@ -9,9 +9,10 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */ details. */
#include <config.h> #include <config.h>
#include <windows.h>
LONG CALLBACK #include "platform.h"
static LONG CALLBACK
win32_exception_handler (LPEXCEPTION_POINTERS e) win32_exception_handler (LPEXCEPTION_POINTERS e)
{ {
if (e->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) if (e->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
...@@ -21,3 +22,16 @@ win32_exception_handler (LPEXCEPTION_POINTERS e) ...@@ -21,3 +22,16 @@ win32_exception_handler (LPEXCEPTION_POINTERS e)
else else
return EXCEPTION_CONTINUE_SEARCH; return EXCEPTION_CONTINUE_SEARCH;
} }
// Platform-specific VM initialization.
void
_Jv_platform_initialize (void)
{
// Initialise winsock for networking
WSADATA data;
if (WSAStartup (MAKEWORD (1, 1), &data))
MessageBox (NULL, "Error initialising winsock library.", "Error",
MB_OK | MB_ICONEXCLAMATION);
// Install exception handler
SetUnhandledExceptionFilter (win32_exception_handler);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment