diff options
author | Andrew Haley <aph@gcc.gnu.org> | 1999-07-21 15:11:56 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 1999-07-21 15:11:56 +0000 |
commit | d342a2e1eb3cb69c77685fbab9c3840ab098887b (patch) | |
tree | 2e494b829b889dd7da83ae1de7cb28dd9ba66f13 /libjava/prims.cc | |
parent | 9daca635ba8a3c669bd02feada87862a2a7eb953 (diff) | |
download | gcc-d342a2e1eb3cb69c77685fbab9c3840ab098887b.zip gcc-d342a2e1eb3cb69c77685fbab9c3840ab098887b.tar.gz gcc-d342a2e1eb3cb69c77685fbab9c3840ab098887b.tar.bz2 |
prims.cc (JvRunMain): Always initialize arithexception.
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.
From-SVN: r28211
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r-- | libjava/prims.cc | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc index 9909485..c26c299 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; +} + |