Skip to content
Open
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.189", 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
7 changes: 1 addition & 6 deletions src/backend/libc/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ pub(super) fn borrowed_fd(fd: BorrowedFd<'_>) -> LibcFd {

#[cfg(all(
feature = "alloc",
not(any(
windows,
target_os = "espidf",
target_os = "horizon",
target_os = "redox"
))
not(any(windows, target_os = "espidf", target_os = "horizon"))
))]
#[inline]
pub(super) fn owned_fd(fd: OwnedFd) -> LibcFd {
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,6 +1,6 @@
#[cfg(all(
feature = "alloc",
not(any(target_os = "espidf", target_os = "horizon", target_os = "redox"))
not(any(target_os = "espidf", target_os = "horizon"))
))]
pub(crate) mod dir;
#[cfg(linux_kernel)]
Expand Down
37 changes: 10 additions & 27 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 @@ -55,7 +55,6 @@ use crate::fs::Timestamps;
apple,
target_os = "espidf",
target_os = "horizon",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
Expand Down Expand Up @@ -206,7 +205,6 @@ fn openat_via_syscall(
}
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn openat(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand Down Expand Up @@ -288,7 +286,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 @@ -302,7 +299,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 @@ -338,7 +334,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 @@ -401,7 +397,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 @@ -628,7 +624,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 @@ -730,7 +725,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 @@ -812,7 +807,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 @@ -880,12 +874,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 @@ -1102,12 +1091,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 @@ -1185,7 +1169,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 @@ -1209,7 +1193,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 @@ -28,7 +28,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 @@ -630,7 +630,6 @@ impl FileType {
target_os = "haiku",
target_os = "horizon",
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 @@ -99,7 +99,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 @@ -130,7 +129,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
4 changes: 1 addition & 3 deletions src/backend/libc/thread/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::pid::Pid;
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 @@ -53,9 +52,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 @@ -244,7 +243,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
17 changes: 5 additions & 12 deletions src/backend/libc/time/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ use crate::io;
#[cfg(not(fix_y2038))]
use crate::timespec::as_libc_timespec_mut_ptr;
#[cfg(not(fix_y2038))]
#[cfg(not(any(
target_os = "redox",
target_os = "wasi",
all(apple, not(target_os = "macos"))
)))]
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
use crate::timespec::as_libc_timespec_ptr;
#[cfg(all(target_env = "gnu", fix_y2038))]
use crate::timespec::LibcTimespec;
Expand Down Expand Up @@ -53,7 +49,7 @@ weak!(fn __timerfd_gettime64(c::c_int, *mut LibcItimerspec) -> c::c_int);
#[cfg(all(target_env = "gnu", fix_y2038))]
weak!(fn __timerfd_settime64(c::c_int, c::c_int, *const LibcItimerspec, *mut LibcItimerspec) -> c::c_int);

#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(not(target_os = "wasi"))]
#[inline]
#[must_use]
pub(crate) fn clock_getres(id: ClockId) -> Timespec {
Expand Down Expand Up @@ -292,11 +288,7 @@ pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
}
}

#[cfg(not(any(
target_os = "redox",
target_os = "wasi",
all(apple, not(target_os = "macos"))
)))]
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
#[cfg(fix_y2038)]
fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
let old_timespec = c::timespec {
Expand Down Expand Up @@ -484,7 +476,8 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "netbsd"
target_os = "netbsd",
target_os = "redox"
))]
#[cfg(fix_y2038)]
fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
Expand Down
Loading
Loading