about summary refs log tree commit diff
path: root/library/std/src/sys_common
AgeCommit message (Collapse)AuthorLines
2021-10-11Rollup merge of #89707 - clemenswasser:apply_clippy_suggestions, ↵Matthias Krüger-4/+2
r=Mark-Simulacrum Apply clippy suggestions for std
2021-10-09Apply clippy suggestionsClemens Wasser-4/+2
2021-10-09Rollup merge of #88436 - lf-:stabilize-command-access, r=yaahcGuillaume Gomez-3/+3
std: Stabilize command_access Tracking issue: #44434 (not yet closed but the FCP is done so that should be soon).
2021-10-05Apply suggestions from code reviewJane Lusby-3/+3
2021-09-16Merge two THREAD_INFO.with and following RefCell borrowbjorn3-2/+5
This is a bit faster
2021-09-16Replace a couple of asserts with rtassert! in rt codebjorn3-1/+1
This replaces a couple of panic locations with hard aborts. The panics can't be catched by the user anyway in these locations.
2021-09-16Remove unused functionbjorn3-4/+0
2021-09-16Use const {} for the THREAD_INFO thread localbjorn3-1/+2
This makes accesses to it cheaper
2021-09-16Optimize ThreadInfo::withbjorn3-6/+7
The RefCell is now borrowed exactly once. In addition a code sequence that contains an unwrap that is guaranteed to never panic at runtime is replaced with get_or_insert_with, which makes the intended behavior clearer and will not emit code to panic even without optimizations.
2021-09-16Merge sys_common::rt into rtbjorn3-83/+0
2021-08-30add `TcpStream::set_linger` and `TcpStream::linger`ibraheemdev-0/+8
2021-08-28std: Stabilize command_accessJade-3/+3
Tracking issue: #44434
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-1/+1
same search
2021-08-22Fix more “a”/“an” typosFrank Steffahn-2/+2
2021-08-19I/O safety.Dan Gohman-24/+18
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-12Auto merge of #87963 - GuillaumeGomez:rollup-e54sbez, r=GuillaumeGomezbors-4/+6
Rollup of 4 pull requests Successful merges: - #87819 (Use a more accurate span on assoc types WF checks) - #87863 (Fix Windows Command::env("PATH")) - #87885 (Link to edition guide instead of issues for 2021 lints.) - #87941 (Fix/improve rustdoc-js tool) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-08-10STD support for the ESP-IDF frameworkivmarkov-1/+3
2021-08-08Fix Windows Command::env("PATH")Chris Denton-4/+6
2021-08-02Rollup merge of #86509 - CDirkx:os_str, r=m-ou-seYuki Okushi-268/+0
Move `os_str_bytes` to `sys::unix` Followup to #84967, with `OsStrExt` and `OsStringExt` moved out of `sys_common`, there is no reason anymore for `os_str_bytes` to live in `sys_common` and not in sys. This pr moves it to the location `sys::unix::os_str` and reuses the code on other platforms via `#[path]` (as is common in `sys`) instead of importing.
2021-07-29[backtraces]: look for the `begin` symbol only after seeing `end`Wesley Wiser-1/+1
On `x86_64-pc-windows-msvc`, we often get backtraces which look like this: ``` 10: 0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook 11: 0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c 12: 0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae 13: 0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805 14: 0x7ff77e0e108c - d 15: 0x7ff77e0e1069 - c 16: 0x7ff77e0e1059 - b 17: 0x7ff77e0e1049 - a 18: 0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81 19: 0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c 20: 0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3 ``` Notice that `__rust_begin_short_backtrace` appears on frame 11 before `__rust_end_short_backtrace` on frame 12. This is because in typical release binaries without debug symbols, dbghelp.dll, which we use to walk and symbolize the stack, does not know where CGU internal functions start or end and so the closure invoked by `__rust_end_short_backtrace` is incorrectly described as `__rust_begin_short_backtrace` because it happens to be near that symbol. While that can obviously change, this has been happening quite consistently since #75048. Since this is a very small change to the std and the change makes sense by itself, I think this is worth doing. This doesn't completely resolve the situation for release binaries on Windows, since without debug symbols, the stack printed can still show incorrect symbol names (this is why the test uses `#[no_mangle]`) but it does slightly improve the situation in that you see the same backtrace you would see with `RUST_BACKTRACE=full` or in a debugger (without the uninteresting bits at the top and bottom).
2021-07-03Move `os_str_bytes` to `sys::unix` and reuse it on other platforms.Christiaan Dirkx-268/+0
2021-06-21Merge `sys_common::bytestring` into `os_str_bytes`Christiaan Dirkx-50/+28
2021-06-20Auto merge of #84967 - CDirkx:os_str_ext, r=m-ou-sebors-71/+6
Move `OsStringExt` and `OsStrExt` to `std::os` Moves the `OsStringExt` and `OsStrExt` traits and implementations from `sys_common` to `os`. `sys_common` is for abstractions over `sys` and shouldn't really contain publicly exported items. This does introduce some duplication: the traits and implementations are now duplicated in `unix`, `wasi`, `hermit`, and `sgx`. However, I would argue that this duplication is no different to how something like `MetadataExt` is duplicated in `linux`, `vxworkx`, `redox`, `solaris` etc. The duplication also matches the fact that the traits on different platforms are technically distinct types: any platform is free to add it's own extra methods to the extension trait.
2021-06-20Make `os_str_bytes::{Buf, Slice}` `pub` and `repr(transparent)`Christiaan Dirkx-8/+4
2021-06-20Move `OsStringExt` and `OsStrExt` to `std::os`Christiaan Dirkx-63/+2
2021-06-20Auto merge of #86463 - fee1-dead:fixed-encode_wide, r=m-ou-sebors-1/+14
Account for self.extra in size_hint for EncodeWide Fixes #86414.
2021-06-19Account for self.extra in size_hint for EncodeWideDeadbeef-1/+14
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-3/+3
2021-06-01Multiple improvements to RwLocksBenoît du Garreau-37/+83
- Split `sys_common::RWLock` between `StaticRWLock` and `MovableRWLock` - Unbox `RwLock` on some platforms (Windows, Wasm and unsupported) - Simplify `RwLock::into_inner`
2021-05-21Auto merge of #85060 - ChrisDenton:win-file-exists, r=yaahcbors-0/+8
Windows implementation of feature `path_try_exists` Draft of a Windows implementation of `try_exists` (#83186). The first commit reorganizes the code so I would be interested to get some feedback on if this is a good idea or not. It moves the `Path::try_exists` function to `fs::exists`. leaving the former as a wrapper for the latter. This makes it easier to provide platform specific implementations and matches the `fs::metadata` function. The other commit implements a Windows specific variant of `exists`. I'm still figuring out my approach so this is very much a first draft. Eventually this will need some more eyes from knowledgable Windows people.
2021-05-20Rollup merge of #85275 - CDirkx:memchr, r=m-ou-seGuillaume Gomez-0/+138
Move `std::memchr` to `sys_common` `std::memchr` is a thin abstraction over the different `memchr` implementations in `sys`, along with documentation and tests. The module is only used internally by `std`, nothing is exported externally. Code like this is exactly what the `sys_common` module is for, so this PR moves it there.
2021-05-19Move the implementation of `Path::exists` to `sys_common::fs` so platforms ↵Chris Denton-0/+8
can specialize it Windows implementation of `fs::try_exists`
2021-05-19Rename `rterr` to `rtprintpanic`Christiaan Dirkx-2/+6
2021-05-19Replace `sys_common::util::dumb_print` with `rterr!`Christiaan Dirkx-10/+0
2021-05-19Replace `sys_common::util::report_overflow` with `rterr!`Christiaan Dirkx-9/+0
2021-05-19Remove `sys_common::util::abort`Christiaan Dirkx-11/+6
2021-05-19Introduce `sys_common::rt::rterr!`Christiaan Dirkx-1/+9
2021-05-14Move `std::memchr` to `sys_common`Christiaan Dirkx-0/+138
2021-04-27Override `clone_from` method for PathBuf and OsStringBenoît du Garreau-1/+13
2021-04-25Auto merge of #84115 - CDirkx:rt, r=m-ou-sebors-127/+66
Rework `init` and `cleanup` This PR reworks the code in `std` that runs before and after `main` and centralizes this code respectively in the functions `init` and `cleanup` in both `sys_common` and `sys`. This makes is easy to see what code is executed during initialization and cleanup on each platform just by looking at e.g. `sys::windows::init`. Full list of changes: - new module `rt` in `sys_common` to contain `init` and `cleanup` and the runtime macros. - `at_exit` and the mechanism to register exit handlers has been completely removed. In practice this was only used for closing sockets on windows and flushing stdout, which have been moved to `cleanup`. - <s>On windows `alloc` and `net` initialization is now done in `init`, this saves a runtime check in every allocation and network use.</s>
2021-04-24Rollup merge of #84387 - CDirkx:poison, r=m-ou-seYuki Okushi-258/+0
Move `sys_common::poison` to `sync::poison` `sys_common` should not contain publicly exported types, only platform-independent abstractions on top of `sys`, which `sys_common::poison` is not. There is thus no reason for the module to not live under `sync`. Part of #84187.
2021-04-22Rollup merge of #84402 - CDirkx:rwlock, r=dtolnayDylan DPC-59/+0
Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock` This moves `sys_common::rwlock::StaticRwLock`, `RWLockReadGuard` and `RWLockWriteGuard` to `sys::unix::rwlock`. They are already `#[cfg(unix)]` and don't need to be in `sys_common`.
2021-04-22Remove `Once` from `init`Christiaan Dirkx-5/+6
2021-04-22Document that `init` and `cleanup` are not guaranteed to runChristiaan Dirkx-2/+3
2021-04-22Apply suggestions from reviewChristiaan Dirkx-2/+2
2021-04-22Move most init to `sys::init`Christiaan Dirkx-6/+1
2021-04-22Move all cleanup to `sys::cleanup`Christiaan Dirkx-2/+0
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-127/+71
2021-04-22Move `sys_common::poison` to `sync::poison`Christiaan Dirkx-258/+0
2021-04-21Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`Christiaan Dirkx-59/+0