Skip to content

Commit 64a9ac5

Browse files
authored
Merge pull request #4169 from flba-eb/add_iosock_1.0
Add support for alternative QNX Neutrino network stack `io-sock`
2 parents 2c9b059 + 0e2dc3f commit 64a9ac5

File tree

4 files changed

+241
-98
lines changed

4 files changed

+241
-98
lines changed

build.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
3131
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin",
3232
],
3333
),
34-
("target_env", &["illumos", "wasi", "aix", "ohos"]),
34+
(
35+
"target_env",
36+
&["illumos", "wasi", "aix", "ohos", "nto71_iosock", "nto80"],
37+
),
3538
(
3639
"target_arch",
3740
&["loongarch64", "mips32r6", "mips64r6", "csky"],

libc-test/build.rs

+20
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,20 @@ fn test_neutrino(target: &str) {
32363236
assert!(target.contains("nto-qnx"));
32373237

32383238
let mut cfg = ctest_cfg();
3239+
if target.ends_with("_iosock") {
3240+
let qnx_target_val = std::env::var("QNX_TARGET")
3241+
.unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into());
3242+
3243+
cfg.include(qnx_target_val + "/usr/include/io-sock");
3244+
headers! { cfg:
3245+
"io-sock.h",
3246+
"sys/types.h",
3247+
"sys/socket.h",
3248+
"sys/sysctl.h",
3249+
"net/if.h",
3250+
"net/if_arp.h"
3251+
}
3252+
}
32393253

32403254
headers! { cfg:
32413255
"ctype.h",
@@ -3393,6 +3407,9 @@ fn test_neutrino(target: &str) {
33933407
// Does not exist in Neutrino
33943408
"locale_t" => true,
33953409

3410+
// FIXME: "'__uint128' undeclared" in C
3411+
"__uint128" => true,
3412+
33963413
_ => false,
33973414
}
33983415
});
@@ -3453,6 +3470,9 @@ fn test_neutrino(target: &str) {
34533470
// stack unwinding bug.
34543471
"__my_thread_exit" => true,
34553472

3473+
// Wrong const-ness
3474+
"dl_iterate_phdr" => true,
3475+
34563476
_ => false,
34573477
}
34583478
});

src/unix/mod.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,13 @@ pub const ATF_PERM: c_int = 0x04;
334334
pub const ATF_PUBL: c_int = 0x08;
335335
pub const ATF_USETRAILERS: c_int = 0x10;
336336

337-
pub const FNM_PERIOD: c_int = 1 << 2;
337+
cfg_if! {
338+
if #[cfg(target_os = "nto")] {
339+
pub const FNM_PERIOD: c_int = 1 << 1;
340+
} else {
341+
pub const FNM_PERIOD: c_int = 1 << 2;
342+
}
343+
}
338344
pub const FNM_NOMATCH: c_int = 1;
339345

340346
cfg_if! {
@@ -354,9 +360,22 @@ cfg_if! {
354360
target_os = "cygwin",
355361
))] {
356362
pub const FNM_PATHNAME: c_int = 1 << 1;
357-
pub const FNM_NOESCAPE: c_int = 1 << 0;
358363
} else {
359364
pub const FNM_PATHNAME: c_int = 1 << 0;
365+
}
366+
}
367+
368+
cfg_if! {
369+
if #[cfg(any(
370+
target_os = "macos",
371+
target_os = "freebsd",
372+
target_os = "android",
373+
target_os = "openbsd",
374+
))] {
375+
pub const FNM_NOESCAPE: c_int = 1 << 0;
376+
} else if #[cfg(target_os = "nto")] {
377+
pub const FNM_NOESCAPE: c_int = 1 << 2;
378+
} else {
360379
pub const FNM_NOESCAPE: c_int = 1 << 1;
361380
}
362381
}

0 commit comments

Comments
 (0)