prims.cc (_Jv_CreateJavaVM): Call _Jv_platform_initialize.
authorTom Tromey <tromey@redhat.com>
Thu, 7 Feb 2002 18:59:52 +0000 (18:59 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 7 Feb 2002 18:59:52 +0000 (18:59 +0000)
* 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

libjava/ChangeLog
libjava/include/posix.h
libjava/include/win32.h
libjava/java/lang/natSystem.cc
libjava/posix.cc
libjava/prims.cc
libjava/win32.cc

index fe7c7a6798c8f49fa8544bf78589eecc6162457f..d0ca38e2e5f36c783f24367e619d46d7ca5d5f02 100644 (file)
@@ -1,5 +1,18 @@
 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.in: Removed unnecessary parens.
 
index e7ba317435406c1ba2ea7bcb4f9efb170fef0d46..bbfb0b244e7fb3e649049a83050000ffef286aad 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -29,4 +29,5 @@ details.  */
 #endif
 
 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);
index 677f5d34529af8b77492b404fb77998b4ac75c9b..82c7f157e200b5c1f3cbc87a80f5cc2941a7e904 100644 (file)
@@ -17,6 +17,6 @@ details.  */
 #undef __INSIDE_CYGWIN__
 #include <winsock.h>
 
-LONG CALLBACK win32_exception_handler (LPEXCEPTION_POINTERS e);
+extern void _Jv_platform_initialize (void);
 
 #endif /* __JV_WIN32_H__ */
index 5844246b7a96f49082de35bc52a89decbae9e238..28ef04dd778f5852f7eedd1bb2e58674c72c22e4 100644 (file)
@@ -159,7 +159,7 @@ jlong
 java::lang::System::currentTimeMillis (void)
 {
   struct timeval tv;
-  _Jv_gettimeofday (&tv);
+  _Jv_platform_gettimeofday (&tv);
   return (jlong) tv.tv_sec * 1000 + tv.tv_usec / 1000;
 }
 
index 1f5b037f704b0b07d53cab9e24834e498b826b87..66443d21e11599744e8cb1864f5da548b44e088e 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -13,6 +13,7 @@ details.  */
 #include "posix.h"
 
 #include <errno.h>
+#include <signal.h>
 
 #include <jvm.h>
 #include <java/lang/Thread.h>
@@ -24,7 +25,7 @@ extern "C" unsigned long long _clock (void);
 
 // gettimeofday implementation.
 void
-_Jv_gettimeofday (struct timeval *tv)
+_Jv_platform_gettimeofday (struct timeval *tv)
 {
 #if defined (HAVE_GETTIMEOFDAY)
   gettimeofday (tv, NULL);
@@ -47,6 +48,22 @@ _Jv_gettimeofday (struct timeval *tv)
 #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.
 int
 _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;
   if (timeout)
     {
-      _Jv_gettimeofday (&end);
+      _Jv_platform_gettimeofday (&end);
       end.tv_usec += timeout->tv_usec;
       if (end.tv_usec >= 1000000)
        {
@@ -87,7 +104,7 @@ _Jv_select (int n, fd_set *readfds, fd_set  *writefds,
       struct timeval after;
       if (timeout)
        {
-         _Jv_gettimeofday (&after);
+         _Jv_platform_gettimeofday (&after);
          // Now compute new timeout argument.
          delay.tv_usec = end.tv_usec - after.tv_usec;
          delay.tv_sec = end.tv_sec - after.tv_sec;
index 995206cb16f246b6fcab67e15a73cd3f79431f8a..e351e23630863d64b372d9153238f6f820370f1a 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -928,23 +928,7 @@ _Jv_CreateJavaVM (void* /*vm_args*/)
   LTDL_SET_PRELOADED_SYMBOLS ();
 #endif
 
-#ifdef WIN32
-  // 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_platform_initialize ();
 
   _Jv_JNI_Init ();
 
index daccf0f94fb5c6c4e188dd51210707c1fc6f9dd9..e54d926b0ef392d88e2c132fbbb27c22cc444dfb 100644 (file)
@@ -9,9 +9,10 @@ Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
 details.  */
 
 #include <config.h>
-#include <windows.h>
 
-LONG CALLBACK
+#include "platform.h"
+
+static LONG CALLBACK
 win32_exception_handler (LPEXCEPTION_POINTERS e)
 {
   if (e->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
@@ -21,3 +22,16 @@ win32_exception_handler (LPEXCEPTION_POINTERS e)
   else
     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);
+}