Skip to content

Commit d8a80cb

Browse files
committed
rt: Add a call stub that switches to the C stack, untested as of yet
1 parent 1eaaae8 commit d8a80cb

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

mk/rt.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ RUNTIME_CS := rt/sync/timer.cpp \
3737

3838
RUNTIME_LL :=
3939

40-
RUNTIME_S := rt/arch/i386/_context.S
40+
RUNTIME_S := rt/arch/i386/_context.S \
41+
rt/arch/i386/ccall.S
4142

4243
RUNTIME_HDR := rt/globals.h \
4344
rt/rust.h \

src/rt/arch/i386/ccall.S

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.text
2+
3+
// upcall_call_c_stack(void (*fn)(), void *new_esp)
4+
.globl _upcall_call_c_stack
5+
_upcall_call_c_stack:
6+
movl %esp,%ecx // grab esp
7+
movl 8(%esp),%eax // save fn
8+
movl 12(%esp),%esp // switch stack
9+
pushl %ecx // save esp on stack
10+
calll *%eax
11+
popl %esp // restore esp
12+
ret
13+
14+

src/rt/arch/i386/context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class context {
3737

3838
void swap(context &out);
3939
void call(void *f, void *arg, void *sp);
40+
void call(void *f, void *sp);
4041

4142
// Note that this doesn't actually adjust esp. Instead, we adjust esp when
4243
// we actually do the call. This is needed for exception safety -- if the

src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ task_yield
6666
task_join
6767
unsupervise
6868
upcall_alloc_c_stack
69+
upcall_call_c_stack
6970
upcall_cmp_type
7071
upcall_dynastack_alloc
7172
upcall_dynastack_alloc_2

0 commit comments

Comments
 (0)