Skip to content

Commit

Permalink
restore: sa_restorer not present in mips* architectures
Browse files Browse the repository at this point in the history
Issue: #38
  • Loading branch information
XuShaohua committed Oct 16, 2024
1 parent 32f14d8 commit 1c807cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,18 @@ fn check_sa_restorer(target_arch: &str) {
//println!("cargo::rustc-check-cfg=cfg(nc_has_sa_restorer)");
println!("cargo:rustc-check-cfg=cfg(nc_has_sa_restorer)");

if target_arch != "riscv64" {
// Some architectures do not contain sa_restorer property in sa_sigaction_t.
// - mips
// - mipsel
// - mips64
// - mips64el
// - riscv64
if target_arch != "mips"
&& target_arch != "mipsel"
&& target_arch != "mips64"
&& target_arch != "mips64el"
&& target_arch != "riscv64"
{
println!("cargo:rustc-cfg=nc_has_sa_restorer");
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/restore/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// Use of this source is governed by Apache-2.0 License that can be found
// in the LICENSE file.

#[cfg(nc_has_sa_restorer)]
use crate::{restorefn_t, rt_sigaction, sigaction_t, SIGSEGV};

/// Reuse sa restorer function.
///
/// This method is unreliable.
#[cfg(nc_has_sa_restorer)]
#[must_use]
#[inline]
pub fn get_sa_restorer() -> Option<restorefn_t> {
Expand All @@ -18,3 +20,10 @@ pub fn get_sa_restorer() -> Option<restorefn_t> {
None
}
}

#[cfg(not(nc_has_sa_restorer))]
#[must_use]
#[inline]
pub fn get_sa_restorer() -> Option<crate::restorefn_t> {
None
}

0 comments on commit 1c807cf

Please sign in to comment.