Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"libc_const_extern_fn_unstable",
"libc_deny_warnings",
"libc_thread_local",
"netbsd10",
];

// Extra values to allow for check-cfg.
Expand Down Expand Up @@ -62,6 +63,12 @@ fn main() {
Some(_) | None => set_cfg("freebsd11"),
}

match which_netbsd() {
// TODO: to update if there is a api breaking change
Some(10..=99) => set_cfg("netbsd10"),
Some(_) | None => (),
}

match emcc_version_code() {
Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"),
// Non-Emscripten or version < 3.1.42.
Expand Down Expand Up @@ -183,6 +190,21 @@ fn which_freebsd() -> Option<i32> {
}
}

fn which_netbsd() -> Option<i32> {
let output = std::process::Command::new("uname").arg("-r").output().ok();
if output.is_none() {
return None;
}

let output = output.unwrap();
let stdout = String::from_utf8(output.stdout).ok().unwrap();

match &stdout {
s if s.starts_with("10") => Some(10),
_ => None,
}
}

fn emcc_version_code() -> Option<u64> {
let output = std::process::Command::new("emcc")
.arg("-dumpversion")
Expand Down
22 changes: 22 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,13 @@ fn test_netbsd(target: &str) {
assert!(target.contains("netbsd"));
let mut cfg = ctest_cfg();

let netbsd_ver = which_netbsd();

match netbsd_ver {
Some(10..=99) => cfg.cfg("netbsd10", None),
_ => &mut cfg,
};

cfg.flag("-Wno-deprecated-declarations");
cfg.define("_NETBSD_SOURCE", Some("1"));

Expand Down Expand Up @@ -4539,6 +4546,21 @@ fn which_freebsd() -> Option<i32> {
}
}

fn which_netbsd() -> Option<i32> {
let output = std::process::Command::new("uname").arg("-r").output().ok();
if output.is_none() {
return None;
}

let output = output.unwrap();
let stdout = String::from_utf8(output.stdout).ok().unwrap();

match &stdout {
s if s.starts_with("10") => Some(10),
_ => None,
}
}

fn test_haiku(target: &str) {
assert!(target.contains("haiku"));

Expand Down
5 changes: 4 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ s! {
pub flags: u32,
pub fflags: u32,
pub data: i64,
pub udata: ::intptr_t, /* FIXME: NetBSD 10.0 will finally have same layout as other BSD */
#[cfg(netbsd10)]
pub udata: *mut ::c_void,
#[cfg(not(netbsd10))]
pub udata: ::intptr_t,
}

pub struct dqblk {
Expand Down