OSDN Git Service

1999-07-07 Andrew Haley <aph@cygnus.com>
[pf3gnuchains/gcc-fork.git] / libjava / prims.cc
index 70dc89c..9909485 100644 (file)
@@ -39,6 +39,9 @@ details.  */
 #include <java/lang/reflect/Modifier.h>
 #include <java/io/PrintStream.h>
 
+#ifdef USE_LTDL
+#include <ltdl.h>
+#endif
 
 #define ObjectClass _CL_Q34java4lang6Object
 extern java::lang::Class ObjectClass;
@@ -52,6 +55,30 @@ static java::lang::OutOfMemoryError *no_memory;
 
 \f
 
+#ifdef HANDLE_SEGV
+static java::lang::NullPointerException *nullp;
+SIGNAL_HANDLER (catch_segv)
+{
+  MAKE_THROW_FRAME;
+  _Jv_Throw (nullp);
+}
+#endif
+
+#ifdef HANDLE_FPE
+static java::lang::ArithmeticException *arithexception;
+SIGNAL_HANDLER (catch_fpe)
+{
+#ifdef HANDLE_DIVIDE_OVERFLOW
+  HANDLE_DIVIDE_OVERFLOW;
+#else
+  MAKE_THROW_FRAME;
+#endif
+  _Jv_Throw (arithexception);
+}
+#endif
+
+\f
+
 jboolean
 _Jv_equalUtf8Consts (Utf8Const* a, Utf8Const *b)
 {
@@ -74,7 +101,7 @@ _Jv_equalUtf8Consts (Utf8Const* a, Utf8Const *b)
 }
 
 /* True iff A is equal to STR.
-   HASH is STR->hashCode().
+   HASH is STR->hashCode().  
 */
 
 jboolean
@@ -426,32 +453,6 @@ _Jv_NewMultiArray (jclass array_type, jint dimensions, ...)
 
 \f
 
-#ifdef HANDLE_SEGV 
-static java::lang::NullPointerException *nullp;
-
-static void
-catch_segv (int dummy)
-{
-  MAKE_THROW_FRAME(dummy);
-  // Don't run `new' in a signal handler, so we always throw the same
-  // exception.
-  _Jv_Throw (nullp);
-}
-#endif
-
-#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
 {
 public:
@@ -572,30 +573,15 @@ 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);
-  }
-#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
+  INIT_SEGV;
+  INIT_FPE;
 
   no_memory = new java::lang::OutOfMemoryError;
 
+#ifdef USE_LTDL
+  LTDL_SET_PRELOADED_SYMBOLS ();
+#endif
+
   arg_vec = JvConvertArgv (argc - 1, argv + 1);
   main_group = new java::lang::ThreadGroup (23);
   main_thread = new java::lang::FirstThread (main_group, klass, arg_vec);