OSDN Git Service

1999-04-13 Andrew Haley <aph@cygnus.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Apr 1999 09:18:09 +0000 (09:18 +0000)
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Apr 1999 09:18:09 +0000 (09:18 +0000)
        * include/i386-signal.h, include/default-signal.h: New files.
        * prims.cc (catch_segv): Call MAKE_THROW_FRAME in exception
        handler.
        (catch_fpe): New function.
        * configure.in: Make link to appropriate include/java-signal.h.
        * configure: Rebuilt.
        * Makefile.am: include/java-signal.h added to dependency list.
        * Makefile.in: Rebuilt.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26400 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/configure
libjava/configure.in
libjava/include/default-signal.h [new file with mode: 0644]
libjava/include/i386-signal.h [new file with mode: 0644]
libjava/prims.cc

index 9b8323a..3314bc4 100644 (file)
@@ -1,3 +1,14 @@
+1999-04-13  Andrew Haley  <aph@cygnus.com>
+
+        * include/i386-signal.h, include/default-signal.h: New files.   
+        * prims.cc (catch_segv): Call MAKE_THROW_FRAME in exception
+        handler.
+        (catch_fpe): New function.      
+        * configure.in: Make link to appropriate include/java-signal.h.
+        * configure: Rebuilt.
+        * Makefile.am: include/java-signal.h added to dependency list.
+        * Makefile.in: Rebuilt.
+
 1999-04-12  Urban Widmark <urban@svenskatest.se>
 
        * java/io/DataInputStream.java (readLine): Corrected handling of
index 615ebd1..3fc6051 100644 (file)
@@ -135,7 +135,7 @@ $(nat_files): %.o: %.cc
        $(CXXCOMPILE) -c -o $@ $<
 
 $(nat_files) $(GCOBJS) $(THREADOBJS) $(libgcj_a_OBJECTS): \
-               include/config.h $(nat_headers)
+               include/config.h include/java-signal.h $(nat_headers)
 
 ## FIXME: GNU make.
 $(c_files): %.o: %.c
index cd6da4c..25dd187 100644 (file)
@@ -1191,7 +1191,7 @@ $(nat_files): %.o: %.cc
        $(CXXCOMPILE) -c -o $@ $<
 
 $(nat_files) $(GCOBJS) $(THREADOBJS) $(libgcj_a_OBJECTS): \
-               include/config.h $(nat_headers)
+               include/config.h include/java-signal.h $(nat_headers)
 
 $(c_files): %.o: %.c
        $(COMPILE) -c -o $@ $<
index 8406708..2ee2021 100755 (executable)
@@ -3298,6 +3298,17 @@ done
 test -n "$PERL" || PERL="false"
 
 
+case "${host}" in
+  i?86-*-linux*)
+    SIGNAL_HANDLER=include/i386-signal.h
+       ;;
+  *)
+    SIGNAL_HANDLER=include/default-signal.h
+       ;;
+esac
+
+
+
 if test "${multilib}" = "yes"; then
   multilib_arg="--enable-multilib"
 else
@@ -3714,8 +3725,8 @@ fi; done
 EOF
 
 cat >> $CONFIG_STATUS <<EOF
-ac_sources="java/io/$FILE_DESCRIPTOR include/$GCHDR include/$THREADH"
-ac_dests="java/io/natFileDescriptor.cc include/java-gc.h include/java-threads.h"
+ac_sources="java/io/$FILE_DESCRIPTOR include/$GCHDR include/$THREADH $SIGNAL_HANDLER"
+ac_dests="java/io/natFileDescriptor.cc include/java-gc.h include/java-threads.h include/java-signal.h"
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
index 98083c9..e2fa12f 100644 (file)
@@ -362,6 +362,17 @@ AC_FUNC_ALLOCA
 
 AC_CHECK_PROGS(PERL, perl, false)
 
+case "${host}" in
+  i?86-*-linux*)
+    SIGNAL_HANDLER=include/i386-signal.h
+       ;;
+  *)
+    SIGNAL_HANDLER=include/default-signal.h
+       ;;
+esac
+
+AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
+
 if test "${multilib}" = "yes"; then
   multilib_arg="--enable-multilib"
 else
