[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] FreeMiNT for ColdFire: Division by Zero
On 20/03/2011 21:55, Vincent Rivière wrote:
Here is he first batch
On the EmuTOS mailing list, we discovered that an integer division by zero
behaves differently on ColdFire than on 680x0.
- On 680x0, such exception returns to the next instruction, so it can be
safely ignored.
- On ColdFire, it returns to the offending instruction, so it can't be
ignored otherwise it causes an endless loop.
FireTOS cleanly emulates the 680x0 behaviour, this works fine with FreeMiNT,
too.
However in a pure ColdFire OS such as EmuTOS, an rte causes an infinite
loop. I fixed that in EmuTOS. Now on ColdFire, a division by zero panics
just like any other unexpected exception.
FreeMiNT for ColdFire suffers of the same trouble, so here is the patch.
div0.patch
Fixed SIGFPE to be fatal on ColdFire without 680x0 emulation, instead of
causing an endless loop. Contributed by Vincent Riviere.
Please commit into the 1.18 branch.
--
Vincent Rivière
--- freemint-1.18.orig/sys/signal.c 2013-02-08 00:18:13.890625000 +0100
+++ freemint-1.18/sys/signal.c 2013-03-12 23:14:17.875000000 +0100
@@ -387,10 +387,23 @@
# endif
case SIGWINCH:
case SIGCHLD:
+ return; /* do nothing */
+
/* SIGFPE is divide by 0
* TOS ignores this, so we will too
*/
case SIGFPE:
+#ifdef __mcoldfire__
+ /* On ColdFire, an integer divide by zero exception
+ * can't just be ignored, because it returns to the
+ * offending instruction, instead of the next one.
+ * Hence we have no other choice than to fail.
+ * However, with proper 680x0 emulation, it can be
+ * safely ignored, as usual.
+ */
+ if (!coldfire_68k_emulation)
+ goto default_signal_handling;
+#endif
return; /* do nothing */
case SIGSTOP:
@@ -422,6 +435,7 @@
}
/* otherwise, fall through */
default:
+ default_signal_handling:
/* Mark the process as being killed
* by a signal. Used by Pwaitpid.
*/