1 /* funcall0 -- funcall3: we can get by with just two sets of these:
2 * for platforms where the control stack is the C-stack, and all others.
6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
22 #include "interrupt.h"
24 /* This is implemented in assembly language and called from C: */
25 extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs);
28 safe_call_into_lisp(lispobj fun, lispobj *args, int nargs)
30 /* SIG_STOP_FOR_GC needs to be enabled before we can call lisp:
31 * otherwise two threads racing here may deadlock: the other will
32 * wait on the GC lock, and the other cannot stop the first
34 check_gc_signals_unblocked_or_lose(0);
35 return call_into_lisp(fun, args, nargs);
38 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
39 /* These functions are an interface to the Lisp call-in facility.
40 * Since this is C we can know nothing about the calling environment.
41 * The control stack might be the C stack if called from the monitor
42 * or the Lisp stack if called as a result of an interrupt or maybe
43 * even a separate stack. The args are most likely on that stack but
44 * could be in registers depending on what the compiler likes. So we
45 * copy the args into a portable vector and let the assembly language
46 * call-in function figure it out. */
49 funcall0(lispobj function)
53 FSHOW((stderr, "/entering funcall0(0x%lx)\n", (long)function));
54 return safe_call_into_lisp(function, args, 0);
57 funcall1(lispobj function, lispobj arg0)
61 return safe_call_into_lisp(function, args, 1);
65 funcall2(lispobj function, lispobj arg0, lispobj arg1)
70 return safe_call_into_lisp(function, args, 2);
74 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
80 return safe_call_into_lisp(function, args, 3);
86 funcall0(lispobj function)
88 lispobj **stack_pointer
89 = &access_control_stack_pointer(arch_os_get_current_thread());
90 lispobj *args = *stack_pointer;
92 return safe_call_into_lisp(function, args, 0);
96 funcall1(lispobj function, lispobj arg0)
98 lispobj **stack_pointer
99 = &access_control_stack_pointer(arch_os_get_current_thread());
100 lispobj *args = *stack_pointer;
105 return safe_call_into_lisp(function, args, 1);
109 funcall2(lispobj function, lispobj arg0, lispobj arg1)
111 lispobj **stack_pointer
112 = &access_control_stack_pointer(arch_os_get_current_thread());
113 lispobj *args = *stack_pointer;
119 return safe_call_into_lisp(function, args, 2);
123 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
125 lispobj **stack_pointer
126 = &access_control_stack_pointer(arch_os_get_current_thread());
127 lispobj *args = *stack_pointer;
134 return safe_call_into_lisp(function, args, 3);