summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/conv.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/backend/libc/conv.rs')
-rw-r--r--vendor/rustix/src/backend/libc/conv.rs36
1 files changed, 23 insertions, 13 deletions
diff --git a/vendor/rustix/src/backend/libc/conv.rs b/vendor/rustix/src/backend/libc/conv.rs
index d6bcc16ee..baf2a05ed 100644
--- a/vendor/rustix/src/backend/libc/conv.rs
+++ b/vendor/rustix/src/backend/libc/conv.rs
@@ -2,10 +2,10 @@
//! `c_uint`, or libc-specific pointer types. This module provides functions
//! for converting between rustix's types and libc types.
-#![allow(dead_code)]
-
use super::c;
-use super::fd::{AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, LibcFd, OwnedFd, RawFd};
+#[cfg(not(any(windows, target_os = "espidf")))]
+use super::fd::IntoRawFd;
+use super::fd::{AsRawFd, BorrowedFd, FromRawFd, LibcFd, OwnedFd, RawFd};
#[cfg(not(windows))]
use crate::ffi::CStr;
use crate::io;
@@ -16,7 +16,7 @@ pub(super) fn c_str(c: &CStr) -> *const c::c_char {
c.as_ptr()
}
-#[cfg(not(windows))]
+#[cfg(not(any(windows, target_os = "espidf", target_os = "wasi")))]
#[inline]
pub(super) fn no_fd() -> LibcFd {
-1
@@ -27,6 +27,7 @@ pub(super) fn borrowed_fd(fd: BorrowedFd<'_>) -> LibcFd {
fd.as_raw_fd() as LibcFd
}
+#[cfg(not(any(windows, target_os = "espidf", target_os = "redox")))]
#[inline]
pub(super) fn owned_fd(fd: OwnedFd) -> LibcFd {
fd.into_raw_fd() as LibcFd
@@ -41,6 +42,7 @@ pub(super) fn ret(raw: c::c_int) -> io::Result<()> {
}
}
+#[cfg(apple)]
#[inline]
pub(super) fn nonnegative_ret(raw: c::c_int) -> io::Result<()> {
if raw >= 0 {
@@ -50,6 +52,7 @@ pub(super) fn nonnegative_ret(raw: c::c_int) -> io::Result<()> {
}
}
+#[cfg(not(any(windows, target_os = "wasi")))]
#[inline]
pub(super) unsafe fn ret_infallible(raw: c::c_int) {
debug_assert_eq!(raw, 0, "unexpected error: {:?}", io::Errno::last_os_error());
@@ -64,6 +67,7 @@ pub(super) fn ret_c_int(raw: c::c_int) -> io::Result<c::c_int> {
}
}
+#[cfg(linux_kernel)]
#[inline]
pub(super) fn ret_u32(raw: c::c_int) -> io::Result<u32> {
if raw == -1 {
@@ -94,7 +98,7 @@ pub(super) fn ret_off_t(raw: c::off_t) -> io::Result<c::off_t> {
}
}
-#[cfg(not(windows))]
+#[cfg(not(any(windows, target_os = "wasi")))]
#[inline]
pub(super) fn ret_pid_t(raw: c::pid_t) -> io::Result<c::pid_t> {
if raw == -1 {
@@ -119,6 +123,7 @@ pub(super) unsafe fn ret_owned_fd(raw: LibcFd) -> io::Result<OwnedFd> {
}
}
+#[cfg(not(any(windows, target_os = "wasi")))]
#[inline]
pub(super) fn ret_discarded_fd(raw: LibcFd) -> io::Result<()> {
if raw == !0 {
@@ -128,6 +133,7 @@ pub(super) fn ret_discarded_fd(raw: LibcFd) -> io::Result<()> {
}
}
+#[cfg(not(any(windows, target_os = "wasi")))]
#[inline]
pub(super) fn ret_discarded_char_ptr(raw: *mut c::c_char) -> io::Result<()> {
if raw.is_null() {
@@ -138,7 +144,7 @@ pub(super) fn ret_discarded_char_ptr(raw: *mut c::c_char) -> io::Result<()> {
}
/// Convert the buffer-length argument value of a `send` or `recv` call.
-#[cfg(not(windows))]
+#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[inline]
pub(super) fn send_recv_len(len: usize) -> usize {
len
@@ -155,7 +161,7 @@ pub(super) fn send_recv_len(len: usize) -> i32 {
}
/// Convert the return value of a `send` or `recv` call.
-#[cfg(not(windows))]
+#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[inline]
pub(super) fn ret_send_recv(len: isize) -> io::Result<usize> {
ret_usize(len)
@@ -170,7 +176,7 @@ pub(super) fn ret_send_recv(len: i32) -> io::Result<usize> {
/// Convert the value to the `msg_iovlen` field of a `msghdr` struct.
#[cfg(all(
- not(any(windows, target_os = "wasi")),
+ not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")),
any(
target_os = "android",
all(target_os = "linux", not(target_env = "musl"))
@@ -183,7 +189,7 @@ pub(super) fn msg_iov_len(len: usize) -> c::size_t {
/// Convert the value to the `msg_iovlen` field of a `msghdr` struct.
#[cfg(all(
- not(any(windows, target_os = "wasi")),
+ not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")),
not(any(
target_os = "android",
all(target_os = "linux", not(target_env = "musl"))
@@ -200,8 +206,9 @@ pub(crate) fn msg_iov_len(len: usize) -> c::c_int {
solarish,
target_env = "musl",
target_os = "emscripten",
+ target_os = "fuchsia",
target_os = "haiku",
- target_os = "fuchsia"
+ target_os = "nto",
))]
#[inline]
pub(crate) fn msg_control_len(len: usize) -> c::socklen_t {
@@ -212,12 +219,15 @@ pub(crate) fn msg_control_len(len: usize) -> c::socklen_t {
#[cfg(not(any(
bsd,
solarish,
+ windows,
target_env = "musl",
target_os = "emscripten",
- target_os = "haiku",
+ target_os = "espidf",
target_os = "fuchsia",
- windows,
- target_os = "wasi"
+ target_os = "haiku",
+ target_os = "nto",
+ target_os = "redox",
+ target_os = "wasi",
)))]
#[inline]
pub(crate) fn msg_control_len(len: usize) -> c::size_t {