Index: /branches/ia32/lisp-kernel/x86-exceptions.c
===================================================================
--- /branches/ia32/lisp-kernel/x86-exceptions.c	(revision 8209)
+++ /branches/ia32/lisp-kernel/x86-exceptions.c	(revision 8210)
@@ -2198,9 +2198,15 @@
 
   /* Set the thread's FP state from the pseudosigcontext */
+#if WORD_SIZE == 64
   kret = thread_set_state(thread,
                           x86_FLOAT_STATE64,
                           (thread_state_t)&(mc->__fs),
                           x86_FLOAT_STATE64_COUNT);
-
+#else
+  kret = thread_set_state(thread,
+                          x86_FLOAT_STATE32,
+                          (thread_state_t)&(mc->__fs),
+                          x86_FLOAT_STATE32_COUNT);
+#endif
   MACH_CHECK_ERROR("setting thread FP state", kret);
 
@@ -2278,9 +2284,8 @@
 #ifdef X8664  
   stackp = (LispObj) find_foreign_rsp(ts->__rsp,tcr->cs_area,tcr);
+  stackp = TRUNC_DOWN(stackp, C_REDZONE_LEN, C_STK_ALIGN);
 #else
   stackp = (LispObj) ts->__esp;
 #endif
-
-  stackp = TRUNC_DOWN(stackp, C_REDZONE_LEN, C_STK_ALIGN);
   stackp = TRUNC_DOWN(stackp, sizeof(siginfo_t), C_STK_ALIGN);
   if (info_ptr) {
@@ -2291,12 +2296,9 @@
 
   stackp = TRUNC_DOWN(stackp, sizeof(*mc), C_STK_ALIGN);
-#ifdef X8664
   mc = (MCONTEXT_T) ptr_from_lispobj(stackp);
-#else
-  mc = (mcontext_t) ptr_from_lispobj(stackp);
-#endif
   
   bcopy(ts,&(mc->__ss),sizeof(*ts));
 
+#ifdef X8664
   thread_state_count = x86_FLOAT_STATE64_COUNT;
   thread_get_state(thread,
@@ -2305,18 +2307,22 @@
 		   &thread_state_count);
 
-
-#ifdef X8664
   thread_state_count = x86_EXCEPTION_STATE64_COUNT;
-#else
-  thread_state_count = x86_EXCEPTION_STATE_COUNT;
-#endif
   thread_get_state(thread,
-#ifdef X8664
                    x86_EXCEPTION_STATE64,
-#else
-		   x86_EXCEPTION_STATE,
-#endif
 		   (thread_state_t)&(mc->__es),
 		   &thread_state_count);
+#else
+  thread_state_count = x86_FLOAT_STATE32_COUNT;
+  thread_get_state(thread,
+		   x86_FLOAT_STATE32,
+		   (thread_state_t)&(mc->__fs),
+		   &thread_state_count);
+
+  thread_state_count = x86_EXCEPTION_STATE32_COUNT;
+  thread_get_state(thread,
+                   x86_EXCEPTION_STATE32,
+		   (thread_state_t)&(mc->__es),
+		   &thread_state_count);
+#endif
 
 
@@ -2407,9 +2413,26 @@
   new_ts.__rflags = ts->__rflags;
 #else
+#define USER_CS 0x17
+#define USER_DS 0x1f
+  bzero(&new_ts, sizeof(new_ts));
+#if 0
+  new_ts.__cs = ts->__cs;
+  new_ts.__ss = ts->__ss;
+  new_ts.__ds = ts->__ds;
+  new_ts.__es = ts->__es;
+  new_ts.__fs = ts->__fs;
+  new_ts.__gs = ts->__gs;
+#endif
   new_ts.__eip = (natural)handler_address;
   stackpp = (natural *)stackp;
+  *--stackpp = 0;		/* alignment */
+  *--stackpp = 0;
+  *--stackpp = (natural)old_valence;
+  *--stackpp = (natural)tcr;
+  *--stackpp = (natural)pseudosigcontext;
+  *--stackpp = (natural)info;
+  *--stackpp = (natural)signum;
   *--stackpp = (natural)pseudo_sigreturn;
   stackp = (natural)stackpp;
-  /* xxx and other stuff */
   new_ts.__esp = stackp;
   new_ts.__eflags = ts->__eflags;
@@ -2423,7 +2446,7 @@
 #else
   thread_set_state(thread, 
-		   x86_THREAD_STATE,
+		   x86_THREAD_STATE32,
 		   (thread_state_t)&new_ts,
-		   x86_THREAD_STATE_COUNT);
+		   x86_THREAD_STATE32_COUNT);
 #endif
 #ifdef DEBUG_MACH_EXCEPTIONS
