summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-09-11Documentation for default types modifiedathulappadan-3/+3
2016-09-11Remove unnecessary `cmp::min` from BufWriter::writeRichard Janis Goldschmidt-2/+1
The first branch of the if statement already checks if `buf.len() >= self.buf.capacity()`, which makes the `cmp::min(buf.len(), self.buf.capacity())` redundant: the result will always be `buf.len()`. Therefore, we can pass the `buf` slice directly into `Write::write`.
2016-09-11Documentation of what does for each typeathulappadan-0/+9
2016-09-10Rollup merge of #36314 - tshepang:not-needed, r=GuillaumeGomezGuillaume Gomez-2/+2
doc: we got coercion going on here, so no need to be this explicit
2016-09-10Rollup merge of #36311 - frewsxcv:instant-elapsed-example, r=GuillaumeGomezGuillaume Gomez-0/+12
Add doc example for `std::time::Instant::elapsed`. None
2016-09-09Add s390x supportUlrich Weigand-6/+25
This adds support for building the Rust compiler and standard library for s390x-linux, allowing a full cross-bootstrap sequence to complete. This includes: - Makefile/configure changes to allow native s390x builds - Full Rust compiler support for the s390x C ABI (only the non-vector ABI is supported at this point) - Port of the standard library to s390x - Update the liblibc submodule to a version including s390x support - Testsuite fixes to allow clean "make check" on s390x Caveats: - Resets base cpu to "z10" to bring support in sync with the default behaviour of other compilers on the platforms. (Usually, upstream supports all older processors; a distribution build may then chose to require a more recent base version.) (Also, using zEC12 causes failures in the valgrind tests since valgrind doesn't fully support this CPU yet.) - z13 vector ABI is not yet supported. To ensure compatible code generation, the -vector feature is passed to LLVM. Note that this means that even when compiling for z13, no vector instructions will be used. In the future, support for the vector ABI should be added (this will require common code support for different ABIs that need different data_layout strings on the same platform). - Two test cases are (temporarily) ignored on s390x to allow passing the test suite. The underlying issues still need to be fixed: * debuginfo/simd.rs fails because of incorrect debug information. This seems to be a LLVM bug (also seen with C code). * run-pass/union/union-basic.rs simply seems to be incorrect for all big-endian platforms. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-08Auto merge of #36322 - uweigand:nonblocking, r=alexcrichtonbors-1/+1
Fix argument to FIONBIO ioctl The FIONBIO ioctl takes as argument a pointer to an integer, which should be either 0 or 1 to indicate whether nonblocking mode is to be switched off or on. The type of the pointed-to variable is "int". However, the set_nonblocking routine in libstd/sys/unix/net.rs passes a pointer to a libc::c_ulong variable. This doesn't matter on all 32-bit platforms and on all litte-endian platforms, but it will break on big-endian 64-bit platforms. Found while porting Rust to s390x (a big-endian 64-bit platform). Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-08Auto merge of #36048 - GuillaumeGomez:code_clean, r=brsonbors-12/+9
Clean code a bit
2016-09-07Zero first byte of CString on dropAleksey Kladov-3/+25
This should prevent code like ``` let ptr = CString::new("hello").unwrap().as_ptr(); ``` from working by accident.
2016-09-07Fix argument to FIONBIO ioctlUlrich Weigand-1/+1
The FIONBIO ioctl takes as argument a pointer to an integer, which should be either 0 or 1 to indicate whether nonblocking mode is to be switched off or on. The type of the pointed-to variable is "int". However, the set_nonblocking routine in libstd/sys/unix/net.rs passes a pointer to a libc::c_ulong variable. This doesn't matter on all 32-bit platforms and on all litte-endian platforms, but it will break on big-endian 64-bit platforms. Found while porting Rust to s390x (a big-endian 64-bit platform). Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-07Add doc example for `std::time::Instant::elapsed`.Corey Farwell-0/+12
2016-09-07doc: we got coercion going on here, so no need to be this explicitTshepang Lekhonkhobe-2/+2
2016-09-06Rollup merge of #36298 - GuillaumeGomez:hashmap_doc, r=steveklabnikJonathan Turner-18/+42
Add missing urls r? @steveklabnik
2016-09-06Rollup merge of #36263 - apasel422:scoped, r=steveklabnikJonathan Turner-20/+15
Clean up thread-local storage docs `std` no longer contains an implementation of scoped TLS. r? @steveklabnik
2016-09-06Add missing urlsggomez-18/+42
2016-09-04Auto merge of #36203 - petrochenkov:uvsdot, r=nrcbors-2/+3
Replace `_, _` with `..` in patterns This is how https://github.com/rust-lang/rust/issues/33627 looks in action. Looks especially nice in leftmost/rightmost positions `(first, ..)`/`(.., last)`. I haven't touched libsyntax intentionally because the feature is still unstable.
2016-09-04Auto merge of #36144 - japaric:rustbuild-musl, r=alexcrichtonbors-1/+1
rustbuild: fix building std for musl targets closes #36143 r? @alexcrichton
2016-09-04Clean up thread-local storage docsAndrew Paseltiner-20/+15
`std` no longer contains an implementation of scoped TLS.
2016-09-04Replace `_, _` with `..`Vadim Petrochenkov-1/+1
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.