rust/library/std/src
bors c3605f8c80 Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa
STD support for the Nintendo 3DS

Rustc already supports compiling for the Nintendo 3DS using the `armv6k-nintendo-3ds` target (Tier 3). Until now though, only `core` and `alloc` were supported. This PR adds standard library support for the Nintendo 3DS. A notable exclusion is `std::thread` support, which will come in a follow-up PR as it requires more complicated changes.

This has been a joint effort by `@Meziu,` `@ian-h-chamberlain,` myself, and prior work by `@rust3ds` members.

### Background

The Nintendo 3DS (Horizon OS) is a mostly-UNIX looking system, with the caveat that it does not come with a full libc implementation out of the box. On the homebrew side (I'm not under NDA), the libc interface is partially implemented by the [devkitPro](https://devkitpro.org/wiki/devkitPro_pacman) toolchain and a user library like [`libctru`](https://github.com/devkitPro/libctru). This is important because there are [some possible legal barriers](https://github.com/rust-lang/rust/pull/88529#issuecomment-919938396) to linking directly to a library that uses the underlying platform APIs, since they might be considered a trade secret or under NDA.

To get around this, the standard library impl for the 3DS does not directly depend on any platform-level APIs. Instead, it expects standard libc functions to be linked in. The implementation of these libc functions is left to the user. Some functions are provided by the devkitPro toolchain, but in our testing, we used the following to fill in the other functions:
- [`libctru`] - provides more basic APIs, such as `nanosleep`. Linked in by way of [`ctru-sys`](https://github.com/Meziu/ctru-rs/tree/master/ctru-sys).
- [`pthread-3ds`](https://github.com/Meziu/pthread-3ds) - provides pthread APIs for `std::thread`. Implemented using [`libctru`].
- [`linker-fix-3ds`](https://github.com/Meziu/rust-linker-fix-3ds) - fulfills some other missing libc APIs. Implemented using [`libctru`].

For more details, see the `src/doc/rustc/src/platform-support/armv6k-nintendo-3ds.md` file added in this PR.

### Notes
We've already upstreamed changes to the [`libc`] crate to support this PR, as well as the upcoming threading PR. These changes have all been released as of 0.2.121, so we bump the crate version in this PR.
Edit: After some rebases, the version bump has already been merged so it doesn't appear in this PR.

A lot of the changes in this PR are straightforward, and follow in the footsteps of the ESP-IDF target: https://github.com/rust-lang/rust/pull/87666.

The 3DS does not support user space process spawning, so these APIs are unimplemented (similar to ESP-IDF).

[`libctru`]: https://github.com/devkitPro/libctru
[`libc`]: https://github.com/rust-lang/libc
2022-06-15 14:21:28 +00:00
..
backtrace Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
collections [perf] std: add missing #[inline] to DefaultHasher::{new,default}. 2022-06-13 18:33:02 +00:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
f32 Implement IEEE 754-2019 minimun and maximum functions for f32/f64 2021-11-20 10:14:03 +01:00
f64 Remove fNN::lerp - consensus unlikely 2021-10-25 22:44:41 -05:00
ffi Auto merge of #96881 - est31:join_osstr, r=dtolnay 2022-05-31 04:28:29 +00:00
fs Use gender neutral terms 2022-04-07 08:51:59 +01:00
io Rollup merge of #97922 - paolobarbolini:no-vecdeque-extra-reserve, r=the8472 2022-06-10 17:22:31 +09:00
lazy Upgrade wasm32 image to Ubuntu 20.04 2021-02-06 13:05:56 +01:00
net Fix stabilization version of Ipv6Addr::to_ipv4_mapped 2022-05-24 01:05:06 +02:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa 2022-06-15 14:21:28 +00:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path Allow unused_macro_rules in path tests 2022-05-16 08:55:05 +02:00
prelude Finish bumping stage0 2022-05-27 07:36:17 -04:00
process Add test for issue #95178 2022-03-23 05:33:44 +00:00
sync Update library/std/src/sync/mutex.rs 2022-06-07 15:15:19 +02:00
sys Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa 2022-06-15 14:21:28 +00:00
sys_common Lower listen backlog to fix accept crashes 2022-06-13 20:44:56 -07:00
thread Stabilize scoped threads. 2022-06-11 15:01:52 +02:00
time Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
alloc.rs Add std::alloc::set_alloc_error_hook example 2022-06-07 15:06:18 +02:00
ascii.rs Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
backtrace.rs revert changes that cast functions to raw pointers, portability hazard 2022-03-29 20:18:27 -04:00
env.rs add aliases for current_dir 2022-05-24 19:41:40 -07:00
error.rs Fix typo (panick -> panic) 2022-05-29 13:14:59 +04:00
f32.rs Rollup merge of #95483 - golddranks:improve_float_docs, r=joshtriplett 2022-05-09 18:45:35 +02:00
f64.rs Rollup merge of #95483 - golddranks:improve_float_docs, r=joshtriplett 2022-05-09 18:45:35 +02:00
fs.rs Fix Windows file metadata docs 2022-06-01 20:32:33 -04:00
keyword_docs.rs remove an unnecessary space in doc 2022-06-13 09:51:13 +09:00
lazy.rs Add #[must_use] to core and std constructors 2021-10-10 02:44:26 -04:00
lib.rs Auto merge of #96837 - tmiasko:stdio-fcntl, r=joshtriplett 2022-06-10 11:50:39 +00:00
macros.rs Make write/print macros eagerly drop temporaries 2022-05-22 16:11:08 -07:00
num.rs Add Saturating type (based on Wrapping type) 2021-08-10 19:27:01 +02:00
panic.rs Configure panic hook backtrace behavior 2022-02-02 13:46:42 -05:00
panicking.rs Auto merge of #92461 - rust-lang:const_tls_local_panic_count, r=Mark-Simulacrum 2022-05-23 13:04:59 +00:00
path.rs fix panic in Path::strip_prefix 2022-05-08 22:15:26 +08:00
primitive_docs.rs Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC 2022-05-24 15:58:26 +02:00
process.rs Rollup merge of #97970 - dtolnay:terminate, r=joshtriplett 2022-06-12 12:14:27 +02:00
rt.rs Change Termination::report return type to ExitCode 2022-01-28 12:53:36 -08:00
time.rs std::time : fix doc variable name 2022-05-23 00:02:09 +02:00