1.0.19.33: Improved interrupt handling on darwin/x86[-64]
[sbcl/eslaughter.git] / src / runtime / funcall.c
blobe364ec21c5d53246947b9b5919cf85f29196c932
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.
3 */
5 /*
6 * This software is part of the SBCL system. See the README file for
7 * more information.
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.
16 #include <stdio.h>
18 #include "sbcl.h"
19 #include "runtime.h"
20 #include "globals.h"
22 /* This is implemented in assembly language and called from C: */
23 extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs);
25 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
26 /* These functions are an interface to the Lisp call-in facility.
27 * Since this is C we can know nothing about the calling environment.
28 * The control stack might be the C stack if called from the monitor
29 * or the Lisp stack if called as a result of an interrupt or maybe
30 * even a separate stack. The args are most likely on that stack but
31 * could be in registers depending on what the compiler likes. So we
32 * copy the args into a portable vector and let the assembly language
33 * call-in function figure it out. */
35 lispobj
36 funcall0(lispobj function)
38 lispobj *args = NULL;
40 FSHOW((stderr, "/entering funcall0(0x%lx)\n", (long)function));
41 return call_into_lisp(function, args, 0);
43 lispobj
44 funcall1(lispobj function, lispobj arg0)
46 lispobj args[1];
47 args[0] = arg0;
48 return call_into_lisp(function, args, 1);
51 lispobj
52 funcall2(lispobj function, lispobj arg0, lispobj arg1)
54 lispobj args[2];
55 args[0] = arg0;
56 args[1] = arg1;
57 return call_into_lisp(function, args, 2);
60 lispobj
61 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
63 lispobj args[3];
64 args[0] = arg0;
65 args[1] = arg1;
66 args[2] = arg2;
67 return call_into_lisp(function, args, 3);
70 #else
72 lispobj
73 funcall0(lispobj function)
75 lispobj *args = current_control_stack_pointer;
77 return call_into_lisp(function, args, 0);
80 lispobj
81 funcall1(lispobj function, lispobj arg0)
83 lispobj *args = current_control_stack_pointer;
85 current_control_stack_pointer += 1;
86 args[0] = arg0;
88 return call_into_lisp(function, args, 1);
91 lispobj
92 funcall2(lispobj function, lispobj arg0, lispobj arg1)
94 lispobj *args = current_control_stack_pointer;
96 current_control_stack_pointer += 2;
97 args[0] = arg0;
98 args[1] = arg1;
100 return call_into_lisp(function, args, 2);
103 lispobj
104 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
106 lispobj *args = current_control_stack_pointer;
108 current_control_stack_pointer += 3;
109 args[0] = arg0;
110 args[1] = arg1;
111 args[2] = arg2;
113 return call_into_lisp(function, args, 3);
115 #endif