about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2015-12-05std: Stabilize APIs for the 1.6 releaseAlex Crichton-30/+32
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-12-05Auto merge of #30177 - retep998:handling-threads, r=alexcrichtonbors-0/+89
Allows a `HANDLE` to be extracted from a `JoinHandle` on Windows. Allows a `pthread_t` to be extracted from a `JoinHandle` everywhere else. Because https://github.com/rust-lang/rust/pull/29461 was closed. r? @alexcrichton
2015-12-04Add JoinHandleExt to get the pthread_t on unix platformsPeter Atashian-0/+55
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-12-04AsRawHandle and IntoRawHandle for JoinHandlePeter Atashian-0/+34
This allows users to get the HANDLE of a spawned thread on Windows Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-12-04Fix the time overflow on mac as wellSean Griffin-1/+1
2015-12-02Ensure two `SystemTime`s are equal when nanos add to exactly 1BSean Griffin-1/+1
Currently if you add a duration which should lead to 0 nanos and 1 additional second, we end up with no additional seconds, and 1000000000 nanos.
2015-11-21Auto merge of #29913 - tbu-:pr_windows_path_error_on_nul, r=alexcrichtonbors-30/+37
On Windows: Previously these paths were silently truncated at these NUL characters, now they fail with `ErrorKind::InvalidInput`.
2015-11-21Also check for NULs in environment variablesTobias Bucher-18/+20
This check is necessary, because the underlying API only reads strings until the first NUL.
2015-11-19Auto merge of #29894 - alexcrichton:stdtime, r=brsonbors-94/+506
This commit is an implementation of [RFC 1288][rfc] which adds two new unstable types to the `std::time` module. The `Instant` type is used to represent measurements of a monotonically increasing clock suitable for measuring time withing a process for operations such as benchmarks or just the elapsed time to do something. An `Instant` favors panicking when bugs are found as the bugs are programmer errors rather than typical errors that can be encountered. [rfc]: https://github.com/rust-lang/rfcs/pull/1288 The `SystemTime` type is used to represent a system timestamp and is not monotonic. Very few guarantees are provided about this measurement of the system clock, but a fixed point in time (`UNIX_EPOCH`) is provided to learn about the relative distance from this point for any particular time stamp. This PR takes the same implementation strategy as the `time` crate on crates.io, namely: | Platform | Instant | SystemTime | |------------|--------------------------|--------------------------| | Windows | QueryPerformanceCounter | GetSystemTimeAsFileTime | | OSX | mach_absolute_time | gettimeofday | | Unix | CLOCK_MONOTONIC | CLOCK_REALTIME | These implementations can perhaps be refined over time, but they currently satisfy the requirements of the `Instant` and `SystemTime` types while also being portable across implementations and revisions of each platform. cc #29866
2015-11-19Error when paths contain NUL charactersTobias Bucher-19/+24
On Windows: Previously these paths were silently truncated at these NUL characters, now they fail with `ErrorKind::InvalidInput`.
2015-11-19Re-unignore environment test on MinGWTobias Bucher-1/+1
2015-11-19Ignore malformed environment variables on Windows tooTobias Bucher-15/+24
Leading equals symbols are treated as part of the variable name, if there is no other equality symbol or none at all, the environment string is ignored.
2015-11-19std: Add Instant and SystemTime to std::timeAlex Crichton-94/+506
This commit is an implementation of [RFC 1288][rfc] which adds two new unstable types to the `std::time` module. The `Instant` type is used to represent measurements of a monotonically increasing clock suitable for measuring time withing a process for operations such as benchmarks or just the elapsed time to do something. An `Instant` favors panicking when bugs are found as the bugs are programmer errors rather than typical errors that can be encountered. [rfc]: https://github.com/rust-lang/rfcs/pull/1288 The `SystemTime` type is used to represent a system timestamp and is not monotonic. Very few guarantees are provided about this measurement of the system clock, but a fixed point in time (`UNIX_EPOCH`) is provided to learn about the relative distance from this point for any particular time stamp. This PR takes the same implementation strategy as the `time` crate on crates.io, namely: | Platform | Instant | SystemTime | |------------|--------------------------|--------------------------| | Windows | QueryPerformanceCounter | GetSystemTimeAsFileTime | | OSX | mach_absolute_time | gettimeofday | | Unix | CLOCK_MONOTONIC | CLOCK_REALTIME | These implementations can perhaps be refined over time, but they currently satisfy the requirements of the `Instant` and `SystemTime` types while also being portable across implementations and revisions of each platform.
2015-11-18Fix buildbot failuresVadim Petrochenkov-0/+3
2015-11-18Add missing annotations and some testsVadim Petrochenkov-6/+36
2015-11-17Rollup merge of #29880 - dignati:fix-freebsd-libc, r=alexcrichtonManish Goregaokar-11/+9
With this change the build on FreeBSD is almost working again.
2015-11-17Fix libc module name for FreeBSDOle Krüger-11/+9
2015-11-16Ignore malformed environment strings like glibc doesTobias Bucher-8/+17
Otherwise, the iterator and the functions for getting specific environment variables might disagree, for environments like FOOBAR Variable names starting with equals sign are OK: glibc only interprets equals signs not in the first position as separators between variable name and variable value. Instead of skipping them entirely, a leading equals sign is interpreted to be part of the variable name.
2015-11-09std: Migrate to the new libcAlex Crichton-2203/+1651
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself * Update all references to use `libc` as a result. * Update all references to the new flat namespace. * Moves all windows bindings into sys::c
2015-11-06Auto merge of #29462 - alexcrichton:refactor-process-ret, r=aturonbors-64/+57
* Store the native representation directly in the `ExitStatus` structure instead of a "parsed version" (mostly for Unix). * On Windows, be more robust against processes exiting with the status of 259. Unfortunately this exit code corresponds to `STILL_ACTIVE`, causing libstd to think the process was still alive, causing an infinite loop. Instead the loop is removed altogether and `WaitForSingleObject` is used to wait for the process to exit.
2015-11-06std: Refactor process exit code handling slightlyAlex Crichton-64/+57
* Store the native representation directly in the `ExitStatus` structure instead of a "parsed version" (mostly for Unix). * On Windows, be more robust against processes exiting with the status of 259. Unfortunately this exit code corresponds to `STILL_ACTIVE`, causing libstd to think the process was still alive, causing an infinite loop. Instead the loop is removed altogether and `WaitForSingleObject` is used to wait for the process to exit.
2015-11-06Auto merge of #29305 - alexcrichton:bad-getenv, r=brsonbors-46/+52
As discovered in #29298, `env::set_var("", "")` will panic, but it turns out that it *also* deadlocks on Unix systems. This happens because if a panic happens while holding the environment lock, we then go try to read RUST_BACKTRACE, grabbing the environment lock, causing a deadlock. Specifically, the changes made here are: * The environment lock is pushed into `std::sys` instead of `std::env`. This also only puts it in the Unix implementation, not Windows where the functions are already threadsafe. * The `std::sys` implementation now returns `io::Result` so panics are explicitly at the `std::env` level.
2015-11-02Auto merge of #29510 - mneumann:dragonfly-guard-page, r=alexcrichtonbors-0/+4
Only tested on DragonFly.
2015-11-01Use guard-pages also on DragonFly/FreeBSD.Michael Neumann-0/+4
Only tested on DragonFly.
2015-11-01Auto merge of #29177 - vadimcn:rtstuff, r=alexcrichtonbors-55/+82
Note: for now, this change only affects `-windows-gnu` builds. So why was this `libgcc` dylib dependency needed in the first place? The stack unwinder needs to know about locations of unwind tables of all the modules loaded in the current process. The easiest portable way of achieving this is to have each module register itself with the unwinder when loaded into the process. All modules compiled by GCC do this by calling the __register_frame_info() in their startup code (that's `crtbegin.o` and `crtend.o`, which are automatically linked into any gcc output). Another important piece is that there should be only one copy of the unwinder (and thus unwind tables registry) in the process. This pretty much means that the unwinder must be in a shared library (unless everything is statically linked). Now, Rust compiler tries very hard to make sure that any given Rust crate appears in the final output just once. So if we link the unwinder statically to one of Rust's crates, everything should be fine. Unfortunately, GCC startup objects are built under assumption that `libgcc` is the one true place for the unwind info registry, so I couldn't find any better way than to replace them. So out go `crtbegin`/`crtend`, in come `rsbegin`/`rsend`! A side benefit of this change is that rustc is now more in control of the command line that goes to the linker, so we could stop using `gcc` as the linker driver and just invoke `ld` directly.
2015-10-31Fix stage0 ICE caused by the old _Unwind_Resume override trickery.Vadim Chugunov-0/+2
2015-10-29Auto merge of #29289 - DiamondLovesYou:pnacl-std-crates, r=alexcrichtonbors-59/+175
2015-10-28Port the standard crates to PNaCl/NaCl.Richard Diamond-59/+175
2015-10-26std: Slightly more robust env var handlingAlex Crichton-46/+52
As discovered in #29298, `env::set_var("", "")` will panic, but it turns out that it *also* deadlocks on Unix systems. This happens because if a panic happens while holding the environment lock, we then go try to read RUST_BACKTRACE, grabbing the environment lock, causing a deadlock. Specifically, the changes made here are: * The environment lock is pushed into `std::sys` instead of `std::env`. This also only puts it in the Unix implementation, not Windows where the functions are already threadsafe. * The `std::sys` implementation now returns `io::Result` so panics are explicitly at the `std::env` level. The panic messages have also been improved in these situations.
2015-10-25Auto merge of #29254 - alexcrichton:stabilize-1.5, r=brsonbors-8/+15
This commit stabilizes and deprecates library APIs whose FCP has closed in the last cycle, specifically: Stabilized APIs: * `fs::canonicalize` * `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists, is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait. * `Formatter::fill` * `Formatter::width` * `Formatter::precision` * `Formatter::sign_plus` * `Formatter::sign_minus` * `Formatter::alternate` * `Formatter::sign_aware_zero_pad` * `string::ParseError` * `Utf8Error::valid_up_to` * `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}` * `<[T]>::split_{first,last}{,_mut}` * `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated but will be once 1.5 is released. * `str::{R,}MatchIndices` * `str::{r,}match_indices` * `char::from_u32_unchecked` * `VecDeque::insert` * `VecDeque::shrink_to_fit` * `VecDeque::as_slices` * `VecDeque::as_mut_slices` * `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`) * `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`) * `Vec::resize` * `str::slice_mut_unchecked` * `FileTypeExt` * `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}` * `BinaryHeap::from` - `from_vec` deprecated in favor of this * `BinaryHeap::into_vec` - plus a `Into` impl * `BinaryHeap::into_sorted_vec` Deprecated APIs * `slice::ref_slice` * `slice::mut_ref_slice` * `iter::{range_inclusive, RangeInclusive}` * `std::dynamic_lib` Closes #27706 Closes #27725 cc #27726 (align not stabilized yet) Closes #27734 Closes #27737 Closes #27742 Closes #27743 Closes #27772 Closes #27774 Closes #27777 Closes #27781 cc #27788 (a few remaining methods though) Closes #27790 Closes #27793 Closes #27796 Closes #27810 cc #28147 (not all parts stabilized)
2015-10-25std: Stabilize library APIs for 1.5Alex Crichton-8/+15
This commit stabilizes and deprecates library APIs whose FCP has closed in the last cycle, specifically: Stabilized APIs: * `fs::canonicalize` * `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists, is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait. * `Formatter::fill` * `Formatter::width` * `Formatter::precision` * `Formatter::sign_plus` * `Formatter::sign_minus` * `Formatter::alternate` * `Formatter::sign_aware_zero_pad` * `string::ParseError` * `Utf8Error::valid_up_to` * `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}` * `<[T]>::split_{first,last}{,_mut}` * `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated but will be once 1.5 is released. * `str::{R,}MatchIndices` * `str::{r,}match_indices` * `char::from_u32_unchecked` * `VecDeque::insert` * `VecDeque::shrink_to_fit` * `VecDeque::as_slices` * `VecDeque::as_mut_slices` * `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`) * `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`) * `Vec::resize` * `str::slice_mut_unchecked` * `FileTypeExt` * `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}` * `BinaryHeap::from` - `from_vec` deprecated in favor of this * `BinaryHeap::into_vec` - plus a `Into` impl * `BinaryHeap::into_sorted_vec` Deprecated APIs * `slice::ref_slice` * `slice::mut_ref_slice` * `iter::{range_inclusive, RangeInclusive}` * `std::dynamic_lib` Closes #27706 Closes #27725 cc #27726 (align not stabilized yet) Closes #27734 Closes #27737 Closes #27742 Closes #27743 Closes #27772 Closes #27774 Closes #27777 Closes #27781 cc #27788 (a few remaining methods though) Closes #27790 Closes #27793 Closes #27796 Closes #27810 cc #28147 (not all parts stabilized)
2015-10-24Remove bare semicolonsFlorian Hahn-2/+2
2015-10-23Drop `advapi32` and `shell32` from late_link_args.Vadim Chugunov-0/+1
2015-10-21Moar comments.Vadim Chugunov-17/+29
2015-10-19Use `cfg_attr` for switching `link` attrs in libunwind.Vadim Chugunov-33/+17
2015-10-19Add error kind handling for ERROR_PATH_NOT_FOUNDPeter Atashian-0/+3
Fixes #29150 Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-10-18Create entry points for unwind frame registry in libstd.Vadim Chugunov-0/+25
2015-10-18Implement `eh_unwind_resume` in libstd.Vadim Chugunov-9/+12
2015-10-15Auto merge of #29021 - ogham:master, r=alexcrichtonbors-0/+3
This commit adds `#[derive(Clone)]` to `std::fs::Metadata`, making that struct cloneable. Although the exact contents of that struct differ between OSes, they all have it contain only value types, meaning that the data can be re-used without repercussions. It also adds `#[derive(Clone)]` to every type used by that struct across all OSes, including the various Unix `stat` structs and Windows's `WIN32_FILE_ATTRIBUTE_DATA`. This stems from my comment here: https://github.com/rust-lang/rfcs/issues/939#issuecomment-140524439
2015-10-14Remove unnecessary parentheses around range expressionsAndrew Paseltiner-1/+1
2015-10-13Make the Metadata struct CloneBen S-0/+3
This commit adds #[derive(Clone)] to std::fs::Metadata, making that struct cloneable. Although the exact contents of that struct differ between OSes, they all have it contain only value types, meaning that the data can be re-used without repercussions. It also adds #[derive(Clone)] to every type used by that struct across all OSes, including the various Unix `stat` structs and Windows's `WIN32_FILE_ATTRIBUTE_DATA`.
2015-10-12Don't use a Vec in os::current_exe on FreeBSD.Peter Marheine-4/+4
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-7/+7
2015-10-05Auto merge of #28717 - nagisa:optional-no-landing-pads, r=alexcrichtonbors-1/+11
Part of #28710 Landing pads during stage0 are now enabled by defaullt. Since this has its downsides and upsides either way, I made it possible to change the option through configure.
2015-10-05Fix MSVC stage0 with landing pads enabledSimonas Kazlauskas-1/+11
2015-09-30Auto merge of #28729 - retep998:canonical-dir, r=alexcrichtonbors-0/+2
cc https://github.com/rust-lang/rust/issues/27706
2015-09-29Tweak Travis to use GCEAlex Crichton-11/+22
Travis CI has new infrastructure using the Google Compute Engine which has both faster CPUs and more memory, and we've been encouraged to switch as it should help our build times! The only downside currently, however, is that IPv6 is disabled, causing a number of standard library tests to fail. Consequently this commit tweaks our travis config in a few ways: * ccache is disabled as it's not working on GCE just yet * Docker is used to run tests inside which reportedly will get IPv6 working * A system LLVM installation is used instead of building LLVM itself. This is primarily done to reduce build times, but we want automation for this sort of behavior anyway and we can extend this in the future with building from source as well if needed. * gcc-specific logic is removed as the docker image for Ubuntu gives us a recent-enough gcc by default.
2015-09-29Make fs::canonicalize work on directories on WindowsPeter Atashian-0/+2
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-09-26Add support for the rumprun unikernelSebastian Wicki-5/+13
For most parts, rumprun currently looks like NetBSD, as they share the same libc and drivers. However, being a unikernel, rumprun does not support process management, signals or virtual memory, so related functions might fail at runtime. Stack guards are disabled exactly for this reason. Code for rumprun is always cross-compiled, it uses always static linking and needs a custom linker.
2015-09-24Explicitly count the number of panicsAndrea Canciani-18/+4
Move the panic handling logic from the `unwind` module to `panicking` and use a panic counter to distinguish between normal state, panics and double panics.