OSDN Git Service

2003-02-28 Joel Sherrill <joel@OARcorp.com>
[pf3gnuchains/gcc-fork.git] / libjava / exception.cc
index 7522361..d983f98 100644 (file)
@@ -1,6 +1,6 @@
 // Functions for Exception Support for Java.
 
-/* Copyright (C) 1998, 1999, 2001  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2001, 2002  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -11,18 +11,26 @@ details.  */
 #include <config.h>
 
 #include <stddef.h>
-#include <cstdlib>
+#include <stdlib.h>
 
 #include <java/lang/Class.h>
 #include <java/lang/NullPointerException.h>
 #include <gcj/cni.h>
 #include <jvm.h>
 
+// unwind-pe.h uses std::abort(), but sometimes we compile libjava
+// without libstdc++-v3. The following hack forces it to use
+// stdlib.h's abort().
+namespace std
+{
+  static __attribute__ ((__noreturn__)) void
+  abort ()
+  {
+    ::abort ();
+  }
+}
 #include "unwind.h"
 
-#include <gc.h>
-
-\f
 struct alignment_test_struct
 {
   char space;
@@ -73,9 +81,8 @@ get_exception_header_from_ue (_Unwind_Exception *exc)
 extern "C" void
 _Jv_Throw (jthrowable value)
 {
-  /* FIXME: Use the proper API to the collector.  */
   java_exception_header *xh
-    = static_cast<java_exception_header *>(GC_malloc (sizeof (*xh)));
+    = static_cast<java_exception_header *>(_Jv_AllocRawObj (sizeof (*xh)));
 
   if (value == NULL)
     value = new java::lang::NullPointerException ();
@@ -100,7 +107,7 @@ _Jv_Throw (jthrowable value)
      recover.  As is the way of such things, almost certainly we will have
      crashed before now, rather than actually being able to diagnose the
      problem.  */
-  std::abort ();
+  abort();
 }
 
 \f
@@ -331,7 +338,7 @@ PERSONALITY_FUNCTION (int version,
              // The catch_type is either a (java::lang::Class*) or
              // is one more than a (Utf8Const*).
              if ((size_t)catch_type & 1)
-               catch_type = _Jv_FindClass ((Utf8Const*)catch_type - 1, NULL);
+               catch_type = _Jv_FindClass ((Utf8Const*)((size_t)catch_type ^ 1), NULL);
 
              if (_Jv_IsInstanceOf (xh->value, catch_type))
                {
@@ -347,7 +354,7 @@ PERSONALITY_FUNCTION (int version,
              // ??? Perhaps better to make them an index into a table
              // of null-terminated strings instead of playing games
              // with Utf8Const+1 as above.
-             std::abort ();
+             abort ();
            }
 
          if (ar_disp == 0)