about summary refs log tree commit diff
path: root/library/std/src/sys/unix/fd.rs
AgeCommit message (Collapse)AuthorLines
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-0/+9
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-03-04Auto merge of #89518 - a1phyr:unix_file_vectored_at, r=workingjubileebors-3/+181
Add vectored positioned I/O on Unix Add methods for vectored I/O with an offset on `File` for `unix` under `#![feature(unix_file_vectored_at)]`. The new methods are wrappers around `preadv` and `pwritev`. Tracking issue: #89517
2023-03-03Use weak linkage for `preadv` and `pwritev` on MacOS and iOSBenoît du Garreau-8/+18
2023-03-02Use weak linkage on AndroidBenoît du Garreau-4/+96
2023-03-02Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubileebors-3/+11
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr` ⚠️ Backtraces on QNX require https://github.com/rust-lang/backtrace-rs/pull/507 which is not yet merged! (But everything else works without these changes) ⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-3/+11
Co-authored-by: gh-tr <troach@qnx.com>
2023-02-27Add vectored positioned I/O on UnixBenoît du Garreau-3/+79
2023-02-21Remove unused FileDesc::get_cloexecTomasz Miąsko-5/+0
2023-02-19Use custom implementation of read_buf in Read for &'a FileDescTomasz Miąsko-0/+4
This allows to skip an unnecessary buffer initialization.
2022-08-18Address reviewer commentsNick Cameron-1/+1
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-05non-linux platformsNick Cameron-2/+2
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-04std::io: migrate ReadBuf to BorrowBuf/BorrowCursorNick Cameron-6/+5
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-07-20Library changes for Apple WatchOSVladimir Michael Eatwell-1/+3
2022-06-13Horizon OS STD supportMeziu-21/+20
Co-authored-by: Ian Chamberlain <ian.h.chamberlain@gmail.com> Co-authored-by: Mark Drobnak <mark.drobnak@gmail.com>
2022-04-19espidf: fix statScott Mabin-2/+17
* corect type usage with new type definitions in libc
2022-01-25Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplettMatthias Krüger-15/+2
Add a `try_clone()` function to `OwnedFd`. As suggested in #88564. This adds a `try_clone()` to `OwnedFd` by refactoring the code out of the existing `File`/`Socket` code. r? ``@joshtriplett``
2021-12-09Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplettbors-6/+18
Implement most of RFC 2930, providing the ReadBuf abstraction This replaces the `Initializer` abstraction for permitting reading into uninitialized buffers, closing #42788. This leaves several APIs described in the RFC out of scope for the initial implementation: * read_buf_vectored * `ReadBufs` Closes #42788, by removing the relevant APIs.
2021-11-12Refactor weak symbols in std::sys::unixJosh Stone-36/+12
This makes a few changes to the weak symbol macros in `sys::unix`: - `dlsym!` is added to keep the functionality for runtime `dlsym` lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't want to show up in ELF symbol tables. - `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime behavior is just a simple null check. This is also used by `syscall!`. - On non-ELF targets (macos/ios) where that linkage is not known to behave, `weak!` is just an alias to `dlsym!` for the old behavior. - `raw_syscall!` is added to always call `libc::syscall` on linux and android, for cases like `clone3` that have no known libc wrapper. The new `weak!` linkage does mean that you'll get versioned symbols if you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`. This might seem problematic, but old non-weak symbols can tie the build to new versions too, like `dlsym@GLIBC_2.34` from their recent library unification. If you build with an old glibc like `dist-x86_64-linux` does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may be resolved based on the runtime glibc. I also found a few functions that don't need to be weak anymore: - Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as these were added in API 12, and our baseline is API 14. - Linux can directly use `splice`, added way back in glibc 2.5 and similarly old musl. Android only added it in API 21 though.
2021-11-02more efficent File::read_buf impl for windows and unixDrMeepster-1/+18
2021-11-02read_bufDrMeepster-6/+1
2021-09-09Add a `try_clone()` function to `OwnedFd`.Dan Gohman-15/+2
As suggested in #88564. This adds a `try_clone()` to `OwnedFd` by refactoring the code out of the existing `File`/`Socket` code.
2021-08-19I/O safety.Dan Gohman-53/+62
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-08-10STD support for the ESP-IDF frameworkivmarkov-4/+32
2020-12-20Check that c_int is i32 in FileDesc::new.Mara Bos-1/+1
2020-12-10Add safety note to library/std/src/sys/unix/fd.rsMichael Howell-0/+1
Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
2020-12-10Mark `-1` as an available niche for file descriptorsMichael Howell-1/+7
Based on discussion from https://internals.rust-lang.org/t/can-the-standard-library-shrink-option-file/12768, the file descriptor -1 is chosen based on the POSIX API designs that use it as a sentinel to report errors. A bigger niche could've been chosen, particularly on Linux, but would not necessarily be portable. This PR also adds a test case to ensure that the -1 niche (which is kind of hacky and has no obvious test case) works correctly. It requires the "upper" bound, which is actually -1, to be expressed in two's complement.
2020-10-16Take sys/vxworks/{fd,fs,io} from sys/unix instead.Mara Bos-2/+4
2020-09-11Ignore unnecessary unsafe warningsThomas de Zeeuw-1/+0
This is a work-around for a libc issue: https://github.com/rust-lang/libc/issues/1888.
2020-09-10Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/OThomas de Zeeuw-16/+26
Also updates the libc dependency to 0.2.77 (from 0.2.74) as the constants were only recently added.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-13/+3
Also doing fmt inplace as requested.
2020-08-06Keep stdout open in limit_vector_count testTomasz Miąsko-2/+2
2020-08-05Add fallback for cfg(unix) targets that do not define libc::_SC_IOV_MAX.Adam Reichold-0/+7
2020-08-05Rely only on POSIX semantics for I/O vector countAdam Reichold-17/+3
All #[cfg(unix)] platforms follow the POSIX standard and define _SC_IOV_MAX so that we rely purely on POSIX semantics to determine the limits on I/O vector count.
2020-08-05Reduce synchronization overhead of I/O vector count memoizationAdam Reichold-10/+14
2020-08-05Memoize the I/O vector count limitAdam Reichold-12/+17
Keep the I/O vector count limit in a `SyncOnceCell` to avoid the overhead of repeatedly calling `sysconf` as these limits are guaranteed to not change during the lifetime of a process by POSIX.
2020-08-05Query maximum vector count on Linux and macOSAdam Reichold-2/+36
Both Linux and MacOS enforce limits on the vector count when performing vectored I/O via the readv and writev system calls and return EINVAL when these limits are exceeded. This changes the standard library to handle those limits as short reads and writes to avoid forcing its users to query these limits using platform specific mechanisms.
2020-07-27mv std libs to library/mark-0/+258