diff --git a/Cargo.toml b/Cargo.toml index 2b2f8a48..84d71c7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,23 +31,30 @@ compiler_builtins = { version = '0.1.49', optional = true } [target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies] once_cell = { version = "1.5.2", optional = true } -# On Linux on selected architectures, we have two supported backends: linux_raw -# and libc. The libc and libc_errno dependencies are only enabled when the libc -# backend is in use. +# Dependencies for platforms where linux_raw is supported, in addition to libc: +# +# On Linux on selected architectures, the linux_raw backend is supported, in +# addition to the libc backend. The linux_raw backend is used by default. +# The libc # backend can be selected via adding `--cfg=rustix_use_libc` to +# `RUSTFLAGS` or enabling the `use-libc` cargo feature. [target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64")))))'.dependencies] linux-raw-sys = { version = "0.0.46", default-features = false, features = ["general", "errno", "ioctl", "no_std"] } libc_errno = { package = "errno", version = "0.2.8", default-features = false, optional = true } libc = { version = "0.2.118", features = ["extra_traits"], 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(any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64")))))))'.dependencies] libc_errno = { package = "errno", version = "0.2.8", default-features = false } libc = { version = "0.2.118", features = ["extra_traits"] } -[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64"))))))))'.dependencies] +# Additional dependencies for Linux with the libc backend: +# # Some syscalls do not have libc wrappers, such as in `io_uring`. For these, -# we use the linux-raw-sys ABI and `libc::syscall`. +# the libc backend uses the linux-raw-sys ABI and `libc::syscall`. +[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64"))))))))'.dependencies] linux-raw-sys = { version = "0.0.46", default-features = false, optional = true, features = ["general", "no_std"] } # For the libc backend on Windows, use the Winsock2 API in windows-sys. diff --git a/benches/mod.rs b/benches/mod.rs index 01c9898a..3097324b 100644 --- a/benches/mod.rs +++ b/benches/mod.rs @@ -2,7 +2,7 @@ windows, target_os = "emscripten", target_os = "redox", - target_os = "wasi" + target_os = "wasi", ))] fn main() { unimplemented!() @@ -12,7 +12,7 @@ fn main() { windows, target_os = "emscripten", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] use criterion::{criterion_group, criterion_main}; @@ -20,7 +20,7 @@ use criterion::{criterion_group, criterion_main}; windows, target_os = "emscripten", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] mod suite { use criterion::Criterion; @@ -135,7 +135,7 @@ mod suite { windows, target_os = "emscripten", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] criterion_group!( benches, @@ -152,6 +152,6 @@ criterion_group!( windows, target_os = "emscripten", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] criterion_main!(benches); diff --git a/examples/process.rs b/examples/process.rs index 8b12539f..49c6b8d9 100644 --- a/examples/process.rs +++ b/examples/process.rs @@ -14,7 +14,7 @@ fn main() -> io::Result<()> { println!("Gid: {}", getgid().as_raw()); #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] { let (a, b) = linux_hwcap(); @@ -82,9 +82,9 @@ fn main() -> io::Result<()> { )))] println!("Rtprio Limit: {:?}", getrlimit(Resource::Rtprio)); #[cfg(not(any( + target_os = "android", target_os = "emscripten", target_os = "freebsd", - target_os = "android", target_os = "ios", target_os = "macos", target_os = "netbsd", diff --git a/examples/stdio.rs b/examples/stdio.rs index 444f9d78..0c400195 100644 --- a/examples/stdio.rs +++ b/examples/stdio.rs @@ -123,7 +123,7 @@ fn show(fd: Fd) -> io::Result<()> { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] if (term.c_iflag & IUTF8) != 0 { print!(" IUTF8"); @@ -141,7 +141,7 @@ fn show(fd: Fd) -> io::Result<()> { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "redox" + target_os = "redox", )))] if (term.c_oflag & OLCUC) != 0 { print!(" OLCUC"); diff --git a/src/fs/abs.rs b/src/fs/abs.rs index 6c91a41c..25556304 100644 --- a/src/fs/abs.rs +++ b/src/fs/abs.rs @@ -4,14 +4,14 @@ target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] use crate::fs::StatFs; #[cfg(not(any( target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] use crate::{imp, io, path}; @@ -25,7 +25,7 @@ use crate::{imp, io, path}; target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] #[inline] pub fn statfs(path: P) -> io::Result { diff --git a/src/fs/fd.rs b/src/fs/fd.rs index 6ed3ff09..7ddceeae 100644 --- a/src/fs/fd.rs +++ b/src/fs/fd.rs @@ -16,7 +16,7 @@ pub use imp::fs::types::FlockOperation; target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub use imp::fs::types::FallocateFlags; @@ -26,7 +26,7 @@ pub use imp::fs::types::Stat; target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub use imp::fs::types::StatFs; @@ -156,7 +156,7 @@ pub fn fstat(fd: Fd) -> io::Result { target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet #[inline] pub fn fstatfs(fd: Fd) -> io::Result { @@ -196,7 +196,7 @@ pub fn futimens(fd: Fd, times: &Timestamps) -> io::Result<()> { target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] // not implemented in libc for netbsd yet #[inline] #[doc(alias = "posix_fallocate")] @@ -223,7 +223,7 @@ pub(crate) fn _is_file_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool) target_os = "android", target_os = "fuchsia", target_os = "linux", - target_os = "emscripten" + target_os = "emscripten", ))] if mode.contains(crate::fs::OFlags::PATH) { return Ok((false, false)); @@ -270,7 +270,7 @@ pub fn fsync(fd: Fd) -> io::Result<()> { target_os = "dragonfly", target_os = "ios", target_os = "macos", - target_os = "redox" + target_os = "redox", )))] #[inline] pub fn fdatasync(fd: Fd) -> io::Result<()> { diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 5a793625..49b9c3b5 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -20,7 +20,7 @@ mod dir; target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] mod fadvise; pub(crate) mod fcntl; @@ -41,7 +41,7 @@ mod getpath; target_os = "netbsd", target_os = "openbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] mod makedev; #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] @@ -58,7 +58,7 @@ mod statx; target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] #[cfg(feature = "fs")] pub use abs::statfs; @@ -114,7 +114,7 @@ pub use dir::{Dir, DirEntry}; target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub use fadvise::{fadvise, Advice}; #[cfg(not(target_os = "wasi"))] @@ -134,22 +134,21 @@ pub use fcopyfile::{ copyfile_state_alloc, copyfile_state_free, copyfile_state_get, copyfile_state_get_copied, copyfile_state_t, fcopyfile, }; +#[cfg(not(any( + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "redox", +)))] +pub use fd::fdatasync; #[cfg(not(any( target_os = "dragonfly", target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub use fd::{fallocate, FallocateFlags}; - -#[cfg(not(any( - target_os = "dragonfly", - target_os = "ios", - target_os = "macos", - target_os = "redox" -)))] -pub use fd::fdatasync; #[cfg(not(target_os = "wasi"))] pub use fd::{fchmod, fchown, flock, FlockOperation}; pub use fd::{fstat, fsync, ftruncate, futimens, is_file_read_write, seek, tell, Stat, Timestamps}; @@ -157,7 +156,7 @@ pub use fd::{fstat, fsync, ftruncate, futimens, is_file_read_write, seek, tell, target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet pub use fd::{fstatfs, StatFs}; @@ -175,7 +174,7 @@ pub use getpath::getpath; target_os = "netbsd", target_os = "openbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub use makedev::{major, makedev, minor}; #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] diff --git a/src/imp/libc/fs/dir.rs b/src/imp/libc/fs/dir.rs index ae9555f8..c0912602 100644 --- a/src/imp/libc/fs/dir.rs +++ b/src/imp/libc/fs/dir.rs @@ -11,7 +11,7 @@ use crate::fs::{fcntl_getfl, fstat, openat, Mode, OFlags, Stat}; target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet use crate::fs::{fstatfs, StatFs}; use crate::io; @@ -38,7 +38,7 @@ use c::readdir as libc_readdir; target_os = "android", target_os = "emscripten", target_os = "l4re", - target_os = "linux" + target_os = "linux", ))] use c::{dirent64 as libc_dirent, readdir64 as libc_readdir}; use core::fmt; @@ -132,7 +132,7 @@ impl Dir { target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet #[inline] pub fn statfs(&self) -> io::Result { @@ -168,7 +168,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent { target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] let d_ino = input.d_ino; @@ -183,7 +183,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent { target_os = "netbsd", target_os = "openbsd", target_os = "ios", - target_os = "macos" + target_os = "macos", ))] let d_namlen = input.d_namlen; @@ -210,7 +210,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent { target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] d_ino, #[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] @@ -307,8 +307,8 @@ impl DirEntry { } /// Returns the type of this directory entry. - #[inline] #[cfg(not(target_os = "illumos"))] + #[inline] pub fn file_type(&self) -> FileType { FileType::from_dirent_d_type(self.dirent.d_type) } @@ -318,7 +318,7 @@ impl DirEntry { target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] #[inline] pub fn ino(&self) -> u64 { @@ -330,7 +330,7 @@ impl DirEntry { target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] #[inline] pub fn ino(&self) -> u64 { diff --git a/src/imp/libc/fs/mod.rs b/src/imp/libc/fs/mod.rs index 0b44025f..02b7b2d6 100644 --- a/src/imp/libc/fs/mod.rs +++ b/src/imp/libc/fs/mod.rs @@ -10,7 +10,7 @@ pub(crate) mod dir; target_os = "netbsd", target_os = "openbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub(crate) mod makedev; #[cfg(not(windows))] diff --git a/src/imp/libc/fs/syscalls.rs b/src/imp/libc/fs/syscalls.rs index 236a0f97..cf31d619 100644 --- a/src/imp/libc/fs/syscalls.rs +++ b/src/imp/libc/fs/syscalls.rs @@ -36,12 +36,12 @@ use super::super::offset::{libc_fstat, libc_fstatat, libc_ftruncate, libc_lseek, target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] use super::super::offset::{libc_fstatfs, libc_statfs}; #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] use super::super::time::types::LibcTimespec; use crate::fd::BorrowedFd; @@ -67,7 +67,7 @@ use crate::fs::Advice; target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] use crate::fs::FallocateFlags; #[cfg(not(target_os = "wasi"))] @@ -85,7 +85,7 @@ use crate::fs::SealFlags; target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet use crate::fs::StatFs; @@ -104,7 +104,7 @@ use crate::io::{self, OwnedFd, SeekFrom}; use crate::process::{Gid, Uid}; #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] use crate::utils::as_ptr; use core::convert::TryInto; @@ -112,7 +112,7 @@ use core::convert::TryInto; target_os = "android", target_os = "ios", target_os = "linux", - target_os = "macos" + target_os = "macos", ))] use core::mem::size_of; use core::mem::MaybeUninit; @@ -122,7 +122,7 @@ use core::ptr::null; target_os = "android", target_os = "ios", target_os = "linux", - target_os = "macos" + target_os = "macos", ))] use core::ptr::null_mut; #[cfg(any(target_os = "ios", target_os = "macos"))] @@ -135,12 +135,12 @@ use {super::super::offset::libc_openat, crate::fs::AtFlags}; #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] weak!(fn __utimensat64(c::c_int, *const c::c_char, *const LibcTimespec, c::c_int) -> c::c_int); #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] weak!(fn __futimens64(c::c_int, *const LibcTimespec) -> c::c_int); @@ -176,7 +176,7 @@ pub(crate) fn openat( oflags: OFlags, mode: Mode, ) -> io::Result { - // Work around https://sourceware.org/bugzilla/show_bug.cgi?id=17523 + // Work around . // Basically old glibc versions don't handle O_TMPFILE correctly. #[cfg(all(unix, target_env = "gnu"))] if oflags.contains(OFlags::TMPFILE) && crate::imp::if_glibc_is_less_than_2_25() { @@ -199,7 +199,7 @@ pub(crate) fn openat( target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] #[inline] pub(crate) fn statfs(filename: &CStr) -> io::Result { @@ -428,7 +428,7 @@ pub(crate) fn utimensat( // default. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_utimensat) = __utimensat64.get() { @@ -455,7 +455,7 @@ pub(crate) fn utimensat( target_os = "macos", all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ) )))] unsafe { @@ -587,7 +587,7 @@ pub(crate) fn utimensat( #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe fn utimensat_old( dirfd: BorrowedFd<'_>, @@ -762,7 +762,7 @@ pub(crate) fn copy_file_range( target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub(crate) fn fadvise(fd: BorrowedFd<'_>, offset: u64, len: u64, advice: Advice) -> io::Result<()> { let offset = offset as i64; @@ -946,7 +946,7 @@ fn fstat_old(fd: BorrowedFd<'_>) -> io::Result { target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result { let mut statfs = MaybeUninit::::uninit(); @@ -960,7 +960,7 @@ pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> // 32-bit gnu version: libc has `futimens` but it is not y2038 safe by default. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_futimens) = __futimens64.get() { @@ -982,7 +982,7 @@ pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> target_os = "macos", all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ) )))] unsafe { @@ -1032,7 +1032,7 @@ pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> { let old_times = [ @@ -1064,7 +1064,7 @@ unsafe fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub(crate) fn fallocate( fd: BorrowedFd<'_>, @@ -1132,7 +1132,7 @@ pub(crate) fn fsync(fd: BorrowedFd<'_>) -> io::Result<()> { target_os = "dragonfly", target_os = "ios", target_os = "macos", - target_os = "redox" + target_os = "redox", )))] pub(crate) fn fdatasync(fd: BorrowedFd<'_>) -> io::Result<()> { unsafe { ret(c::fdatasync(borrowed_fd(fd))) } @@ -1232,7 +1232,7 @@ pub(crate) fn sendfile( /// Convert from a Linux `statx` value to rustix's `Stat`. #[cfg(all( any(target_os = "android", target_os = "linux"), - target_pointer_width = "32" + target_pointer_width = "32", ))] fn statx_to_stat(x: crate::fs::Statx) -> io::Result { Ok(Stat { @@ -1272,7 +1272,7 @@ fn statx_to_stat(x: crate::fs::Statx) -> io::Result { /// mips64' `struct stat64` in libc has private fields, and `stx_blocks` #[cfg(all( any(target_os = "android", target_os = "linux"), - target_arch = "mips64" + target_arch = "mips64", ))] fn statx_to_stat(x: crate::fs::Statx) -> io::Result { let mut result: Stat = unsafe { core::mem::zeroed() }; @@ -1312,7 +1312,7 @@ fn statx_to_stat(x: crate::fs::Statx) -> io::Result { /// Convert from a Linux `stat64` value to rustix's `Stat`. #[cfg(all( any(target_os = "android", target_os = "linux"), - target_pointer_width = "32" + target_pointer_width = "32", ))] fn stat64_to_stat(s64: c::stat64) -> io::Result { Ok(Stat { @@ -1350,7 +1350,7 @@ fn stat64_to_stat(s64: c::stat64) -> io::Result { /// type `i64`. #[cfg(all( any(target_os = "android", target_os = "linux"), - target_arch = "mips64" + target_arch = "mips64", ))] fn stat64_to_stat(s64: c::stat64) -> io::Result { let mut result: Stat = unsafe { core::mem::zeroed() }; diff --git a/src/imp/libc/fs/types.rs b/src/imp/libc/fs/types.rs index b161024b..9af3ab12 100644 --- a/src/imp/libc/fs/types.rs +++ b/src/imp/libc/fs/types.rs @@ -466,7 +466,7 @@ impl FileType { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] #[derive(Debug, Copy, Clone, Eq, PartialEq)] #[repr(u32)] @@ -684,7 +684,7 @@ bitflags! { target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] bitflags! { /// `FALLOC_FL_*` constants for use with [`fallocate`]. @@ -807,7 +807,7 @@ pub enum FlockOperation { target_os = "android", target_os = "linux", target_os = "emscripten", - target_os = "l4re" + target_os = "l4re", )))] pub type Stat = c::stat; @@ -818,10 +818,10 @@ pub type Stat = c::stat; #[cfg(any( all( any(target_os = "android", target_os = "linux"), - target_pointer_width = "64" + target_pointer_width = "64", ), target_os = "emscripten", - target_os = "l4re" + target_os = "l4re", ))] pub type Stat = c::stat64; @@ -834,7 +834,7 @@ pub type Stat = c::stat64; // y2038 bug. #[cfg(all( any(target_os = "android", target_os = "linux"), - target_pointer_width = "32" + target_pointer_width = "32", ))] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -881,7 +881,7 @@ pub type StatFs = c::statfs; target_os = "android", target_os = "linux", target_os = "emscripten", - target_os = "l4re" + target_os = "l4re", ))] pub type StatFs = c::statfs64; @@ -976,7 +976,7 @@ pub type FsWord = c::__fsword_t; /// `__fsword_t` #[cfg(all( any(target_os = "android", all(target_os = "linux", target_env = "musl")), - target_pointer_width = "32" + target_pointer_width = "32", ))] pub type FsWord = u32; @@ -984,7 +984,7 @@ pub type FsWord = u32; #[cfg(all( any(target_os = "android", all(target_os = "linux", target_env = "musl")), not(target_arch = "s390x"), - target_pointer_width = "64" + target_pointer_width = "64", ))] pub type FsWord = u64; diff --git a/src/imp/libc/io/epoll.rs b/src/imp/libc/io/epoll.rs index 8bff92a0..9be4e033 100644 --- a/src/imp/libc/io/epoll.rs +++ b/src/imp/libc/io/epoll.rs @@ -474,7 +474,7 @@ impl<'context, Context: self::Context> Iterator for Iter<'context, Context> { not(target_env = "musl"), not(target_os = "android") ), - target_arch = "x86_64" + target_arch = "x86_64", ), repr(packed) )] diff --git a/src/imp/libc/io/errno.rs b/src/imp/libc/io/errno.rs index c51ebcf4..9da461fa 100644 --- a/src/imp/libc/io/errno.rs +++ b/src/imp/libc/io/errno.rs @@ -48,7 +48,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const AUTH: Self = Self(c::EAUTH); /// `EBADE` @@ -99,7 +99,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const BADRPC: Self = Self(c::EBADRPC); /// `EBADRQC` @@ -237,7 +237,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const FTYPE: Self = Self(c::EFTYPE); /// `EHOSTDOWN` @@ -510,7 +510,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const NEEDAUTH: Self = Self(c::ENEEDAUTH); /// `ENETDOWN` @@ -541,7 +541,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const NOATTR: Self = Self(c::ENOATTR); /// `ENOBUFS` @@ -743,7 +743,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const PROCLIM: Self = Self(c::EPROCLIM); /// `EPROCUNAVAIL` @@ -753,7 +753,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const PROCUNAVAIL: Self = Self(c::EPROCUNAVAIL); /// `EPROGMISMATCH` @@ -763,7 +763,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const PROGMISMATCH: Self = Self(c::EPROGMISMATCH); /// `EPROGUNAVAIL` @@ -773,7 +773,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const PROGUNAVAIL: Self = Self(c::EPROGUNAVAIL); /// `EPROTO` @@ -857,7 +857,7 @@ impl Errno { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] pub const RPCMISMATCH: Self = Self(c::ERPCMISMATCH); /// `ESHUTDOWN` diff --git a/src/imp/libc/io/syscalls.rs b/src/imp/libc/io/syscalls.rs index c7754178..c9874066 100644 --- a/src/imp/libc/io/syscalls.rs +++ b/src/imp/libc/io/syscalls.rs @@ -382,10 +382,10 @@ pub(crate) fn dup2(fd: BorrowedFd<'_>, new: &mut OwnedFd) -> io::Result<()> { #[cfg(not(any( target_os = "android", target_os = "dragonfly", - target_os = "macos", target_os = "ios", + target_os = "macos", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, flags: DupFlags) -> io::Result<()> { unsafe { @@ -400,9 +400,9 @@ pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, flags: DupFlags) -> io #[cfg(any( target_os = "android", target_os = "dragonfly", - target_os = "macos", target_os = "ios", - target_os = "redox" + target_os = "macos", + target_os = "redox", ))] pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, _flags: DupFlags) -> io::Result<()> { // Android 5.0 has `dup3`, but libc doesn't have bindings. Emulate it diff --git a/src/imp/libc/io/types.rs b/src/imp/libc/io/types.rs index d42ab803..0f76cc24 100644 --- a/src/imp/libc/io/types.rs +++ b/src/imp/libc/io/types.rs @@ -34,7 +34,12 @@ bitflags! { /// [`dup2`]: crate::io::dup2 pub struct DupFlags: c::c_int { /// `O_CLOEXEC` - #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos", target_os = "redox")))] // Android 5.0 has dup3, but libc doesn't have bindings + #[cfg(not(any( + target_os = "android", + target_os = "ios", + target_os = "macos", + target_os = "redox", + )))] // Android 5.0 has dup3, but libc doesn't have bindings const CLOEXEC = c::O_CLOEXEC; } } diff --git a/src/imp/libc/mm/types.rs b/src/imp/libc/mm/types.rs index ae4c3c0c..ff0f7ea0 100644 --- a/src/imp/libc/mm/types.rs +++ b/src/imp/libc/mm/types.rs @@ -78,7 +78,7 @@ bitflags! { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] const DENYWRITE = c::MAP_DENYWRITE; /// `MAP_FIXED` @@ -107,7 +107,7 @@ bitflags! { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] const GROWSDOWN = c::MAP_GROWSDOWN; /// `MAP_HUGETLB` diff --git a/src/imp/libc/mod.rs b/src/imp/libc/mod.rs index 827f8f11..0f0efbb9 100644 --- a/src/imp/libc/mod.rs +++ b/src/imp/libc/mod.rs @@ -32,11 +32,11 @@ pub(crate) mod fd { pub(crate) mod fd { pub use io_lifetimes::*; - #[allow(unused_imports)] #[cfg(target_os = "wasi")] - pub(crate) use super::c::c_int as LibcFd; #[allow(unused_imports)] + pub(crate) use super::c::c_int as LibcFd; #[cfg(unix)] + #[allow(unused_imports)] pub(crate) use std::os::unix::io::RawFd as LibcFd; #[cfg(unix)] pub use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; @@ -71,7 +71,7 @@ pub(crate) mod net; feature = "param", feature = "runtime", feature = "time", - target_arch = "x86" + target_arch = "x86", ))] pub(crate) mod param; #[cfg(not(windows))] diff --git a/src/imp/libc/net/addr.rs b/src/imp/libc/net/addr.rs index f7d0e869..1aeda5e5 100644 --- a/src/imp/libc/net/addr.rs +++ b/src/imp/libc/net/addr.rs @@ -26,7 +26,7 @@ pub struct SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] len: c::socklen_t, } @@ -56,7 +56,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] { unix.sun_len = (offsetof_sun_path() + bytes.len()).try_into().unwrap(); @@ -70,7 +70,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] len: (offsetof_sun_path() + bytes.len()).try_into().unwrap(), }) @@ -98,7 +98,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] len, }) @@ -112,7 +112,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sun_len: 0, sun_family: c::AF_UNIX as _, @@ -122,7 +122,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sun_path: [0; 104], #[cfg(not(any( @@ -131,7 +131,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] sun_path: [0; 108], } @@ -158,8 +158,8 @@ impl SocketAddrUnix { } /// For an abstract address, return the identifier. - #[inline] #[cfg(any(target_os = "android", target_os = "linux"))] + #[inline] pub fn abstract_name(&self) -> Option<&[u8]> { let len = self.len(); if len != 0 && self.unix.sun_path[0] == b'\0' as c::c_char { @@ -180,7 +180,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] { self.len @@ -191,7 +191,7 @@ impl SocketAddrUnix { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] { c::socklen_t::from(self.unix.sun_len) @@ -276,7 +276,7 @@ pub(crate) fn offsetof_sun_path() -> usize { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sun_len: 0_u8, #[cfg(any( @@ -285,7 +285,7 @@ pub(crate) fn offsetof_sun_path() -> usize { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sun_family: 0_u8, #[cfg(not(any( @@ -294,7 +294,7 @@ pub(crate) fn offsetof_sun_path() -> usize { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] sun_family: 0_u16, #[cfg(any( @@ -303,7 +303,7 @@ pub(crate) fn offsetof_sun_path() -> usize { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sun_path: [0; 104], #[cfg(not(any( @@ -312,7 +312,7 @@ pub(crate) fn offsetof_sun_path() -> usize { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] sun_path: [0; 108], }; diff --git a/src/imp/libc/net/ext.rs b/src/imp/libc/net/ext.rs index 7aff4079..a89c4c30 100644 --- a/src/imp/libc/net/ext.rs +++ b/src/imp/libc/net/ext.rs @@ -151,7 +151,7 @@ pub(crate) const fn sockaddr_in6_new( target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sin6_len: u8, sin6_family: c::sa_family_t, @@ -167,7 +167,7 @@ pub(crate) const fn sockaddr_in6_new( target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sin6_len, sin6_family, diff --git a/src/imp/libc/net/read_sockaddr.rs b/src/imp/libc/net/read_sockaddr.rs index ab475385..19a6ad54 100644 --- a/src/imp/libc/net/read_sockaddr.rs +++ b/src/imp/libc/net/read_sockaddr.rs @@ -19,7 +19,7 @@ struct sockaddr_header { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sa_len: u8, #[cfg(any( @@ -28,7 +28,7 @@ struct sockaddr_header { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] ss_family: u8, #[cfg(not(any( @@ -37,7 +37,7 @@ struct sockaddr_header { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] ss_family: u16, } @@ -52,7 +52,7 @@ unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sa_len: 0_u8, #[cfg(any( @@ -70,7 +70,7 @@ unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] sa_family: 0_u16, sa_data: [0; 14], diff --git a/src/imp/libc/net/send_recv.rs b/src/imp/libc/net/send_recv.rs index ef25d019..9ab908d6 100644 --- a/src/imp/libc/net/send_recv.rs +++ b/src/imp/libc/net/send_recv.rs @@ -13,7 +13,7 @@ bitflags! { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] const CONFIRM = c::MSG_CONFIRM; /// `MSG_DONTROUTE` @@ -33,7 +33,7 @@ bitflags! { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] const MORE = c::MSG_MORE; #[cfg(not(any(windows, target_os = "ios", target_os = "macos")))] @@ -62,7 +62,7 @@ bitflags! { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] const ERRQUEUE = c::MSG_ERRQUEUE; /// `MSG_OOB` diff --git a/src/imp/libc/net/syscalls.rs b/src/imp/libc/net/syscalls.rs index e133add0..b3f1ea92 100644 --- a/src/imp/libc/net/syscalls.rs +++ b/src/imp/libc/net/syscalls.rs @@ -255,7 +255,7 @@ pub(crate) fn accept(sockfd: BorrowedFd<'_>) -> io::Result { target_os = "ios", target_os = "macos", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub(crate) fn accept_with(sockfd: BorrowedFd<'_>, flags: AcceptFlags) -> io::Result { unsafe { @@ -291,7 +291,7 @@ pub(crate) fn acceptfrom(sockfd: BorrowedFd<'_>) -> io::Result<(OwnedFd, Option< target_os = "ios", target_os = "macos", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub(crate) fn acceptfrom_with( sockfd: BorrowedFd<'_>, diff --git a/src/imp/libc/net/types.rs b/src/imp/libc/net/types.rs index d99ef741..63e3a317 100644 --- a/src/imp/libc/net/types.rs +++ b/src/imp/libc/net/types.rs @@ -425,7 +425,14 @@ impl Protocol { #[cfg(not(any(windows, target_os = "illumos")))] pub const TP: Self = Self(c::IPPROTO_TP as _); /// `IPPROTO_DCCP` - #[cfg(not(any(windows, target_os = "dragonfly", target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "openbsd")))] + #[cfg(not(any( + windows, + target_os = "dragonfly", + target_os = "illumos", + target_os = "ios", + target_os = "macos", + target_os = "openbsd", + )))] pub const DCCP: Self = Self(c::IPPROTO_DCCP as _); /// `IPPROTO_IPV6` pub const IPV6: Self = Self(c::IPPROTO_IPV6 as _); @@ -442,7 +449,12 @@ impl Protocol { #[cfg(not(target_os = "illumos"))] pub const AH: Self = Self(c::IPPROTO_AH as _); /// `IPPROTO_MTP` - #[cfg(not(any(windows, target_os = "illumos", target_os = "netbsd", target_os = "openbsd")))] + #[cfg(not(any( + windows, + target_os = "illumos", + target_os = "netbsd", + target_os = "openbsd", + )))] pub const MTP: Self = Self(c::IPPROTO_MTP as _); /// `IPPROTO_BEETPH` #[cfg(not(any( @@ -485,11 +497,18 @@ impl Protocol { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] pub const UDPLITE: Self = Self(c::IPPROTO_UDPLITE as _); /// `IPPROTO_MPLS` - #[cfg(not(any(windows, target_os = "dragonfly", target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "netbsd")))] + #[cfg(not(any( + windows, + target_os = "dragonfly", + target_os = "illumos", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + )))] pub const MPLS: Self = Self(c::IPPROTO_MPLS as _); /// `IPPROTO_RAW` pub const RAW: Self = Self(c::IPPROTO_RAW as _); diff --git a/src/imp/libc/net/write_sockaddr.rs b/src/imp/libc/net/write_sockaddr.rs index 1ac5c959..adbf7255 100644 --- a/src/imp/libc/net/write_sockaddr.rs +++ b/src/imp/libc/net/write_sockaddr.rs @@ -29,7 +29,7 @@ pub(crate) unsafe fn encode_sockaddr_v4(v4: &SocketAddrV4) -> c::sockaddr_in { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] sin_len: size_of::() as _, sin_family: c::AF_INET as _, @@ -52,7 +52,7 @@ pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", ))] { sockaddr_in6_new( @@ -70,7 +70,7 @@ pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] { sockaddr_in6_new( diff --git a/src/imp/libc/offset.rs b/src/imp/libc/offset.rs index c559f1e5..d7b4cdb5 100644 --- a/src/imp/libc/offset.rs +++ b/src/imp/libc/offset.rs @@ -190,7 +190,7 @@ pub(super) use c::posix_fadvise64 as libc_posix_fadvise; windows, target_os = "android", target_os = "linux", - target_os = "emscripten" + target_os = "emscripten", ))))] pub(super) use c::{pread as libc_pread, pwrite as libc_pwrite}; #[cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten"))] diff --git a/src/imp/libc/param/auxv.rs b/src/imp/libc/param/auxv.rs index afa1e128..cd449d5e 100644 --- a/src/imp/libc/param/auxv.rs +++ b/src/imp/libc/param/auxv.rs @@ -1,14 +1,14 @@ use super::super::c; #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] use crate::ffi::CStr; // `getauxval` wasn't supported in glibc until 2.16. #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] weak!(fn getauxval(c::c_ulong) -> *mut c::c_void); @@ -25,7 +25,7 @@ pub(crate) fn clock_ticks_per_second() -> u64 { #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] #[inline] pub(crate) fn linux_hwcap() -> (usize, usize) { @@ -42,7 +42,7 @@ pub(crate) fn linux_hwcap() -> (usize, usize) { #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] #[inline] pub(crate) fn linux_execfn() -> &'static CStr { diff --git a/src/imp/libc/process/mod.rs b/src/imp/libc/process/mod.rs index 163c8173..8675c1af 100644 --- a/src/imp/libc/process/mod.rs +++ b/src/imp/libc/process/mod.rs @@ -1,8 +1,8 @@ #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] pub(crate) mod cpu_set; #[cfg(not(windows))] diff --git a/src/imp/libc/process/syscalls.rs b/src/imp/libc/process/syscalls.rs index 41a4ce1e..9874f617 100644 --- a/src/imp/libc/process/syscalls.rs +++ b/src/imp/libc/process/syscalls.rs @@ -7,10 +7,10 @@ use super::super::conv::{c_str, ret, ret_c_int, ret_discarded_char_ptr}; #[cfg(any(target_os = "android", target_os = "linux"))] use super::super::conv::{syscall_ret, syscall_ret_u32}; #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] use super::types::RawCpuSet; #[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))] @@ -146,10 +146,10 @@ pub(crate) fn getppid() -> Option { } #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] #[inline] pub(crate) fn sched_getaffinity(pid: Option, cpuset: &mut RawCpuSet) -> io::Result<()> { @@ -163,10 +163,10 @@ pub(crate) fn sched_getaffinity(pid: Option, cpuset: &mut RawCpuSet) -> io: } #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] #[inline] pub(crate) fn sched_setaffinity(pid: Option, cpuset: &RawCpuSet) -> io::Result<()> { diff --git a/src/imp/libc/process/types.rs b/src/imp/libc/process/types.rs index 9ce8406d..f642d61c 100644 --- a/src/imp/libc/process/types.rs +++ b/src/imp/libc/process/types.rs @@ -238,7 +238,7 @@ pub enum Signal { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] #[doc(alias = "Pwr")] Power = c::SIGPWR, @@ -332,18 +332,18 @@ pub type RawCpuid = u32; pub(crate) type RawUname = c::utsname; #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] pub(crate) type RawCpuSet = c::cpu_set_t; #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] #[inline] pub(crate) fn raw_cpu_set_new() -> RawCpuSet { @@ -353,9 +353,9 @@ pub(crate) fn raw_cpu_set_new() -> RawCpuSet { } #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] pub(crate) const CPU_SETSIZE: usize = c::CPU_SETSIZE as usize; diff --git a/src/imp/libc/termios/types.rs b/src/imp/libc/termios/types.rs index cdf41e93..7e672875 100644 --- a/src/imp/libc/termios/types.rs +++ b/src/imp/libc/termios/types.rs @@ -99,7 +99,7 @@ pub const VMIN: usize = c::VMIN as usize; target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] pub const VSWTC: usize = c::VSWTC as usize; @@ -196,7 +196,7 @@ pub const IMAXBEL: c::c_uint = c::IMAXBEL; target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub const IUTF8: c::c_uint = c::IUTF8; @@ -211,7 +211,7 @@ pub const OPOST: c::c_uint = c::OPOST; target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "redox" + target_os = "redox", )))] pub const OLCUC: c::c_uint = c::OLCUC; diff --git a/src/imp/libc/thread/syscalls.rs b/src/imp/libc/thread/syscalls.rs index 5c82812a..462c86ba 100644 --- a/src/imp/libc/thread/syscalls.rs +++ b/src/imp/libc/thread/syscalls.rs @@ -23,12 +23,12 @@ use {crate::thread::ClockId, core::ptr::null_mut}; #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] weak!(fn __clock_nanosleep_time64(c::clockid_t, c::c_int, *const LibcTimespec, *mut LibcTimespec) -> c::c_int); #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] weak!(fn __nanosleep64(*const LibcTimespec, *mut LibcTimespec) -> c::c_int); @@ -51,7 +51,7 @@ pub(crate) fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> Nanos // default. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_clock_nanosleep) = __clock_nanosleep_time64.get() { @@ -75,7 +75,7 @@ pub(crate) fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> Nanos // Main version: libc is y2038 safe and has `clock_nanosleep`. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] unsafe { match c::clock_nanosleep(id as c::clockid_t, flags, request, remain.as_mut_ptr()) { @@ -90,7 +90,7 @@ pub(crate) fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> Nanos #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe fn clock_nanosleep_relative_old(id: ClockId, request: &Timespec) -> NanosleepRelativeResult { use core::convert::TryInto; @@ -138,7 +138,7 @@ pub(crate) fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::R // default. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] { if let Some(libc_clock_nanosleep) = __clock_nanosleep_time64.get() { @@ -161,7 +161,7 @@ pub(crate) fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::R // Main version: libc is y2038 safe and has `clock_nanosleep`. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] match unsafe { c::clock_nanosleep(id as c::clockid_t, flags, request, null_mut()) } { 0 => Ok(()), @@ -171,7 +171,7 @@ pub(crate) fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::R #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] fn clock_nanosleep_absolute_old(id: ClockId, request: &Timespec) -> io::Result<()> { use core::convert::TryInto; @@ -197,7 +197,7 @@ pub(crate) fn nanosleep(request: &Timespec) -> NanosleepRelativeResult { // default. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_nanosleep) = __nanosleep64.get() { @@ -216,7 +216,7 @@ pub(crate) fn nanosleep(request: &Timespec) -> NanosleepRelativeResult { // Main version: libc is y2038 safe and has `nanosleep`. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] unsafe { match ret(c::nanosleep(request, remain.as_mut_ptr())) { @@ -229,7 +229,7 @@ pub(crate) fn nanosleep(request: &Timespec) -> NanosleepRelativeResult { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe fn nanosleep_old(request: &Timespec) -> NanosleepRelativeResult { use core::convert::TryInto; diff --git a/src/imp/libc/time/syscalls.rs b/src/imp/libc/time/syscalls.rs index 30f1c19b..ce3338f0 100644 --- a/src/imp/libc/time/syscalls.rs +++ b/src/imp/libc/time/syscalls.rs @@ -22,23 +22,23 @@ use { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] weak!(fn __clock_gettime64(c::clockid_t, *mut LibcTimespec) -> c::c_int); #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] weak!(fn __clock_getres64(c::clockid_t, *mut LibcTimespec) -> c::c_int); #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[cfg(feature = "time")] weak!(fn __timerfd_gettime64(c::c_int, *mut LibcItimerspec) -> c::c_int); #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[cfg(feature = "time")] weak!(fn __timerfd_settime64(c::c_int, c::c_int, *const LibcItimerspec, *mut LibcItimerspec) -> c::c_int); @@ -53,7 +53,7 @@ pub(crate) fn clock_getres(id: ClockId) -> Timespec { // default. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_clock_getres) = __clock_getres64.get() { @@ -67,7 +67,7 @@ pub(crate) fn clock_getres(id: ClockId) -> Timespec { // Main version: libc is y2038 safe and has `clock_getres`. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] unsafe { let _ = c::clock_getres(id as c::clockid_t, timespec.as_mut_ptr()); @@ -77,7 +77,7 @@ pub(crate) fn clock_getres(id: ClockId) -> Timespec { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[must_use] unsafe fn clock_getres_old(id: ClockId) -> Timespec { @@ -102,7 +102,7 @@ pub(crate) fn clock_gettime(id: ClockId) -> Timespec { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_clock_gettime) = __clock_gettime64.get() { @@ -123,7 +123,7 @@ pub(crate) fn clock_gettime(id: ClockId) -> Timespec { // configured. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] unsafe { ret(c::clock_gettime(id as c::clockid_t, timespec.as_mut_ptr())).unwrap(); @@ -133,7 +133,7 @@ pub(crate) fn clock_gettime(id: ClockId) -> Timespec { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[must_use] unsafe fn clock_gettime_old(id: ClockId) -> Timespec { @@ -186,7 +186,7 @@ pub(crate) fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result) -> io::Result) -> io::Result io::Result { @@ -250,7 +250,7 @@ pub(crate) fn timerfd_settime( #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_timerfd_settime) = __timerfd_settime64.get() { @@ -268,7 +268,7 @@ pub(crate) fn timerfd_settime( #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] unsafe { ret(c::timerfd_settime( @@ -284,7 +284,7 @@ pub(crate) fn timerfd_settime( #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[cfg(feature = "time")] unsafe fn timerfd_settime_old( @@ -349,7 +349,7 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] unsafe { if let Some(libc_timerfd_gettime) = __timerfd_gettime64.get() { @@ -362,7 +362,7 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result { #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] unsafe { ret(c::timerfd_gettime(borrowed_fd(fd), result.as_mut_ptr())).map(|()| result.assume_init()) @@ -372,7 +372,7 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result { #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[cfg(feature = "time")] unsafe fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result { diff --git a/src/imp/libc/time/types.rs b/src/imp/libc/time/types.rs index 906ce24d..4aa2b22e 100644 --- a/src/imp/libc/time/types.rs +++ b/src/imp/libc/time/types.rs @@ -7,14 +7,14 @@ use bitflags::bitflags; /// `struct timespec` #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] pub type Timespec = c::timespec; /// `struct timespec` #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[derive(Debug, Clone)] #[repr(C)] @@ -29,7 +29,7 @@ pub struct Timespec { /// A type for the `tv_sec` field of [`Timespec`]. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] #[allow(deprecated)] pub type Secs = c::time_t; @@ -37,7 +37,7 @@ pub type Secs = c::time_t; /// A type for the `tv_sec` field of [`Timespec`]. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] pub type Secs = i64; @@ -52,7 +52,7 @@ pub type Nsecs = c::c_long; /// On most platforms, `LibcTimespec` is just `Timespec`. #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] pub(crate) type LibcTimespec = Timespec; @@ -61,7 +61,7 @@ pub(crate) type LibcTimespec = Timespec; /// struct with explicit padding, with bidirectional `From` impls. #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[repr(C)] #[derive(Debug, Clone)] @@ -79,7 +79,7 @@ pub(crate) struct LibcTimespec { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] impl From for Timespec { #[inline] @@ -93,7 +93,7 @@ impl From for Timespec { #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] impl From for LibcTimespec { #[inline] @@ -131,7 +131,7 @@ pub enum ClockId { target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] ProcessCPUTime = c::CLOCK_PROCESS_CPUTIME_ID, @@ -140,7 +140,7 @@ pub enum ClockId { target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] ThreadCPUTime = c::CLOCK_THREAD_CPUTIME_ID, @@ -219,7 +219,7 @@ pub enum DynamicClockId<'a> { #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] pub type Itimerspec = c::itimerspec; @@ -227,7 +227,7 @@ pub type Itimerspec = c::itimerspec; #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[allow(missing_docs)] #[repr(C)] @@ -241,7 +241,7 @@ pub struct Itimerspec { #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(not(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", )))] pub(crate) type LibcItimerspec = Itimerspec; @@ -250,7 +250,7 @@ pub(crate) type LibcItimerspec = Itimerspec; #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] #[repr(C)] #[derive(Debug, Clone)] @@ -262,7 +262,7 @@ pub(crate) struct LibcItimerspec { #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] impl From for Itimerspec { #[inline] @@ -277,7 +277,7 @@ impl From for Itimerspec { #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg(all( any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), - target_env = "gnu" + target_env = "gnu", ))] impl From for LibcItimerspec { #[inline] diff --git a/src/imp/linux_raw/arch/inline/mod.rs b/src/imp/linux_raw/arch/inline/mod.rs index 69bbfe1c..3e25e214 100644 --- a/src/imp/linux_raw/arch/inline/mod.rs +++ b/src/imp/linux_raw/arch/inline/mod.rs @@ -1,3 +1,5 @@ +//! Inline asm for making system calls. +//! //! Compilers should really have intrinsics for making system calls. They're //! much like regular calls, with custom calling conventions, and calling //! conventions are otherwise the compiler's job. But for now, use inline asm. diff --git a/src/imp/linux_raw/arch/outline/mod.rs b/src/imp/linux_raw/arch/outline/mod.rs index ac5006a4..ce135275 100644 --- a/src/imp/linux_raw/arch/outline/mod.rs +++ b/src/imp/linux_raw/arch/outline/mod.rs @@ -15,7 +15,7 @@ mod x86; target_arch = "mips64", target_arch = "powerpc64", target_arch = "riscv64", - target_arch = "x86_64" + target_arch = "x86_64", ))] mod nr_last; @@ -26,7 +26,7 @@ mod nr_last; target_arch = "mips64", target_arch = "powerpc64", target_arch = "riscv64", - target_arch = "x86_64" + target_arch = "x86_64", ))] pub(in crate::imp) use nr_last::*; #[cfg(target_arch = "x86")] diff --git a/src/imp/linux_raw/fs/syscalls.rs b/src/imp/linux_raw/fs/syscalls.rs index 70c1878e..25b51c8d 100644 --- a/src/imp/linux_raw/fs/syscalls.rs +++ b/src/imp/linux_raw/fs/syscalls.rs @@ -18,7 +18,7 @@ use super::super::conv::{loff_t, loff_t_from_u64, ret_u64}; target_arch = "aarch64", target_arch = "riscv64", target_arch = "mips64", - target_pointer_width = "32" + target_pointer_width = "32", ))] use crate::fd::AsFd; use crate::fd::{BorrowedFd, RawFd}; diff --git a/src/imp/linux_raw/fs/types.rs b/src/imp/linux_raw/fs/types.rs index 99273e38..f79105ca 100644 --- a/src/imp/linux_raw/fs/types.rs +++ b/src/imp/linux_raw/fs/types.rs @@ -578,7 +578,7 @@ pub type StatxTimestamp = linux_raw_sys::general::statx_timestamp; target_arch = "x86", target_arch = "sparc", target_arch = "avr", - target_arch = "arm" + target_arch = "arm", )))] pub type RawMode = linux_raw_sys::general::__kernel_mode_t; @@ -587,7 +587,7 @@ pub type RawMode = linux_raw_sys::general::__kernel_mode_t; target_arch = "x86", target_arch = "sparc", target_arch = "avr", - target_arch = "arm" + target_arch = "arm", ))] // Don't use `__kernel_mode_t` since it's `u16` which differs from `st_size`. pub type RawMode = c::c_uint; diff --git a/src/imp/linux_raw/io/syscalls.rs b/src/imp/linux_raw/io/syscalls.rs index 6d16dc17..ca081082 100644 --- a/src/imp/linux_raw/io/syscalls.rs +++ b/src/imp/linux_raw/io/syscalls.rs @@ -435,7 +435,7 @@ pub(crate) fn pipe() -> io::Result<(OwnedFd, OwnedFd)> { target_arch = "aarch64", target_arch = "mips", target_arch = "mips64", - target_arch = "riscv64" + target_arch = "riscv64", ))] { pipe_with(PipeFlags::empty()) @@ -444,7 +444,7 @@ pub(crate) fn pipe() -> io::Result<(OwnedFd, OwnedFd)> { target_arch = "aarch64", target_arch = "mips", target_arch = "mips64", - target_arch = "riscv64" + target_arch = "riscv64", )))] unsafe { let mut result = MaybeUninit::<[OwnedFd; 2]>::uninit(); diff --git a/src/imp/linux_raw/mod.rs b/src/imp/linux_raw/mod.rs index 7abe6214..ed46eaad 100644 --- a/src/imp/linux_raw/mod.rs +++ b/src/imp/linux_raw/mod.rs @@ -28,7 +28,7 @@ mod vdso_wrappers; feature = "param", feature = "runtime", feature = "time", - target_arch = "x86" + target_arch = "x86", ))] pub(crate) mod param; // #[cfg(feature = "fs")] // TODO: Enable once `OwnedFd` moves out of the tree. diff --git a/src/imp/linux_raw/net/ext.rs b/src/imp/linux_raw/net/ext.rs index 821c863c..8556c9d9 100644 --- a/src/imp/linux_raw/net/ext.rs +++ b/src/imp/linux_raw/net/ext.rs @@ -1,5 +1,4 @@ #![allow(unsafe_code)] -#![allow(dead_code)] use super::super::c; diff --git a/src/imp/linux_raw/net/mod.rs b/src/imp/linux_raw/net/mod.rs index f7196ae4..5e67dfd2 100644 --- a/src/imp/linux_raw/net/mod.rs +++ b/src/imp/linux_raw/net/mod.rs @@ -1,4 +1,5 @@ pub(crate) mod addr; +#[cfg(not(feature = "std"))] pub(crate) mod ext; pub(crate) mod read_sockaddr; pub(crate) mod send_recv; diff --git a/src/imp/linux_raw/process/syscalls.rs b/src/imp/linux_raw/process/syscalls.rs index d1365792..3c833ede 100644 --- a/src/imp/linux_raw/process/syscalls.rs +++ b/src/imp/linux_raw/process/syscalls.rs @@ -325,7 +325,7 @@ unsafe fn getrlimit_old(limit: Resource) -> Rlimit { target_arch = "arm", target_arch = "powerpc", target_arch = "powerpc64", - target_arch = "x86" + target_arch = "x86", ))] { ret_infallible(syscall!(__NR_ugetrlimit, limit, &mut result)); @@ -336,7 +336,7 @@ unsafe fn getrlimit_old(limit: Resource) -> Rlimit { target_arch = "arm", target_arch = "powerpc", target_arch = "powerpc64", - target_arch = "x86" + target_arch = "x86", )))] { ret_infallible(syscall!(__NR_getrlimit, limit, &mut result)); diff --git a/src/io/mod.rs b/src/io/mod.rs index 23a5d329..7a2f012e 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -52,7 +52,7 @@ pub use pipe::pipe; windows, target_os = "illumos", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub use pipe::PIPE_BUF; #[cfg(not(any(windows, target_os = "ios", target_os = "macos", target_os = "wasi")))] diff --git a/src/io/pipe.rs b/src/io/pipe.rs index b1aee902..b3ae5a41 100644 --- a/src/io/pipe.rs +++ b/src/io/pipe.rs @@ -17,7 +17,7 @@ pub use imp::io::types::PipeFlags; windows, target_os = "illumos", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] pub const PIPE_BUF: usize = imp::io::types::PIPE_BUF; diff --git a/src/io_uring.rs b/src/io_uring.rs index 320a2ee5..55da62a2 100644 --- a/src/io_uring.rs +++ b/src/io_uring.rs @@ -563,21 +563,21 @@ pub const fn io_uring_register_files_skip() -> BorrowedFd<'static> { #[repr(C)] #[derive(Copy, Clone)] pub struct io_uring_ptr { - #[doc(hidden)] #[cfg(all(target_pointer_width = "32", target_endian = "big"))] - pub __pad32: u32, #[doc(hidden)] + pub __pad32: u32, #[cfg(all(target_pointer_width = "16", target_endian = "big"))] + #[doc(hidden)] pub __pad16: u16, /// The pointer value. pub ptr: *mut c_void, - #[doc(hidden)] #[cfg(all(target_pointer_width = "16", target_endian = "little"))] - pub __pad16: u16, #[doc(hidden)] + pub __pad16: u16, #[cfg(all(target_pointer_width = "32", target_endian = "little"))] + #[doc(hidden)] pub __pad32: u32, } diff --git a/src/lib.rs b/src/lib.rs index 264c3981..4f8d41d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -203,8 +203,8 @@ pub mod time; // "runtime" is also a public API module, but it's only for libc-like users. #[cfg(not(windows))] -#[doc(hidden)] #[cfg(feature = "runtime")] +#[doc(hidden)] #[cfg_attr(doc_cfg, doc(cfg(feature = "runtime")))] pub mod runtime; diff --git a/src/net/send_recv.rs b/src/net/send_recv.rs index 54a57a9b..617b1a31 100644 --- a/src/net/send_recv.rs +++ b/src/net/send_recv.rs @@ -1,4 +1,4 @@ -//! `recv` and `send`, and variants +//! `recv` and `send`, and variants. #[cfg(unix)] use crate::net::SocketAddrUnix; @@ -175,9 +175,9 @@ pub fn sendto_v6( /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html /// [Linux]: https://man7.org/linux/man-pages/man2/sendto.2.html /// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto +#[cfg(unix)] #[inline] #[doc(alias = "sendto")] -#[cfg(unix)] pub fn sendto_unix( fd: Fd, buf: &[u8], diff --git a/src/net/socket.rs b/src/net/socket.rs index 775d7719..9bcbc93c 100644 --- a/src/net/socket.rs +++ b/src/net/socket.rs @@ -149,9 +149,9 @@ pub fn bind_v6(sockfd: Fd, addr: &SocketAddrV6) -> io::Result<()> { /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html /// [Linux]: https://man7.org/linux/man-pages/man2/bind.2.html /// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind +#[cfg(unix)] #[inline] #[doc(alias = "bind")] -#[cfg(unix)] pub fn bind_unix(sockfd: Fd, addr: &SocketAddrUnix) -> io::Result<()> { imp::net::syscalls::bind_unix(sockfd.as_fd(), addr) } @@ -240,9 +240,9 @@ pub fn connect_v6(sockfd: Fd, addr: &SocketAddrV6) -> io::Result<()> { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html /// [Linux]: https://man7.org/linux/man-pages/man2/connect.2.html +#[cfg(unix)] #[inline] #[doc(alias = "connect")] -#[cfg(unix)] pub fn connect_unix(sockfd: Fd, addr: &SocketAddrUnix) -> io::Result<()> { imp::net::syscalls::connect_unix(sockfd.as_fd(), addr) } diff --git a/src/param/auxv.rs b/src/param/auxv.rs index 1c7a80b2..6aec061f 100644 --- a/src/param/auxv.rs +++ b/src/param/auxv.rs @@ -4,7 +4,7 @@ libc, any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ) ) ))] @@ -62,7 +62,7 @@ pub fn clock_ticks_per_second() -> u64 { libc, any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ) ) ))] @@ -86,7 +86,7 @@ pub fn linux_hwcap() -> (usize, usize) { libc, any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ) ) ))] diff --git a/src/param/mod.rs b/src/param/mod.rs index 56986df3..5050c323 100644 --- a/src/param/mod.rs +++ b/src/param/mod.rs @@ -25,7 +25,7 @@ pub use auxv::page_size; libc, any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ) ) ))] diff --git a/src/process/mod.rs b/src/process/mod.rs index 9a43f1d9..45673c0e 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -14,10 +14,10 @@ mod priority; #[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))] mod rlimit; #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] mod sched; mod sched_yield; @@ -60,10 +60,10 @@ pub use rlimit::prlimit; #[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))] pub use rlimit::{getrlimit, setrlimit, Resource, Rlimit}; #[cfg(any( - target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "fuchsia", - target_os = "dragonfly" + target_os = "linux", ))] pub use sched::{sched_getaffinity, sched_setaffinity, CpuSet}; pub use sched_yield::sched_yield; diff --git a/src/runtime.rs b/src/runtime.rs index 8538ae8a..187da634 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -234,8 +234,8 @@ pub unsafe fn fork() -> io::Result> { /// - [Linux] /// /// [Linux]: https://man7.org/linux/man-pages/man2/execveat.2.html -#[inline] #[cfg(linux_raw)] +#[inline] pub unsafe fn execveat( dirfd: Fd, path: &CStr, @@ -258,8 +258,8 @@ pub unsafe fn execveat( /// - [Linux] /// /// [Linux]: https://man7.org/linux/man-pages/man2/execve.2.html -#[inline] #[cfg(linux_raw)] +#[inline] pub unsafe fn execve(path: &CStr, argv: *const *const u8, envp: *const *const u8) -> io::Errno { imp::runtime::syscalls::execve(path, argv, envp) } diff --git a/src/termios/constants.rs b/src/termios/constants.rs index e7cd5d87..c93a0305 100644 --- a/src/termios/constants.rs +++ b/src/termios/constants.rs @@ -372,7 +372,7 @@ pub use imp::termios::types::IUCLC; target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub use imp::termios::types::IUTF8; #[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))] @@ -444,7 +444,7 @@ pub use imp::termios::types::OFILL; target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "redox" + target_os = "redox", )))] pub use imp::termios::types::OLCUC; #[cfg(not(any(target_os = "ios", target_os = "macos")))] @@ -531,7 +531,7 @@ pub use imp::termios::types::TOSTOP; target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] pub use imp::termios::types::VSWTC; #[cfg(not(any( diff --git a/src/termios/mod.rs b/src/termios/mod.rs index 96d76aeb..121979bd 100644 --- a/src/termios/mod.rs +++ b/src/termios/mod.rs @@ -7,7 +7,6 @@ mod tc; mod tty; pub use cf::{cfgetispeed, cfgetospeed, cfmakeraw, cfsetispeed, cfsetospeed, cfsetspeed}; -pub use constants::speed_value; #[cfg(not(any( target_os = "dragonfly", target_os = "freebsd", @@ -381,7 +380,7 @@ pub use constants::IUCLC; target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] pub use constants::IUTF8; #[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))] @@ -453,7 +452,7 @@ pub use constants::OFILL; target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "redox" + target_os = "redox", )))] pub use constants::OLCUC; #[cfg(not(any(target_os = "ios", target_os = "macos")))] @@ -540,7 +539,7 @@ pub use constants::TOSTOP; target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] pub use constants::VSWTC; #[cfg(not(any( @@ -595,9 +594,9 @@ pub use constants::XCASE; )))] pub use constants::XTABS; pub use constants::{ - B0, B110, B115200, B1200, B134, B150, B1800, B19200, B200, B230400, B2400, B300, B38400, B4800, - B50, B57600, B600, B75, B9600, ICANON, VDISCARD, VEOF, VEOL, VEOL2, VERASE, VINTR, VKILL, - VLNEXT, VMIN, VQUIT, VREPRINT, VSTART, VSTOP, VSUSP, VTIME, VWERASE, + speed_value, B0, B110, B115200, B1200, B134, B150, B1800, B19200, B200, B230400, B2400, B300, + B38400, B4800, B50, B57600, B600, B75, B9600, ICANON, VDISCARD, VEOF, VEOL, VEOL2, VERASE, + VINTR, VKILL, VLNEXT, VMIN, VQUIT, VREPRINT, VSTART, VSTOP, VSUSP, VTIME, VWERASE, }; pub use tc::{ tcdrain, tcflow, tcflush, tcgetattr, tcgetpgrp, tcgetsid, tcgetwinsize, tcsendbreak, tcsetattr, diff --git a/src/thread/mod.rs b/src/thread/mod.rs index ecad6d0f..ac48b435 100644 --- a/src/thread/mod.rs +++ b/src/thread/mod.rs @@ -7,15 +7,6 @@ mod futex; #[cfg(any(target_os = "android", target_os = "linux"))] mod id; -#[cfg(linux_raw)] -pub use futex::{futex, FutexFlags, FutexOperation}; - -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use id::gettid; - -#[cfg(not(target_os = "redox"))] -pub use clock::{nanosleep, NanosleepRelativeResult, Timespec}; - #[cfg(not(any( target_os = "dragonfly", target_os = "emscripten", @@ -27,3 +18,9 @@ pub use clock::{nanosleep, NanosleepRelativeResult, Timespec}; target_os = "wasi", )))] pub use clock::{clock_nanosleep_absolute, clock_nanosleep_relative, ClockId}; +#[cfg(not(target_os = "redox"))] +pub use clock::{nanosleep, NanosleepRelativeResult, Timespec}; +#[cfg(linux_raw)] +pub use futex::{futex, FutexFlags, FutexOperation}; +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use id::gettid; diff --git a/tests/fs/file.rs b/tests/fs/file.rs index cfa9c07a..5c09f640 100644 --- a/tests/fs/file.rs +++ b/tests/fs/file.rs @@ -47,7 +47,7 @@ fn test_file() { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] rustix::fs::fadvise(&file, 0, 10, rustix::fs::Advice::Normal).unwrap(); @@ -68,7 +68,7 @@ fn test_file() { target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet { diff --git a/tests/fs/invalid_offset.rs b/tests/fs/invalid_offset.rs index 0fac5741..cfe64ec3 100644 --- a/tests/fs/invalid_offset.rs +++ b/tests/fs/invalid_offset.rs @@ -1,3 +1,5 @@ +//! Tests for extreme `u64` file offsets. +//! //! POSIX-ish interfaces tend to use signed integers for file offsets, while //! Rust APIs tend to use `u64`. Test that extreme `u64` values in APIs that //! take file offsets are properly diagnosed. @@ -35,7 +37,7 @@ fn invalid_offset_seek() { target_os = "illumos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] #[test] fn invalid_offset_fallocate() { @@ -63,7 +65,7 @@ fn invalid_offset_fallocate() { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "redox" + target_os = "redox", )))] #[test] fn invalid_offset_fadvise() { diff --git a/tests/fs/main.rs b/tests/fs/main.rs index 5171274b..23928a6b 100644 --- a/tests/fs/main.rs +++ b/tests/fs/main.rs @@ -24,7 +24,7 @@ mod long_paths; target_os = "netbsd", target_os = "openbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] mod makedev; mod mkdirat; @@ -39,7 +39,7 @@ mod renameat; target_os = "illumos", target_os = "netbsd", target_os = "redox", - target_os = "wasi" + target_os = "wasi", )))] // not implemented in libc for netbsd yet mod statfs; diff --git a/tests/fs/y2038.rs b/tests/fs/y2038.rs index a59f3261..4299d709 100644 --- a/tests/fs/y2038.rs +++ b/tests/fs/y2038.rs @@ -2,10 +2,10 @@ /// `utimensat` and read it back again. /// /// See tests/time/y2038.rs for more information about y2038 testing. -#[test] #[cfg(not(all(target_env = "musl", target_pointer_width = "32")))] #[cfg(not(all(target_os = "android", target_pointer_width = "32")))] #[cfg(not(all(target_os = "emscripten", target_pointer_width = "32")))] +#[test] fn test_y2038_with_utimensat() { use rustix::fs::{ cwd, fstat, openat, statat, utimensat, AtFlags, Mode, OFlags, Timespec, Timestamps, @@ -77,10 +77,10 @@ fn test_y2038_with_utimensat() { /// `futimens` and read it back again. /// /// See tests/time/y2038.rs for more information about y2038 testing. -#[test] #[cfg(not(all(target_env = "musl", target_pointer_width = "32")))] #[cfg(not(all(target_os = "android", target_pointer_width = "32")))] #[cfg(not(all(target_os = "emscripten", target_pointer_width = "32")))] +#[test] fn test_y2038_with_futimens() { use rustix::fs::{ cwd, fstat, futimens, openat, statat, AtFlags, Mode, OFlags, Timespec, Timestamps, diff --git a/tests/mm/mlock.rs b/tests/mm/mlock.rs index 46dca2f3..d2c6da12 100644 --- a/tests/mm/mlock.rs +++ b/tests/mm/mlock.rs @@ -1,6 +1,7 @@ -//! Tests for `mlock`. We can't easily test that it actually locks memory, -//! but we can test that we can call it and either get success or a reasonable -//! error message. +//! Tests for `mlock`. +//! +//! We can't easily test that it actually locks memory, but we can test that we +//! can call it and either get success or a reasonable error message. use std::ffi::c_void; diff --git a/tests/net/sockopt.rs b/tests/net/sockopt.rs index eef70c4a..8e4cf52e 100644 --- a/tests/net/sockopt.rs +++ b/tests/net/sockopt.rs @@ -39,7 +39,7 @@ fn test_sockopts() { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] assert_eq!( rustix::net::sockopt::get_ip_multicast_loop(&s).unwrap(), @@ -52,7 +52,7 @@ fn test_sockopts() { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] assert_eq!(rustix::net::sockopt::get_ip_multicast_ttl(&s).unwrap(), 1); assert_eq!(rustix::net::sockopt::get_tcp_nodelay(&s).unwrap(), false); @@ -96,7 +96,7 @@ fn test_sockopts() { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] assert_eq!( rustix::net::sockopt::get_socket_broadcast(&s).unwrap(), @@ -137,7 +137,7 @@ fn test_sockopts() { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", )))] { // Set the multicast loop flag; diff --git a/tests/net/unix.rs b/tests/net/unix.rs index 1dfe0475..21a6542f 100644 --- a/tests/net/unix.rs +++ b/tests/net/unix.rs @@ -1,5 +1,6 @@ -//! Test a simple Unix-domain socket server and client. The client sends lists -//! of integers and the server sends back sums. +//! Test a simple Unix-domain socket server and client. +//! +//! The client sends lists of integers and the server sends back sums. // This test uses `AF_UNIX` with `SOCK_SEQPACKET` which is unsupported on macOS. #![cfg(not(any( diff --git a/tests/net/v4.rs b/tests/net/v4.rs index 6c414353..0908057b 100644 --- a/tests/net/v4.rs +++ b/tests/net/v4.rs @@ -1,5 +1,6 @@ -//! Test a simple IPv4 socket server and client. The client send a -//! message and the server sends one back. +//! Test a simple IPv4 socket server and client. +//! +//! The client send a message and the server sends one back. #![cfg(not(any(target_os = "redox", target_os = "wasi")))] diff --git a/tests/net/v6.rs b/tests/net/v6.rs index 68bb7865..07205be8 100644 --- a/tests/net/v6.rs +++ b/tests/net/v6.rs @@ -1,5 +1,6 @@ -//! Test a simple IPv6 socket server and client. The client send a -//! message and the server sends one back. +//! Test a simple IPv6 socket server and client. +//! +//! The client send a message and the server sends one back. #![cfg(not(any(target_os = "redox", target_os = "wasi")))] diff --git a/tests/param/auxv.rs b/tests/param/auxv.rs index 9b0d9e76..90a08810 100644 --- a/tests/param/auxv.rs +++ b/tests/param/auxv.rs @@ -1,6 +1,6 @@ #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] use rustix::param::linux_hwcap; use rustix::param::{clock_ticks_per_second, page_size}; @@ -21,11 +21,11 @@ fn test_clock_ticks_per_second() { assert_eq!(size, unsafe { libc::sysconf(libc::_SC_CLK_TCK) as u64 }); } -#[test] #[cfg(any( all(target_os = "android", target_pointer_width = "64"), - target_os = "linux" + target_os = "linux", ))] +#[test] fn test_linux_hwcap() { weak!(fn getauxval(libc::c_ulong) -> libc::c_ulong); diff --git a/tests/time/y2038.rs b/tests/time/y2038.rs index 4c545a50..45a073d1 100644 --- a/tests/time/y2038.rs +++ b/tests/time/y2038.rs @@ -11,10 +11,10 @@ /// such support itself. /// /// [not y2038 compatible]: https://android.googlesource.com/platform/bionic/+/refs/heads/master/docs/32-bit-abi.md#is-32_bit-on-lp32-y2038 -#[test] #[cfg(not(all(target_env = "musl", target_pointer_width = "32")))] #[cfg(not(all(target_os = "android", target_pointer_width = "32")))] #[cfg(not(all(target_os = "emscripten", target_pointer_width = "32")))] +#[test] fn test_y2038() { use rustix::time::{Secs, Timespec};