about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2016-07-28Add OpenOptionsExt doc examplesGuillaume Gomez-0/+38
2016-07-28Add doc examples for std::fs::unix::OpenOptionsExtGuillaume Gomez-0/+12
2016-07-27Auto merge of #34946 - alexcrichton:fix-cfg, r=brsonbors-2/+2
std: Fix usage of SOCK_CLOEXEC This code path was intended to only get executed on Linux, but unfortunately the `cfg!` was malformed so it actually never got executed.
2016-07-28Rename `char::escape` to `char::escape_debug` and add tracking issueTobias Bucher-3/+3
2016-07-27Auto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichtonbors-10/+21
DoubleEndedIterator for Args This PR implements the DoubleEndedIterator trait for the `std::env::Args[Os]` structure, as well as the internal implementations. It is primarily motivated by me, as I happened to implement a simple `reversor` program many times now, which so far had to use code like this: ```Rust for arg in std::env::args().skip(1).collect::<Vec<_>>().iter().rev() {} ``` ... even though I would have loved to do this instead: ```Rust for arg in std::env::args().skip(1).rev() {} ``` The latter is more natural, and I did not find a reason for not implementing it. After all, on every system, the number of arguments passed to the program are known at runtime. To my mind, it follows KISS, and does not try to be smart at all. Also, there are no unit-tests, primarily as I did not find any existing tests for the `Args` struct either. The windows implementation is basically a copy-pasted variant of the `next()` method implementation, and I could imagine sharing most of the code instead. Actually I would be happy if the reviewer would ask for it.
2016-07-26keep backtraces if using the old build systemJorge Aparicio-3/+3
2016-07-26Rollup merge of #35009 - GuillaumeGomez:dir_entry_doc, r=steveklabnikSteve Klabnik-0/+16
Dir entry doc Part of #29356. r? @steveklabnik
2016-07-26rustbuild: make backtraces (RUST_BACKTRACE) optionalJorge Aparicio-0/+3
but keep them enabled by default to maintain the status quo. When disabled shaves ~56KB off every x86_64-unknown-linux-gnu binary. To disable backtraces you have to use a config.toml (see src/bootstrap/config.toml.example for details) when building rustc/std: $ python bootstrap.py --config=config.toml
2016-07-26DoubleEndedIterator for ArgsSebastian Thiel-10/+21
The number of arguments given to a process is always known, which makes implementing DoubleEndedIterator possible. That way, the Iterator::rev() method becomes usable, among others. Signed-off-by: Sebastian Thiel <byronimo@gmail.com> Tidy for DoubleEndedIterator I chose to not create a new feature for it, even though technically, this makes me lie about the original availability of the implementation. Verify with @alexchrichton Setup feature flag for new std::env::Args iterators Add test for Args reverse iterator It's somewhat depending on the input of the test program, but made in such a way that should be somewhat flexible to changes to the way it is called. Deduplicate windows ArgsOS code for DEI DEI = DoubleEndedIterator Move env::args().rev() test to run-pass It must be controlling it's arguments for full isolation. Remove superfluous feature name Assert all arguments returned by env::args().rev() Let's be very sure it works as we expect, why take chances. Fix rval of os_string_from_ptr A trait cannot be returned, but only the corresponding object. Deref pointers to actually operate on the argument Put unsafe to correct location
2016-07-24Add DirEntry doc examplesGuillaume Gomez-0/+16
2016-07-23Add DirBuilder doc examplesGuillaume Gomez-0/+10
2016-07-20std: Fix usage of SOCK_CLOEXECAlex Crichton-2/+2
This code path was intended to only get executed on Linux, but unfortunately the `cfg!` was malformed so it actually never got executed.
2016-07-15Rollup merge of #34456 - tbu-:pr_ptr_null, r=aturonGuillaume Gomez-16/+20
Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`
2016-07-13Auto merge of #34776 - cuviper:solaris-readdir, r=alexcrichtonbors-22/+40
std: fix `readdir` errors for solaris A `NULL` from `readdir` could be the end of stream or an error. The only way to know is to check `errno`, so it must be set to a known value first, like a 0 that POSIX will never use. This currently only matters for solaris targets, as the other unix platforms are using `readdir_r` with a direct error return indication. However, this is getting deprecated (#34668) so they should all eventually switch to `readdir`. This PR adds `set_errno`, uses it to clear the value before calling `readdir`, then checks it again after to see the reason for a `NULL`. A few other small fixes are included just to get solaris compiling at all. I couldn't get cross-compilation completely going, so I don't have a good way to test this beyond a smoke-test cargo build of std. I'd appreciate input from someone more familiar with solaris -- cc @nbaksalyar?
2016-07-12Auto merge of #34705 - alexcrichton:clean-deprecated, r=brsonbors-52/+64
std: Clean out deprecated APIs This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12std: Clean out deprecated APIsAlex Crichton-52/+64
This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12Auto merge of #34757 - sourcefrog:debug-filetype, r=alexcrichtonbors-2/+2
Derive Debug on FileType. Partially fixes #32054
2016-07-12Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`Tobias Bucher-16/+20
2016-07-11std: clear errno before readdir, then check it (solaris)Josh Stone-17/+32
A `NULL` from `readdir` could be the end of stream or an error. The only way to know is to check `errno`, so it must be set to a known value first, like a 0 that POSIX will never use. This patch adds `set_errno`, uses it to clear the value before calling `readdir`, then checks it again after to see the reason for a `NULL`.
2016-07-11std: Fix IPV6 imports for solarisJosh Stone-4/+8
Like BSDs, Solaris maps `IPV6_ADD_MEMBERSHIP` and `IPV6_DROP_MEMBERSHIP` from `IPV6_JOIN_GROUP` and `IPV6_LEAVE_GROUP` respectively.
2016-07-11std: Fix `Thread::set_name()` for newlib and solarisJosh Stone-1/+0
The `use ffi::CStr` in `unix/thread.rs` was previously guarded, but now all platforms need it for `Thread::set_name()`. Newlib and Solaris do nothing here, as they have no way to set a thread name, but they still define the same method signature.
2016-07-11Auto merge of #34686 - alexcrichton:new-stage, r=luqmanabors-3/+3
rustc: Update stage0 to beta-2016-07-06 Hot off the presses, let's update our stage0 compiler!
2016-07-10Derive Debug on FileType.Martin Pool-2/+2
Partially fixes #32054
2016-07-10Demangle curly bracesSteven Fackler-1/+3
They show up in things like fn(&std..panic..PanicInfo<'_>) $u7b$hook$u7d$::fn_pointer_shim.8352::h01f889b2277c719d
2016-07-08Add test for std::net::lookup_host() duplicatesIvan Nejgebauer-0/+19
2016-07-07Use hints with getaddrinfo() in std::net::lokup_host()Ivan Nejgebauer-1/+11
When resolving a hostname, pass a hints struct where ai_socktype is set to SOCK_STREAM in order to eliminate repeated results for each protocol family.
2016-07-06rustc: Update stage0 to beta-2016-07-06Alex Crichton-3/+3
Hot off the presses, let's update our stage0 compiler!
2016-07-03Auto merge of #34530 - alexcrichton:stabilize-1.11, r=aturonbors-14/+54
std: Stabilize APIs for the 1.11.0 release Although the set of APIs being stabilized this release is relatively small, the trains keep going! Listed below are the APIs in the standard library which have either transitioned from unstable to stable or those from unstable to deprecated. Stable * `BTreeMap::{append, split_off}` * `BTreeSet::{append, split_off}` * `Cell::get_mut` * `RefCell::get_mut` * `BinaryHeap::append` * `{f32, f64}::{to_degrees, to_radians}` - libcore stabilizations mirroring past libstd stabilizations * `Iterator::sum` * `Iterator::product` Deprecated * `{f32, f64}::next_after` * `{f32, f64}::integer_decode` * `{f32, f64}::ldexp` * `{f32, f64}::frexp` * `num::One` * `num::Zero` Added APIs (all unstable) * `iter::Sum` * `iter::Product` * `iter::Step` - a few methods were added to accomodate deprecation of One/Zero Removed APIs * `From<Range<T>> for RangeInclusive<T>` - everything about `RangeInclusive` is unstable Closes #27739 Closes #27752 Closes #32526 Closes #33444 Closes #34152 cc #34529 (new tracking issue)
2016-07-03std: Stabilize APIs for the 1.11.0 releaseAlex Crichton-14/+54
Although the set of APIs being stabilized this release is relatively small, the trains keep going! Listed below are the APIs in the standard library which have either transitioned from unstable to stable or those from unstable to deprecated. Stable * `BTreeMap::{append, split_off}` * `BTreeSet::{append, split_off}` * `Cell::get_mut` * `RefCell::get_mut` * `BinaryHeap::append` * `{f32, f64}::{to_degrees, to_radians}` - libcore stabilizations mirroring past libstd stabilizations * `Iterator::sum` * `Iterator::product` Deprecated * `{f32, f64}::next_after` * `{f32, f64}::integer_decode` * `{f32, f64}::ldexp` * `{f32, f64}::frexp` * `num::One` * `num::Zero` Added APIs (all unstable) * `iter::Sum` * `iter::Product` * `iter::Step` - a few methods were added to accomodate deprecation of One/Zero Removed APIs * `From<Range<T>> for RangeInclusive<T>` - everything about `RangeInclusive` is unstable Closes #27739 Closes #27752 Closes #32526 Closes #33444 Closes #34152 cc #34529 (new tracking issue)
2016-06-29Convert a simple tail call to a loopTobias Bucher-10/+14
2016-06-29Ignore unknown address types when looking up hostsTobias Bucher-5/+9
Previously, any function using a `ToSocketAddrs` input would fail if passed a hostname that resolves to an address type different from the ones recognized by Rust. This also changes the `LookupHost` iterator to only include the known address types, as a result, it doesn't have to return `Result`s any more, which are likely misinterpreted as failed name lookups.
2016-06-24Auto merge of #34441 - tbu-:pr_dont_ignore_errors, r=alexcrichtonbors-30/+30
Don't ignore errors of syscalls in std::sys::unix::fd If any of these syscalls fail, it indicates a programmer error that should not be silently ignored.
2016-06-24Auto merge of #34425 - tbu-:pr_len_instead_of_size_hint, r=alexcrichtonbors-1/+1
Use `len` instead of `size_hint` where appropiate This makes it clearer that we're not just looking for a lower bound but rather know that the iterator is an `ExactSizeIterator`.
2016-06-24Auto merge of #34399 - alexcrichton:issue-audit, r=brsonbors-1/+1
std: Fix up stabilization discrepancies * Remove the deprecated `CharRange` type which was forgotten to be removed awhile back. * Stabilize the `os::$platform::raw::pthread_t` type which was intended to be stabilized as part of #32804
2016-06-24Bubble up the errors in `set_nonblocking` and `set_cloexec`Tobias Bucher-30/+30
2016-06-23std: Fix up stabilization discrepanciesAlex Crichton-1/+1
* Remove the deprecated `CharRange` type which was forgotten to be removed awhile back. * Stabilize the `os::$platform::raw::pthread_t` type which was intended to be stabilized as part of #32804
2016-06-23Don't ignore errors of syscalls in std::sys::unix::fdTobias Bucher-4/+4
If any of these syscalls fail, it indicates a programmer error that should not be silently ignored.
2016-06-23Use `len` instead of `size_hint` where appropiateTobias Bucher-1/+1
This makes it clearer that we're not just looking for a lower bound but rather know that the iterator is an `ExactSizeIterator`.
2016-06-21Fix overflow error in thread::sleepGuillaume Gomez-6/+15
2016-06-14Add ERROR_FILE_EXISTS to ErrorKind conversion on WindowsGleb Kozyrev-0/+2
Bug report: https://users.rust-lang.org/t/detecting-error-kind-for-opening-file/6215 Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx#error_file_exists
2016-06-09use the slice_pat hack in libstd tooAriel Ben-Yehuda-18/+9
2016-06-09address review commentsAriel Ben-Yehuda-5/+5
2016-06-09implement RFC495 semantics for slice patternsAriel Ben-Yehuda-6/+15
non-MIR translation is still not supported for these and will happily ICE. This is a [breaking-change] for many uses of slice_patterns.
2016-06-03Auto merge of #33861 - Amanieu:lock_elision_fix, r=alexcrichtonbors-9/+108
Make sure Mutex and RwLock can't be re-locked on the same thread Fixes #33770 r? @alexcrichton
2016-06-02Fix rwlock successfully acquiring a write lock after a read lockAmanieu d'Antras-12/+27
2016-06-02Don't allow pthread_rwlock_t to recursively lock itselfAmanieu d'Antras-9/+52
This is allowed by POSIX and can happen on glibc with processors that support hardware lock elision.
2016-06-02Fix undefined behavior when re-locking a mutex from the same threadAmanieu d'Antras-0/+41
The only applies to pthread mutexes. We solve this by creating the mutex with the PTHREAD_MUTEX_NORMAL type, which guarantees that re-locking from the same thread will deadlock.
2016-06-01Auto merge of #33853 - alexcrichton:remove-deprecated, r=aturonbors-31/+0
std: Clean out old unstable + deprecated APIs These should all have been deprecated for at least one cycle, so this commit cleans them all out.
2016-06-01Auto merge of #33814 - lambda:rtabort-use-platform-abort, r=alexcrichtonbors-9/+17
Open code the __fastfail intrinsic for rtabort! on windows As described https://msdn.microsoft.com/en-us/library/dn774154.aspx This is a Windows 8+ mechanism for terminating the process quickly, which degrades to either an access violation or bugcheck in older versions. I'm not sure this is better the the current mechanism of terminating with an illegal instruction, but we recently converted unix to terminate more correctly with SIGABORT, and this *seems* more correct for windows. [breaking-change]
2016-05-30std: Clean out old unstable + deprecated APIsAlex Crichton-31/+0
These should all have been deprecated for at least one cycle, so this commit cleans them all out.