about summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2014-07-03Fix spelling errors.Joseph Crail-1/+1
2014-06-30libstd: set baseline stability levels.Aaron Turon-0/+2
Earlier commits have established a baseline of `experimental` stability for all crates under the facade (so their contents are considered experimental within libstd). Since `experimental` is `allow` by default, we should use the same baseline stability for libstd itself. This commit adds `experimental` tags to all of the modules defined in `std`, and `unstable` to `std` itself.
2014-06-28Rename all raw pointers as necessaryAlex Crichton-42/+45
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-1/+1
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-16Move `num_cpus` from `std::rt::util` to `std::os`. Closes #14707Jorge Aparicio-13/+1
2014-06-16auto merge of #14715 : vhbit/rust/ios-pr2, r=alexcrichtonbors-8/+57
2014-06-13Rolling up PRs in the queueAlex Crichton-4/+4
Closes #14797 (librustc: Fix the issue with labels shadowing variable names by making) Closes #14823 (Improve error messages for io::fs) Closes #14827 (libsyntax: Allow `+` to separate trait bounds from objects.) Closes #14834 (configure: Don't sync unused submodules) Closes #14838 (Remove typo on collections::treemap::UnionItems) Closes #14839 (Fix the unused struct field lint for struct variants) Closes #14840 (Clarify `Any` docs) Closes #14846 (rustc: [T, ..N] and [T, ..N+1] are not the same) Closes #14847 (Audit usage of NativeMutex) Closes #14850 (remove unnecessary PaX detection) Closes #14856 (librustc: Take in account mutability when casting array to raw ptr.) Closes #14859 (librustc: Forbid `transmute` from being called on types whose size is) Closes #14860 (Fix `quote_pat!` & parse outer attributes in `quote_item!`)
2014-06-13Cosmetic fixes & commentsValerii Hiora-3/+8
2014-06-12Basic iOS supportValerii Hiora-8/+52
2014-06-11sync: Move underneath libstdAlex Crichton-352/+1
This commit is the final step in the libstd facade, #13851. The purpose of this commit is to move libsync underneath the standard library, behind the facade. This will allow core primitives like channels, queues, and atomics to all live in the same location. There were a few notable changes and a few breaking changes as part of this movement: * The `Vec` and `String` types are reexported at the top level of libcollections * The `unreachable!()` macro was copied to libcore * The `std::rt::thread` module was moved to librustrt, but it is still reexported at the same location. * The `std::comm` module was moved to libsync * The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`. It is now a private module with types/functions being reexported under `sync::comm`. This is a breaking change for any existing users of duplex streams. * All concurrent queues/deques were moved directly under libsync. They are also all marked with #![experimental] for now if they are public. * The `task_pool` and `future` modules no longer live in libsync, but rather live under `std::sync`. They will forever live at this location, but they may move to libsync if the `std::task` module moves as well. [breaking-change]
2014-06-10auto merge of #14696 : jakub-/rust/dead-struct-fields, r=alexcrichtonbors-0/+1
This uncovered some dead code, most notably in middle/liveness.rs, which I think suggests there must be something fishy with that part of the code. The #[allow(dead_code)] annotations on some of the fields I am not super happy about but as I understand, marker type may disappear at some point.
2014-06-09std: Move dynamic_lib from std::unstable to stdBrian Anderson-1/+1
This leaves a deprecated reexport in place temporarily. Closes #1457.
2014-06-09core: Move the collections traits to libcollectionsAlex Crichton-1/+1
This commit moves Mutable, Map, MutableMap, Set, and MutableSet from `core::collections` to the `collections` crate at the top-level. Additionally, this removes the `deque` module and moves the `Deque` trait to only being available at the top-level of the collections crate. All functionality continues to be reexported through `std::collections`. [breaking-change]
2014-06-08core: Rename `container` mod to `collections`. Closes #12543Brian Anderson-2/+2
Also renames the `Container` trait to `Collection`. [breaking-change]
2014-06-08Fix spelling errors in comments.Joseph Crail-1/+1
2014-06-08Remove the dead code identified by the new lintJakub Wieczorek-0/+1
2014-06-06libs: Fix miscellaneous fallout of librustrtAlex Crichton-5/+6
2014-06-06std: Extract librustrt out of libstdAlex Crichton-3450/+143
As part of the libstd facade efforts, this commit extracts the runtime interface out of the standard library into a standalone crate, librustrt. This crate will provide the following services: * Definition of the rtio interface * Definition of the Runtime interface * Implementation of the Task structure * Implementation of task-local-data * Implementation of task failure via unwinding via libunwind * Implementation of runtime initialization and shutdown * Implementation of thread-local-storage for the local rust Task Notably, this crate avoids the following services: * Thread creation and destruction. The crate does not require the knowledge of an OS threading system, and as a result it seemed best to leave out the `rt::thread` module from librustrt. The librustrt module does depend on mutexes, however. * Implementation of backtraces. There is no inherent requirement for the runtime to be able to generate backtraces. As will be discussed later, this functionality continues to live in libstd rather than librustrt. As usual, a number of architectural changes were required to make this crate possible. Users of "stable" functionality will not be impacted by this change, but users of the `std::rt` module will likely note the changes. A list of architectural changes made is: * The stdout/stderr handles no longer live directly inside of the `Task` structure. This is a consequence of librustrt not knowing about `std::io`. These two handles are now stored inside of task-local-data. The handles were originally stored inside of the `Task` for perf reasons, and TLD is not currently as fast as it could be. For comparison, 100k prints goes from 59ms to 68ms (a 15% slowdown). This appeared to me to be an acceptable perf loss for the successful extraction of a librustrt crate. * The `rtio` module was forced to duplicate more functionality of `std::io`. As the module no longer depends on `std::io`, `rtio` now defines structures such as socket addresses, addrinfo fiddly bits, etc. The primary change made was that `rtio` now defines its own `IoError` type. This type is distinct from `std::io::IoError` in that it does not have an enum for what error occurred, but rather a platform-specific error code. The native and green libraries will be updated in later commits for this change, and the bulk of this effort was put behind updating the two libraries for this change (with `rtio`). * Printing a message on task failure (along with the backtrace) continues to live in libstd, not in librustrt. This is a consequence of the above decision to move the stdout/stderr handles to TLD rather than inside the `Task` itself. The unwinding API now supports registration of global callback functions which will be invoked when a task fails, allowing for libstd to register a function to print a message and a backtrace. The API for registering a callback is experimental and unsafe, as the ramifications of running code on unwinding is pretty hairy. * The `std::unstable::mutex` module has moved to `std::rt::mutex`. * The `std::unstable::sync` module has been moved to `std::rt::exclusive` and the type has been rewritten to not internally have an Arc and to have an RAII guard structure when locking. Old code should stop using `Exclusive` in favor of the primitives in `libsync`, but if necessary, old code should port to `Arc<Exclusive<T>>`. * The local heap has been stripped down to have fewer debugging options. None of these were tested, and none of these have been used in a very long time. [breaking-change]
2014-06-06rtio: Remove usage of `Path`Alex Crichton-3/+2
The rtio interface is a thin low-level interface over the I/O subsystems, and the `Path` type is a little too high-level for this interface.
2014-06-06rtio: Remove unused stuctAlex Crichton-12/+0
2014-06-06Test fixes from the rollupAlex Crichton-1/+0
2014-06-06Rename Iterator::len to countAaron Turon-1/+1
This commit carries out the request from issue #14678: > The method `Iterator::len()` is surprising, as all the other uses of > `len()` do not consume the value. `len()` would make more sense to be > called `count()`, but that would collide with the current > `Iterator::count(|T| -> bool) -> unit` method. That method, however, is > a bit redundant, and can be easily replaced with > `iter.filter(|x| x < 5).count()`. > After this change, we could then define the `len()` method > on `iter::ExactSize`. Closes #14678. [breaking-change]
2014-06-05How about a less cringe-worthy double-failure message?Brian Anderson-3/+1
2014-06-05auto merge of #14644 : alexcrichton/rust/more-no-runtime-use-cases, r=brsonbors-149/+200
A few notable improvements were implemented to cut down on the number of aborts triggered by the standard library when a local task is not found. * Primarily, the unwinding functionality was restructured to support an unsafe top-level function, `try`. This function invokes a closure, capturing any failure which occurs inside of it. The purpose of this function is to be as lightweight of a "try block" as possible for rust, intended for use when the runtime is difficult to set up. This function is *not* meant to be used by normal rust code, nor should it be consider for use with normal rust code. * When invoking spawn(), a `fail!()` is triggered rather than an abort. * When invoking LocalIo::borrow(), which is transitively called by all I/O constructors, None is returned rather than aborting to indicate that there is no local I/O implementation. A test case was also added showing the variety of things that you can do without a runtime or task set up now. In general, this is just a refactoring to abort less quickly in the standard library when a local task is not found.
2014-06-04std: Improve non-task-based usageAlex Crichton-149/+200
A few notable improvements were implemented to cut down on the number of aborts triggered by the standard library when a local task is not found. * Primarily, the unwinding functionality was restructured to support an unsafe top-level function, `try`. This function invokes a closure, capturing any failure which occurs inside of it. The purpose of this function is to be as lightweight of a "try block" as possible for rust, intended for use when the runtime is difficult to set up. This function is *not* meant to be used by normal rust code, nor should it be consider for use with normal rust code. * When invoking spawn(), a `fail!()` is triggered rather than an abort. * When invoking LocalIo::borrow(), which is transitively called by all I/O constructors, None is returned rather than aborting to indicate that there is no local I/O implementation. * Invoking get() on a TLD key will return None if no task is available * Invoking replace() on a TLD key will fail if no task is available. A test case was also added showing the variety of things that you can do without a runtime or task set up now. In general, this is just a refactoring to abort less quickly in the standard library when a local task is not found.
2014-06-03std: Remove generics from Option::expectAlex Crichton-1/+1
This commit removes the <M: Any + Send> type parameter from Option::expect in favor of just taking a hard-coded `&str` argument. This allows this function to move into libcore. Previous code using strings with `expect` will continue to work, but code using this implicitly to transmit task failure will need to unwrap manually with a `match` statement. [breaking-change] Closes #14008
2014-05-30Register new snapshotsAlex Crichton-70/+2
2014-05-30windows: Allow snake_case errors for now.Kevin Butler-1/+5
2014-05-28std: Remove format_strbuf!()Alex Crichton-1/+1
This was only ever a transitionary macro.
2014-05-27std: Rename strbuf operations to stringRicho Healey-2/+2
[breaking-change]
2014-05-25De-realstd os::argsKevin Ballard-34/+7
With the test runner using ::std::os::args(), and std::std::os now being a re-export of realstd::os, there's no more need for realstd stuff mucking up rt::args. Remove the one test of os::args(), as it's not very useful and it won't work anymore now that rt::args doesn't use realstd.
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-4/+4
[breaking-change]
2014-05-24auto merge of #14392 : alexcrichton/rust/mem-updates, r=sfacklerbors-2/+2
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-23core: Finish stabilizing the `mem` module.Alex Crichton-2/+2
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-23std: Move unstable::finally to std::finally. #1457Brian Anderson-2/+2
[breaking-change]
2014-05-23std: Move running_on_valgrind to rt::util. #1457Brian Anderson-1/+17
[breaking-change]
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-19/+26
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-12/+19
2014-05-21auto merge of #14301 : alexcrichton/rust/remove-unsafe-arc, r=brsonbors-8/+9
This type can be built with `Arc<Unsafe<T>>` now that liballoc exists.
2014-05-19std: Use Arc instead of UnsafeArc in BlockedTaskAlex Crichton-8/+9
2014-05-19rustc: Add official support for weak failureAlex Crichton-8/+72
This commit is part of the ongoing libstd facade efforts (cc #13851). The compiler now recognizes some language items as "extern { fn foo(...); }" and will automatically perform the following actions: 1. The foreign function has a pre-defined name. 2. The crate and downstream crates can only be built as rlibs until a crate defines the lang item itself. 3. The actual lang item has a pre-defined name. This is essentially nicer compiler support for the hokey core-depends-on-std-failure scheme today, but it is implemented the same way. The details are a little more hidden under the covers. In addition to failure, this commit promotes the eh_personality and rust_stack_exhausted functions to official lang items. The compiler can generate calls to these functions, causing linkage errors if they are left undefined. The checking for these items is not as precise as it could be. Crates compiling with `-Z no-landing-pads` will not need the eh_personality lang item, and crates compiling with no split stacks won't need the stack exhausted lang item. For ease, however, these items are checked for presence in all final outputs of the compiler. It is quite easy to define dummy versions of the functions necessary: #[lang = "stack_exhausted"] extern fn stack_exhausted() { /* ... */ } #[lang = "eh_personality"] extern fn eh_personality() { /* ... */ } cc #11922, rust_stack_exhausted is now a lang item cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-17std: Refactor liballoc out of lib{std,sync}Alex Crichton-272/+4
This commit is part of the libstd facade RFC, issue #13851. This creates a new library, liballoc, which is intended to be the core allocation library for all of Rust. It is pinned on the basic assumption that an allocation failure is an abort or failure. This module has inherited the heap/libc_heap modules from std::rt, the owned/rc modules from std, and the arc module from libsync. These three pointers are currently the three most core pointer implementations in Rust. The UnsafeArc type in std::sync should be considered deprecated and replaced by Arc<Unsafe<T>>. This commit does not currently migrate to this type, but future commits will continue this refactoring.
2014-05-15Updates with core::fmt changesAlex Crichton-4/+5
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15core: Implement unwrap()/unwrap_err() on ResultAlex Crichton-15/+3
Now that std::fmt is in libcore, it's possible to implement this as an inherit method rather than through extension traits. This commit also tweaks the failure interface of libcore to libstd to what it should be, one method taking &fmt::Arguments
2014-05-15std: Remove run_in_bare_threadBrian Anderson-11/+11
2014-05-15use sched_yield on linux and freebsdDaniel Micay-10/+0
pthread_yield is non-standard, while sched_yield is POSIX The Linux documentation recommends using the standard function. This is the only feature we're currently using that's present in glibc but not in musl.
2014-05-14Process::new etc should support non-utf8 commands/argsAaron Turon-2/+57
The existing APIs for spawning processes took strings for the command and arguments, but the underlying system may not impose utf8 encoding, so this is overly limiting. The assumption we actually want to make is just that the command and arguments are viewable as [u8] slices with no interior NULLs, i.e., as CStrings. The ToCStr trait is a handy bound for types that meet this requirement (such as &str and Path). However, since the commands and arguments are often a mixture of strings and paths, it would be inconvenient to take a slice with a single T: ToCStr bound. So this patch revamps the process creation API to instead use a builder-style interface, called `Command`, allowing arguments to be added one at a time with differing ToCStr implementations for each. The initial cut of the builder API has some drawbacks that can be addressed once issue #13851 (libstd as a facade) is closed. These are detailed as FIXMEs. Closes #11650. [breaking-change]
2014-05-13io: Implement process wait timeoutsAlex Crichton-1/+2
This implements set_timeout() for std::io::Process which will affect wait() operations on the process. This follows the same pattern as the rest of the timeouts emerging in std::io::net. The implementation was super easy for everything except libnative on unix (backwards from usual!), which required a good bit of signal handling. There's a doc comment explaining the strategy in libnative. Internally, this also required refactoring the "helper thread" implementation used by libnative to allow for an extra helper thread (not just the timer). This is a breaking change in terms of the io::Process API. It is now possible for wait() to fail, and subsequently wait_with_output(). These two functions now return IoResult<T> due to the fact that they can time out. Additionally, the wait_with_output() function has moved from taking `&mut self` to taking `self`. If a timeout occurs while waiting with output, the semantics are undesirable in almost all cases if attempting to re-wait on the process. Equivalent functionality can still be achieved by dealing with the output handles manually. [breaking-change] cc #13523
2014-05-13std: Move the owned module from core to stdAlex Crichton-2/+1
The compiler was updated to recognize that implementations for ty_uniq(..) are allowed if the Box lang item is located in the current crate. This enforces the idea that libcore cannot allocated, and moves all related trait implementations from libcore to libstd. This is a breaking change in that the AnyOwnExt trait has moved from the any module to the owned module. Any previous users of std::any::AnyOwnExt should now use std::owned::AnyOwnExt instead. This was done because the trait is intended for Box traits and only Box traits. [breaking-change]
2014-05-12Add `stat` method to `std::io::fs::File` to stat without a Path.Yuri Kunde Schlesner-0/+1
The `FileStat` struct contained a `path` field, which was filled by the `stat` and `lstat` function. Since this field isn't in fact returned by the operating system (it was copied from the paths passed to the functions) it was removed, as in the `fstat` case we aren't working with a `Path`, but directly with a fd. If your code used the `path` field of `FileStat` you will now have to manually store the path passed to `stat` along with the returned struct. [breaking-change]