summary refs log tree commit diff
path: root/src/libstd/sys/unix
AgeCommit message (Collapse)AuthorLines
2016-08-22std: Stabilize APIs for the 1.12 releaseAlex Crichton-1/+1
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-14Rollup merge of #35574 - badboy:emscripten-test-fixes, r=brsonEduard-Mihai Burtescu-8/+9
Emscripten test fixes This picks up parts of #31623 to disable certain tests that emscripten can't run, as threads/processes are not supported. I re-applied @tomaka's changes manually, I can rebase those commits with his credentials if he wants. It also disables jemalloc for emscripten (at least in Rustbuild, I have to check if there is another setting for the same thing in the old makefile approach). This should not impact anything for normal builds.
2016-08-10Clarify std::os::unix::net::SocketAddr::is_unnamed's docstringPietro Albini-1/+1
2016-08-10Fix docs typo in std::os::unix::net::SocketAddr::is_unnamedPietro Albini-1/+1
2016-08-10[emscripten] Disable code paths that don't work on emscriptenJan-Erik Rediger-8/+9
2016-08-09Auto merge of #35426 - frewsxcv:os-sys-env-args-phantoms, r=alexcrichtonbors-6/+7
Utilize `PhantomData` to enforce `!Sync` and `!Send` field. None
2016-08-07Rollup merge of #35433 - mneumann:dragonfly-fix-libstd-errno-location, ↵Jonathan Turner-0/+1
r=alexcrichton Fix build on DragonFly (unused function errno_location) Function errno_location() is not used on DragonFly. As warnings are errors, this breaks the build.
2016-08-07Utilize `PhantomData` to enforce `!Sync` and `!Send` field.Corey Farwell-6/+7
2016-08-06Auto merge of #35378 - Amanieu:rwlock_eagain, r=alexcrichtonbors-1/+3
Handle RwLock reader count overflow `pthread_rwlock_rdlock` may return `EAGAIN` if the maximum reader count overflows. We shouldn't return a successful lock in that case.
2016-08-06Fix build on DragonFly (unused function errno_location)Michael Neumann-0/+1
Function errno_location() is not used on DragonFly. As warnings are errors, this breaks the build.
2016-08-06Rollup merge of #34916 - tbu-:pr_comment_on_seek_cast, r=GuillaumeGomezEduard-Mihai Burtescu-4/+6
Comment on the casts in the `seek` implementations on files
2016-08-05Handle RwLock reader count overflowAmanieu d'Antras-1/+3
2016-08-05Comment on the casts in the `seek` implementations on filesTobias Bucher-4/+6
2016-07-30Auto merge of #35051 - japaric:backtrace, r=alexcrichtonbors-0/+1
rustbuild: make backtraces (RUST_BACKTRACE) optional 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 --- r? @alexcrichton cc rust-lang/rfcs#1417
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-27Auto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichtonbors-0/+4
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-1/+1
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/+1
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-0/+4
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-12/+15
Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`
2016-07-13Auto merge of #34776 - cuviper:solaris-readdir, r=alexcrichtonbors-18/+32
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-12Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`Tobias Bucher-12/+15
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 `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-10Derive Debug on FileType.Martin Pool-1/+1
Partially fixes #32054
2016-07-03std: Stabilize APIs for the 1.11.0 releaseAlex Crichton-6/+19
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-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 #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-21Fix overflow error in thread::sleepGuillaume Gomez-6/+15
2016-06-03Auto merge of #33861 - Amanieu:lock_elision_fix, r=alexcrichtonbors-9/+100
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/+33
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-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.
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-274/+271
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-09Auto merge of #32900 - alexcrichton:panic2abort, r=nikomatsakisbors-123/+1
rustc: Implement custom panic runtimes This commit is an implementation of [RFC 1513] which allows applications to alter the behavior of panics at compile time. A new compiler flag, `-C panic`, is added and accepts the values `unwind` or `panic`, with the default being `unwind`. This model affects how code is generated for the local crate, skipping generation of landing pads with `-C panic=abort`. [RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md Panic implementations are then provided by crates tagged with `#![panic_runtime]` and lazily required by crates with `#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic runtime must match the final product, and if the panic strategy is not `abort` then the entire DAG must have the same panic strategy. With the `-C panic=abort` strategy, users can expect a stable method to disable generation of landing pads, improving optimization in niche scenarios, decreasing compile time, and decreasing output binary size. With the `-C panic=unwind` strategy users can expect the existing ability to isolate failure in Rust code from the outside world. Organizationally, this commit dismantles the `sys_common::unwind` module in favor of some bits moving part of it to `libpanic_unwind` and the rest into the `panicking` module in libstd. The custom panic runtime support is pretty similar to the custom allocator support with the only major difference being how the panic runtime is injected (takes the `-C panic` flag into account). Closes #32837
2016-05-09Auto merge of #33224 - alexcrichton:create-exit-status, r=aturonbors-0/+15
std: Allow creating ExitStatus from raw values Sometimes a process may be waited on externally from the standard library, in which case it can be useful to create a raw `ExitStatus` structure to return. This commit extends the existing Unix `ExitStatusExt` extension trait and adds a new Windows-specific `ExitStatusExt` extension trait to do this. The methods are currently called `ExitStatus::from_raw`. cc #32713
2016-05-09rustc: Implement custom panic runtimesAlex Crichton-123/+1
This commit is an implementation of [RFC 1513] which allows applications to alter the behavior of panics at compile time. A new compiler flag, `-C panic`, is added and accepts the values `unwind` or `panic`, with the default being `unwind`. This model affects how code is generated for the local crate, skipping generation of landing pads with `-C panic=abort`. [RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md Panic implementations are then provided by crates tagged with `#![panic_runtime]` and lazily required by crates with `#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic runtime must match the final product, and if the panic strategy is not `abort` then the entire DAG must have the same panic strategy. With the `-C panic=abort` strategy, users can expect a stable method to disable generation of landing pads, improving optimization in niche scenarios, decreasing compile time, and decreasing output binary size. With the `-C panic=unwind` strategy users can expect the existing ability to isolate failure in Rust code from the outside world. Organizationally, this commit dismantles the `sys_common::unwind` module in favor of some bits moving part of it to `libpanic_unwind` and the rest into the `panicking` module in libstd. The custom panic runtime support is pretty similar to the custom allocator support with the only major difference being how the panic runtime is injected (takes the `-C panic` flag into account).
2016-05-07Rollup merge of #33438 - birkenfeld:dup-words, r=steveklabnikSteve Klabnik-1/+1
Fix some some duplicate words.
2016-05-06Auto merge of #33086 - cardoe:non-blocking-rand-read, r=alexcrichtonbors-1/+16
rand: don't block before random pool is initialized If we attempt a read with getrandom() on Linux the syscall can block before the random pool is initialized unless the GRND_NONBLOCK flag is passed. This flag causes getrandom() to instead return EAGAIN while the pool is uninitialized. To avoid downstream users of crate or std functionality that have no ability to avoid this blocking behavior this change causes Rust to read bytes from /dev/urandom while getrandom() would block and once getrandom() is available to use that. Fixes #32953. Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
2016-05-05Fix some some duplicate words.Georg Brandl-1/+1