about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-09-04Replace `_, _, _` with `..`Vadim Petrochenkov-1/+2
2016-09-03Auto merge of #36104 - KiChjang:issue-35847, r=brsonbors-4/+24
Fix illegal instruction caused by overflow in channel cloning Fixes #35847. r? @alexcrichton
2016-09-02Auto merge of #36024 - japaric:mips64, r=alexcrichtonbors-0/+11
add mips64-gnu and mips64el-gnu targets With this commit one can build no_core (and probably no_std as well) Rust programs for these targets. It's not yet possible to cross compile std for these targets because rust-lang/libc doesn't know about the mips64 architecture. These targets have been tested by cross compiling the "smallest hello" program (see code below) and then running it under QEMU. ``` rust extern { fn puts(_: *const u8); } fn start(_: isize, _: *const *const u8) -> isize { unsafe { let msg = b"Hello, world!\0"; puts(msg as *const _ as *const u8); } 0 } trait Copy {} trait Sized {} ``` cc #36015 r? @alexcrichton cc @brson The cabi stuff is likely wrong. I just copied cabi_mips source and changed some `4`s to `8`s and `32`s to `64`s. It was enough to get libc's `puts` to work but I'd like someone familiar with this module to check it.
2016-09-01Auto merge of #35755 - SimonSapin:char_convert, r=alexcrichtonbors-0/+7
Implement std::convert traits for char This is motivated by avoiding the `as` operator, which sometimes silently truncates, and instead use conversions that are explicitly lossless and infallible. I’m less certain that `From<u8> for char` should be implemented: while it matches an existing behavior of `as`, it’s not necessarily the right thing to use for non-ASCII bytes. It effectively decodes bytes as ISO/IEC 8859-1 (since Unicode designed its first 256 code points to be compatible with that encoding), but that is not apparent in the API name.
2016-08-31Rollup merge of #35911 - tbu-:pr_io_errorkind_traits, r=alexcrichtonJonathan Turner-2/+3
Implement more traits for `std::io::ErrorKind` This makes it possible to use it as key in various maps.
2016-08-31Rollup merge of #35786 - GuillaumeGomez:paths_doc, r=steveklabnikJonathan Turner-34/+149
Improve Path and PathBuf docs r? @steveklabnik
2016-08-31Improve Path and PathBuf docsGuillaume Gomez-34/+149
2016-08-31Rollup merge of #36134 - tshepang:more-simple, r=steveklabnikJonathan Turner-8/+1
doc: make TcpListener example more simple
2016-08-31Rollup merge of #36101 - frewsxcv:debug-path-components, r=alexcrichtonJonathan Turner-0/+81
Implement `Debug` for `std::path::{Components,Iter}`. None
2016-08-30Implement `Debug` for `std::path::Iter`.Corey Farwell-0/+41
2016-08-30Auto merge of #35048 - tmiasko:monotonic-wait-timeout, r=alexcrichtonbors-9/+82
Use monotonic time in condition variables. Configure condition variables to use monotonic time using pthread_condattr_setclock on systems where this is possible. This fixes the issue when thread waiting on condition variable is woken up too late when system time is moved backwards.
2016-08-30Implement `Debug` for `std::path::Components`.Corey Farwell-0/+40
2016-08-30for mips-musl pass -ldl and co to the linkerJorge Aparicio-1/+1
2016-08-30rustbuild: fix building std for musl targetsJorge Aparicio-1/+1
closes #36143
2016-08-30Rollup merge of #35997 - matthew-piziak:thread-current-example, r=GuillaumeGomezGuillaume Gomez-0/+18
add a simple example for `thread::current()` r? @GuillaumeGomez
2016-08-30doc: make TcpListener example more simpleTshepang Lekhonkhobe-8/+1
2016-08-29Fix illegal instruction caused by overflow in channel cloningKeith Yeung-4/+24
2016-08-29Implement TryFrom<u32> for charSimon Sapin-0/+7
For symmetry with From<char> for u32.
2016-08-29Avoid using pthread_condattr_setclock on Android.Tomasz Miąsko-4/+4
The pthread_condattr_setclock is available only since Android 5.0 and API level 21.
2016-08-28Improve Demangling of Rust SymbolsChristopher Serr-19/+47
This turns `..` into `::`, handles some more escapes and gets rid of unwanted underscores at the beginning of path elements. ![Image of Diff](http://puu.sh/qQIN3.png)
2016-08-27Clean code a bitGuillaume Gomez-12/+9
2016-08-27Auto merge of #35969 - bluss:memrchr-alignment, r=nagisabors-1/+23
memrchr: Correct aligned offset computation The memrchr fallback did not compute the offset correctly. It was intentioned to land on usize-aligned addresses but did not. This was suspected to have resulted in a crash on ARMv7! This bug affected non-linux platforms. I think like this, if we have a slice with pointer `ptr` and length `len`, we want to find the last usize-aligned offset in the slice. The correct computation should be: For example if ptr = 1 and len = 6, and `size_of::<usize>()` is 4: ``` [ x x x x x x ] 1 2 3 4 5 6 ^-- last aligned address at offset 3 from the start. ``` The last aligned address is ptr + len - (ptr + len) % usize_size. Compute offset from the start as: offset = len - (ptr + len) % usize_size = 6 - (1 + 6) % 4 = 6 - 3 = 3. I believe the function's return value was always correct previously, if the platform supported unaligned addresses. Fixes #35967
2016-08-27fix cross compilation of stdJorge Aparicio-0/+11
2016-08-26Introduce `into_inner` method on `std::io::Take`.Corey Farwell-0/+27
https://github.com/rust-lang/rust/issues/23755
2016-08-26Replace unnecessary uses of `TraitObject` with castsAndrew Paseltiner-18/+4
2016-08-25Auto merge of #35906 - jseyfried:local_prelude, r=eddybbors-205/+11
Use `#[prelude_import]` in `libcore` and `libstd` r? @eddyb
2016-08-25add a simple example for `thread::current()`Matthew Piziak-0/+18
2016-08-25Auto merge of #35884 - habnabit:freebsd-arc4rand, r=alexcrichtonbors-30/+77
Use arc4rand(9) on FreeBSD From rust-lang-nursery/rand#112: >After reading through #30691 it seems that there's general agreement that using OS-provided facilities for seeding rust userland processes is fine as long as it doesn't use too much from libc. FreeBSD's `arc4random_buf(3)` is not only a whole lot of libc code, but also not even currently exposed in the libc crate. Fortunately, the mechanism `arc4random_buf(3)` et al. use for getting entropy from the kernel ([`arc4rand(9)`](https://www.freebsd.org/cgi/man.cgi?query=arc4random&apropos=0&sektion=9&manpath=FreeBSD+10.3-RELEASE&arch=default&format=html)) is exposed via `sysctl(3)` with constants that are already in the libc crate. >I haven't found too much documentation on `KERN_ARND`—it's missing or only briefly described in most of the places that cover sysctl mibs. But, from digging through the kernel source, it appears that the sysctl used in this PR is very close to just calling `arc4rand(9)` directly (with `reseed` set to 0 and no way to change it). I expected [rand](/rust-lang-nursery/rand) to reply quicker, so I tried submitting it there first. It's been a few weeks with no comment, so I don't know the state of it, but maybe someone will see it here and have an opinion. This is basically the same patch. It pains me to duplicate the code but I guess it hasn't been factored out into just one place yet.
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-205/+11
2016-08-24memrchr: Use a conditional instead of subtracting a complicated minUlrik Sverdrup-1/+1
This makes the critical calculation easier to understand.
2016-08-24memrchr: Correct aligned offset computationUlrik Sverdrup-1/+23
The memrchr fallback did not compute the offset correctly. It was intentioned to land on usize-aligned addresses but did not. This was suspected to resulted in a crash on ARMv7 platform! This bug affected non-linux platforms. I think like this, if we have a slice with pointer `ptr` and length `len`, we want to find the last usize-aligned offset in the slice. The correct computation should be: For example if ptr = 1 and len = 6, and size_of::<usize>() is 4: [ x x x x x x ] 1 2 3 4 5 6 ^-- last aligned address at offset 3 from the start. The last aligned address is ptr + len - (ptr + len) % usize_size. Compute offset from the start as: offset = len - (ptr + len) % usize_size = 6 - (1 + 6) % 4 = 6 - 3 = 3. I believe the function's return value was always correct previously, if the platform supported unaligned addresses.
2016-08-24Remove drop flags from structs and enums implementing Drop.Eduard Burtescu-3/+3
2016-08-24Restore old ordering of `io::ErrorKind`sTobias Bucher-3/+4
2016-08-23Auto merge of #35656 - Stebalien:fused, r=alexcrichtonbors-3/+55
Implement 1581 (FusedIterator) * [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642. * [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be? * [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice. * I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`. * `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`. Closes: #35602 (Tracking Issue) Implements: rust-lang/rfcs#1581
2016-08-23Implement more traits for `std::io::ErrorKind`Tobias Bucher-6/+6
This makes it possible to use it as key in various maps.
2016-08-22Rollup merge of #35842 - apasel422:typo, r=GuillaumeGomezJonathan Turner-2/+2
Fix typos in unix/rwlock.rs r? @steveklabnik
2016-08-22Auto merge of #35871 - bluss:cstring-new, r=alexcrichtonbors-0/+1
cstring: avoid excessive growth just to 0-terminate Based on following what happens in CString::new("string literal"): 1. Using `Into<Vec<u8>>`, a Vec is allocated with capacity exactly equal to the string's input length. 2. By `v.push(0)`, the Vec is grown to twice capacity, since it was full. 3. By `v.into_boxed_slice()`, the Vec capacity is shrunk to fit the length again. If we use `.reserve_exact(1)` just before the push, then we avoid the capacity doubling that we're going to have to shrink anyway. Growing by just 1 byte means that the step (2) is less likely to have to move the memory to a larger allocation chunk, and that the step (3) does not have to reallocate. Addresses part of #35838
2016-08-21Use the kernel arc4rand for FreeBSD OsRng.Aaron Gallagher-1/+52
This means that /dev/urandom doesn't have to be opened.
2016-08-21Reduce duplication in std::sys::unix::rand.Aaron Gallagher-29/+25
There were a bunch of more-of-less the same few lines for doing a fill_bytes+transmute, and I didn't want to copy-paste it yet again.
2016-08-21cstring: avoid excessive growth just to 0-terminateUlrik Sverdrup-0/+1
Based on following what happens in CString::new("string literal"): 1. Using `Into<Vec<u8>>`, a Vec is allocated with capacity exactly equal to the string's input length. 2. By `v.push(0)`, the Vec is grown to twice capacity, since it was full. 3. By `v.into_boxed_slice()`, the Vec capacity is shrunk to fit the length again. If we use `.reserve_exact(1)` just before the push, then we avoid the capacity doubling that we're going to have to shrink anyway. Growing by just 1 byte means that the step (2) is less likely to have to move the memory to a larger allocation chunk, and that the step (3) does not have to reallocate.
2016-08-20Rollup merge of #35775 - frewsxcv:os-str-doc-examples, r=GuillaumeGomezJonathan Turner-0/+32
Add a few doc examples for `std::ffi::OsStr`.
2016-08-20Rollup merge of #35234 - nrc:rustdoc-macros, r=steveklabnikJonathan Turner-5/+5
rustdoc: remove the `!` from macro URLs and titles Because the `!` is part of a macro use, not the macro's name. E.g., you write `macro_rules! foo` not `macro_rules! foo!`, also `#[macro_import(foo)]`. (Pulled out of #35020).
2016-08-19Fix typos in unix/rwlock.rsAndrew Paseltiner-2/+2
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-24/+23
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-08-19Document that Condvar makes the best effort to use monotonic clock.Tomasz Miąsko-0/+8
2016-08-18Add a FusedIterator trait.Steven Allen-3/+55
This trait can be used to avoid the overhead of a fuse wrapper when an iterator is already well-behaved. Conforming to: RFC 1581 Closes: #35602
2016-08-18Add a few doc examples for `std::ffi::OsStr`.Corey Farwell-0/+32
* `std::ffi::OsStr::new`. * `std::ffi::OsStr::is_empty`. * `std::ffi::OsStr::len`.
2016-08-18Fix linksNick Cameron-5/+5
2016-08-17Rollup merge of #35621 - frewsxcv:cstring-from-vec-doc, r=peschkajJonathan Turner-0/+11
Add doc example for `std::ffi::CString::from_vec_unchecked`. None
2016-08-17Rollup merge of #35613 - matthew-piziak:array-docs-trait-justification, ↵Jonathan Turner-3/+8
r=steveklabnik provide additional justification for array interface design Explain why Rust does not implement traits for large arrays. Explain why most methods are implemented on slices rather than arrays. Note: I'm dipping my toes in the water with a tiny PR. Especially looking for feedback on wording and style. Points of concern: appropriate level of top-level explanation; foreshadowing (is it appropriate to imply that we expect Rust's type system to eventually support size-generic arrays?); using `Foo` and `Bar` as type variables instead of e.g. `T` and `S`. @peschkaj