-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Labels
bugSomething isn't workingSomething isn't working
Description
use std::arch::asm;
fn getpid_syscall() -> i32 {
let pid: i32;
unsafe {
asm!(
"syscall",
in("rax") 39, // assuming x86_64 Linux
lateout("rax") pid,
options(nostack)
);
}
pid
}
fn exit_syscall(status: i32) -> ! {
unsafe {
asm!(
"syscall",
in("rax") 60, // assuming x86_64 Linux
in("rdi") status,
options(noreturn)
);
}
}
fn main() {
//works
dbg!(getpid_syscall());
// crash with rustc_codegen_gcc
exit_syscall(0);
// unreachable
std::process::exit(1);
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working