Lines Matching +full:use +full:- +full:libc
3 use crate::errno::Errno;
4 use crate::Result;
5 use libc::{self, c_int, c_void, off_t, size_t};
6 use std::io::{IoSlice, IoSliceMut};
7 use std::marker::PhantomData;
8 use std::os::unix::io::RawFd;
10 /// Low-level vectored write to a raw file descriptor
13 pub fn writev(fd: RawFd, iov: &[IoSlice<'_>]) -> Result<usize> { in writev()
22 libc::writev(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int) in writev() constant
28 /// Low-level vectored read from a raw file descriptor
31 pub fn readv(fd: RawFd, iov: &mut [IoSliceMut<'_>]) -> Result<usize> { in readv()
32 // SAFETY: same as in writev(), IoSliceMut is ABI-compatible with iovec in readv()
34 libc::readv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int) in readv() constant
48 pub fn pwritev(fd: RawFd, iov: &[IoSlice<'_>], offset: off_t) -> Result<usize> { in pwritev()
50 let offset = offset as libc::off64_t; // uclibc doesn't use off_t in pwritev()
54 libc::pwritev( in pwritev()
56 iov.as_ptr() as *const libc::iovec, in pwritev() constant
78 ) -> Result<usize> { in preadv()
80 let offset = offset as libc::off64_t; // uclibc doesn't use off_t in preadv()
84 libc::preadv( in preadv()
86 iov.as_ptr() as *const libc::iovec, in preadv() constant
95 /// Low-level write to a file, with specified offset.
99 pub fn pwrite(fd: RawFd, buf: &[u8], offset: off_t) -> Result<usize> { in pwrite()
101 libc::pwrite( in pwrite()
112 /// Low-level read from a file, with specified offset.
116 pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t) -> Result<usize> { in pread()
118 libc::pread( in pread()
150 /// Vectored I/O methods like [`writev`] and [`readv`] use this structure for
155 … note = "`IoVec` is no longer used in the public interface, use `IoSlice` or `IoSliceMut` instead"
160 // Clippy false positive: https://github.com/rust-lang/rust-clippy/issues/8867
163 pub struct IoVec<T>(pub(crate) libc::iovec, PhantomData<T>);
170 note = "Use the `Deref` impl of `IoSlice` or `IoSliceMut` instead"
173 pub fn as_slice(&self) -> &[u8] { in as_slice()
174 use std::slice; in as_slice()
185 #[deprecated(since = "0.24.0", note = "Use `IoSlice::new` instead")]
186 pub fn from_slice(buf: &'a [u8]) -> IoVec<&'a [u8]> { in from_slice()
188 libc::iovec { in from_slice()
200 #[deprecated(since = "0.24.0", note = "Use `IoSliceMut::new` instead")]
201 pub fn from_mut_slice(buf: &'a mut [u8]) -> IoVec<&'a mut [u8]> { in from_mut_slice()
203 libc::iovec { in from_mut_slice()
212 // The only reason IoVec isn't automatically Send+Sync is because libc::iovec
238 /// [`process_vm_writev`(2)]: https://man7.org/linux/man-pages/man2/process_vm_writev.2.html
240 /// [`IoSlice`]: https://doc.rust-lang.org/std/io/struct.IoSlice.html
246 remote_iov: &[RemoteIoVec]) -> Result<usize>
249 libc::process_vm_writev(pid.into(),
250 … local_iov.as_ptr() as *const libc::iovec, local_iov.len() as libc::c_ulong,
251 … remote_iov.as_ptr() as *const libc::iovec, remote_iov.len() as libc::c_ulong, 0)
273 /// [`process_vm_readv`(2)]: https://man7.org/linux/man-pages/man2/process_vm_readv.2.html
275 /// [`IoSliceMut`]: https://doc.rust-lang.org/std/io/struct.IoSliceMut.html
281 remote_iov: &[RemoteIoVec]) -> Result<usize>
284 libc::process_vm_readv(pid.into(),
285 … local_iov.as_ptr() as *const libc::iovec, local_iov.len() as libc::c_ulong,
286 … remote_iov.as_ptr() as *const libc::iovec, remote_iov.len() as libc::c_ulong, 0)