Skip to content

Commit e65da91

Browse files
committed
proposal to separate netbsd 10 release from its predecessors which
will be still used for a while. One of the visible example is the kevent using finally a void pointer like other BSD.
1 parent 794b8b3 commit e65da91

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

build.rs

+22
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
2929
"libc_thread_local",
3030
"libc_underscore_const_names",
3131
"libc_union",
32+
"netbsd10",
3233
];
3334

3435
// Extra values to allow for check-cfg.
@@ -73,6 +74,12 @@ fn main() {
7374
Some(_) | None => set_cfg("freebsd11"),
7475
}
7576

77+
match which_netbsd() {
78+
// TODO: to update if there is a api breaking change
79+
Some(10..=99) => set_cfg("netbsd10"),
80+
Some(_) | None => (),
81+
}
82+
7683
match emcc_version_code() {
7784
Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"),
7885
// Non-Emscripten or version < 3.1.42.
@@ -256,6 +263,21 @@ fn which_freebsd() -> Option<i32> {
256263
}
257264
}
258265

266+
fn which_netbsd() -> Option<i32> {
267+
let output = std::process::Command::new("uname").arg("-r").output().ok();
268+
if output.is_none() {
269+
return None;
270+
}
271+
272+
let output = output.unwrap();
273+
let stdout = String::from_utf8(output.stdout).ok().unwrap();
274+
275+
match &stdout {
276+
s if s.starts_with("10") => Some(10),
277+
_ => None,
278+
}
279+
}
280+
259281
fn emcc_version_code() -> Option<u64> {
260282
let output = std::process::Command::new("emcc")
261283
.arg("-dumpversion")

libc-test/build.rs

+22
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,13 @@ fn test_netbsd(target: &str) {
10371037
assert!(target.contains("netbsd"));
10381038
let mut cfg = ctest_cfg();
10391039

1040+
let netbsd_ver = which_netbsd();
1041+
1042+
match netbsd_ver {
1043+
Some(10..=99) => cfg.cfg("netbsd10", None),
1044+
_ => &mut cfg,
1045+
};
1046+
10401047
cfg.flag("-Wno-deprecated-declarations");
10411048
cfg.define("_NETBSD_SOURCE", Some("1"));
10421049

@@ -4458,6 +4465,21 @@ fn which_freebsd() -> Option<i32> {
44584465
}
44594466
}
44604467

4468+
fn which_netbsd() -> Option<i32> {
4469+
let output = std::process::Command::new("uname").arg("-r").output().ok();
4470+
if output.is_none() {
4471+
return None;
4472+
}
4473+
4474+
let output = output.unwrap();
4475+
let stdout = String::from_utf8(output.stdout).ok().unwrap();
4476+
4477+
match &stdout {
4478+
s if s.starts_with("10") => Some(10),
4479+
_ => None,
4480+
}
4481+
}
4482+
44614483
fn test_haiku(target: &str) {
44624484
assert!(target.contains("haiku"));
44634485

src/unix/bsd/netbsdlike/netbsd/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ s! {
286286
pub flags: u32,
287287
pub fflags: u32,
288288
pub data: i64,
289-
pub udata: ::intptr_t, /* FIXME: NetBSD 10.0 will finally have same layout as other BSD */
289+
#[cfg(netbsd10)]
290+
pub udata: *mut ::c_void,
291+
#[cfg(not(netbsd10))]
292+
pub udata: ::intptr_t,
290293
}
291294

292295
pub struct dqblk {

0 commit comments

Comments
 (0)