about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-08-29std::thread::set_name exploit the return on haikuDavid CARLIER-1/+3
2023-08-29further expand on Arc and Box analogyRalf Jung-3/+6
2023-08-29Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomccbors-0/+5
fix(sys/hermit): add is_interrupted https://github.com/rust-lang/rust/pull/115228 broke compilation for Hermit by not adding a Hermit implementation of is_interrupted.
2023-08-29Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviperbors-8/+1
fix(sys/hermit): remove obsolete network initialization This function does not exist as of hermit-sys 0.4.1 ([`e38f246`]). Once std does not call this function, we can remove it entirely. CC: `@stlankes` [`e38f246`]: https://github.com/hermitcore/hermit-rs/commit/e38f246e046c3ad50bd2f5e33d8d810d33891cbd#diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10
2023-08-29fix std::primitive doc: homogenous -> homogeneousMeng Xiangzhuo-3/+3
2023-08-29fix a doc typo at std::os::unix::fs::FileExt::write_atMeng Xiangzhuo-1/+1
2023-08-28Remove old bindings that have been movedChris Denton-7/+1
2023-08-28Add GetActiveProcessorCount and process attributesChris Denton-0/+7
2023-08-28Abstract over internal `SOCKET` typeChris Denton-20/+26
This allows `SOCKET` to be `usize` internally
2023-08-28Update windows ffi bindingsChris Denton-98/+82
2023-08-28Rollup merge of #115310 - RalfJung:panic-and-format, r=scottmcmMatthias Krüger-0/+12
Document panic behavior across editions, and improve xrefs This revives (parts of) https://github.com/rust-lang/rust/pull/96518. r? `@scottmcm` Cc `@ijackson`
2023-08-28Auto merge of #114848 - michaelvanstraten:spawn_with_attributes, r=ChrisDentonbors-2/+306
Add ability to spawn Windows process with Proc Thread Attributes | Take 2 This is the second attempt to merge pull request #88193 into the standard library. This PR implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait. `@TyPR124` and my main motivation behind adding this feature is to enable the support of pseudo terminals in the std library, but there are many more applications. A good starting point to get into this topic is to head over to the [`Win32 API documentation`](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute).
2023-08-28fix(sys/hermit): add is_interruptedMartin Kröning-0/+5
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-08-28fix(sys/hermit): remove obsolete network initializationMartin Kröning-8/+1
This function does not exist as of hermit-sys 0.4.1 [1]. Once std does not call this function, we can remove it entirely. [1]: https://github.com/hermitcore/hermit-rs/commit/e38f246e046c3ad50bd2f5e33d8d810d33891cbd#diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10 Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-08-28print macros: add xrefs to format syntax documentationIan Jackson-0/+12
2023-08-28Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=AmanieuMatthias Krüger-6/+30
avoid triple-backtrace due to panic-during-cleanup Supersedes https://github.com/rust-lang/rust/pull/115020 Cc https://github.com/rust-lang/rust/issues/114954 r? ``@Amanieu``
2023-08-28Rollup merge of #114512 - devnexen:fix_tests_fbsd, r=thomccMatthias Krüger-1/+1
std/tests: disable ancillary tests on freebsd since the feature itsel… …f is.
2023-08-28Rollup merge of #109660 - ijackson:leap, r=thomccMatthias Krüger-0/+24
Document that SystemTime does not count leap seconds Fixes #77994 This may not be entirely uncontroversial. I know that `@Ekleog` is going to disagree. However, in support of this docs change: This documents the current behaviour. The alternative would be to plan to *change* the behaviour. There are many programs which need to get a POSIX time (a `time_t`). Right now, `duration_since(UNIX_EPOCH)` is the only facility in std that does that. So, that is what programs use. Changing the behaviour would break[1] all of those programs. We would need to define a new API that can be used to get a POSIX time, and get everyone to use it. This seems highly unpalatable. And, even if we wanted to do that, time with leap seconds is a lot less easy to work with. We would need to arrange to have a leap seconds table available to `std` somehow, and make sure that it was kept up to date. Currently we don't offer to do that for timezone data, which has similar needs. There are other complications. So it seems it would be awkwarrd to *implement* a facility that provides time including leap seconds, and the resulting value would be hard for applications to work with. Therefore, I think it's clear that we don't want to plan to ever change `SystemTime`. We should plan to keep it the way it is. Providing TAI (for example) should be left to external crates, or additional APIs we may add in the future. For more discussion see #77994 and in particular `@fanf2's` https://github.com/rust-lang/rust/issues/77994#issuecomment-1409448174 [1] Of course, by "break" we really only mean *future* breakage in the case where there is, in fact, ever another leap second. There may well not be: they are in the process of being abolished (although this is of course being contested). But if we decide that `SystemTime::now().duraton_since(UNIX_EPOCH)` counts leap seconds, it would start to return `Durations`s that are 27s different to the current answers. That's clearly unacceptable. And we can hardly change `UNIX_EPOCH` by 27s.
2023-08-28Auto merge of #115254 - cuviper:aligned_alloc-size, r=thomccbors-1/+5
wasi: round up the size for `aligned_alloc` C11 `aligned_alloc` requires that the size be a multiple of the alignment. This is enforced in the wasi-libc emmalloc implementation, which always returns NULL if the size is not a multiple. (The default `MALLOC_IMPL=dlmalloc` does not currently check this.)
2023-08-27avoid triple-backtrace due to panic-during-cleanupRalf Jung-6/+30
2023-08-27Rollup merge of #115007 - kpreid:alloc, r=Mark-SimulacrumMatthias Krüger-6/+20
Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`. The primary goal of this change is to remove the false claim that `handle_alloc_error` always aborts; instead, code should be prepared for `handle_alloc_error` to possibly unwind, and be sound under that condition. I saw other opportunities for improvement, so I have added all the following information: * `handle_alloc_error` may panic instead of aborting. (Fixes #114898) * What happens if a hook returns rather than diverging. * A hook may panic. (This was already demonstrated in an example, but not stated in prose.) * A hook must be sound to call — it cannot assume that it is only called by the runtime, since its function pointer can be retrieved by safe code. I've checked these statements against the source code of `alloc` and `std`, but there may be nuances I haven't caught, so a careful review is welcome.
2023-08-26wasi: round up the size for `aligned_alloc`Josh Stone-1/+5
C11 `aligned_alloc` requires that the size be a multiple of the alignment. This is enforced in the wasi-libc emmalloc implementation, which always returns NULL if the size is not a multiple. (The default `MALLOC_IMPL=dlmalloc` does not currently check this.)
2023-08-26Document std limitations before/after mainThe 8472-1/+25
2023-08-26Auto merge of #115228 - saethlin:is-interrupted, r=thomccbors-7/+66
Add a new helper to avoid calling io::Error::kind On `cfg(unix)`, `Error::kind` emits an enormous jump table that LLVM seems unable to optimize out. I don't really understand why, but see for yourself: https://godbolt.org/z/17hY496KG This change lets us check for `ErrorKind::Interrupted` without going through a big match. I've checked the codegen locally, and it has the desired effect on the codegen for `BufReader::read_exact`.
2023-08-25Add a new helper to avoid calling io::Error::kindBen Kimock-7/+66
2023-08-25Added option to set ProcThreadAttributes for Windows processesMichael van Straten-2/+306
This implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait. Setting these attributes provides extended configuration options for Windows processes. Co-authored-by: Tyler Ruckinger <t.ruckinger@gmail.com>
2023-08-25Rollup merge of #114754 - workingjubilee:gamma-ray-logger, r=thomccMatthias Krüger-2/+6
Name what ln_gamma does The previous description omitted some important details.
2023-08-24Rollup merge of #115124 - ↵Weihang Lo-1/+1
solid-rs:patch/kmc-solid/import-poison-error-in-os, r=cuviper kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os` Follow-up to #114968. Fixes a missing import in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. ``` error[E0433]: failed to resolve: use of undeclared type `PoisonError` C:\Users\xxxxx\.rustup\toolchains\nightly-2023-08-23-x86_64-pc-windows-gnu\lib\rustlib\src\rust\library\std\src\sys\solid\os.rs(85,36) | 85 | ENV_LOCK.read().unwrap_or_else(PoisonError::into_inner) | ^^^^^^^^^^^ use of undeclared type `PoisonError` | ```
2023-08-24Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonurbors-21/+21
Update bootstrap compiler to 1.73.0 beta
2023-08-24also use 'env' for printing unsettingRalf Jung-8/+4
2023-08-24also print clearing the environment entirelyRalf Jung-12/+44
2023-08-24fix a typo in env_clear docsRalf Jung-1/+1
2023-08-24make unsetting env vars print as executable commandRalf Jung-4/+19
2023-08-24Command: also print removed env varsRalf Jung-1/+24
2023-08-23Bump cfg(bootstrap)Mark Rousskov-2/+2
2023-08-23Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-SimulacrumGuillaume Gomez-0/+8
Fix a pthread_t handle leak #114610 https://github.com/rust-lang/rust/issues/114610 Ran the tests as described in https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md?plain=1#L125
2023-08-23Rollup merge of #115053 - waywardmonkeys:augment-type-keyword-docs, r=cuviperDylan DPC-1/+9
docs: Add example, reference link for `type` keyword. Fixes #114281.
2023-08-23kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os`Tomoaki Kawada-1/+1
2023-08-22std: unix process_unsupported: Provide a wait status emulation (tidy)Ian Jackson-36/+39
Move tests into a module as demanded by tidy.
2023-08-22fixup! std: unix process: Test exit statuses / wait statusesIan Jackson-1/+1
2023-08-22std: unix process_unsupported: Provide a wait status emulation (fmt)Ian Jackson-15/+3
Worsify formatting as required by rustfmt.
2023-08-22fixup! std: unix process_unsupported: Provide a wait status emulationIan Jackson-1/+1
2023-08-22std: unix process: Test exit statuses / wait statusesIan Jackson-0/+33
This is a pretty basic test but should spot any other platforms which are `#[cfg(unix)]` but not Unix and where the wait status representation is wrong. (And any actual Unix platforms where it's not as expected, but I don't think they exist.)
2023-08-22std: unix process_unsupported: Provide a wait status emulationIan Jackson-50/+120
Fixes #114593 Needs FCP due to behavioural changes.
2023-08-22Improve UdpSocket documentationPatiga-1/+20
I tried working with `UdpSocket` and ran into `EINVAL` errors with no clear indication of what causes the error. Also, it was uncharacteristically hard to figure this module out, compared to other Rust `std` modules. 1. `send` and `send_to` return a `usize` This one is just clarity. Usually, returned `usize`s indicate that the buffer might have only been sent partially. This is not the case with UDP. Since that `usize` must always be `buffer.len()`, I have documented that. 2. `bind` limits `connect` and `send_to` When you bind to a limited address space like localhost, you can only `connect` to addresses in that same address space. Error kind: `AddrNotAvailable`. 3. `connect`ing to localhost locks you to localhost On Linux, if you first `connect` to localhost, subsequent `connect`s to non-localhost addresses fail. Error kind: `InvalidInput`. Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2023-08-22std: enable feature(slice_ptr_len) on xousSean Cross-0/+1
Xous passes slice pointers around in order to manipulate memory. This is feature-gated behind `slice_ptr_len`. Xous is currently the only target to use this feature, so gate it behind an OS flag. Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22std: xous: add support for locksSean Cross-1/+310
Add support for Condvar, Mutex, and RWLock. These are all backed by the ticktimer server. Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22std: xous: add thread_local_keySean Cross-1/+190
Add an implementation of thread local storage. This uses a container that is pointed to by the otherwise-unsed `$tp` register. This container is allocated on-demand, so threads that use no TLS will not allocate this extra memory. Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22std: xous: add thread supportSean Cross-1/+144
Add initial support for threads on Xous. This includes thread creation and joining. Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22std: xous: add support for timeSean Cross-1/+57
Add support for determining the current time. This connects to the ticktimer server in order to get the system uptime. Signed-off-by: Sean Cross <sean@xobs.io>