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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ libc = { version = "0.2.171", default-features = false, optional = true }
libc_errno = { package = "errno", version = "0.3.10", default-features = false }
libc = { version = "0.2.171", default-features = false }

# Additional dependencies for Linux with the libc backend:
# Additional dependencies for Linux and Android with the libc backend:
#
# Some syscalls do not have libc wrappers, such as in `io_uring`. For these,
# the libc backend uses the linux-raw-sys ABI and `libc::syscall`.
[target.'cfg(all(any(target_os = "linux"), 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]
[target.'cfg(all(any(target_os = "linux", target_os = "android"), 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]
linux-raw-sys = { version = "0.11.0", default-features = false, features = ["general", "ioctl", "no_std"] }

# For the libc backend on Windows, use the Winsock API in windows-sys.
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn main() {
|| arch.starts_with("mips"))
&& !rustix_use_experimental_asm);
if libc {
if os != "android" && os == "linux" && !cfg_no_linux_raw {
if (os == "linux" || os == "android") && !cfg_no_linux_raw {
use_feature("linux_raw_dep");
}

Expand Down
1 change: 1 addition & 0 deletions src/backend/libc/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ mod statx_flags {
linux_like,
linux_raw_dep,
not(any(
target_os = "android",
target_os = "emscripten",
target_env = "gnu",
all(target_arch = "loongarch64", target_env = "musl")
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub(crate) mod event;
#[cfg(feature = "fs")]
pub(crate) mod fs;
pub(crate) mod io;
#[cfg(linux_kernel)]
#[cfg(all(linux_kernel, not(target_os = "android")))]
#[cfg(feature = "io_uring")]
pub(crate) mod io_uring;
#[cfg(not(any(
Expand Down
6 changes: 3 additions & 3 deletions src/backend/libc/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ use c::TCP_KEEPALIVE as TCP_KEEPIDLE;
use c::TCP_KEEPIDLE;
use core::mem::{size_of, MaybeUninit};
use core::time::Duration;
#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, target_os = "linux"))]
use linux_raw_sys::xdp::{xdp_mmap_offsets, xdp_statistics, xdp_statistics_v1};

#[inline]
Expand Down Expand Up @@ -1153,7 +1153,7 @@ pub(crate) fn set_xdp_rx_ring_size(fd: BorrowedFd<'_>, value: u32) -> io::Result
setsockopt(fd, c::SOL_XDP, c::XDP_RX_RING, value)
}

#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, target_os = "linux"))]
#[inline]
pub(crate) fn xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffsets> {
// The kernel will write `xdp_mmap_offsets` or `xdp_mmap_offsets_v1` to the
Expand Down Expand Up @@ -1240,7 +1240,7 @@ pub(crate) fn xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffsets>
}
}

#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, target_os = "linux"))]
#[inline]
pub(crate) fn xdp_statistics(fd: BorrowedFd<'_>) -> io::Result<XdpStatistics> {
let mut optlen = size_of::<xdp_statistics>().try_into().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub mod ffi;
#[cfg_attr(docsrs, doc(cfg(feature = "fs")))]
pub mod fs;
pub mod io;
#[cfg(linux_kernel)]
#[cfg(all(linux_kernel, not(target_os = "android")))]
#[cfg(feature = "io_uring")]
#[cfg_attr(docsrs, doc(cfg(feature = "io_uring")))]
pub mod io_uring;
Expand Down
4 changes: 2 additions & 2 deletions src/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ pub fn set_xdp_rx_ring_size<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> {
/// - [Linux]
///
/// [Linux]: https://www.kernel.org/doc/html/next/networking/af_xdp.html
#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, target_os = "linux"))]
#[doc(alias = "XDP_MMAP_OFFSETS")]
pub fn xdp_mmap_offsets<Fd: AsFd>(fd: Fd) -> io::Result<XdpMmapOffsets> {
backend::net::sockopt::xdp_mmap_offsets(fd.as_fd())
Expand All @@ -1786,7 +1786,7 @@ pub fn xdp_mmap_offsets<Fd: AsFd>(fd: Fd) -> io::Result<XdpMmapOffsets> {
/// - [Linux]
///
/// [Linux]: https://www.kernel.org/doc/html/next/networking/af_xdp.html#xdp-statistics-getsockopt
#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, target_os = "linux"))]
#[doc(alias = "XDP_STATISTICS")]
pub fn xdp_statistics<Fd: AsFd>(fd: Fd) -> io::Result<XdpStatistics> {
backend::net::sockopt::xdp_statistics(fd.as_fd())
Expand Down
10 changes: 5 additions & 5 deletions tests/io/read_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn test_rwf_values() {
);
}

#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, not(target_os = "android")))]
#[cfg(feature = "fs")]
#[test]
fn test_pwritev2() {
Expand Down Expand Up @@ -256,7 +256,7 @@ fn test_pwritev2() {
assert_eq!(&buf, b"world");
}

#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, not(target_os = "android")))]
#[cfg(all(feature = "net", feature = "pipe"))]
#[test]
fn test_preadv2_nowait() {
Expand Down Expand Up @@ -308,7 +308,7 @@ fn test_preadv2_nowait() {
fn test_p_offsets() {
use rustix::fs::{openat, Mode, OFlags, CWD};
use rustix::io::{pread, preadv, pwrite, pwritev};
#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, not(target_os = "android")))]
use rustix::io::{preadv2, pwritev2, ReadWriteFlags};

let mut buf = [0_u8; 5];
Expand Down Expand Up @@ -343,7 +343,7 @@ fn test_p_offsets() {
Ok(_) => {}
Err(e) => panic!("pwritev failed with an unexpected error: {:?}", e),
}
#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, not(target_os = "android")))]
{
match preadv2(
&f,
Expand Down Expand Up @@ -393,7 +393,7 @@ fn test_p_offsets() {
Err(e) => panic!("pwritev failed with an unexpected error: {:?}", e),
}
}
#[cfg(linux_raw_dep)]
#[cfg(all(linux_raw_dep, not(target_os = "android")))]
{
match preadv2(
&f,
Expand Down
Loading