Index: /branches/arm/lisp-kernel/arm-exceptions.c
===================================================================
--- /branches/arm/lisp-kernel/arm-exceptions.c	(revision 13798)
+++ /branches/arm/lisp-kernel/arm-exceptions.c	(revision 13799)
@@ -321,5 +321,5 @@
 }
 
-OSStatus
+Boolean
 handle_alloc_trap(ExceptionInformation *xp, TCR *tcr)
 {
@@ -331,6 +331,5 @@
 
   cur_allocptr = xpGPR(xp,allocptr);
-  program_counter = xpPC(xp);
-  prev_instr = *(program_counter-1);
+
   allocptr_tag = fulltag_of(cur_allocptr);
 
@@ -341,8 +340,4 @@
     break;
 
-  case fulltag_even_fixnum:
-  case fulltag_odd_fixnum:
-    break;
-
   case fulltag_misc:
     disp = allocptr_displacement(xp);
@@ -352,21 +347,14 @@
     /* else fall thru */
   default:
-    return -1;
-  }
-
-  if (bytes_needed) {
-    update_bytes_allocated(tcr,((BytePtr)(cur_allocptr-disp)));
-    if (allocate_object(xp, bytes_needed, disp, tcr)) {
-#if 0
-      fprintf(dbgout, "alloc_trap in 0x%lx, new allocptr = 0x%lx\n",
-              tcr, xpGPR(xp, allocptr));
-#endif
-      adjust_exception_pc(xp,4);
-      return 0;
-    }
-    lisp_allocation_failure(xp,tcr,bytes_needed);
-    return -1;
-  }
-  return -1;
+    return false;
+  }
+
+  update_bytes_allocated(tcr,((BytePtr)(cur_allocptr-disp)));
+  if (allocate_object(xp, bytes_needed, disp, tcr)) {
+    adjust_exception_pc(xp,4);
+    return true;
+  }
+  lisp_allocation_failure(xp,tcr,bytes_needed);
+  return true;
 }
 
@@ -379,5 +367,5 @@
 }
 
-OSStatus
+Boolean
 handle_gc_trap(ExceptionInformation *xp, TCR *tcr)
 {
@@ -511,5 +499,5 @@
 
   adjust_exception_pc(xp,4);
-  return 0;
+  return true;
 }
 
@@ -831,5 +819,5 @@
 }
 
-OSStatus
+Boolean
 handle_protection_violation(ExceptionInformation *xp, siginfo_t *info, TCR *tcr, int old_valence)
 {
@@ -850,5 +838,5 @@
 
     xpGPR(xp,imm0) = 0;
-    return 0;
+    return true;
   }
 
@@ -856,5 +844,5 @@
     xpGPR(xp,imm0) = 0;
     xpPC(xp) = (pc)touch_page_end;
-    return 0;
+    return true;
   }
 
@@ -870,12 +858,18 @@
         UnProtectMemory((LogicalAddress)(truncate_to_power_of_2(addr,log2_page_size)),
                         page_size);
-	return 0;
+	return true;
       }
     }
   }
   if (old_valence == TCR_STATE_LISP) {
-    callback_for_trap(nrs_CMAIN.vcell, xp, is_write_fault(xp,info)?SIGBUS:SIGSEGV, (natural)addr);
-  }
-  return -1;
+    LispObj cmain = nrs_CMAIN.vcell;
+    
+    if ((fulltag_of(cmain) == fulltag_misc) &&
+      (header_subtag(header_of(cmain)) == subtag_macptr)) {
+      
+      callback_for_trap(nrs_CMAIN.vcell, xp, is_write_fault(xp,info)?SIGBUS:SIGSEGV, (natural)addr);
+    }
+  }
+  return false;
 }
 
@@ -991,12 +985,11 @@
 }
 
-OSStatus
-PMCL_exception_handler(int xnum, 
-                       ExceptionInformation *xp, 
-                       TCR *tcr, 
-                       siginfo_t *info,
-                       int old_valence)
-{
-  OSStatus status = -1;
+Boolean
+handle_exception(int xnum, 
+                 ExceptionInformation *xp, 
+                 TCR *tcr, 
+                 siginfo_t *info,
+                 int old_valence)
+{
   pc program_counter;
   opcode instruction = 0;
@@ -1010,25 +1003,25 @@
 
   if (IS_ALLOC_TRAP(instruction)) {
-    status = handle_alloc_trap(xp, tcr);
+    return handle_alloc_trap(xp, tcr);
   } else if ((xnum == SIGSEGV) ||
 	     (xnum == SIGBUS)) {
-    status = handle_protection_violation(xp, info, tcr, old_valence);
+    return handle_protection_violation(xp, info, tcr, old_valence);
   } else if (xnum == SIGFPE) {
-    status = handle_sigfpe(xp, tcr);
+    return handle_sigfpe(xp, tcr);
   } else if ((xnum == SIGILL)) {
     if (IS_GC_TRAP(instruction)) {
-      status = handle_gc_trap(xp, tcr);
+      return handle_gc_trap(xp, tcr);
     } else if (IS_UUO(instruction)) {
-      status = handle_uuo(xp, instruction);
+      return handle_uuo(xp, instruction);
     } else {
-      status = handle_unimplemented_instruction(xp,instruction,tcr);
+      return handle_unimplemented_instruction(xp,instruction,tcr);
     }
   } else if (xnum == SIGNAL_FOR_PROCESS_INTERRUPT) {
     tcr->interrupt_pending = 0;
     callback_for_trap(nrs_CMAIN.vcell, xp, xnum, 0);
-    status = 0;
-  }
-
-  return status;
+    return true;
+  }
+
+  return false;
 }
 
