Index: /trunk/ccl/lisp-kernel/x86-exceptions.c
===================================================================
--- /trunk/ccl/lisp-kernel/x86-exceptions.c	(revision 5297)
+++ /trunk/ccl/lisp-kernel/x86-exceptions.c	(revision 5298)
@@ -372,4 +372,6 @@
 
 
+extern unsigned get_mxcsr();
+extern void set_mxcsr(unsigned);
   
 int
@@ -380,4 +382,7 @@
   natural  callback_ptr, i;
   int delta;
+  unsigned old_mxcsr = get_mxcsr();
+
+  set_mxcsr(0x1f80);
 
   /* Put the active stack pointers where .SPcallback expects them */
@@ -393,4 +398,5 @@
   delta = ((int (*)())callback_ptr) (xp, arg1, arg2, arg3, arg4, arg5);
   LOCK(lisp_global(EXCEPTION_LOCK), tcr);
+  set_mxcsr(old_mxcsr);
   return delta;
 }
@@ -832,5 +838,5 @@
 
 void
-signal_handler(int signum, siginfo_t *info, ExceptionInformation  *context, TCR *tcr)
+signal_handler(int signum, siginfo_t *info, ExceptionInformation  *context, TCR *tcr, int old_valence)
 {
 #ifdef DARWIN_GS_HACK
@@ -838,5 +844,4 @@
 #endif
   xframe_list xframe_link;
-  int old_valence;
 #ifndef DARWIN
   tcr = get_tcr(false);
@@ -857,7 +862,5 @@
   }
   unlock_exception_lock_in_handler(tcr);
-#ifndef DARWIN
   exit_signal_handler(tcr, old_valence);
-#endif
   /* raise_pending_interrupt(tcr); */
 #ifdef DARWIN_GS_HACK
@@ -866,11 +869,21 @@
   }
 #endif
-#ifndef DARWIN
   SIGRETURN(context);
-#endif
 }
 
 #ifdef DARWIN
-#endif
+void
+pseudo_signal_handler(int signum, siginfo_t *info, ExceptionInformation  *context, TCR *tcr, int old_valence)
+{
+  sigset_t mask;
+
+  sigfillset(&mask);
+
+  pthread_sigmask(SIG_SETMASK,&mask,&(context->uc_sigmask));
+  signal_handler(signum, info, context, tcr, old_valence);
+}
+#endif
+
+
 
 #ifdef LINUX
@@ -1886,5 +1899,5 @@
 #endif
   ExceptionInformation *pseudosigcontext;
-  int i, j;
+  int i, j, old_valence = tcr->valence;
   kern_return_t result;
   natural stackp, *stackpp;
@@ -1919,5 +1932,7 @@
   new_ts.__rdx = (natural)pseudosigcontext;
   new_ts.__rcx = (natural)tcr;
+  new_ts.__r8 = (natural)old_valence;
   new_ts.__rsp = stackp;
+  new_ts.__rflags = ts->__rflags;
 
 
@@ -2053,5 +2068,5 @@
       if (signum) {
         kret = setup_signal_frame(thread,
-                                  (void *)signal_handler,
+                                  (void *)pseudo_signal_handler,
                                   signum,
                                   code,
