more asm! -> naked_asm! in tests

This commit is contained in:
Folkert de Vries 2024-09-05 17:48:13 +02:00
parent 562ec5a6fb
commit bc0a9543a3
7 changed files with 22 additions and 23 deletions

View File

@ -5,7 +5,7 @@
#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;
// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
// meaning "no prologue whatsoever, no, really, not one instruction."
@ -17,5 +17,5 @@
pub unsafe extern "C" fn _hlt() -> ! {
// CHECK-NOT: hint #34
// CHECK: hlt #0x1
asm!("hlt #1", options(noreturn))
naked_asm!("hlt #1")
}

View File

@ -5,7 +5,7 @@
#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;
// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
// meaning "no prologue whatsoever, no, really, not one instruction."
@ -17,7 +17,7 @@
pub unsafe extern "sysv64" fn will_halt() -> ! {
// CHECK-NOT: endbr{{32|64}}
// CHECK: hlt
asm!("hlt", options(noreturn))
naked_asm!("hlt")
}
// what about aarch64?

View File

@ -12,8 +12,7 @@
pub unsafe extern "C" fn c_variadic(_: usize, _: ...) {
// CHECK-NOT: va_start
// CHECK-NOT: alloca
core::arch::asm! {
core::arch::naked_asm! {
"ret",
options(noreturn),
}
}

View File

@ -3,9 +3,9 @@
//@ only-x86_64
#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;
#[naked]
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
naked_asm!("lea rax, [rdi + rsi]", "ret");
}

View File

@ -1,7 +1,7 @@
#![feature(naked_functions, asm_const, linkage)]
#![crate_type = "dylib"]
use std::arch::asm;
use std::arch::naked_asm;
pub trait TraitWithConst {
const COUNT: u32;
@ -28,7 +28,7 @@ extern "C" fn private_vanilla() -> u32 {
#[naked]
extern "C" fn private_naked() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret") }
}
#[no_mangle]
@ -39,7 +39,7 @@ pub extern "C" fn public_vanilla() -> u32 {
#[naked]
#[no_mangle]
pub extern "C" fn public_naked() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret") }
}
pub extern "C" fn public_vanilla_generic<T: TraitWithConst>() -> u32 {
@ -48,7 +48,7 @@ pub extern "C" fn public_vanilla_generic<T: TraitWithConst>() -> u32 {
#[naked]
pub extern "C" fn public_naked_generic<T: TraitWithConst>() -> u32 {
unsafe { asm!("mov rax, {}", "ret", const T::COUNT, options(noreturn)) }
unsafe { naked_asm!("mov rax, {}", "ret", const T::COUNT) }
}
#[linkage = "external"]
@ -59,7 +59,7 @@ extern "C" fn vanilla_external_linkage() -> u32 {
#[naked]
#[linkage = "external"]
extern "C" fn naked_external_linkage() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret") }
}
#[cfg(not(windows))]
@ -72,7 +72,7 @@ extern "C" fn vanilla_weak_linkage() -> u32 {
#[cfg(not(windows))]
#[linkage = "weak"]
extern "C" fn naked_weak_linkage() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret", options(noreturn)) }
}
// functions that are declared in an `extern "C"` block are currently not exported

View File

@ -1,7 +1,7 @@
error[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:9:5
|
LL | naked_asm!("", options(noreturn))
LL | naked_asm!("")
| ^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
@ -11,7 +11,7 @@ LL | naked_asm!("", options(noreturn))
error[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:17:5
|
LL | naked_asm!("", options(noreturn))
LL | naked_asm!("")
| ^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
@ -51,16 +51,16 @@ LL | use std::arch::naked_asm;
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:9:5
|
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
LL | naked_asm!("")
| ^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:17:5
|
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
LL | naked_asm!("")
| ^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

View File

@ -1,14 +1,14 @@
//@ needs-asm-support
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;
#[track_caller] //~ ERROR [E0736]
//~^ ERROR `#[track_caller]` requires Rust ABI
#[naked]
extern "C" fn f() {
unsafe {
asm!("", options(noreturn));
naked_asm!("");
}
}
@ -20,7 +20,7 @@ impl S {
#[naked]
extern "C" fn g() {
unsafe {
asm!("", options(noreturn));
naked_asm!("");
}
}
}