// On PowerPC, the regular `termios` has the `termios2` fields and there is no // `termios2`, so we define aliases. #[cfg(all(
linux_kernel,
feature = "termios",
any(target_arch = "powerpc", target_arch = "powerpc64")
))] pub(crate) use {
termios as termios2, TCGETS as TCGETS2, TCSETS as TCSETS2, TCSETSF as TCSETSF2,
TCSETSW as TCSETSW2,
};
// And PowerPC doesn't define `CIBAUD`, but it does define `IBSHIFT`, so we can // compute `CIBAUD` ourselves. #[cfg(all(
linux_kernel,
feature = "termios",
any(target_arch = "powerpc", target_arch = "powerpc64")
))] pub(crate) const CIBAUD: u32 = CBAUD << IBSHIFT;
// Automatically enable “large file” support (LFS) features.
#[cfg(target_os = "vxworks")] pub(super) use _Vx_ticks64_t as _Vx_ticks_t; #[cfg(linux_kernel)] pub(super) use fallocate64 as fallocate; #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] #[cfg(any(linux_like, target_os = "aix"))] pub(super) use open64 as open; #[cfg(any(
linux_kernel,
target_os = "aix",
target_os = "hurd",
target_os = "l4re"
))] pub(super) use posix_fallocate64 as posix_fallocate; #[cfg(any(all(linux_like, not(target_os = "android")), target_os = "aix"))] pub(super) use {blkcnt64_t as blkcnt_t, rlim64_t as rlim_t}; // TODO: AIX has `stat64x`, `fstat64x`, `lstat64x`, and `stat64xat`; add them // to the upstream libc crate and implement rustix's `statat` etc. with them. #[cfg(target_os = "aix")] pub(super) use {
blksize64_t as blksize_t, fstat64 as fstat, fstatfs64 as fstatfs, fstatvfs64 as fstatvfs,
ftruncate64 as ftruncate, getrlimit64 as getrlimit, ino_t, lseek64 as lseek, mmap,
off64_t as off_t, openat, posix_fadvise64 as posix_fadvise, preadv, pwritev,
rlimit64 as rlimit, setrlimit64 as setrlimit, stat64at as fstatat, statfs64 as statfs,
statvfs64 as statvfs, RLIM_INFINITY,
}; #[cfg(any(linux_like, target_os = "hurd"))] pub(super) use {
fstat64 as fstat, fstatat64 as fstatat, fstatfs64 as fstatfs, fstatvfs64 as fstatvfs,
ftruncate64 as ftruncate, getrlimit64 as getrlimit, ino64_t as ino_t, lseek64 as lseek,
mmap64 as mmap, off64_t as off_t, openat64 as openat, posix_fadvise64 as posix_fadvise,
rlimit64 as rlimit, setrlimit64 as setrlimit, statfs64 as statfs, statvfs64 as statvfs,
RLIM64_INFINITY as RLIM_INFINITY,
}; #[cfg(apple)] pub(super) use {
host_info64_t as host_info_t, host_statistics64 as host_statistics,
vm_statistics64_t as vm_statistics_t,
}; #[cfg(not(all(
linux_kernel,
any(
target_pointer_width = "32",
target_arch = "mips64",
target_arch = "mips64r6"
)
)))] #[cfg(any(linux_like, target_os = "aix", target_os = "hurd"))] pub(super) use {lstat64 as lstat, stat64 as stat}; #[cfg(any(
linux_kernel,
target_os = "aix",
target_os = "hurd",
target_os = "emscripten"
))] pub(super) use {pread64 as pread, pwrite64 as pwrite}; #[cfg(any(target_os = "linux", target_os = "hurd", target_os = "emscripten"))] pub(super) use {preadv64 as preadv, pwritev64 as pwritev};
// glibc added `preadv64v2` and `pwritev64v2` in version 2.26. #[cfg(all(target_os = "linux", target_env = "gnu"))] mod readwrite_pv64v2 { usesuper::*;
pub(insuper::super) unsafefn preadv64v2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset: off64_t,
flags: c_int,
) -> ssize_t { // Older glibc lacks `preadv64v2`, so use the `weak!` mechanism to // test for it, and call back to `syscall`. We don't use // `weak_or_syscall` here because we need to pass the 64-bit offset // specially.
weak! { fn preadv64v2(c_int, *const iovec, c_int, off64_t, c_int) -> ssize_t
} iflet Some(fun) = preadv64v2.get() {
fun(fd, iov, iovcnt, offset, flags)
} else { // Unlike the plain "p" functions, the "pv" functions pass their // offset in an endian-independent way, and always in two // registers.
syscall! { fn preadv2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset_lo: usize,
offset_hi: usize,
flags: c_int
) via SYS_preadv2 -> ssize_t
}
preadv2(
fd,
iov,
iovcnt,
offset as usize,
(offset >> 32) as usize,
flags,
)
}
} pub(insuper::super) unsafefn pwritev64v2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset: off64_t,
flags: c_int,
) -> ssize_t { // See the comments in `preadv64v2`.
weak! { fn pwritev64v2(c_int, *const iovec, c_int, off64_t, c_int) -> ssize_t
} iflet Some(fun) = pwritev64v2.get() {
fun(fd, iov, iovcnt, offset, flags)
} else { // Unlike the plain "p" functions, the "pv" functions pass their // offset in an endian-independent way, and always in two // registers.
syscall! { fn pwritev2(
fd: c_int,
iov: *const iovec,
iovec: c_int,
offset_lo: usize,
offset_hi: usize,
flags: c_int
) via SYS_pwritev2 -> ssize_t
}
pwritev2(
fd,
iov,
iovcnt,
offset as usize,
(offset >> 32) as usize,
flags,
)
}
}
} #[cfg(all(target_os = "linux", target_env = "gnu"))] pub(super) use readwrite_pv64v2::{preadv64v2 as preadv2, pwritev64v2 as pwritev2};
// On non-glibc, assume we don't have `pwritev2`/`preadv2` in libc and use // `c::syscall` instead. #[cfg(any(
target_os = "android",
all(target_os = "linux", not(target_env = "gnu")),
))] mod readwrite_pv64v2 { usesuper::*;
pub(insuper::super) unsafefn preadv64v2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset: off64_t,
flags: c_int,
) -> ssize_t { // Unlike the plain "p" functions, the "pv" functions pass their offset // in an endian-independent way, and always in two registers.
syscall! { fn preadv2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset_lo: usize,
offset_hi: usize,
flags: c_int
) via SYS_preadv2 -> ssize_t
}
preadv2(
fd,
iov,
iovcnt,
offset as usize,
(offset >> 32) as usize,
flags,
)
} pub(insuper::super) unsafefn pwritev64v2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset: off64_t,
flags: c_int,
) -> ssize_t { // Unlike the plain "p" functions, the "pv" functions pass their offset // in an endian-independent way, and always in two registers.
syscall! { fn pwritev2(
fd: c_int,
iov: *const iovec,
iovcnt: c_int,
offset_lo: usize,
offset_hi: usize,
flags: c_int
) via SYS_pwritev2 -> ssize_t
}
pwritev2(
fd,
iov,
iovcnt,
offset as usize,
(offset >> 32) as usize,
flags,
)
}
} #[cfg(any(
target_os = "android",
all(target_os = "linux", not(target_env = "gnu")),
))] pub(super) use readwrite_pv64v2::{preadv64v2 as preadv2, pwritev64v2 as pwritev2};
#[test] #[cfg(linux_kernel)] fn test_flags() { // libc may publicly define `O_LARGEFILE` to 0, but we want the real // non-zero value.
assert_ne!(O_LARGEFILE, 0);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.