Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ rustc-std-workspace-alloc = { version = "1.0.0", optional = true } # not aliased
[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))'.dependencies]
linux-raw-sys = { version = "0.12", default-features = false, features = ["auxvec", "general", "errno", "ioctl", "no_std", "elf"] }
libc_errno = { package = "errno", version = "0.3.10", default-features = false, optional = true }
libc = { version = "0.2.182", default-features = false, optional = true }
libc = { version = "0.2.186", default-features = false, optional = true }

# Dependencies for platforms where only libc is supported:
#
# On all other Unix-family platforms, and under Miri, we always use the libc
# backend, so enable its dependencies unconditionally.
[target.'cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
libc_errno = { package = "errno", version = "0.3.10", default-features = false }
libc = { version = "0.2.182", default-features = false }
libc = { version = "0.2.189", default-features = false }

# Additional dependencies for Linux and Android with the libc backend:
#
Expand All @@ -69,7 +69,7 @@ default-features = false

[dev-dependencies]
tempfile = "3.5.0"
libc = "0.2.171"
libc = "0.2.189"
libc_errno = { package = "errno", version = "0.3.10", default-features = false }
serial_test = "2.0.0"
memoffset = "0.9.0"
Expand Down
5 changes: 1 addition & 4 deletions src/backend/libc/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ pub(super) fn borrowed_fd(fd: BorrowedFd<'_>) -> LibcFd {
fd.as_raw_fd() as LibcFd
}

#[cfg(all(
feature = "alloc",
not(any(windows, target_os = "espidf", target_os = "redox"))
))]
#[cfg(all(feature = "alloc", not(any(windows, target_os = "espidf"))))]
#[inline]
pub(super) fn owned_fd(fd: OwnedFd) -> LibcFd {
fd.into_raw_fd() as LibcFd
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/event/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ pub(crate) fn port_send(
unsafe { ret(c::port_send(borrowed_fd(port), events, userdata)) }
}

#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(not(target_os = "wasi"))]
pub(crate) fn pause() {
let r = unsafe { c::pause() };
let errno = libc_errno::errno().0;
Expand Down
10 changes: 7 additions & 3 deletions src/backend/libc/event/types.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "illumos"))]
#[cfg(any(
linux_kernel,
target_os = "freebsd",
target_os = "illumos",
))]
use crate::backend::c;
#[cfg(any(
linux_kernel,
target_os = "freebsd",
target_os = "illumos",
target_os = "espidf"
target_os = "espidf",
))]
use bitflags::bitflags;

#[cfg(any(
linux_kernel,
target_os = "freebsd",
target_os = "illumos",
target_os = "espidf"
target_os = "espidf",
))]
bitflags! {
/// `EFD_*` flags for use with [`eventfd`].
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/fs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(feature = "alloc", not(any(target_os = "espidf", target_os = "redox"))))]
#[cfg(all(feature = "alloc", not(target_os = "espidf")))]
pub(crate) mod dir;
#[cfg(linux_kernel)]
pub mod inotify;
Expand Down
44 changes: 11 additions & 33 deletions src/backend/libc/fs/syscalls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! libc syscalls supporting `rustix::fs`.

use crate::backend::c;
#[cfg(any(not(target_os = "redox"), feature = "alloc"))]
use crate::backend::conv::ret_usize;
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
use crate::backend::conv::{
borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd, ret_usize,
};
use crate::fd::{BorrowedFd, OwnedFd};
#[allow(unused_imports)]
use crate::ffi;
Expand All @@ -12,7 +12,7 @@ use crate::ffi::CStr;
use crate::ffi::CString;
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
use crate::fs::Access;
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
#[cfg(not(target_os = "espidf"))]
use crate::fs::AtFlags;
#[cfg(not(any(
netbsdlike,
Expand Down Expand Up @@ -51,13 +51,7 @@ use crate::fs::SealFlags;
use crate::fs::StatFs;
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
use crate::fs::Timestamps;
#[cfg(not(any(
apple,
target_os = "espidf",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
#[cfg(not(any(apple, target_os = "espidf", target_os = "vita", target_os = "wasi")))]
use crate::fs::{Dev, FileType};
use crate::fs::{Mode, OFlags, SeekFrom, Stat};
#[cfg(not(target_os = "wasi"))]
Expand Down Expand Up @@ -205,7 +199,6 @@ fn openat_via_syscall(
}
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn openat(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand Down Expand Up @@ -287,7 +280,6 @@ pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
unsafe { ret_usize(c::readlink(c_str(path), buf.as_mut_ptr().cast(), buf.len()) as isize) }
}

