about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-11-17Fixed docs for advance() in Iterator traitAndrei Formiga-6/+3
2013-11-17Fixed uses of get() to unwrap() in doc examples in std::iterAndrei Formiga-28/+28
2013-11-17auto merge of #10466 : alexcrichton/rust/issue-10334, r=cmrbors-102/+157
These commits create a `Buffer` trait in the `io` module which represents an I/O reader which is internally buffered. This abstraction is used to reasonably implement `read_line` and `read_until` along with at least an ok implementation of `read_char` (although I certainly haven't benchmarked `read_char`).
2013-11-16auto merge of #10420 : sanxiyn/rust/path, r=cmrbors-1/+1
Fix #10283.
2013-11-16Implement read_char on the Buffer traitAlex Crichton-0/+43
2013-11-14remove `cast::unsafe_copy`Daniel Micay-8/+0
This is the same functionality as `ptr::read_ptr`.
2013-11-14auto merge of #10428 : toffaletti/rust/try_lock, r=alexcrichtonbors-1/+16
I need try_lock for an algorithm I'm trying to implement in Rust.
2013-11-14test: Fix signal-exit-status on windowsklutzy-0/+1
2013-11-13auto merge of #10457 : alexcrichton/rust/native-io, r=brsonbors-350/+434
This commit re-organizes the io::native module slightly in order to have a working implementation of rtio::IoFactory which uses native implementations. The goal is to seamlessly multiplex among libuv/native implementations wherever necessary. Right now most of the native I/O is unimplemented, but we have existing bindings for file descriptors and processes which have been hooked up. What this means is that you can now invoke println!() from libstd with no local task, no local scheduler, and even without libuv. There's still plenty of work to do on the native I/O factory, but this is the first steps into making it an official portion of the standard library. I don't expect anyone to reach into io::native directly, but rather only std::io primitives will be used. Each std::io interface seamlessly falls back onto the native I/O implementation if the local scheduler doesn't have a libuv one (hurray trait ojects!)
2013-11-13Implement native::IoFactoryAlex Crichton-350/+434
This commit re-organizes the io::native module slightly in order to have a working implementation of rtio::IoFactory which uses native implementations. The goal is to seamlessly multiplex among libuv/native implementations wherever necessary. Right now most of the native I/O is unimplemented, but we have existing bindings for file descriptors and processes which have been hooked up. What this means is that you can now invoke println!() from libstd with no local task, no local scheduler, and even without libuv. There's still plenty of work to do on the native I/O factory, but this is the first steps into making it an official portion of the standard library. I don't expect anyone to reach into io::native directly, but rather only std::io primitives will be used. Each std::io interface seamlessly falls back onto the native I/O implementation if the local scheduler doesn't have a libuv one (hurray trait ojects!)
2013-11-13add rust_trylock_little_lockJason Toffaletti-1/+16
Try to acquire lock and succeed only if lock is not already held. Uses TryEnterCriticalSection or pthread_mutex_trylock.
2013-11-13auto merge of #10451 : zkamsler/rust/buf_writer, r=alexcrichtonbors-10/+99
I implemented BufWriter. I realize the use of conditions are on their way out for IO, but it does raise a condition if a write will not fit in the buffer for now. I also replaced the seek code for MemWriter. It was adding the offset as a uint, which is unsound for negative offsets. It only happened to work because unsigned addition performs the same operation with two's complement, and sizeof(uint) <= sizeof(i64) so there was no (lack of) sign extension. I replaced this with computing an offset as an i64 and clamping to zero. I don't expect anyone will have use BufWriter with a byte buffer greater than 2^63 bytes any time soon. @alexcrichton Closes #10433
2013-11-13Introduce an io::Buffer traitAlex Crichton-102/+114
This trait is meant to abstract whether a reader is actually implemented with an underlying buffer. For all readers which are implemented as such, we can efficiently implement things like read_char, read_line, read_until, etc. There are two required methods for managing the internal buffer, and otherwise read_line and friends can all become default methods. Closes #10334
2013-11-13Implemented BufWriterZach Kamsler-10/+99
Filled in the implementations of Writer and Seek for BufWriter. It raises the io_error condition if a write cannot fit in the buffer. The Seek implementation for MemWriter, which was incorrectly using unsigned arithmatic to add signed offsets, has also been replaced.
2013-11-12io: benchmarks for creation of the various Buffered objectsCorey Richardson-0/+42
2013-11-12auto merge of #10423 : alexcrichton/rust/move-io, r=pcwaltonbors-141/+152
I still plan on reorganizing the internals of the IO module a bit, but this is the major move which has been on the horizon for awhile.
2013-11-12auto merge of #10435 : jayanderson/rust/docs, r=huonwbors-2/+131
This fills in some missing docs in the nums package. Let me know if this is on the right track for what's wanted for docs. I can probably fill in more in the future. Thanks. (As a side note the precedence of the unary negative operator '-' tripped me up for a bit. Essentially I would expect `-25.0f32.sqrt()` to result in NaN instead of `-5.0`.)
2013-11-11Move std::rt::io to std::ioAlex Crichton-141/+152
2013-11-11Use constants instead of raw values.Jay Anderson-4/+2
2013-11-11auto merge of #10424 : alexcrichton/rust/optimize-buffered, r=brsonbors-2/+13
I was benchmarking rust-http recently, and I saw that 50% of its time was spent creating buffered readers/writers. Albeit rust-http wasn't using std::rt::io::buffered, but the same idea applies here. It's much cheaper to malloc a large region and not initialize it than to set it all to 0. Buffered readers/writers never use uninitialized data, and their internal buffers are encapsulated, so any usage of uninitialized slots are an implementation bug in the readers/writers.
2013-11-11Got directions backwards in to_degrees and to_radians docs.Jay Anderson-2/+2
2013-11-11Add docs for traits Exponential, Hyperbolic, BitCount.Jay Anderson-2/+44
2013-11-11Update docs for Fractional, Algebraic, Round, and Trigonometric traits.Jay Anderson-0/+89
2013-11-12Implemented a ProcessExit enum and helper methods to std::rt::io::process ↵Matthew Iselin-16/+56
for getting process termination status, or the signal that terminated a process. A test has been added to rtio-processes.rs to ensure signal termination is picked up correctly.
2013-11-11auto merge of #10407 : alexcrichton/rust/no-fixed-stack-segment, r=brsonbors-230/+42
The commit messages have more details, but this removes all analysis and usage related to fixed_stack_segment and rust_stack attributes. It's now the assumption that we always have "enough stack" and we'll implement detection of stack overflow through other means. The stack overflow detection is currently implemented for rust functions, but it is unimplemented for C functions (we still don't have guard pages).
2013-11-11Decrease the default stack size back to 2MBAlex Crichton-1/+1
I increased this to 4MB when I implemented abort-on-stack-overflow for Rust functions. Now that the fixed_stack_segment attribute is removed, no rust function will ever reasonably request 2MB of stack (due to calling an FFI function). The default size of 2MB should be plenty for everyday use-cases, and tasks can still request more stack via the spawning API.
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-229/+41
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
2013-11-11Optimize creation of buffered readers/writersAlex Crichton-2/+13
I was benchmarking rust-http recently, and I saw that 50% of its time was spent creating buffered readers/writers. Albeit rust-http wasn't using std::rt::io::buffered, but the same idea applies here. It's much cheaper to malloc a large region and not initialize it than to set it all to 0. Buffered readers/writers never use uninitialized data, and their internal buffers are encapsulated, so any usage of uninitialized slots are an implementation bug in the readers/writers.
2013-11-11auto merge of #10417 : cmr/rust/vec_overflow, r=huonwbors-1/+5
Fixes #10271
2013-11-11auto merge of #10409 : alexcrichton/rust/issue-10386, r=brsonbors-1/+5
Turns out the pipe names must have special names on windows. Once we have special names, all the tests pass just fine. Closes #10386
2013-11-11auto merge of #10394 : yichoi/rust/make_check_pass_android, r=brsonbors-102/+12
To enable test on android bot #9120 some tests are disabled and can be fixed further.
2013-11-11Fix path parsingSeo Sanghyeon-1/+1
2013-11-11Implement `size_hint` for RangeCorey Richardson-8/+80
Closes #8606
2013-11-11vec: with_capacity: check for overflowCorey Richardson-1/+5
Fixes #10271
2013-11-11Clean lint on test buildCorey Richardson-2/+0
2013-11-10auto merge of #10408 : alexcrichton/rust/snapshots, r=huonwbors-188/+12
Mostly just using the `system` abi where possible.
2013-11-10Enable uv pipe tests on windowsAlex Crichton-1/+5
Turns out the pipe names must have special names on windows. Once we have special names, all the tests pass just fine. Closes #10386
2013-11-10Register new snapshotsAlex Crichton-188/+12
2013-11-10auto merge of #10406 : alexcrichton/rust/issue-10405, r=huonwbors-1/+0
The logging macros all use libuv-based I/O, and there was one stray debug statement in task::spawn which was executing before the I/O context was ready. Remove it and add a test to make sure that we can continue to debug this sort of code. Closes #10405
2013-11-10Remove a debug! statement before I/O is readyAlex Crichton-1/+0
The logging macros all use libuv-based I/O, and there was one stray debug statement in task::spawn which was executing before the I/O context was ready. Remove it and add a test to make sure that we can continue to debug this sort of code. Closes #10405
2013-11-10Fix usage of libuv for windowsAlex Crichton-7/+13
2013-11-10Another round of test fixes from previous commitsAlex Crichton-26/+25
2013-11-10Fall back from uv tty instances more aggressivelyAlex Crichton-5/+2
It appears that uv's support for interacting with a stdio stream as a tty when it's actually a pipe is pretty problematic. To get around this, promote a check to see if the stream is a tty to the top of the tty constructor, and bail out quickly if it's not identified as a tty. Closes #10237
2013-11-10Assorted test fixes and merge conflictsAlex Crichton-4/+5
2013-11-10Rework the idle callback to have a safer interfaceAlex Crichton-21/+11
It turns out that the uv implementation would cause use-after-free if the idle callback was used after the call to `close`, and additionally nothing would ever really work that well if `start()` were called twice. To change this, the `start` and `close` methods were removed in favor of specifying the callback at creation, and allowing destruction to take care of closing the watcher.
2013-11-10Add bindings to uv's utime functionAlex Crichton-4/+47
This exposes the ability to change the modification and access times on a file. Closes #10266
2013-11-10Clean up the remaining chunks of uvAlex Crichton-21/+23
2013-11-10Start migrating stream I/O away from ~fn()Alex Crichton-2/+0
2013-11-10Remove usage of ~fn from the schedulerAlex Crichton-3/+2
2013-11-10Remove usage of ~fn() from uv async/idleAlex Crichton-18/+31