about summary refs log tree commit diff
path: root/library/std/src/os
AgeCommit message (Collapse)AuthorLines
2024-02-18Add uncontroversial syscall doc aliases to std docsSabrinaJewson-0/+14
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-1/+0
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-11Rollup merge of #120459 - rytheo:handle-conversion-docs, r=Mark-SimulacrumMatthias Krüger-0/+25
Document various I/O descriptor/handle conversions Related to #51430
2024-02-04Document various I/O handle conversionsRyan Lowe-0/+25
2024-01-30Rollup merge of #120434 - fmease:revert-speeder, r=petrochenkovGuillaume Gomez-10/+1
Revert outdated version of "Add the wasm32-wasi-preview2 target" An outdated version of #119616 was merged in rollup #120309. This reverts those changes to enable #119616 to “retain the intended diff” after a rebase. ```@rylev``` has agreed that this would be the cleanest approach with respect to the history. Unblocks #119616. r? ```@petrochenkov``` or compiler or libs
2024-01-30Rollup merge of #120452 - alexcrichton:update-windows-seek-write-docs, ↵Guillaume Gomez-1/+1
r=ChrisDenton std: Update documentation of seek_write on Windows Currently the documentation of `FileExt::seek_write` on Windows indicates that writes beyond the end of the file leave intermediate bytes uninitialized. This commentary dates back to the original inclusion of these functions in #35704 (wow blast from the past!). At the time the functionality here was implemented using `WriteFile`, but nowadays the `NtWriteFile` method is used instead. The documentation for `NtWriteFile` explicitly states: > If Length and ByteOffset specify a write operation past the current > end-of-file mark, NtWriteFile automatically extends the file and updates > the end-of-file mark; any bytes that are not explicitly written between > such old and new end-of-file marks are defined to be zero. This commentary has had a downstream impact in the `system-interface` crate where it tries to handle this by explicitly writing zeros, but I don't believe that's necessary any more. I'm sending a PR upstream here to avoid future confusion and codify that zeros are written in the intermediate bytes matching what Windows currently provides.
2024-01-28Make `impl<T: AsHandle>` impl take `?Sized`Gary Guo-5/+5
2024-01-28Make `impl<Fd: AsFd>` impl take `?Sized`Gary Guo-5/+5
2024-01-28std: Update documentation of seek_write on WindowsAlex Crichton-1/+1
Currently the documentation of `FileExt::seek_write` on Windows indicates that writes beyond the end of the file leave intermediate bytes uninitialized. This commentary dates back to the original inclusion of these functions in #35704 (wow blast from the past!). At the time the functionality here was implemented using `WriteFile`, but nowadays the `NtWriteFile` method is used instead. The documentation for `NtWriteFile` explicitly states: > If Length and ByteOffset specify a write operation past the current > end-of-file mark, NtWriteFile automatically extends the file and updates > the end-of-file mark; any bytes that are not explicitly written between > such old and new end-of-file marks are defined to be zero. This commentary has had a downstream impact in the `system-interface` crate where it tries to handle this by explicitly writing zeros, but I don't believe that's necessary any more. I'm sending a PR upstream here to avoid future confusion and codify that zeros are written in the intermediate bytes matching what Windows currently provides.
2024-01-28Revert "Add the wasm32-wasi-preview2 target"León Orell Valerian Liehr-10/+1
This reverts commit 31ecf341250a889ac1154b2cbe3f0b97f9d008c1. Co-authored-by: Ryan Levick <me@ryanlevick.com>
2024-01-25Rollup merge of #120306 - safinaskar:clone3-clean-up, r=petrochenkovMatthias Krüger-2/+1
Clean up after clone3 removal from pidfd code (docs and tests) https://github.com/rust-lang/rust/pull/113939 removed clone3 from pidfd code. This patchset does necessary clean up: fixes docs and tests
2024-01-24Finishing clone3 clean upAskar Safin-2/+1
2024-01-23Add the wasm32-wasi-preview2 targetRyan Levick-1/+10
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-01-22Rollup merge of #119943 - devnexen:listener_update3, r=thomccMatthias Krüger-1/+7
std::net: bind update for using backlog as `-1` too. Albeit not documented, macOs also support negative value for the backlog argument. ref: https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/kern/uipc_socket.c#L1061
2024-01-22Rollup merge of #119408 - betrusted-io:xous-fixes-add-network, r=Mark-SimulacrumMatthias Krüger-10/+152
xous: misc fixes + add network support This patchset makes several fixes to Xous support. Additionally, this patch adds networking support. Many of these fixes are the result of the recent patch to get `unwinding` support merged. As a result of this patch, we can now run rust tests. As a result of these tests, we now have 729 tests passing: ``` failures: env::tests::test env::tests::test_self_exe_path env::tests::vars_debug env::tests::vars_os_debug os::raw::tests::same path::tests::test_push path::tests::test_set_file_name time::tests::since_epoch test result: FAILED. 729 passed; 8 failed; 1 ignored; 0 measured; 0 filtered out; finished in 214.54s ``` In the course of fixing several tests and getting the test sequence to reliably run, several issues were found. This patchset fixes those issues.
2024-01-15std::net: bind update for using backlog as `-1` too.David Carlier-1/+7
Albeit not documented, macOs also support negative value for the backlog argument. ref: https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/kern/uipc_socket.c#L1061
2024-01-13std: xous: use constants for stdout and stderrSean Cross-0/+11
Use constants for the opcodes when writing to stdout or stderr. There still is no stdin operation. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13xous: net: initial commit of network supportSean Cross-0/+129
This is an initial commit of network support for Xous. On hardware, is backed by smoltcp running via a Xous server in a separate process space. This patch adds TCP and UDP client and server support as well as DNS resolution support using the dns Xous server. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: pass entire memory range to flag updaterSean Cross-1/+1
When updating memory flags via `update_memory_flags()`, ensure we multiply the slice length by the element size to get the full memory size. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13xous: ffi: correct size of freed memorySean Cross-1/+1
The amount of memory allocated was multiplied by sizeof::<T>(), so the amount of memory to be freed should also be multiplied by sizeof::<T>(). Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13xous: ffi: fix lend_impl() return valuesSean Cross-8/+10
The `ret1` and `ret2` return values from lend operations are returned in $a1 and $a2. This function incorrectly pulled them from $a6 and $a7, causing them to always be `0`. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-09Backlog for HorizonOS UnixListenerAndrea Ciliberti-2/+8
2024-01-05Fix broken build for ESP IDF due to #119026ivmarkov-2/+3
2024-01-04Rollup merge of #119026 - devnexen:listener_upd, r=Mark-SimulacrumMatthias Krüger-2/+12
std::net::bind using -1 for openbsd which in turn sets it to somaxconn. trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
2023-12-24Fix doc typo for read_exact_atAlexBuz-1/+1
2023-12-24std::net::bind using -1 for openbsd which in turn sets it to somaxconn.David Carlier-2/+12
trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
2023-11-23Fix tracking issue of Windows ExitCodeExtDavid Tolnay-3/+3
2023-11-23Auto merge of #115159 - solid-rs:patch/kmc-solid/io-safety, r=workingjubileebors-4/+298
kmc-solid: I/O safety Adds the I/O safety API (#87329) for socket file descriptors in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. All new public items are gated by the `solid_ext` library feature. This PR adds the following public types and traits: std::os::solid::io::AsFd std::os::solid::io::BorrowedFd std::os::solid::io::OwnedFd std::os::solid::prelude::AsFd (re-export) std::os::solid::prelude::BorrowedFd (re-export) std::os::solid::prelude::OwnedFd (re-export) And trait implementations: From<std::net::TcpListener> for std::os::solid::io::OwnedFd From<std::net::TcpStream> for std::os::solid::io::OwnedFd From<std::net::UdpSocket> for std::os::solid::io::OwnedFd From<std::os::solid::io::OwnedFd> for std::net::TcpListener From<std::os::solid::io::OwnedFd> for std::net::TcpStream From<std::os::solid::io::OwnedFd> for std::net::UdpSocket std::fmt::Debug for std::os::solid::io::BorrowedFd<'_> std::fmt::Debug for std::os::solid::io::OwnedFd std::io::IsTerminal for std::os::solid::io::BorrowedFd<'_> std::io::IsTerminal for std::os::solid::io::OwnedFd std::os::fd::AsRawFd for std::os::solid::io::BorrowedFd<'_> std::os::fd::AsRawFd for std::os::solid::io::OwnedFd std::os::fd::FromRawFd for std::os::solid::io::OwnedFd std::os::fd::IntoRawFd for std::os::solid::io::OwnedFd std::os::solid::io::AsFd for &impl std::os::solid::io::AsFd std::os::solid::io::AsFd for &mut impl std::os::solid::io::AsFd std::os::solid::io::AsFd for Arc<impl std::os::solid::io::AsFd> std::os::solid::io::AsFd for Box<impl std::os::solid::io::AsFd> std::os::solid::io::AsFd for Rc<impl std::os::solid::io::AsFd> std::os::solid::io::AsFd for std::net::TcpListener std::os::solid::io::AsFd for std::net::TcpStream std::os::solid::io::AsFd for std::net::UdpSocket std::os::solid::io::AsFd for std::os::solid::io::BorrowedFd<'_> std::os::solid::io::AsFd for std::os::solid::io::OwnedFd Taking advantage of the above change, this PR also refactors the internal details of `std::sys::solid::net` to match the design of other targets, e.g., by redefining `Socket` as a newtype of `OwnedFd`.
2023-11-22unnecessary_mut_passedChris Denton-2/+2
This is where our Windows API bindings previously (and incorrectly) used `*mut` instead of `*const` pointers. Now that the bindings have been corrected, the mutable references (which auto-convert to `*mut`) are unnecessary and we can use shared references.
2023-11-22useless_conversionChris Denton-1/+1
2023-11-19Rollup merge of #117957 - the8472:pidfd-wait, r=Mark-SimulacrumMichael Goulet-0/+6
if available use a Child's pidfd for kill/wait This should get us closer to stabilization of pidfds since they now do something useful. And they're `CLOEXEC` now. ``` $ strace -ffe clone,sendmsg,recvmsg,execve,kill,pidfd_open,pidfd_send_signal,waitpid,waitid ./x test std --no-doc -- pidfd [...] running 1 tests strace: Process 816007 attached [pid 816007] pidfd_open(816006, 0) = 3 [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0c6b787990) = 816008 strace: Process 816008 attached [pid 816007] recvmsg(3, <unfinished ...> [pid 816008] pidfd_open(816008, 0) = 3 [pid 816008] sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[4]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816008] execve("/usr/bin/false", ["false"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 4, <unfinished ...> [pid 816008] +++ exited with 1 +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0} --- [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process 816009 attached , child_tidptr=0x7f0c6b787990) = 816009 [pid 816007] recvmsg(3, <unfinished ...> [pid 816009] pidfd_open(816009, 0) = 3 [pid 816009] sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[5]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816009] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 5, {}, WNOHANG|WEXITED, NULL) = 0 [pid 816007] pidfd_send_signal(5, SIGKILL, NULL, 0) = 0 [pid 816007] waitid(P_PIDFD, 5, <unfinished ...> [pid 816009] +++ killed by SIGKILL +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0} --- [pid 816007] +++ exited with 0 +++ ```
2023-11-17Rollup merge of #117338 - workingjubilee:asmjs-meets-thanatos, r=b-naberMatthias Krüger-2/+0
Remove asmjs Fulfills [MCP 668](https://github.com/rust-lang/compiler-team/issues/668). `asmjs-unknown-emscripten` does not work as-specified, and lacks essential upstream support for generating asm.js, so it should not exist at all.
2023-11-16if available use a Child's pidfd for kill/waitThe 8472-0/+6
2023-11-15Substitute version placeholdersMark Rousskov-12/+12
2023-11-08kmc-solid: Re-export `{As,Borrowed,Owned}Fd` in `std::os::solid::prelude`Tomoaki Kawada-1/+1
2023-11-08kmc-solid: Reimplement `AsFd` etc for `{TcpStream,TcpListener,UdpSocket}` by ↵Tomoaki Kawada-3/+3
delegating to inner `Socket` Removes some `unsafe` blocks.
2023-11-08kmc-solid: Replace `{From,Into}Inner<c_int>` impls with `*RawFd` for `Socket`Tomoaki Kawada-3/+3
Follows how other targets are implemented.
2023-11-08kmc-solid: Implement `AsFd` for `{Arc,Rc,Box}<impl AsFd>`Tomoaki Kawada-0/+33
2023-11-08kmc-solid: Implement `AsFd` and conversion to/from `OwnedFd` for ↵Tomoaki Kawada-0/+26
`{TcpStream,TcpListener,UdpSocket}`
2023-11-08kmc-solid: Document I/O safety in `std::os::solid::io`Tomoaki Kawada-0/+44
Mostly copied from `std::os::unix::io`, except quantifying file descriptors with SOLID Sockets and removing the paragraph mentioning `mmap`.
2023-11-08kmc-solid: Add `std::os::solid::io::{BorrowedFd,OwnedFd,AsFd}`Tomoaki Kawada-0/+191
It's mostly based on `std::os::fd::owned`.
2023-10-31Stabilize `file_set_times`Josh Triplett-12/+12
Approved via FCP in https://github.com/rust-lang/rust/issues/98245 .
2023-10-28Remove asmjs from libraryJubilee Young-2/+0
2023-10-29Don't use LFS64 symbols on muslgit-bruh-1/+8
Simplify #[cfg] blocks fmt don't try to use the more appropriate direntry on musl
2023-10-25Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traitsJohn Millikin-128/+230
These methods are the pre-stabilized API for obtaining peer credentials from an `AF_UNIX` socket, part of the `unix_socket_ancillary_data` feature. Their current behavior is to get/set one of the `SO_PASSCRED` (Linux), `LOCAL_CREDS_PERSISTENT` (FreeBSD), or `LOCAL_CREDS` (NetBSD) socket options. On other targets the `{set_}passcred()` methods do not exist. There are two problems with this approach: 1. Having public methods only exist for certain targets isn't permitted in a stable `std` API. 2. These options have generally similar purposes, but they are non-POSIX and their details can differ in subtle and surprising ways (such as whether they continue to be set after the next call to `recvmsg()`). Splitting into OS-specific extension traits is the preferred solution to both problems.
2023-10-20changes from feedbackDavid Carlier-10/+0
2023-10-17Updated libc and doc for Vita targetNikolay Arhipov-3/+3
2023-10-14Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkanbors-6/+6
Bump bootstrap compiler to just-released beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-09Support AIX in Rust standard libraryQiu Chaofan-0/+367
2023-10-03Bump version placeholdersMark Rousskov-6/+6