Try to make the :lurking-threads test more robust.
[sbcl.git] / src / runtime / funcall.c
blob4843c71bbbbdcbc9603d1003a0e8ec9445b67991
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"
21 #include "os.h"
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)
26 #ifdef LISP_FEATURE_X86_64
27 __attribute__((sysv_abi))
28 #endif
31 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
32 /* These functions are an interface to the Lisp call-in facility.
33 * Since this is C we can know nothing about the calling environment.
34 * The control stack might be the C stack if called from the monitor
35 * or the Lisp stack if called as a result of an interrupt or maybe
36 * even a separate stack. The args are most likely on that stack but
37 * could be in registers depending on what the compiler likes. So we
38 * copy the args into a portable vector and let the assembly language
39 * call-in function figure it out. */
41 lispobj
42 funcall0(lispobj function)
44 lispobj *args = NULL;
46 FSHOW((stderr, "/entering funcall0(0x%lx)\n", (long)function));
47 return call_into_lisp(function, args, 0);
49 lispobj
50 funcall1(lispobj function, lispobj arg0)
52 lispobj args[1];
53 args[0] = arg0;
54 return call_into_lisp(function, args, 1);
57 lispobj
58 funcall2(lispobj function, lispobj arg0, lispobj arg1)
60 lispobj args[2];
61 args[0] = arg0;
62 args[1] = arg1;
63 return call_into_lisp(function, args, 2);
66 lispobj
67 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
69 lispobj args[3];
70 args[0] = arg0;
71 args[1] = arg1;
72 args[2] = arg2;
73 return call_into_lisp(function, args, 3);
76 #else
78 lispobj
79 funcall0(lispobj function)
81 lispobj **stack_pointer
82 = &access_control_stack_pointer(arch_os_get_current_thread());
83 lispobj *args = *stack_pointer;
85 return call_into_lisp(function, args, 0);
88 lispobj
89 funcall1(lispobj function, lispobj arg0)
91 lispobj **stack_pointer
92 = &access_control_stack_pointer(arch_os_get_current_thread());
93 lispobj *args = *stack_pointer;
95 *stack_pointer += 1;
96 args[0] = arg0;
98 return call_into_lisp(function, args, 1);
101 lispobj
102 funcall2(lispobj function, lispobj arg0, lispobj arg1)
104 lispobj **stack_pointer
105 = &access_control_stack_pointer(arch_os_get_current_thread());
106 lispobj *args = *stack_pointer;
108 *stack_pointer += 2;
109 args[0] = arg0;
110 args[1] = arg1;
112 return call_into_lisp(function, args, 2);
115 lispobj
116 funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2)
118 lispobj **stack_pointer
119 = &access_control_stack_pointer(arch_os_get_current_thread());
120 lispobj *args = *stack_pointer;
122 *stack_pointer += 3;
123 args[0] = arg0;
124 args[1] = arg1;
125 args[2] = arg2;
127 return call_into_lisp(function, args, 3);
129 #endif