Stop using naked functions for restore_context

This commit is contained in:
Gary Guo 2023-12-30 21:36:11 +00:00
parent 96888d814f
commit 06699c21b0
5 changed files with 12 additions and 12 deletions

View File

@ -94,8 +94,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p
} }
} }
#[naked] pub unsafe fn restore_context(ctx: &Context) -> ! {
pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
unsafe { unsafe {
asm!( asm!(
" "
@ -136,6 +135,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
ldp x0, x1, [x0, 0x00] ldp x0, x1, [x0, 0x00]
ret ret
", ",
in("x0") ctx,
options(noreturn) options(noreturn)
); );
} }

View File

@ -214,8 +214,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p
} }
} }
#[naked] pub unsafe fn restore_context(ctx: &Context) -> ! {
pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
#[cfg(target_feature = "d")] #[cfg(target_feature = "d")]
unsafe { unsafe {
asm!( asm!(
@ -225,6 +224,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
lw a0, 0x28(a0) lw a0, 0x28(a0)
ret ret
", ",
in("a0") ctx,
options(noreturn) options(noreturn)
); );
} }
@ -236,6 +236,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
lw a0, 0x28(a0) lw a0, 0x28(a0)
ret ret
", ",
in("a0") ctx,
options(noreturn) options(noreturn)
); );
} }

View File

@ -214,8 +214,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p
} }
} }
#[naked] pub unsafe fn restore_context(ctx: &Context) -> ! {
pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
#[cfg(target_feature = "d")] #[cfg(target_feature = "d")]
unsafe { unsafe {
asm!( asm!(
@ -225,6 +224,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
ld a0, 0x50(a0) ld a0, 0x50(a0)
ret ret
", ",
in("a0") ctx,
options(noreturn) options(noreturn)
); );
} }
@ -236,6 +236,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
ld a0, 0x50(a0) ld a0, 0x50(a0)
ret ret
", ",
in("a0") ctx,
options(noreturn) options(noreturn)
); );
} }

View File

@ -96,13 +96,10 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p
} }
} }
#[naked] pub unsafe fn restore_context(ctx: &Context) -> ! {
pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
unsafe { unsafe {
asm!( asm!(
" "
mov edx, [esp + 4]
/* Restore stack */ /* Restore stack */
mov esp, [edx + 16] mov esp, [edx + 16]
@ -130,6 +127,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
ret ret
", ",
in("edx") ctx,
options(noreturn) options(noreturn)
); );
} }

View File

@ -94,8 +94,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p
} }
} }
#[naked] pub unsafe fn restore_context(ctx: &Context) -> ! {
pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
unsafe { unsafe {
asm!( asm!(
" "
@ -134,6 +133,7 @@ pub unsafe extern "C" fn restore_context(ctx: &Context) -> ! {
ret ret
", ",
in("rdi") ctx,
options(noreturn) options(noreturn)
); );
} }