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 #ifndef LISP_FEATURE_SB_SAFEPOINT
31 /* SIG_STOP_FOR_GC needs to be enabled before we can call lisp:
32 * otherwise two threads racing here may deadlock: the other will
33 * wait on the GC lock, and the other cannot stop the first
35 check_gc_signals_unblocked_or_lose(0);
37 return call_into_lisp(fun, args, nargs);
40 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
41 /* These functions are an interface to the Lisp call-in facility.
42 * Since this is C we can know nothing about the calling environment.
43 * The control stack might be the C stack if called from the monitor
44 * or the Lisp stack if called as a result of an interrupt or maybe
45 * even a separate stack. The args are most likely on that stack but
46 * could be in registers depending on what the compiler likes. So we
47 * copy the args into a portable vector and let the assembly language
48 * call-in function figure it out. */
51 funcall0(lispobj function)
55 FSHOW((stderr, "/entering funcall0(0x%lx)\n", (long)function));
56 return safe_call_into_lisp(function, args, 0);
59 funcall1(lispobj function, lispobj arg0)
63 return safe_call_into_lisp(function, args, 1);
67 funcall2(lispobj function, lispobj arg0, lispobj arg1)
72 return safe_call_into_lisp(function, args, 2);
76 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
82 return safe_call_into_lisp(function, args, 3);
88 funcall0(lispobj function)
90 lispobj **stack_pointer
91 = &access_control_stack_pointer(arch_os_get_current_thread());
92 lispobj *args = *stack_pointer;
94 return safe_call_into_lisp(function, args, 0);
98 funcall1(lispobj function, lispobj arg0)
100 lispobj **stack_pointer
101 = &access_control_stack_pointer(arch_os_get_current_thread());
102 lispobj *args = *stack_pointer;
107 return safe_call_into_lisp(function, args, 1);
111 funcall2(lispobj function, lispobj arg0, lispobj arg1)
113 lispobj **stack_pointer
114 = &access_control_stack_pointer(arch_os_get_current_thread());
115 lispobj *args = *stack_pointer;
121 return safe_call_into_lisp(function, args, 2);
125 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
127 lispobj **stack_pointer
128 = &access_control_stack_pointer(arch_os_get_current_thread());
129 lispobj *args = *stack_pointer;
136 return safe_call_into_lisp(function, args, 3);