summaryrefslogtreecommitdiffstats
path: root/libjava/prims.cc
diff options
context:
space:
mode:
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>1999-07-21 15:11:56 +0000
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>1999-07-21 15:11:56 +0000
commit81e900f90a98e20be13581005c60e073cc6df057 (patch)
tree2e494b829b889dd7da83ae1de7cb28dd9ba66f13 /libjava/prims.cc
parent023ebba2c2278bbc7147137ee8105f2ab15fb950 (diff)
downloadppe42-gcc-81e900f90a98e20be13581005c60e073cc6df057.tar.gz
ppe42-gcc-81e900f90a98e20be13581005c60e073cc6df057.zip
1999-07-19 Andrew Haley <aph@cygnus.com>
* prims.cc (JvRunMain): Always initialize arithexception. (_Jv_divI): New function. (_Jv_remI): New function. (_Jv_divJ): New function. (_Jv_remI): New function. * include/jvm.h: Add these new functions. Makefile.am: add DIVIDESPEC. aclocal.m4: ditto. configure.host: set DIVIDESPEC. libgcj.spec.in: pass DIVIDESPEC to compiler. configure: rebuilt. Makefile.in: rebuilt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28211 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r--libjava/prims.cc64
1 files changed, 63 insertions, 1 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc
index 9909485ded0..c26c2996a21 100644
--- a/libjava/prims.cc
+++ b/libjava/prims.cc
@@ -64,8 +64,9 @@ SIGNAL_HANDLER (catch_segv)
}
#endif
-#ifdef HANDLE_FPE
static java::lang::ArithmeticException *arithexception;
+
+#ifdef HANDLE_FPE
SIGNAL_HANDLER (catch_fpe)
{
#ifdef HANDLE_DIVIDE_OVERFLOW
@@ -574,7 +575,12 @@ void
JvRunMain (jclass klass, int argc, const char **argv)
{
INIT_SEGV;
+#ifdef HANDLE_FPE
INIT_FPE;
+#else
+ arithexception = new java::lang::ArithmeticException
+ (JvNewStringLatin1 ("/ by zero"));
+#endif
no_memory = new java::lang::OutOfMemoryError;
@@ -610,3 +616,59 @@ _Jv_Free (void* ptr)
{
return free (ptr);
}
+
+
+
+// In theory, these routines can be #ifdef'd away on machines which
+// support divide overflow signals. However, we never know if some
+// code might have been compiled with "-fuse-divide-subroutine", so we
+// always include them in libgcj.
+
+jint
+_Jv_divI (jint dividend, jint divisor)
+{
+ if (divisor == 0)
+ _Jv_Throw (arithexception);
+
+ if (dividend == 0x80000000L && divisor == -1)
+ return dividend;
+
+ return dividend / divisor;
+}
+
+jint
+_Jv_remI (jint dividend, jint divisor)
+{
+ if (divisor == 0)
+ _Jv_Throw (arithexception);
+
+ if (dividend == 0x80000000L && divisor == -1)
+ return 0;
+
+ return dividend % divisor;
+}
+
+jlong
+_Jv_divJ (jlong dividend, jlong divisor)
+{
+ if (divisor == 0)
+ _Jv_Throw (arithexception);
+
+ if (dividend == 0x8000000000000000LL && divisor == -1)
+ return dividend;
+
+ return dividend / divisor;
+}
+
+jlong
+_Jv_remJ (jlong dividend, jlong divisor)
+{
+ if (divisor == 0)
+ _Jv_Throw (arithexception);
+
+ if (dividend == 0x8000000000000000LL && divisor == -1)
+ return 0;
+
+ return dividend % divisor;
+}
+
OpenPOWER on IntegriCloud