Code formatting cleanups.

Wrap long lines that were hidden from rustfmt by macros, be consistent
about trailing commas in `cfg`s, alphabetize operands to `any`/`all`,
and add some comments.
This commit is contained in:
Dan Gohman
2022-06-10 09:55:18 -07:00
parent 7e9b0a6586
commit 6cc35afe8b
66 changed files with 316 additions and 282 deletions
+12 -5
View File
@@ -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.
+5 -5
View File
@@ -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);
+2 -2
View File
@@ -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",
+2 -2
View File
@@ -123,7 +123,7 @@ fn show<Fd: AsFd>(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: AsFd>(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");
+3 -3
View File
@@ -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<P: path::Arg>(path: P) -> io::Result<StatFs> {
+6 -6
View File
@@ -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: AsFd>(fd: Fd) -> io::Result<Stat> {
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: AsFd>(fd: Fd) -> io::Result<StatFs> {
@@ -196,7 +196,7 @@ pub fn futimens<Fd: AsFd>(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: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "dragonfly",
target_os = "ios",
target_os = "macos",
target_os = "redox"
target_os = "redox",
)))]
#[inline]
pub fn fdatasync<Fd: AsFd>(fd: Fd) -> io::Result<()> {
+14 -15
View File
@@ -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"))]
+9 -9
View File
@@ -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<StatFs> {
@@ -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 {
+1 -1
View File
@@ -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))]
+25 -25
View File
@@ -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<OwnedFd> {
// Work around https://sourceware.org/bugzilla/show_bug.cgi?id=17523
// Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
// 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<StatFs> {
@@ -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<Stat> {
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<StatFs> {
let mut statfs = MaybeUninit::<StatFs>::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<Stat> {
Ok(Stat {
@@ -1272,7 +1272,7 @@ fn statx_to_stat(x: crate::fs::Statx) -> io::Result<Stat> {
/// 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<Stat> {
let mut result: Stat = unsafe { core::mem::zeroed() };
@@ -1312,7 +1312,7 @@ fn statx_to_stat(x: crate::fs::Statx) -> io::Result<Stat> {
/// 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<Stat> {
Ok(Stat {
@@ -1350,7 +1350,7 @@ fn stat64_to_stat(s64: c::stat64) -> io::Result<Stat> {
/// 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<Stat> {
let mut result: Stat = unsafe { core::mem::zeroed() };
+9 -9
View File
@@ -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;
+1 -1
View File
@@ -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)
)]
+10 -10
View File
@@ -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`
+4 -4
View File
@@ -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
+6 -1
View File
@@ -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;
}
}
+2 -2
View File
@@ -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`
+3 -3
View File
@@ -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))]
+15 -15
View File
@@ -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],
};
+2 -2
View File
@@ -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,
+5 -5
View File
@@ -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],
+3 -3
View File
@@ -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`
+2 -2
View File
@@ -255,7 +255,7 @@ pub(crate) fn accept(sockfd: BorrowedFd<'_>) -> io::Result<OwnedFd> {
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<OwnedFd> {
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<'_>,
+23 -4
View File
@@ -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 _);
+3 -3
View File
@@ -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::<c::sockaddr_in>() 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(
+1 -1
View File
@@ -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"))]
+4 -4
View File
@@ -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 {
+2 -2
View File
@@ -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))]
+6 -6
View File
@@ -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<Pid> {
}
#[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<Pid>, cpuset: &mut RawCpuSet) -> io::Result<()> {
@@ -163,10 +163,10 @@ pub(crate) fn sched_getaffinity(pid: Option<Pid>, 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<Pid>, cpuset: &RawCpuSet) -> io::Result<()> {
+7 -7
View File
@@ -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;
+3 -3
View File
@@ -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;
+11 -11
View File
@@ -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;
+19 -19
View File
@@ -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<Timesp
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu"
target_env = "gnu",
))]
{
if let Some(libc_clock_gettime) = __clock_gettime64.get() {
@@ -203,7 +203,7 @@ pub(crate) fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result<Timesp
#[cfg(not(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu"
target_env = "gnu",
)))]
{
ret(c::clock_gettime(id as c::clockid_t, timespec.as_mut_ptr()))?;
@@ -215,7 +215,7 @@ pub(crate) fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result<Timesp
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu"
target_env = "gnu",
))]
#[inline]
unsafe fn clock_gettime_dynamic_old(id: c::clockid_t) -> io::Result<Timespec> {
@@ -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<Itimerspec> {
#[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<Itimerspec> {
#[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<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",
))]
#[cfg(feature = "time")]
unsafe fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
+16 -16
View File
@@ -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<LibcTimespec> for Timespec {
#[inline]
@@ -93,7 +93,7 @@ impl From<LibcTimespec> for Timespec {
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu"
target_env = "gnu",
))]
impl From<Timespec> 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<LibcItimerspec> for Itimerspec {
#[inline]
@@ -277,7 +277,7 @@ impl From<LibcItimerspec> 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<Itimerspec> for LibcItimerspec {
#[inline]
+2
View File
@@ -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.
+2 -2
View File
@@ -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")]
+1 -1
View File
@@ -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};
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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();
+1 -1
View File
@@ -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.
-1
View File
@@ -1,5 +1,4 @@
#![allow(unsafe_code)]
#![allow(dead_code)]
use super::super::c;
+1
View File
@@ -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;
+2 -2
View File
@@ -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));
+1 -1
View File
@@ -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")))]
+1 -1
View File
@@ -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;
+4 -4
View File
@@ -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,
}
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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<Fd: AsFd>(
/// [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: AsFd>(
fd: Fd,
buf: &[u8],
+2 -2
View File
@@ -149,9 +149,9 @@ pub fn bind_v6<Fd: AsFd>(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<Fd: AsFd>(sockfd: Fd, addr: &SocketAddrUnix) -> io::Result<()> {
imp::net::syscalls::bind_unix(sockfd.as_fd(), addr)
}
@@ -240,9 +240,9 @@ pub fn connect_v6<Fd: AsFd>(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<Fd: AsFd>(sockfd: Fd, addr: &SocketAddrUnix) -> io::Result<()> {
imp::net::syscalls::connect_unix(sockfd.as_fd(), addr)
}
+3 -3
View File
@@ -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",
)
)
))]
+1 -1
View File
@@ -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",
)
)
))]
+4 -4
View File
@@ -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;
+2 -2
View File
@@ -234,8 +234,8 @@ pub unsafe fn fork() -> io::Result<Option<Pid>> {
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/execveat.2.html
#[inline]
#[cfg(linux_raw)]
#[inline]
pub unsafe fn execveat<Fd: AsFd>(
dirfd: Fd,
path: &CStr,
@@ -258,8 +258,8 @@ pub unsafe fn execveat<Fd: AsFd>(
/// - [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)
}
+3 -3
View File
@@ -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(
+6 -7
View File
@@ -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,
+6 -9
View File
@@ -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;
+2 -2
View File
@@ -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
{
+4 -2
View File
@@ -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() {
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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,
+4 -3
View File
@@ -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;
+4 -4
View File
@@ -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;
+3 -2
View File
@@ -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(
+3 -2
View File
@@ -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")))]
+3 -2
View File
@@ -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")))]
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -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};