summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/system/syscalls.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/backend/libc/system/syscalls.rs')
-rw-r--r--vendor/rustix/src/backend/libc/system/syscalls.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/vendor/rustix/src/backend/libc/system/syscalls.rs b/vendor/rustix/src/backend/libc/system/syscalls.rs
index a731e9302..27efd2653 100644
--- a/vendor/rustix/src/backend/libc/system/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/system/syscalls.rs
@@ -7,7 +7,12 @@ use crate::backend::conv::ret_infallible;
#[cfg(linux_kernel)]
use crate::system::Sysinfo;
use core::mem::MaybeUninit;
-#[cfg(not(any(target_os = "emscripten", target_os = "redox", target_os = "wasi")))]
+#[cfg(not(any(
+ target_os = "emscripten",
+ target_os = "espidf",
+ target_os = "redox",
+ target_os = "wasi"
+)))]
use {crate::backend::conv::ret, crate::io};
#[cfg(not(target_os = "wasi"))]
@@ -15,7 +20,15 @@ use {crate::backend::conv::ret, crate::io};
pub(crate) fn uname() -> RawUname {
let mut uname = MaybeUninit::<RawUname>::uninit();
unsafe {
- ret_infallible(c::uname(uname.as_mut_ptr()));
+ let r = c::uname(uname.as_mut_ptr());
+
+ // On POSIX, `uname` is documented to return non-negative on success
+ // instead of the usual 0, though some specific systems do document
+ // that they always use zero allowing us to skip this check.
+ #[cfg(not(any(apple, freebsdlike, linux_like, target_os = "netbsd")))]
+ let r = core::cmp::min(r, 0);
+
+ ret_infallible(r);
uname.assume_init()
}
}
@@ -29,7 +42,12 @@ pub(crate) fn sysinfo() -> Sysinfo {
}
}
-#[cfg(not(any(target_os = "emscripten", target_os = "redox", target_os = "wasi")))]
+#[cfg(not(any(
+ target_os = "emscripten",
+ target_os = "espidf",
+ target_os = "redox",
+ target_os = "wasi"
+)))]
pub(crate) fn sethostname(name: &[u8]) -> io::Result<()> {
unsafe {
ret(c::sethostname(