about summary refs log tree commit diff
path: root/library/std/src/sys_common
AgeCommit message (Collapse)AuthorLines
2023-10-19Auto merge of #116132 - darthunix:connect_poll, r=cuviperbors-3/+1
Make TCP connect handle EINTR correctly According to the [POSIX](https://pubs.opengroup.org/onlinepubs/009695399/functions/connect.html) standard, if connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to EINTR, but the connection request shall not be aborted, and the connection shall be established asynchronously. When the connection has been established asynchronously, select() and poll() shall indicate that the file descriptor for the socket is ready for writing. The previous implementation differs from the recomendation: in a case of the EINTR we tried to reconnect in a loop and sometimes get EISCONN error (this problem was originally detected on MacOS). 1. More details about the problem in an [article](http://www.madore.org/~david/computers/connect-intr.html). 2. The original [issue](https://git.picodata.io/picodata/picodata/tarantool-module/-/issues/157).
2023-10-13Make TCP connect() handle EINTR correctlyDenis Smirnov-3/+1
According to the POSIX standard, if connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to EINTR, but the connection request shall not be aborted, and the connection shall be established asynchronously. If asynchronous connection was successfully established after EINTR and before the next connection attempt, OS returns EISCONN that was handled as an error before. This behavior is fixed now and we handle it as success. The problem affects MacOS users: Linux doesn't return EISCONN in this case, Windows connect() can not be interrupted without an old-fashoin WSACancelBlockingCall function that is not used in the library. So current solution gives connect() as OS specific implementation.
2023-10-04std: abort instead of panicking if the global allocator uses TLSjoboet-1/+4
2023-10-03std: panic when the global allocator tries to register a TLS destructorjoboet-5/+9
2023-09-24Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubileebors-0/+1
Add Minimal Std implementation for UEFI # Implemented modules: 1. alloc 2. os_str 3. env 4. math # Related Links Tracking Issue: https://github.com/rust-lang/rust/issues/100499 API Change Proposal: https://github.com/rust-lang/libs-team/issues/87 # Additional Information This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR. The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Fixes from PRAyush Singh-1/+0
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Add Minimal Std implementation for UEFIAyush Singh-0/+2
Implemented modules: 1. alloc 2. os_str 3. env 4. math Tracking Issue: https://github.com/rust-lang/rust/issues/100499 API Change Proposal: https://github.com/rust-lang/libs-team/issues/87 This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from @dvdhrm, I have extracted a minimal std implementation to this PR. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Rollup merge of #114379 - RalfJung:command-removed-env-vars, r=m-ou-seMatthias Krüger-0/+4
Command: also print removed env vars There is no real shell syntax for unsetting an env var so easily, so we have to make one up. But we already do that for showing the 'program' name so I hope that's okay here, too. No strong opinion on what that should look like, I went with `unset(VAR_NAME)` for now.
2023-09-21Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naberbors-0/+1
added support for GNU/Hurd adding support for i686-unknown-hurd-gnu
2023-09-21added support for GNU/HurdSamuel Thibault-0/+1
2023-09-20Auto merge of #115753 - tgross35:threadinfo-refactor, r=thomccbors-16/+21
Refactor `thread_info` to remove the `RefCell` `thread_info` currently uses `RefCell`-based initialization. Refactor this to use `OnceCell` instead which is more performant and better suits the needs of one-time initialization. This is nobody's bottleneck but OnceCell checks are a single `cmp` vs. `RefCell<Option>` needing runtime logic
2023-09-11Refactor `thread_info` to remove the `RefCell`Trevor Gross-16/+21
`thread_info` currently uses `RefCell`-based initialization. Refactor this to use `OnceCell` instead which is more performant and better suits the needs of one-time initialization.
2023-08-24also print clearing the environment entirelyRalf Jung-0/+4
2023-08-22libstd: add xous to libstdSean Cross-0/+1
Add the `xous` target to libstd. Currently this defers everything to the `unsupported` target. Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-18Auto merge of #114591 - joboet:thread_parking_ordering_fix, r=thomccbors-11/+6
Synchronize with all calls to `unpark` in id-based thread parker [The documentation for `thread::park`](https://doc.rust-lang.org/nightly/std/thread/fn.park.html#memory-ordering) guarantees that "park synchronizes-with all prior unpark operations". In the id-based thread parking implementation, this is not implemented correctly, as the state variable is reset with a simple store, so there will not be a *synchronizes-with* edge if an `unpark` happens just before the reset. This PR corrects this, replacing the load-check-reset sequence with a single `compare_exchange`.
2023-08-14std: add some missing repr(transparent)Ralf Jung-0/+2
2023-08-07std: synchronize with all calls to `unpark` in id-based thread parkerjoboet-11/+6
2023-07-29print omitted frames count for short backtrace modeyukang-0/+19
2023-07-24remove additional [allow(unused_unsafe)]James Dietz-1/+0
2023-07-07Allow limited access to `OsString` bytesEd Page-0/+15
This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.
2023-06-21wip: Support Apple tvOS in libstdThom Chiovoloni-1/+1
2023-06-14Rollup merge of #98202 - aticu:impl_tryfrom_osstr_for_str, r=AmanieuMatthias Krüger-10/+5
Implement `TryFrom<&OsStr>` for `&str` Recently when trying to work with `&OsStr` I was surprised to find this `impl` missing. Since the `to_str` method already existed the actual implementation is fairly non-controversial, except for maybe the choice of the error type. I chose an opaque error here instead of something like `std::str::Utf8Error`, since that would already make a number of assumption about the underlying implementation of `OsStr`. As this is a trait implementation, it is insta-stable, if I'm not mistaken? Either way this will need an FCP. I chose "1.64.0" as the version, since this is unlikely to land before the beta cut-off. `@rustbot` modify labels: +T-libs-api API Change Proposal: rust-lang/rust#99031 (accepted)
2023-06-12Implement `TryFrom<&OsStr>` for `&str`aticu-10/+5
2023-03-27Allow access to `OsStr` bytesEd Page-1/+7
`OsStr` has historically kept its implementation details private out of concern for locking us into a specific encoding on Windows. This is an alternative to #95290 which proposed specifying the encoding on Windows. Instead, this only specifies that for cross-platform code, `OsStr`'s encoding is a superset of UTF-8 and defines rules for safely interacting with it At minimum, this can greatly simplify the `os_str_bytes` crate and every arg parser that interacts with `OsStr` directly (which is most of those that support invalid UTF-8).
2023-05-17Fix #107910, Shorten backtraces in ICEsyukang-5/+6
2023-05-03Rollup merge of #105695 - joboet:remove_generic_parker, r=m-ou-seManish Goregaokar-129/+1
Replace generic thread parker with explicit no-op parker With #98391 merged, all platforms supporting threads now have their own parking implementations. Therefore, the generic implementation can be removed. On the remaining platforms (really just WASM without atomics), parking is not supported, so calls to `thread::park` now return instantly, which is [allowed by their API](https://doc.rust-lang.org/nightly/std/thread/fn.park.html). This is a change in behaviour, as spurious wakeups do not currently occur since all platforms guard against them. It is invalid to depend on this, but I'm still going to tag this as libs-api for confirmation. ````@rustbot```` label +T-libs +T-libs-api +A-atomic r? rust-lang/libs
2023-05-01Inline socket function implementationsKonrad Borowski-0/+3
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+2
2023-04-27Update test.Mara Bos-19/+1
2023-04-27Remove unused std::sys_common::thread_local_key::Key.Mara Bos-61/+0
2023-04-14Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitorMatthias Krüger-1/+0
Remove some unneeded imports / qualified paths Continuation of #105537.
2023-04-12remove some unneeded importsKaDiWa-1/+0
2023-04-10Fix typos in libraryDaniPopes-1/+1
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-1/+5
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-03-03Match unmatched backticks in library/est31-2/+2
2023-03-02Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubileebors-5/+25
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr` ⚠️ Backtraces on QNX require https://github.com/rust-lang/backtrace-rs/pull/507 which is not yet merged! (But everything else works without these changes) ⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-5/+25
Co-authored-by: gh-tr <troach@qnx.com>
2023-02-24add support of RustyHermit's BSD socket layerStefan Lankes-1/+0
RustHermit publishs a new kernel interface and supports a common BSD socket layer. By supporting this interface, the implementation can be harmonized to other operating systems. To realize this socket layer, the handling of file descriptors is also harmonized to other operating systems.
2023-02-22Rollup merge of #107736 - tgross35:atomic-as-ptr, r=m-ou-seMatthias Krüger-3/+3
Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893) Originally discussed in https://github.com/rust-lang/rust/issues/66893#issuecomment-1419198623 ~~This uses #107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased `@rustbot` label +T-libs-api r? m-ou-se
2023-02-18Auto merge of #107329 - joboet:optimize_lazylock, r=m-ou-sebors-0/+22
Optimize `LazyLock` size The initialization function was unnecessarily stored separately from the data to be initialized. Since both cannot exist at the same time, a `union` can be used, with the `Once` acting as discriminant. This unfortunately requires some extra methods on `Once` so that `Drop` can be implemented correctly and efficiently. `@rustbot` label +T-libs +A-atomic
2023-02-16std: replace generic thread parker with explicit no-op parkerjoboet-129/+1
2023-02-16Rollup merge of #106372 - joboet:solid_id_parking, r=m-ou-seDylan DPC-105/+1
Use id-based thread parking on SOLID By using the [`slp_tsk`/`wup_tsk`](https://cs.uwaterloo.ca/~brecht/courses/702/Possible-Readings/embedded/uITRON-4.0-specification.pdf) system functions instead of an event-flag structure, `Parker` becomes cheaper to construct and SOLID can share the implementation used by NetBSD and SGX. ping ``@kawadakk`` r? ``@m-ou-se`` ``@rustbot`` label +T-libs
2023-02-12Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcmbors-3/+3
Use associated items of `char` instead of freestanding items in `core::char` The associated functions and constants on `char` have been stable since 1.52 and the freestanding items have soft-deprecated since 1.62 (https://github.com/rust-lang/rust/pull/95566). This PR ~~marks them as "deprecated in future", similar to the integer and floating point modules (`core::{i32, f32}` etc)~~ replaces all uses of `core::char::*` with `char::*` to prepare for future deprecation of `core::char::*`.
2023-02-10Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893)Trevor Gross-3/+3
2023-01-28Replace libc::{type} with crate::ffi::{type}Ayush Singh-4/+4
Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-26std: optimize `LazyLock` sizejoboet-0/+22
2023-01-17refactor[std]: do not use box syntaxjoboet-1/+1
2023-01-14Use associated items of `char` instead of freestanding items in `core::char`Lukas Markeffsky-3/+3
2023-01-04Update rand in the stdlib tests, and remove the getrandom feature from itThom Chiovoloni-1/+2
2022-12-31std: use id-based thread parking on SOLIDjoboet-105/+1