about summary refs log tree commit diff
path: root/library/std/src/sys_common
AgeCommit message (Collapse)AuthorLines
2022-06-05std: solve priority issue for Parkerjoboet-24/+31
2022-06-03Lazily allocate+initialize locks.Mara Bos-8/+83
2022-06-03Use Drop instead of destroy() for locks.Mara Bos-25/+0
2022-05-30Remove "sys isn't exported yet" phraseest31-2/+2
The oldest occurence is from 9e224c2bf18ebf8f871efb2e1aba43ed7970ebb7, which is from the pre-1.0 days. In the years since then, std::sys still hasn't been exported, and the last attempt was met with strong criticism: https://github.com/rust-lang/rust/pull/97151 Thus, removing the "yet" part makes a lot of sense.
2022-05-19std: fix deadlock in `Parker`joboet-4/+4
2022-05-18std: use an event flag based thread parker on SOLIDjoboet-3/+100
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-2/+1
2022-05-06Auto merge of #96510 - m-ou-se:futex-bsd, r=Amanieubors-0/+3
Use futex-based locks and thread parker on {Free, Open, DragonFly}BSD. This switches *BSD to our futex-based locks and thread parker. Tracking issue: https://github.com/rust-lang/rust/issues/93740 This is a draft, because this still needs a new version of the `libc` crate to be published that includes https://github.com/rust-lang/libc/pull/2770. r? `@Amanieu`
2022-05-05Rollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, ↵Yuki Okushi-2/+8
r=m-ou-se Relax memory ordering used in SameMutexCheck `SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.
2022-05-03Don't use futexes on netbsd.Mara Bos-1/+0
The latest NetBSD release doesn't include the futex syscall yet.
2022-05-01Add commentAustin Kiekintveld-0/+2
2022-05-01Fix formattingAustin Kiekintveld-2/+6
2022-05-01Relax memory ordering used in SameMutexCheckAustin Kiekintveld-1/+1
`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.
2022-05-01Relax memory ordering used in `min_stack`Austin Kiekintveld-2/+2
`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.
2022-04-29Use futex-based locks and thread parker on FreeBSD.Mara Bos-0/+1
2022-04-29Use futex-based locks and thread parker on DragonFlyBSD.Mara Bos-0/+1
2022-04-29Use futex-based locks and thread parker on NetBSD.Mara Bos-0/+1
2022-04-29Use futex-based locks and thread parker on OpenBSD.Mara Bos-0/+1
2022-04-28Auto merge of #96393 - joboet:pthread_parker, r=thomccbors-16/+28
std: directly use pthread in UNIX parker implementation `Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways. This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives. I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
2022-04-25Make EncodeWide implement FusedIteratorAron Parker-1/+4
2022-04-25std: directly use pthread in UNIX parker implementationjoboet-16/+28
Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore use the pthread synchronization primitives directly. Also, avoid allocating because the Parker struct is being placed in an Arc anyways.
2022-04-16Use a single ReentrantMutex implementation on all platforms.Mara Bos-13/+86
2022-04-14Use u32 instead of i32 for futexes.Mara Bos-6/+6
2022-04-06Rename RWLock to RwLock in std::sys.Mara Bos-18/+18
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-5/+7
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-21Move pthread locks to own module.Mara Bos-10/+9
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-6/+6
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-02-20Remove assertion on output length for `getsockopt`.Chris Copeland-1/+0
POSIX allows `getsockopt` to set `*option_len` to a smaller value if necessary. Windows will set `*option_len` to 1 for boolean options even when the caller passes a `BOOL` (`int`) with `*option_len` as 4.
2022-02-20Fix `setsockopt` and `getsockopt` parameter names.Chris Copeland-9/+25
Previously `level` was named `opt` and `option_name` was named `val`, then extra names of `payload` or `slot` were used for the option value. This change aligns the wrapper parameters with their names in POSIX. Winsock uses similar but more abbreviated names: `level`, `optname`, `optval`, `optlen`.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-5/+5
2022-02-02Configure panic hook backtrace behaviorMark Rousskov-57/+0
2022-01-25Avoid double panics when using `TempDir` in testsChris Denton-1/+7
2022-01-17Help optimize out backtraces when disabledKornel-7/+18
2022-01-01Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrumbors-16/+0
Remove CommandEnv::apply It's not being used and uses unsound set_var and remove_var functions. This is an internal function that isn't exported (even with `process_internals` feature), so this shouldn't break anything. Also see #92365. Note that this isn't the only use of those methods in standard library, so that particular pull request will need more changes than just this to work (in particular, `test_capture_env_at_spawn` is using `set_var` and `remove_var`).
2021-12-29Remove CommandEnv::applyKonrad Borowski-16/+0
It's not being used and uses unsound set_var and remove_var functions.
2021-12-29Address commentsXuanwo-4/+4
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-28Implement support in wtf8Xuanwo-0/+37
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-14Fix a bunch of typosFrank Steffahn-3/+3
2021-11-21libcore: assume the input of `next_code_point` and `next_code_point_reverse` ↵Eduardo Sánchez Muñoz-1/+2
is UTF-8-like The functions are now `unsafe` and they use `Option::unwrap_unchecked` instead of `unwrap_or_0` `unwrap_or_0` was added in 42357d772b8a3a1ce4395deeac0a5cf1f66e951d. I guess `unwrap_unchecked` was not available back then. Given this example: ```rust pub fn first_char(s: &str) -> Option<char> { s.chars().next() } ``` Previously, the following assembly was produced: ```asm _ZN7example10first_char17ha056ddea6bafad1cE: .cfi_startproc test rsi, rsi je .LBB0_1 movzx edx, byte ptr [rdi] test dl, dl js .LBB0_3 mov eax, edx ret .LBB0_1: mov eax, 1114112 ret .LBB0_3: lea r8, [rdi + rsi] xor eax, eax mov r9, r8 cmp rsi, 1 je .LBB0_5 movzx eax, byte ptr [rdi + 1] add rdi, 2 and eax, 63 mov r9, rdi .LBB0_5: mov ecx, edx and ecx, 31 cmp dl, -33 jbe .LBB0_6 cmp r9, r8 je .LBB0_9 movzx esi, byte ptr [r9] add r9, 1 and esi, 63 shl eax, 6 or eax, esi cmp dl, -16 jb .LBB0_12 .LBB0_13: cmp r9, r8 je .LBB0_14 movzx edx, byte ptr [r9] and edx, 63 jmp .LBB0_16 .LBB0_6: shl ecx, 6 or eax, ecx ret .LBB0_9: xor esi, esi mov r9, r8 shl eax, 6 or eax, esi cmp dl, -16 jae .LBB0_13 .LBB0_12: shl ecx, 12 or eax, ecx ret .LBB0_14: xor edx, edx .LBB0_16: and ecx, 7 shl ecx, 18 shl eax, 6 or eax, ecx or eax, edx ret ``` After this change, the assembly is reduced to: ```asm _ZN7example10first_char17h4318683472f884ccE: .cfi_startproc test rsi, rsi je .LBB0_1 movzx ecx, byte ptr [rdi] test cl, cl js .LBB0_3 mov eax, ecx ret .LBB0_1: mov eax, 1114112 ret .LBB0_3: mov eax, ecx and eax, 31 movzx esi, byte ptr [rdi + 1] and esi, 63 cmp cl, -33 jbe .LBB0_4 movzx edx, byte ptr [rdi + 2] shl esi, 6 and edx, 63 or edx, esi cmp cl, -16 jb .LBB0_7 movzx ecx, byte ptr [rdi + 3] and eax, 7 shl eax, 18 shl edx, 6 and ecx, 63 or ecx, edx or eax, ecx ret .LBB0_4: shl eax, 6 or eax, esi ret .LBB0_7: shl eax, 12 or eax, edx ret ```
2021-11-10Use `target_family = "wasm"`Alex Crichton-2/+1
2021-11-10std: Get the standard library compiling for wasm64Alex Crichton-0/+1
This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged.
2021-10-30Add #[must_use] to remaining std functions (O-Z)John Kugelman-0/+1
2021-10-22docs: Escape brackets to satisfy the linkcheckerNoah Lev-1/+1
My change to use `Type::def_id()` (formerly `Type::def_id_full()`) in more places caused some docs to show up that used to be missed by rustdoc. Those docs contained unescaped square brackets, which triggered linkcheck errors. This commit escapes the square brackets and adds this particular instance to the linkcheck exception list.
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