Skip to content

Commit f5bfa9f

Browse files
committed
Add support for alternative QNX Neutrino network stack io-sock
Signed-off-by: Florian Bartels <[email protected]>
1 parent 094464b commit f5bfa9f

File tree

3 files changed

+237
-97
lines changed

3 files changed

+237
-97
lines changed

libc-test/build.rs

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

32223222
let mut cfg = ctest_cfg();
3223+
if target.ends_with("_iosock") {
3224+
let qnx_target_val = std::env::var("QNX_TARGET")
3225+
.unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into());
3226+
3227+
cfg.include(qnx_target_val + "/usr/include/io-sock");
3228+
headers! { cfg:
3229+
"io-sock.h",
3230+
"sys/types.h",
3231+
"sys/socket.h",
3232+
"sys/sysctl.h",
3233+
"net/if.h",
3234+
"net/if_arp.h"
3235+
}
3236+
}
32233237

32243238
headers! { cfg:
32253239
"ctype.h",
@@ -3377,6 +3391,9 @@ fn test_neutrino(target: &str) {
33773391
// Does not exist in Neutrino
33783392
"locale_t" => true,
33793393

3394+
// FIXME: "'__uint128' undeclared" in C
3395+
"__uint128" => true,
3396+
33803397
_ => false,
33813398
}
33823399
});
@@ -3437,6 +3454,9 @@ fn test_neutrino(target: &str) {
34373454
// stack unwinding bug.
34383455
"__my_thread_exit" => true,
34393456

3457+
// Wrong const-ness
3458+
"dl_iterate_phdr" => true,
3459+
34403460
_ => false,
34413461
}
34423462
});

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! {
@@ -353,9 +359,22 @@ cfg_if! {
353359
target_os = "openbsd",
354360
))] {
355361
pub const FNM_PATHNAME: c_int = 1 << 1;
356-
pub const FNM_NOESCAPE: c_int = 1 << 0;
357362
} else {
358363
pub const FNM_PATHNAME: c_int = 1 << 0;
364+
}
365+
}
366+
367+
cfg_if! {
368+
if #[cfg(any(
369+
target_os = "macos",
370+
target_os = "freebsd",
371+
target_os = "android",
372+
target_os = "openbsd",
373+
))] {
374+
pub const FNM_NOESCAPE: c_int = 1 << 0;
375+
} else if #[cfg(target_os = "nto")] {
376+
pub const FNM_NOESCAPE: c_int = 1 << 2;
377+
} else {
359378
pub const FNM_NOESCAPE: c_int = 1 << 1;
360379
}
361380
}

0 commit comments

Comments
 (0)