changes from feedback

This commit is contained in:
David Carlier 2023-10-20 15:12:02 +01:00 committed by David CARLIER
parent 9a963e8026
commit f4791420ab
2 changed files with 2 additions and 16 deletions

View File

@ -3,15 +3,11 @@
fn main() { fn main() {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
let target = env::var("TARGET").expect("TARGET was not set"); let target = env::var("TARGET").expect("TARGET was not set");
if target.contains("freebsd") { if target.contains("linux")
println!("cargo:rustc-cfg=freebsd12");
if env::var("RUST_STD_FREEBSD_13_ABI").is_ok() {
println!("cargo:rustc-cfg=freebsd13");
}
} else if target.contains("linux")
|| target.contains("netbsd") || target.contains("netbsd")
|| target.contains("dragonfly") || target.contains("dragonfly")
|| target.contains("openbsd") || target.contains("openbsd")
|| target.contains("freebsd")
|| target.contains("solaris") || target.contains("solaris")
|| target.contains("illumos") || target.contains("illumos")
|| target.contains("apple-darwin") || target.contains("apple-darwin")

View File

@ -76,12 +76,7 @@ impl MetadataExt for Metadata {
fn as_raw_stat(&self) -> &raw::stat { fn as_raw_stat(&self) -> &raw::stat {
// The methods below use libc::stat, so they work fine when libc is built with FreeBSD 12 ABI. // The methods below use libc::stat, so they work fine when libc is built with FreeBSD 12 ABI.
// This method would just return nonsense. // This method would just return nonsense.
#[cfg(freebsd12)]
panic!("as_raw_stat not supported with FreeBSD 12 ABI"); panic!("as_raw_stat not supported with FreeBSD 12 ABI");
#[cfg(not(freebsd12))]
unsafe {
&*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
}
} }
fn st_dev(&self) -> u64 { fn st_dev(&self) -> u64 {
self.as_inner().as_inner().st_dev as u64 self.as_inner().as_inner().st_dev as u64
@ -143,12 +138,7 @@ fn st_gen(&self) -> u32 {
fn st_flags(&self) -> u32 { fn st_flags(&self) -> u32 {
self.as_inner().as_inner().st_flags as u32 self.as_inner().as_inner().st_flags as u32
} }
#[cfg(freebsd12)]
fn st_lspare(&self) -> u32 { fn st_lspare(&self) -> u32 {
panic!("st_lspare not supported with FreeBSD 12 ABI"); panic!("st_lspare not supported with FreeBSD 12 ABI");
} }
#[cfg(not(freebsd12))]
fn st_lspare(&self) -> u32 {
self.as_inner().as_inner().st_lspare as u32
}
} }