#[cfg(not(target_os = "redox"))]
#[inline]
pub(crate) unsafe fn readlinkat(
dirfd: BorrowedFd<'_>,
Expand All @@ -301,7 +293,6 @@ pub(crate) fn mkdir(path: &CStr, mode: Mode) -> io::Result<()> {
unsafe { ret(c::mkdir(c_str(path), mode.bits() as c::mode_t)) }
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn mkdirat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Result<()> {
unsafe {
ret(c::mkdirat(
Expand Down Expand Up @@ -337,7 +328,7 @@ pub(crate) fn link(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
unsafe { ret(c::link(c_str(old_path), c_str(new_path))) }
}

#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
#[cfg(not(target_os = "espidf"))]
pub(crate) fn linkat(
old_dirfd: BorrowedFd<'_>,
old_path: &CStr,
Expand Down Expand Up @@ -400,7 +391,7 @@ pub(crate) fn unlink(path: &CStr) -> io::Result<()> {
unsafe { ret(c::unlink(c_str(path))) }
}

#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
#[cfg(not(target_os = "espidf"))]
pub(crate) fn unlinkat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<()> {
// macOS ≤ 10.9 lacks `unlinkat`.
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -627,7 +618,6 @@ pub(crate) fn symlink(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
unsafe { ret(c::symlink(c_str(old_path), c_str(new_path))) }
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn symlinkat(
old_path: &CStr,
new_dirfd: BorrowedFd<'_>,
Expand Down Expand Up @@ -729,7 +719,7 @@ pub(crate) fn lstat(path: &CStr) -> io::Result<Stat> {
}
}

#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
#[cfg(not(target_os = "espidf"))]
pub(crate) fn statat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<Stat> {
// See the comments in `fstat` about using `crate::fs::statx` here.
#[cfg(all(
Expand Down Expand Up @@ -811,7 +801,6 @@ pub(crate) fn access(path: &CStr, access: Access) -> io::Result<()> {
target_os = "emscripten",
target_os = "espidf",
target_os = "horizon",
target_os = "redox",
target_os = "vita"
)))]
pub(crate) fn accessat(
Expand Down Expand Up @@ -879,12 +868,7 @@ pub(crate) fn accessat(
Ok(())
}

#[cfg(not(any(
target_os = "espidf",
target_os = "horizon",
target_os = "redox",
target_os = "vita"
)))]
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
pub(crate) fn utimensat(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand Down Expand Up @@ -1092,12 +1076,7 @@ pub(crate) fn chmod(path: &CStr, mode: Mode) -> io::Result<()> {
unsafe { ret(c::chmod(c_str(path), mode.bits() as c::mode_t)) }
}

#[cfg(not(any(
linux_kernel,
target_os = "espidf",
target_os = "redox",
target_os = "wasi"
)))]
#[cfg(not(any(linux_kernel, target_os = "espidf", target_os = "wasi")))]
pub(crate) fn chmodat(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand Down Expand Up @@ -1175,7 +1154,7 @@ pub(crate) fn fclonefileat(
}
}

#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
pub(crate) fn chownat(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand All @@ -1199,7 +1178,6 @@ pub(crate) fn chownat(
apple,
target_os = "espidf",
target_os = "horizon",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
Expand Down
3 changes: 1 addition & 2 deletions src/backend/libc/fs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bitflags! {
}
}

#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "redox")))]
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
bitflags! {
/// `AT_*` constants for use with [`openat`], [`statat`], and other `*at`
/// functions.
Expand Down Expand Up @@ -620,7 +620,6 @@ impl FileType {
target_os = "espidf",
target_os = "haiku",
target_os = "nto",
target_os = "redox",
target_os = "vita"
)))]
#[inline]
Expand Down
2 changes: 0 additions & 2 deletions src/backend/libc/io/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ pub(crate) fn writev(fd: BorrowedFd<'_>, bufs: &[IoSlice<'_>]) -> io::Result<usi
target_os = "haiku",
target_os = "horizon",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
)))]
Expand Down Expand Up @@ -129,7 +128,6 @@ pub(crate) fn preadv(
target_os = "haiku",
target_os = "nto",
target_os = "horizon",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
)))]
Expand Down
6 changes: 2 additions & 4 deletions src/backend/libc/thread/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ use crate::pid::Pid;
target_os = "emscripten",
target_os = "espidf",
target_os = "haiku",
target_os = "openbsd",
target_os = "redox",
target_os = "openbsd",
target_os = "vita",
target_os = "wasi",
)))]
use crate::thread::ClockId;
#[cfg(linux_kernel)]
use crate::thread::{Cpuid, MembarrierCommand, MembarrierQuery};
#[cfg(not(target_os = "redox"))]
use crate::thread::{NanosleepRelativeResult, Timespec};
#[cfg(all(target_env = "gnu", fix_y2038))]
use crate::timespec::LibcTimespec;
Expand Down Expand Up @@ -52,9 +51,9 @@ weak!(fn __nanosleep64(*const LibcTimespec, *mut LibcTimespec) -> c::c_int);
target_os = "espidf",
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
target_os = "haiku",
target_os = "redox",
target_os = "horizon",
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi",
)))]
Expand Down Expand Up @@ -243,7 +242,6 @@ fn clock_nanosleep_absolute_old(id: crate::clockid::ClockId, request: &Timespec)
}
}

#[cfg(not(target_os = "redox"))]
#[inline]
pub(crate) fn nanosleep(request: &Timespec) -> NanosleepRelativeResult {
// Old 32-bit version: libc has `nanosleep` but it is not y2038 safe by
Expand Down
Loading
Loading