Skip to content

Commit

Permalink
examples: Fix fork() and stat() not found on riscv64
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Oct 12, 2023
1 parent 28bd842 commit e4c0403
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions examples/pidfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ fn main() {
run_main();
}

#[cfg(any(target_arch = "aarch64", target_arch = "loongarch64"))]
#[cfg(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64"
))]
fn run_main() {}

#[cfg(not(any(target_arch = "aarch64", target_arch = "loongarch64")))]
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64"
)))]
fn run_main() {
const STDOUT_FD: i32 = 1;

Expand Down
12 changes: 10 additions & 2 deletions examples/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ fn main() {
let filepath = "/dev/fd/0";
#[cfg(target_os = "linux")]
let ret = {
#[cfg(not(any(target_arch = "aarch64", target_arch = "loongarch64")))]
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64"
)))]
unsafe {
nc::stat(filepath, &mut statbuf)
}

#[cfg(any(target_arch = "aarch64", target_arch = "loongarch64"))]
#[cfg(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64"
))]
unsafe {
nc::fstatat(nc::AT_FDCWD, filepath, &mut statbuf, 0)
}
Expand Down

0 comments on commit e4c0403

Please sign in to comment.