Index: interrupt.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.c,v
retrieving revision 1.118
diff -u -r1.118 interrupt.c
--- interrupt.c	5 Dec 2006 15:27:24 -0000	1.118
+++ interrupt.c	13 Dec 2006 17:18:58 -0000
@@ -51,6 +51,7 @@
 #include <sys/wait.h>
 #endif
 #include <errno.h>
+#include <stdarg.h>
 
 #include "runtime.h"
 #include "arch.h"
@@ -840,8 +841,10 @@
 extern void post_signal_tramp(void);
 extern void call_into_lisp_tramp(void);
 void
-arrange_return_to_lisp_function(os_context_t *context, lispobj function)
+arrange_return_to_lisp_function(os_context_t *context, lispobj function, unsigned int nargs, ...)
 {
+    /* Note that the nargs != 0 case only works on x86-darwin for now */
+
 #if !(defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64))
     void * fun=native_pointer(function);
     void *code = &(((struct simple_fun *) fun)->code);
@@ -911,6 +914,27 @@
 
     *os_context_pc_addr(context) = call_into_lisp_tramp;
     *os_context_register_addr(context,reg_ECX) = register_save_area;
+
+    *os_context_register_addr(context, reg_EAX) = nargs;
+    *os_context_register_addr(context, reg_EDX) = 0;
+    *os_context_register_addr(context, reg_EBX) = 0;
+    *os_context_register_addr(context, reg_ESI) = 0;
+    {
+	va_list ap;
+	int arg_storage_regs[3] = {reg_EDX, reg_EBX, reg_ESI};
+	int i;
+	
+	if (nargs > 3) {
+	    lose("too many args (%d) for a_r_t_l_f(), must be <= 3", nargs);
+	}
+	
+	va_start(ap, nargs);
+	for (i = 0; i < nargs; i++) {
+	    *os_context_register_addr(context, arg_storage_regs[i])
+		= va_arg(ap, lispobj);
+	}
+	va_end(ap);
+    }
 #else
 
     /* return address for call_into_lisp: */
@@ -1019,7 +1043,7 @@
 
     /* let the handler enable interrupts again when it sees fit */
     sigaddset_deferrable(os_context_sigmask_addr(context));
-    arrange_return_to_lisp_function(context, SymbolFunction(RUN_INTERRUPTION));
+    arrange_return_to_lisp_function(context, SymbolFunction(RUN_INTERRUPTION), 0);
 }
 
 #endif
@@ -1052,7 +1076,7 @@
         protect_control_stack_return_guard_page(1);
 
         arrange_return_to_lisp_function
-            (context, SymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR));
+            (context, SymbolFunction(CONTROL_STACK_EXHAUSTED_ERROR), 0);
         return 1;
     }
     else if(addr >= CONTROL_STACK_RETURN_GUARD_PAGE(th) &&
@@ -1068,7 +1092,7 @@
     else if (addr >= undefined_alien_address &&
              addr < undefined_alien_address + os_vm_page_size) {
         arrange_return_to_lisp_function
-          (context, SymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR));
+          (context, SymbolFunction(UNDEFINED_ALIEN_VARIABLE_ERROR), 0);
         return 1;
     }
     else return 0;
@@ -1402,6 +1426,6 @@
     * now -- some address is better then no address in this case.
     */
     current_memory_fault_address = addr;
-    arrange_return_to_lisp_function(context, SymbolFunction(MEMORY_FAULT_ERROR));
+    arrange_return_to_lisp_function(context, SymbolFunction(MEMORY_FAULT_ERROR), 0);
 }
 #endif
Index: interrupt.h
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.h,v
retrieving revision 1.26
diff -u -r1.26 interrupt.h
--- interrupt.h	3 Jun 2006 20:26:53 -0000	1.26
+++ interrupt.h	13 Dec 2006 17:19:00 -0000
@@ -63,7 +63,7 @@
 extern void interrupt_init();
 extern void fake_foreign_function_call(os_context_t* context);
 extern void undo_fake_foreign_function_call(os_context_t* context);
-extern void arrange_return_to_lisp_function(os_context_t *, lispobj);
+extern void arrange_return_to_lisp_function(os_context_t *, lispobj, unsigned int, ...);
 extern void interrupt_handle_now(int, siginfo_t*, void*);
 extern void interrupt_handle_pending(os_context_t*);
 extern void interrupt_internal_error(int, siginfo_t*, os_context_t*,
Index: x86-assem.S
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-assem.S,v
retrieving revision 1.36
diff -u -r1.36 x86-assem.S
--- x86-assem.S	9 Oct 2006 16:53:35 -0000	1.36
+++ x86-assem.S	13 Dec 2006 17:19:04 -0000
@@ -860,6 +860,12 @@
         pushl   %ebp
         movl    %esp, %ebp
 
+	pushl	$0		/* Alignment */
+	pushl	%esi		/* Arg 2 */
+	pushl	%ebx		/* Arg 1 */
+	pushl	%edx		/* Arg 0 */
+	movl	%esp, %esi	/* Save arg pointer */
+
         pushl   32(%ecx)         /* eflags */
         pushl   28(%ecx)         /* EAX */
         pushl   20(%ecx)         /* ECX */
@@ -869,8 +875,8 @@
         pushl   %ebp              /* is this right?? */
         pushl   12(%ecx)         /* ESI */
         pushl   8(%ecx)          /* EDI */
-        pushl   $0                /* args for call_into_lisp */
-        pushl   $0
+        pushl   %eax             /* call_into_lisp: nargs */
+        pushl   %esi	         /* call_into_lisp: arg vector */
         pushl   4(%ecx)          /* function to call */
 
         /* free our save block */
@@ -882,11 +888,11 @@
         call    GNAME(os_invalidate)
 
         /* call call_into_lisp */
-        leal    -48(%ebp), %esp
+        leal    -64(%ebp), %esp
         call    GNAME(call_into_lisp)
 
         /* Clean up our mess */
-        leal    -36(%ebp), %esp
+        leal    -52(%ebp), %esp
         popal
         popfl
         leave
