about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2018-08-26Reduce number of syscalls in `rand`Tobias Bucher-39/+57
In case that it is statically known that the OS doesn't support `getrandom` (non-Linux) or becomes clear at runtime that `getrandom` isn't available (`ENOSYS`), the opened fd ("/dev/urandom") isn't closed after the function, so that future calls can reuse it. This saves repeated `open`/`close` system calls at the cost of one permanently open fd. Additionally, this skips the initial zero-length `getrandom` call and directly hands the user buffer to the operating system, saving one `getrandom` syscall.
2018-08-24Rollup merge of #53311 - RalfJung:windows-mutex, r=retep998kennytm-0/+2
Window Mutex: Document that we properly initialize the SRWLock See https://github.com/rust-lang/rust/issues/35836
2018-08-21Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJungkennytm-1/+1
Replace usages of ptr::offset with ptr::{add,sub}. Rust provides these helper methods – so let's use them!
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-1/+1
2018-08-19Fix typos found by codespell.Matthias Krüger-2/+2
2018-08-18Auto merge of #53436 - cuviper:trace_fn-stop, r=alexcrichtonbors-24/+30
std: stop backtracing when the frames are full This is a defensive measure to mitigate the infinite unwind loop seen in #53372. That case will still repeatedly unwind `__rust_try`, but now it will at least stop when `cx.frames` is full. r? @alexcrichton
2018-08-16std: stop backtracing when the frames are fullJosh Stone-24/+30
2018-08-17Rollup merge of #53395 - varkor:__Nonexhaustive-to-non_exhaustive, r=shepmasterkennytm-9/+9
Use #[non_exhaustive] on internal enums This replaces `__Nonexhaustive` variants (and variants thereof) with `#[non_exhaustive]`. These were mostly unstable previously, with the exception of the `cloudabi` enums and `Level` in proc_macro: these were `#[doc(hidden)]`, so clearly intended not to be used directly. It should be safe to replace all of these.
2018-08-15Start adding an `aarch64-pc-windows-msvc` targetAlex Crichton-4/+94
This commit adds the necessary definitions for target specs and such as well as the necessary support in libstd to compile basic `aarch64-pc-windows-msvc` binaries. The target is not currently built on CI, but it can be built locally with: ./configure --target=aarch64-pc-windows-msvc --set rust.lld ./x.py build src/libstd --target aarch64-pc-windows-msvc Currently this fails to build `libtest` due to a linker bug (seemingly in LLD?) which hasn't been investigate yet. Otherwise though with libstd you can build a hello world program (linked with LLD). I've not tried to execute it yet, but it at least links! Full support for this target is still a long road ahead, but this is hopefully a good stepping stone to get started. Points of note about this target are: * Currently defaults to `panic=abort` as support is still landing in LLVM for SEH on AArch64. * Currently defaults to LLD as a linker as I was able to get farther with it than I was with `link.exe`
2018-08-15Make cloudapi enums #[non_exhaustive]varkor-9/+9
2018-08-14Rollup merge of #53208 - BurntPizza:protect-the-environment, r=alexcrichtonkennytm-5/+1
Don't panic on std::env::vars() when env is null. Fixes #53200. Reviewer(s): * Do I need to do any `#[cfg()]` here? * Is this use of libc ok for a dev-dependency?
2018-08-14fixed wordingRalf Jung-1/+1
2018-08-13Window Mutex: make sure we properly initialize the SRWLockRalf Jung-0/+2
2018-08-11Add links to std::char::REPLACEMENT_CHARACTER from docs.Corey Farwell-1/+2
There are a few places where we mention the replacement character in the docs, and it could be helpful for users to utilize the constant which is available in the standard library, so let’s link to it!
2018-08-09Don't panic on std::env::vars() when env in null.BurntPizza-5/+1
Fixes #53200
2018-08-09Auto merge of #53108 - RalfJung:mutex, r=alexcrichtonbors-2/+8
clarify partially initialized Mutex issues Using a `sys_common::mutex::Mutex` without calling `init` is dangerous, and yet there are some places that do this. I tried to find all of them and add an appropriate comment about reentrancy. I found two places where (I think) reentrancy can actually occur, and was not able to come up with an argument for why this is okay. Someone who knows `io::lazy` and/or `sys_common::at_exit_imp` should have a careful look at this.
2018-08-08missed oneRalf Jung-2/+2
2018-08-08avoid using the word 'initialized' to talk about that non-reentrant-capable ↵Ralf Jung-2/+2
state of the mutex
2018-08-08Use repr(align(x)) for redox in6_addrLinus Färnstrand-1/+1
2018-08-06actually, reentrant uninitialized mutex acquisition is outright UBRalf Jung-6/+4
2018-08-06clarify partially initialized Mutex issuesRalf Jung-2/+10
2018-08-06Remove references to `StaticMutex` which got removed a while agoRalf Jung-3/+0
2018-08-02Auto merge of #52847 - upsuper:thread-stack-reserve, r=alexcrichtonbors-1/+4
Don't commit thread stack on Windows On Windows, there is a system level resource limitation called commit limit, which is roughly the sum of physical memory + paging files[1]. `CreateThread` by default commits the stack size[2], which unnecessarily takes such resource from the shared limit. This PR changes it to only reserve the stack size rather than commit it. Reserved memory would only take the address space of the current process until it's actually accessed. This should make the behavior on Windows match other platforms, and is also a pretty standard practice on Windows nowadays. [1] https://blogs.technet.microsoft.com/markrussinovich/2008/11/17/pushing-the-limits-of-windows-virtual-memory/ [2] https://docs.microsoft.com/zh-cn/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createthread
2018-07-31Fix coding style.Colin Finck-1/+4
2018-07-30Add targets for HermitCore (https://hermitcore.org) to the Rust compiler and ↵Colin Finck-14/+33
port libstd to it. As a start, the port uses the simplest possible configuration (no jemalloc, abort on panic) and makes use of existing Unix-specific code wherever possible. It adds targets for x86_64 (current main HermitCore platform) and aarch64 (HermitCore platform under development). Together with the patches to "liblibc" and "llvm", this enables HermitCore applications to be written in Rust.
2018-07-30Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkovbors-1/+1
Don't format!() string literals Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
2018-07-30Don't commit thread stack on WindowsXidorn Quan-1/+4
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-11/+8
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-11/+8
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-1/+1
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-28Don't format!() string literalsljedrz-1/+1
2018-07-27Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrumbors-10/+10
Rollup of bare_trait_objects PRs All deny attributes were moved into bootstrap so they can be disabled with a line of config. Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free. r? @Mark-Simulacrum cc @ljedrz @kennytm
2018-07-27Prefer to_string() to format!()ljedrz-1/+1
2018-07-25Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and ↵Tatsuyuki Ishi-8/+8
'ljedrz/dyn_libterm' into dyn-rollup
2018-07-25Add missing dynTatsuyuki Ishi-2/+2
2018-07-24Rollup merge of #52656 - jD91mZM2:stablize-uds, r=alexcrichtonMark Rousskov-1/+41
Stablize Redox Unix Sockets I don't know if I did this correctly, but I basically spammed the `#[stable]` attribute everywhere :^)
2018-07-24Stablize Redox Unix SocketsjD91mZM2-1/+41
2018-07-23Change single char str patterns to charsljedrz-3/+3
2018-07-13Fix redox libstd leftoverTatsuyuki Ishi-2/+2
2018-07-11Use fast TLS on FuchsiaTaylor Cramer-6/+1
2018-07-11Auto merge of #51553 - jD91mZM2:uds, r=sfacklerbors-1/+740
Unix sockets on redox This is done using the ipcd daemon. It's not exactly like unix sockets because there is not actually a physical file for the path, but it's close enough for a basic implementation :) This allows mio-uds and tokio-uds to work with a few modifications as well, which is exciting!
2018-07-10Add missing `dyn` for cloudabi, redox, unix and wasmljedrz-7/+7
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-1/+1
2018-07-08Delete leftover filesjD91mZM2-606/+0
2018-07-07Add is_unnamedjD91mZM2-0/+27
2018-07-07Revert unification of interfacesjD91mZM2-29/+1539
2018-07-03Rollup merge of #51809 - drrlvn:rw_exact_all_at, r=alexcrichtonPietro Albini-0/+127
Add read_exact_at and write_all_at methods to FileExt on unix This PR adds `FileExt::read_exact_at()` and `FileExt::write_all_at()`, which are to `read_at()` and `write_at()` as `read_exact()` and `write_all()` are to `read()` and `write()`. This allows the user to not have to deal with `ErrorKind::Interrupted` and calling the functions in a loop. I was unsure as to how to mark these new methods so I marked them `unstable`, please let me know if I should have done it differently. I asked in Discord and was told that as this change is small it does not require an RFC.
2018-07-03Remove stability attributes on private types and leftover docsjD91mZM2-18/+0
2018-07-02Fill in tracking issue number for read_exact_at/write_all_atDror Levin-2/+2
2018-06-28Change traits to bare FnMut where possible.moxian-111/+67