CVS: sml/src/runtime/mach-dep signal-sysdep.h, 1.17, 1.18 unix-fault.c, 1.9, 1.10
John Reppy <[email protected]> Tue, 26 Sep 2006 18:35:25 -0700
| Newsgroups | gmane.comp.lang.sml.smlnj.commits |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/smlnj/sml/src/runtime/mach-dep
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv18278/mach-dep
Modified Files:
signal-sysdep.h unix-fault.c
Log Message:
Added overflow/divide-by-zero workaround for Mac OS X on Intel.
Index: signal-sysdep.h
===================================================================
RCS file: /cvsroot/smlnj/sml/src/runtime/mach-dep/signal-sysdep.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** signal-sysdep.h 27 Feb 2006 17:47:32 -0000 1.17
--- signal-sysdep.h 27 Sep 2006 01:35:22 -0000 1.18
***************
*** 500,503 ****
--- 500,506 ----
/** x86, Darwin **/
# define SIG_FAULT1 SIGFPE
+ /* NOTE: MacOS X 10.4.7 sets the code to 0, so we need to test the opcode. */
+ # define INTO_OPCODE 0xce /* the 'into' instruction is a single */
+ /* instruction that signals Overflow */
# define INT_DIVZERO(s, c) (((s) == SIGFPE) && ((c) == FPE_FLTDIV))
# define INT_OVFLW(s, c) (((s) == SIGFPE) && ((c) == FPE_FLTOVF))
Index: unix-fault.c
===================================================================
RCS file: /cvsroot/smlnj/sml/src/runtime/mach-dep/unix-fault.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** unix-fault.c 23 Feb 2006 22:18:34 -0000 1.9
--- unix-fault.c 27 Sep 2006 01:35:22 -0000 1.10
***************
*** 60,65 ****
#ifdef SIGNAL_DEBUG
! SayDebug ("Fault handler: sig = %d, inML = %d\n",
! signal, SELF_VPROC->vp_inMLFlag);
#endif
--- 60,65 ----
#ifdef SIGNAL_DEBUG
! SayDebug ("Fault handler: sig = %d, code = %d, inML = %d\n",
! signal, code, SELF_VPROC->vp_inMLFlag);
#endif
***************
*** 69,72 ****
--- 69,83 ----
/* Map the signal to the appropriate ML exception. */
+ #if defined(HOST_X86) && defined(OPSYS_DARWIN)
+ /* NOTE: early versions of Mac OS X 10.4.x set the code to FPE_FLTDIV or
+ * FPE_FLTOVF, but 10.4.7 sets it to 0, so we need this workaround.
+ */
+ if ((signal == SIGFPE) && (code == 0)) {
+ if (((Byte_t *)SIG_GetPC(scp))[-1] == INTO_OPCODE)
+ code = FPE_FLTOVF;
+ else
+ code = FPE_FLTDIV;
+ }
+ #endif
if (INT_OVFLW(signal, code)) {
msp->ml_faultExn = OverflowId;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV