about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-02-18Spellcheck library docs.Huon Wilson-7/+6
2014-02-16Allow configuration of uid/gid/detach on processesAlex Crichton-31/+138
This just copies the libuv implementation for libnative which seems reasonable enough (uid/gid fail on windows). Closes #12082
2014-02-16auto merge of #12313 : bjz/rust/tuple, r=huonwbors-289/+179
This renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters. It also removes the `CloneableTuple` and `ImmutableTuple` traits.
2014-02-17Remove CloneableTuple and ImmutableTuple traitsBrendan Zabarauskas-81/+5
These are adequately covered by the Tuple2 trait.
2014-02-17Improve naming of tuple getters, and add mutable tuple getterBrendan Zabarauskas-125/+128
Renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters.
2014-02-16Merge ImmutableTuple* traits into their respective Tuple* traitBrendan Zabarauskas-38/+16
2014-02-16Delegate ToStr implementation to Show for tuplesBrendan Zabarauskas-48/+7
2014-02-16Implement Show for 1-12 element tuplesBrendan Zabarauskas-0/+26
2014-02-15auto merge of #12302 : alexcrichton/rust/issue-12295, r=brsonbors-10/+28
The previous code erroneously assumed that 'steals > cnt' was always true, but that was a false assumption. The code was altered to decrement steals to a minimum of 0 instead of taking all of cnt into account. I didn't include the exact test from #12295 because it could run for quite awhile, and instead set the threshold for MAX_STEALS to much lower during testing. I found that this triggered the old bug quite frequently when running without this fix. Closes #12295
2014-02-15auto merge of #12299 : sfackler/rust/limit-return, r=alexcrichtonbors-2/+24
This is useful in contexts like this: ```rust let size = rdr.read_be_i32() as uint; let mut limit = LimitReader::new(rdr.by_ref(), size); let thing = read_a_thing(&mut limit); assert!(limit.limit() == 0); ```
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-52/+80
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-15Correctly reset steals when hitting MAX_STEALSAlex Crichton-7/+28
The previous code erroneously assumed that 'steals > cnt' was always true, but that was a false assumption. The code was altered to decrement steals to a minimum of 0 instead of taking all of cnt into account. I didn't include the exact test from #12295 because it could run for quite awhile, and instead set the threshold for MAX_STEALS to much lower during testing. I found that this triggered the old bug quite frequently when running without this fix. Closes #12295
2014-02-15Silence some unused import warningsAlex Crichton-3/+0
2014-02-15auto merge of #12235 : huonw/rust/raii-lock, r=alexcrichtonbors-146/+276
- adds a `LockGuard` type returned by `.lock` and `.trylock` that unlocks the mutex in the destructor - renames `mutex::Mutex` to `StaticNativeMutex` - adds a `NativeMutex` type with a destructor - removes `LittleLock` - adds `#[must_use]` to `sync::mutex::Guard` to remind people to use it
2014-02-16Convert some unnecessary StaticNativeMutexes to NativeMutexes.Huon Wilson-4/+3
2014-02-16std::unstable::mutex: streamline & clarify documentation.Huon Wilson-26/+37
2014-02-16std: add a NativeMutex type as a wrapper to destroy StaticNativeMutex.Huon Wilson-65/+107
This obsoletes LittleLock, and so it is removed.
2014-02-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-45/+49
This better reflects its purpose and design.
2014-02-16std: add tests for the _noguard lock/signal/wait methods on Mutex.Huon Wilson-2/+28
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-57/+105
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-15Add a method to LimitReader to return the limitSteven Fackler-2/+24
This is useful in contexts like this: let size = rdr.read_be_i32() as uint; let mut limit = LimitReader::new(rdr.by_ref(), size); let thing = read_a_thing(&mut limit); assert!(limit.limit() == 0);
2014-02-15auto merge of #12272 : alexcrichton/rust/snapshot, r=kballardbors-28/+10
This notably contains the `extern mod` => `extern crate` change. Closes #9880
2014-02-15auto merge of #12282 : cmr/rust/cleanup-ptr, r=huonwbors-142/+108
2014-02-15impl fmt::Pointer for &T and &mut TCorey Richardson-1/+11
2014-02-15std: clean up ptr a bitCorey Richardson-141/+97
2014-02-15auto merge of #12283 : kballard/rust/env-args-bytes, r=ericktbors-42/+148
Change `os::args()` and `os::env()` to use `str::from_utf8_lossy()`. Add new functions `os::args_as_bytes()` and `os::env_as_bytes()` to retrieve the args/env as byte vectors instead. The existing methods were left returning strings because I expect that the common use-case is to want string handling. Fixes #7188.
2014-02-14Fix all code examplesAlex Crichton-52/+80
2014-02-14extern mod => extern crateAlex Crichton-6/+6
This was previously implemented, and it just needed a snapshot to go through
2014-02-14Register new snapshotsAlex Crichton-22/+4
This enables the parser error for `extern mod` => `extern crate` transitions.
2014-02-15Update LimitReader to take the Reader to wrap by valuePalmer Cox-7/+8
2014-02-15Create RefReader and RefWriter adaptor structsPalmer Cox-0/+33
RefReader and RefWriter allow a caller to pass a Reader or Writer instance by reference to generic functions that are expecting arguments by value.
2014-02-14Use str::from_utf8_lossy() for os::env() and friendsKevin Ballard-11/+60
Parse the environment by default with from_utf8_lossy. Also provide byte-vector equivalents (e.g. os::env_as_bytes()). Unfortunately, setenv() can't have a byte-vector equivalent because of Windows support, unless we want to define a setenv_bytes() that fails under Windows for non-UTF8 (or non-UTF16).
2014-02-14Use str::from_utf8_lossy() in os::args(), add os::args_as_bytes()Kevin Ballard-25/+50
os::args() was using str::raw::from_c_str(), which would assert if the C-string wasn't valid UTF-8. Switch to using from_utf8_lossy() instead, and add a separate function os::args_as_bytes() that returns the ~[u8] byte-vectors instead.
2014-02-14Add c_str::CString.as_bytes_no_nul()Kevin Ballard-6/+38
2014-02-14auto merge of #12276 : alexcrichton/rust/issue-8449, r=kballardbors-5/+1
This was just waiting for compiler-rt support, which was added in #12027 Closes #8449
2014-02-14Enable 64-bit checked multiplication on 32-bitAlex Crichton-5/+1
This was just waiting for compiler-rt support, which was added in #12027 Closes #8449
2014-02-14auto merge of #12267 : alexcrichton/rust/rollup, r=alexcrichtonbors-21/+30
The last commit has the closed PRs
2014-02-14Invoke gcc with -nodefaultlibsAlex Crichton-1/+13
This will hopefully bring us closer to #11937. We're still using gcc's idea of "startup files", but this should prevent us from leaking in dependencies that we don't quite want (libgcc for example once compiler-rt is what we use).
2014-02-14extra: Capture stdout/stderr of tests by defaultAlex Crichton-0/+6
When tests fail, their stdout and stderr is printed as part of the summary, but this helps suppress failure messages from #[should_fail] tests and generally clean up the output of the test runner.
2014-02-14return value/use extra::test::black_box in benchmarkslpy-21/+24
2014-02-14auto merge of #12186 : alexcrichton/rust/no-sleep-2, r=brsonbors-0/+1
Any single-threaded task benchmark will spend a good chunk of time in `kqueue()` on osx and `epoll()` on linux, and the reason for this is that each time a task is terminated it will hit the syscall. When a task terminates, it context switches back to the scheduler thread, and the scheduler thread falls out of `run_sched_once` whenever it figures out that it did some work. If we know that `epoll()` will return nothing, then we can continue to do work locally (only while there's work to be done). We must fall back to `epoll()` whenever there's active I/O in order to check whether it's ready or not, but without that (which is largely the case in benchmarks), we can prevent the costly syscall and can get a nice speedup. I've separated the commits into preparation for this change and then the change itself, the last commit message has more details.
2014-02-13auto merge of #12172 : alexcrichton/rust/green-improvements, r=brsonbors-11/+26
These commits pick off some low-hanging fruit which were slowing down spawning green threads. The major speedup comes from fixing a bug in stack caching where we never used any cached stacks! The program I used to benchmark is at the end. It was compiled with `rustc --opt-level=3 bench.rs --test` and run as `RUST_THREADS=1 ./bench --bench`. I chose to use `RUST_THREADS=1` due to #11730 as the profiles I was getting interfered too much when all the schedulers were in play (and shouldn't be after #11730 is fixed). All of the units below are in ns/iter as reported by `--bench` (lower is better). | | green | native | raw | | ------------- | ----- | ------ | ------ | | osx before | 12699 | 24030 | 19734 | | linux before | 10223 | 125983 | 122647 | | osx after | 3847 | 25771 | 20835 | | linux after | 2631 | 135398 | 122765 | Note that this is *not* a benchmark of spawning green tasks vs native tasks. I put in the native numbers just to get a ballpark of where green tasks are. This is benchmark is *clearly* benefiting from stack caching. Also, OSX is clearly not 5x faster than linux, I think my VM is just much slower. All in all, this ended up being a nice 4x speedup for spawning a green task when you're using a cached stack. ```rust extern mod extra; extern mod native; use std::rt::thread::Thread; #[bench] fn green(bh: &mut extra::test::BenchHarness) { let (p, c) = SharedChan::new(); bh.iter(|| { let c = c.clone(); spawn(proc() { c.send(()); }); p.recv(); }); } #[bench] fn native(bh: &mut extra::test::BenchHarness) { let (p, c) = SharedChan::new(); bh.iter(|| { let c = c.clone(); native::task::spawn(proc() { c.send(()); }); p.recv(); }); } #[bench] fn raw(bh: &mut extra::test::BenchHarness) { bh.iter(|| { Thread::start(proc() {}).join() }); } ```
2014-02-13Remove two allocations from spawning a green taskAlex Crichton-0/+6
Two unfortunate allocations were wrapping a proc() in a proc() with GreenTask::build_start_wrapper, and then boxing this proc in a ~proc() inside of Context::new(). Both of these allocations were a direct result from two conditions: 1. The Context::new() function has a nice api of taking a procedure argument to start up a new context with. This inherently required an allocation by build_start_wrapper because extra code needed to be run around the edges of a user-provided proc() for a new task. 2. The initial bootstrap code only understood how to pass one argument to the next function. By modifying the assembly and entry points to understand more than one argument, more information is passed through in registers instead of allocating a pointer-sized context. This is sadly where I end up throwing mips under a bus because I have no idea what's going on in the mips context switching code and don't know how to modify it. Closes #7767 cc #11389
2014-02-13Don't require an allocation for on_exit messagesAlex Crichton-4/+12
Instead, use an enum to allow running both a procedure and sending the task result over a channel. I expect the common case to be sending on a channel (e.g. task::try), so don't require an extra allocation in the common case. cc #11389
2014-02-13Don't allocate in LocalHeap::new()Alex Crichton-7/+8
One of these is allocated for every task, trying to cut down on allocations cc #11389
2014-02-13Removed num::OrderableMichael Darakananda-215/+10
2014-02-13Rebase conflicts from this giant stack of patchesAlex Crichton-3/+3
List of PRs contained in this rollup: Closes #12167 r=alexcrichton Closes #12200 r=alexcrichton Closes #12206 r=pcwalton Closes #12209 r=huonw Closes #12211 r=pcwalton Closes #12217 r=brson Closes #12218 r=alexcrichton Closes #12220 r=alexcrichton Closes #12222 r=kballard Closes #12225 r=alexcrichton Closes #12227 r=kballard Closes #12237 r=alexcrichton Closes #12240 r=kballard
2014-02-13Lift $dst outside the closure in write!Alex Crichton-6/+8
If you were writing to something along the lines of `self.foo` then with the new closure rules it meant that you were borrowing `self` for the entirety of the closure, meaning that you couldn't format other fields of `self` at the same time as writing to a buffer contained in `self`. By lifting the borrow outside of the closure the borrow checker can better understand that you're only borrowing one of the fields at a time. This had to use type ascription as well in order to preserve trait object coercions.
2014-02-13remove duplicate function from std::ptr (is_null, is_not_null, offset, ↵JeremyLetang-82/+59
mut_offset)
2014-02-13Register new snapshotsAlex Crichton-186/+1