@@ -1053,10 +1046,10 @@
 }
 
-OSStatus
+Boolean
 handle_uuo(ExceptionInformation *xp, opcode the_uuo) 
 {
   unsigned 
     format = UUO_FORMAT(the_uuo);
-  OSStatus status = -1;
+  Boolean handled = false;
   int bump = 4;
   TCR *tcr = get_tcr(true);
@@ -1068,31 +1061,38 @@
       int service = UUO_UNARY_field(the_uuo);
 
-      status = 0;
       switch (service) {
       case error_propagate_suspend:
+        handled = true;
         break;
       case error_interrupt:
         xpGPR(xp,imm0) = (LispObj) raise_thread_interrupt(target);
+        handled = true;
         break;
       case error_suspend:
         xpGPR(xp,imm0) = (LispObj) lisp_suspend_tcr(target);
+        handled = true;
         break;
       case error_suspend_all:
         lisp_suspend_other_threads();
+        handled = true;
         break;
       case error_resume:
         xpGPR(xp,imm0) = (LispObj) lisp_resume_tcr(target);
+        handled = true;
         break;
       case error_resume_all:
         lisp_resume_other_threads();
+        handled = true;
         break;
       case error_kill:
         xpGPR(xp,imm0) = (LispObj)kill_tcr(target);
+        handled = true;
         break;
       case error_allocate_list:
         allocate_list(xp,tcr);
+        handled = true;
         break;
       default:
-        status = -1;
+        handled = false;
         break;
       }
@@ -1103,5 +1103,5 @@
     case 3:
       if (extend_tcr_tlb(tcr,xp,UUOA_field(the_uuo))) {
-        status = 0;
+        handled = true;
         bump = 4;
         break;
@@ -1109,5 +1109,5 @@
       /* fall in */
     default:
-      status = -1;
+      handled = false;
       break;
 
@@ -1120,4 +1120,8 @@
       tcr->interrupt_pending = 0;
       callback_for_trap(nrs_CMAIN.vcell, xp, SIGNAL_FOR_PROCESS_INTERRUPT, 0);
+      handled = true;
+      break;
+    default:
+      handled = false;
       break;
     }
@@ -1129,19 +1133,16 @@
   case uuo_format_unary_error:
   case uuo_format_binary_error:
-    bump = handle_error(xp,0,the_uuo);
-    if (bump >= 0) {
-      status = 0;
-    }
+    handled = handle_error(xp,0,the_uuo);
     break;
 
   default:
-    status = -1;
+    handled = false;
     bump = 0;
   }
   
-  if ((!status) && bump) {
+  if (handled && bump) {
     adjust_exception_pc(xp, bump);
   }
-  return status;
+  return handled;
 }
 
@@ -1249,8 +1250,7 @@
 }
 
-/* The main opcode.  */
-
-
-int
+
+
+Boolean
 handle_error(ExceptionInformation *xp, unsigned arg1, unsigned arg2)
 {
@@ -1263,5 +1263,5 @@
     }
 
-  return(-1);
+  return false;
 }
 	       
@@ -1358,5 +1358,5 @@
   
   wait_for_exception_lock_in_handler(tcr, context, &xframe_link);
-  if ((noErr != PMCL_exception_handler(signum, context, tcr, info, old_valence))) {
+  if ((!handle_exception(signum, context, tcr, info, old_valence))) {
     char msg[512];
     snprintf(msg, sizeof(msg), "Unhandled exception %d at 0x%lx, context->regs at #x%lx", signum, xpPC(context), (natural)xpGPRvector(context));
@@ -1574,5 +1574,5 @@
 	  old_valence = prepare_to_wait_for_exception_lock(tcr, context);
 	  wait_for_exception_lock_in_handler(tcr, context, &xframe_link);
-	  PMCL_exception_handler(signum, context, tcr, info, old_valence);
+	  handle_exception(signum, context, tcr, info, old_valence);
           if (disp) {
             xpGPR(context,allocptr) -= disp;