diff --git a/libjava/include/default-signal.h b/libjava/include/default-signal.h
new file mode 100644 (file)
index 0000000..63ba129
--- /dev/null
@@ -0,0 +1,18 @@
+// default-signal.h - Catch runtime signals and turn them into exceptions.
+
+/* Copyright (C) 1998, 1999  Cygnus Solutions
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#ifndef JAVA_SIGNAL_H
+#define JAVA_SIGNAL_H 1
+
+#undef HANDLE_SEGV
+#undef HANDLE_FPE
+
+#endif /* JAVA_SIGNAL_H */
+  
diff --git a/libjava/include/i386-signal.h b/libjava/include/i386-signal.h
new file mode 100644 (file)
index 0000000..de893af
--- /dev/null
@@ -0,0 +1,38 @@
+// i386-signal.h - Catch runtime signals and turn them into exceptions.
+
+/* Copyright (C) 1998, 1999  Cygnus Solutions
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+/* This technique should work for all i386 based Unices which conform
+   to iBCS2.  This includes all versions of Linux more recent than
+   version 1.3 */
+
+
+#ifndef JAVA_SIGNAL_H
+#define JAVA_SIGNAL_H 1
+
+#include <signal.h>
+
+#define HANDLE_SEGV 1
+#define HANDLE_FPE 1
+
+
+#define MAKE_THROW_FRAME(_dummy)                                       \
+{                                                                      \
+  void **_p = (void **)&_dummy;                                                \
+  struct sigcontext_struct *_regs = (struct sigcontext_struct *)++_p;  \
+                                                                       \
+  register unsigned long _ebp = _regs->ebp;                            \
+  register unsigned long _eip = _regs->eip;                            \
+                                                                       \
+  asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)"                    \
+               : : "r"(_ebp), "r"(_eip));                              \
+}
+
+#endif /* JAVA_SIGNAL_H */
+  
index 265e281..70dc89c 100644 (file)
@@ -14,14 +14,12 @@ details.  */
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#ifdef HANDLE_SEGV
-#include <signal.h>
-#endif
 
 #pragma implementation "java-array.h"
 
 #include <cni.h>
 #include <jvm.h>
+#include <java-signal.h>
 
 #include <java/lang/Class.h>
 #include <java/lang/Runtime.h>
@@ -30,6 +28,7 @@ details.  */
 #include <java/lang/ThreadGroup.h>
 #include <java/lang/FirstThread.h>
 #include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/ArithmeticException.h>
 #include <java/lang/ClassFormatError.h>
 #include <java/lang/ClassCastException.h>
 #include <java/lang/NegativeArraySizeException.h>
@@ -40,6 +39,7 @@ details.  */
 #include <java/lang/reflect/Modifier.h>
 #include <java/io/PrintStream.h>
 
+
 #define ObjectClass _CL_Q34java4lang6Object
 extern java::lang::Class ObjectClass;
 
@@ -426,19 +426,31 @@ _Jv_NewMultiArray (jclass array_type, jint dimensions, ...)
 
 \f
 
-#ifdef HANDLE_SEGV
-
+#ifdef HANDLE_SEGV 
 static java::lang::NullPointerException *nullp;
 
 static void
-catch_segv (int)
+catch_segv (int dummy)
 {
+  MAKE_THROW_FRAME(dummy);
   // Don't run `new' in a signal handler, so we always throw the same
-  // null pointer exception.
+  // exception.
   _Jv_Throw (nullp);
 }
+#endif
 
-#endif /* HANDLE_SEGV */
+#ifdef HANDLE_FPE
+static java::lang::ArithmeticException *arithexception;
+
+static void
+catch_fpe (int dummy)
+{
+  MAKE_THROW_FRAME(dummy);
+  // Don't run `new' in a signal handler, so we always throw the same
+  // exception.
+  _Jv_Throw (arithexception);
+}
+#endif
 
 class _Jv_PrimClass : public java::lang::Class
 {
@@ -560,14 +572,26 @@ static java::lang::Thread *main_thread;
 void
 JvRunMain (jclass klass, int argc, const char **argv)
 {
-#ifdef HANDLE_SEGV
-  nullp = new java::lang::NullPointerException ();
-
-  struct sigaction act;
-  act.sa_handler = catch_segv;
-  sigemptyset (&act.sa_mask);
-  act.sa_flags = 0;
-  sigaction (SIGSEGV, &act, NULL);
+#ifdef HANDLE_SEGV 
+  {
+    nullp = new java::lang::NullPointerException ();    
+    struct sigaction act;
+    act.sa_handler = catch_segv;
+    sigemptyset (&act.sa_mask);
+    act.sa_flags = 0;
+    sigaction (SIGSEGV, &act, NULL);
+  }
+#endif
+  
+#ifdef HANDLE_FPE
+  { 
+    arithexception = new java::lang::ArithmeticException ();
+    struct sigaction act;
+    act.sa_handler = catch_fpe;
+    sigemptyset (&act.sa_mask);
+    act.sa_flags = 0;
+    sigaction (SIGFPE, &act, NULL);
+  }
 #endif
 
   no_memory = new java::lang::OutOfMemoryError;