about summary refs log tree commit diff
path: root/library/std/src/os
AgeCommit message (Collapse)AuthorLines
2025-03-11Migrate std to Rust 2024Eric Huss-1/+1
2025-03-10Remove unused fileNicole L-4/+0
2025-03-10Format after patches have been appliedNicole LeGare-6/+11
2025-03-10Apply rustc-0054-Add-std-os-fd-support-for-Trusty.patchNicole LeGare-6/+43
2025-03-10Readd os::cygwin::raw as pub(crate)王宇逸-0/+5
2025-03-10Remove std::os::cygwin::raw王宇逸-91/+0
2025-03-10Fix building for cygwin王宇逸-0/+1
2025-03-10Initial STD support for Cygwin王宇逸-2/+207
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-25/+17
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-02-28Use correct error message casing for `io::const_error`sNoratrieb-1/+1
Error messages are supposed to start with lowercase letters, but a lot of `io::const_error` messages did not. This fixes them to start with a lowercase letter. I did consider adding a const check for this to the macro, but some of them start with proper nouns that make sense to uppercase them. See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html
2025-02-17Remove std::os::wasi::fs::FileExt::tellThalia Archibald-11/+0
Following #137165 (Use `tell` for `<File as Seek>::stream_position`), `tell` is now directly exposed via `stream_position`, making `<File as FileExt>::tell` redundant. Remove it.
2025-02-14Add safe new to NotAllOnesKornel-24/+12
2025-02-12std: replace the `FromInner` implementation for addresses with private ↵joboet-2/+2
conversion functions Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed. I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-34/+40
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-08Rustfmtbjorn3-34/+40
2025-02-07std: get rid of `sys_common::io`joboet-3/+3
2025-02-02std: move network code into `sys`joboet-9/+9
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2025-01-27Overhaul examples for PermissionsExtMarijn Schouten-49/+75
This fixes #91707 by including one overarching example, instead of the small examples that can be misleading.
2025-01-14wasi/io: remove dead filesRalf Jung-29/+4
2025-01-14remove unnecessary rustc_allowed_through_unstable_modulesRalf Jung-5/+0
2025-01-09Update a bunch of library types for MCP807Scott McMurray-59/+41
This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3: ``` library/core\src\ptr\non_null.rs 68:#[rustc_layout_scalar_valid_range_start(1)] library/core\src\num\niche_types.rs 19: #[rustc_layout_scalar_valid_range_start($low)] 20: #[rustc_layout_scalar_valid_range_end($high)] ``` Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
2025-01-01Avoid use of LFS64 symbols on EmscriptenKleis Auke Wolthuizen-3/+1
Since Emscripten uses musl libc internally. Non-functional change: all LFS64 symbols were aliased to their non-LFS64 counterparts in rust-lang/libc@7c952dceaad4cdc35e00884fcb12a713d41a87e0.
2024-12-21Rollup merge of #123604 - michaelvanstraten:proc_thread_attribute_list, ↵Matthias Krüger-55/+273
r=ChrisDenton Abstract `ProcThreadAttributeList` into its own struct As extensively discussed in issue #114854, the current implementation of the unstable `windows_process_extensions_raw_attribute` features lacks support for passing a raw pointer. This PR wants to explore the opportunity to abstract away the `ProcThreadAttributeList` into its own struct to for one improve safety and usability and secondly make it possible to maybe also use it to spawn new threads. try-job: x86_64-mingw
2024-12-15Auto merge of #133223 - zachs18:uniquerc-impls, r=Noratriebbors-0/+32
`UniqueRc` trait impls UniqueRc tracking Issue: #112566 Stable traits: (i.e. impls behind only the `unique_rc_arc` feature gate) * Support the same formatting as `Rc`: * `fmt::Debug` and `fmt::Display` delegate to the pointee. * `fmt::Pointer` prints the address of the pointee. * Add explicit `!Send` and `!Sync` impls, to mirror `Rc`. * Borrowing traits: `Borrow`, `BorrowMut`, `AsRef`, `AsMut` * `Rc` does not implement `BorrowMut` and `AsMut`, but `UniqueRc` can. * Unconditional `Unpin`, like other heap-allocated types. * Comparison traits `(Partial)Ord` and `(Partial)Eq` delegate to the pointees. * `PartialEq for UniqueRc` does not do `Rc`'s specialization shortcut for pointer equality when `T: Eq`, since by definition two `UniqueRc`s cannot share an allocation. * `Hash` delegates to the pointee. * `AsRawFd`, `AsFd`, `AsHandle`, `AsSocket` delegate to the pointee like `Rc`. * Sidenote: The bounds on `T` for the existing `Pointer<T>` impls for specifically `AsRawFd` and `AsSocket` do not allow `T: ?Sized`. For the added `UniqueRc` impls I allowed `T: ?Sized` for all four traits, but I did not change the existing (stable) impls. Unstable traits: * `DispatchFromDyn`, allows using `UniqueRc<Self>` as a method receiver under `feature(arbitrary_self_types)`. * Existing `PinCoerceUnsized for UniqueRc` is generalized to allow non-`Global` allocators, like `Rc`. * `DerefPure`, allows using `UniqueRc` in deref-patterns under `feature(deref_patterns)`, like `Rc`. For documentation, `Rc` only has documentation on the comparison traits' methods, so I copied/adapted the documentation for those, and left the rest without impl-specific docs. ~~Edit: Marked as draft while I figure out `UnwindSafe`.~~ Edit: Ignoring `UnwindSafe` for this PR
2024-12-11Forbid unsafe_op_in_unsafe_fn in hurd-specific os and sys filesSamuel Thibault-0/+1
Adding it did not cause any error. Most of this falls back on Unix already. See #127747
2024-12-01Rollup merge of #133515 - SteveLauC:fix/hurd, r=ChrisDentonMatthias Krüger-1/+1
fix: hurd build, stat64.st_fsid was renamed to st_dev On hurd, `stat64.st_fsid` was renamed to `st_dev` in https://github.com/rust-lang/libc/pull/3785, so if you have a new libc with this patch included, and you build std from source, you get this error: ```sh error[E0609]: no field `st_fsid` on type `&stat64` --> /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/os/hurd/fs.rs:301:36 | 301 | self.as_inner().as_inner().st_fsid as u64 | ^^^^^^^ unknown field | help: a field with a similar name exists | 301 | self.as_inner().as_inner().st_uid as u64 | ~~~~~~ ``` Full CI log: https://github.com/nix-rust/nix/actions/runs/12033180710/job/33546728266?pr=2544
2024-11-30fix: hurd build, stat64.st_fsid was renamed to st_devSteve Lau-1/+1
2024-11-30Abstract `ProcThreadAttributeList` into its own structMichael van Straten-55/+273
2024-11-29Auto merge of #133533 - BoxyUwU:bump-boostrap, r=jieyouxu,Mark-Simulacrumbors-1/+1
Bump boostrap compiler to new beta Currently failing due to something about the const stability checks and `panic!`. I'm not sure why though since I wasn't able to see any PRs merged in the past few days that would result in a `cfg(bootstrap)` that shouldn't be removed. cc `@RalfJung` #131349
2024-11-28Rollup merge of #129409 - grinapo:patch-1, r=AmanieuGuillaume Gomez-0/+5
Expand std::os::unix::fs::chown() doc with a warning Include warning about losing setuid/gid when chowning, per POSIX. It is about the underlying system call but it is rather useful to mention it in the help in case someone accidentally forgets (don't look at me :)).
2024-11-27replace placeholder versionBoxy-1/+1
2024-11-26std: update internal uses of `io::const_error!`joboet-8/+7
2024-11-22library: update comment around close()Ralf Jung-10/+11
2024-11-19UniqueRc: platform-specific AsFd/Handle/etc impls to mirror RcZachary S-0/+32
2024-11-14Remove one stray space.Peter Gervai-1/+1
2024-11-14Fix a copy-paste issue in the NuttX raw type definitionHuang Qi-1/+1
This file is copied from the rtems as initial implementation, and forgot to change the OS name in the comment. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-11-04docs: fix grammar in doc comment at unix/process.rsNotWearingPants-1/+1
2024-11-03Auto merge of #123723 - madsmtm:apple-std-os, r=dtolnaybors-15/+37
Make `std::os::darwin` public I'm not sure of the reasoning behind them not being public before, but I think they should be, just like `std::os::ios` and `std::os::macos` are public. Additionally, I've merged their source code, as it was otherwise just a bunch of unnecessary duplication. Ultimately, I've done this PR to fix `./x build library --target=aarch64-apple-tvos,aarch64-apple-watchos,aarch64-apple-visionos`, as that currently fails because of dead code warnings. Since you reviewed https://github.com/rust-lang/rust/pull/121419 r? davidtwco Fixes https://github.com/rust-lang/rust/issues/121640. `@rustbot` label O-tvos O-watchos O-visionos
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-1/+1
2024-10-18Rollup merge of #131654 - betrusted-io:xous-various-fixes, r=thomccMatthias Krüger-1/+1
Various fixes for Xous This patchset includes several fixes for Xous that have crept in over the last few months: * The `adjust_process()` syscall was incorrect * Warnings have started appearing in `alloc` -- adopt the same approach as wasm, until wasm figures out a workaround * Dead code warnings have appeared in the networking code. Add `allow(dead_code)` as these structs are used as IPC values * Add support for `args` and `env`, which have been useful for running tests * Update `unwinding` to `0.2.3` which fixes the recent regression due to changes in `asm!()` code
2024-10-17Add must_use to CommandExt::execCallum Ryan-0/+1
2024-10-13xous: ffi: correct syscall number for adjust_processSean Cross-1/+1
The AdjustProcessLimit syscall was using the correct call number. Signed-off-by: Sean Cross <sean@xobs.io>
2024-10-09Decouple WASIp2 sockets from WasiFdNicola Krumschmidt-0/+2
2024-09-27Rollup merge of #130861 - cuviper:sun-path-offset, r=ibraheemdevGuillaume Gomez-12/+9
Use `mem::offset_of!` for `sockaddr_un.sun_path` We don't need manual pointer math here anymore! try-job: dist-i686-msvc
2024-09-26Add `sun_path` to the fake doc `sockaddr_un`Josh Stone-1/+3
2024-09-25Use `&raw` in the standard libraryJosh Stone-20/+16
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-25Use `mem::offset_of!` for `sockaddr_un.sun_path`Josh Stone-11/+6
2024-09-24Initial std library support for NuttXHuang Qi-0/+133
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-54/+48
2024-09-19[Clippy] Swap `non_octal_unix_permissions` to use diagnostic item instead of ↵GnomedDev-0/+1
path