Skip to content

Commit

Permalink
Add support for alternative QNX Neutrino network stack io-sock
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>

Adhere to coding guidelines

Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>

Fix mismatch of constants

Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
  • Loading branch information
flba-eb committed Feb 23, 2025
1 parent 4bc5300 commit ff5a039
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 97 deletions.
20 changes: 20 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3033,6 +3033,20 @@ fn test_neutrino(target: &str) {
assert!(target.contains("nto-qnx"));

let mut cfg = ctest_cfg();
if target.ends_with("_iosock") {
let qnx_target_val = std::env::var("QNX_TARGET")
.unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into());

cfg.include(qnx_target_val + "/usr/include/io-sock");
headers! { cfg:
"io-sock.h",
"sys/types.h",
"sys/socket.h",
"sys/sysctl.h",
"net/if.h",
"net/if_arp.h"
}
}

headers! { cfg:
"ctype.h",
Expand Down Expand Up @@ -3190,6 +3204,9 @@ fn test_neutrino(target: &str) {
// Does not exist in Neutrino
"locale_t" => true,

// FIXME: "'__uint128' undeclared" in C
"__uint128" => true,

_ => false,
}
});
Expand Down Expand Up @@ -3250,6 +3267,9 @@ fn test_neutrino(target: &str) {
// stack unwinding bug.
"__my_thread_exit" => true,

// Wrong const-ness
"dl_iterate_phdr" => true,

_ => false,
}
});
Expand Down
23 changes: 21 additions & 2 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,13 @@ pub const ATF_PERM: c_int = 0x04;
pub const ATF_PUBL: c_int = 0x08;
pub const ATF_USETRAILERS: c_int = 0x10;

pub const FNM_PERIOD: c_int = 1 << 2;
cfg_if! {
if #[cfg(target_os = "nto")] {
pub const FNM_PERIOD: c_int = 1 << 1;
} else {
pub const FNM_PERIOD: c_int = 1 << 2;
}
}
pub const FNM_NOMATCH: c_int = 1;

cfg_if! {
Expand All @@ -354,9 +360,22 @@ cfg_if! {
target_os = "openbsd",
))] {
pub const FNM_PATHNAME: c_int = 1 << 1;
pub const FNM_NOESCAPE: c_int = 1 << 0;
} else {
pub const FNM_PATHNAME: c_int = 1 << 0;
}
}

cfg_if! {
if #[cfg(any(
target_os = "macos",
target_os = "freebsd",
target_os = "android",
target_os = "openbsd",
))] {
pub const FNM_NOESCAPE: c_int = 1 << 0;
} else if #[cfg(target_os = "nto")] {
pub const FNM_NOESCAPE: c_int = 1 << 2;
} else {
pub const FNM_NOESCAPE: c_int = 1 << 1;
}
}
Expand Down
Loading

0 comments on commit ff5a039

Please sign in to comment.