about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-11-26port the runtime to `#[thread_local]`Daniel Micay-5/+105
2013-11-26auto merge of #10660 : alexcrichton/rust/little-scope, r=pcwaltonbors-71/+71
This moves the locking/waiting methods to returning an RAII struct instead of relying on closures. Additionally, this changes the methods to all take '&mut self' to discourage recursive locking. The new method to block is to call `wait` on the returned RAII structure instead of calling it on the lock itself (this enforces that the lock is held). At the same time, this improves the Mutex interface a bit by allowing destruction of non-initialized members and by allowing construction of an empty mutex (nothing initialized inside).
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-337/+342
2013-11-25auto merge of #10631 : klutzy/rust/win-fixes, r=alexcrichtonbors-185/+53
This patchset fixes some parts broken on Win64. This also adds `--disable-pthreads` flags to llvm on mingw-w64 archs (both 32-bit and 64-bit, not mingw) due to bad performance. See #8996 for discussion.
2013-11-26std: Remove unused attributesklutzy-4/+2
This also enables two tests properly.
2013-11-26rustc: Add lint for obsolete attributesklutzy-1/+0
This also moves `#[auto_{en,de}code]` checker from syntax to lint.
2013-11-25Move LittleLock to using RAIIAlex Crichton-71/+71
This moves the locking/waiting methods to returning an RAII struct instead of relying on closures. Additionally, this changes the methods to all take '&mut self' to discourage recursive locking. The new method to block is to call `wait` on the returned RAII structure instead of calling it on the lock itself (this enforces that the lock is held). At the same time, this improves the Mutex interface a bit by allowing destruction of non-initialized members and by allowing construction of an empty mutex (nothing initialized inside).
2013-11-25auto merge of #10650 : andreasots/rust/ipv6-is-in-hex, r=alexcrichtonbors-1/+2
Without this the assert in <tt>rust_malloc_ip6_addr</tt> is triggered as it expects a correctly formatted IPv6 address.
2013-11-25auto merge of #10658 : LeoTestard/rust/serialize-rc, r=cmrbors-0/+8
Implement various traits (IterBytes and extra's Encodable and Decodable) for Rc<T> when T alreay implements the trait.
2013-11-25Implement IterBytes for Rc<T>.Léo Testard-0/+8
2013-11-25rm #[mutable_doc]Daniel Micay-2/+0
2013-11-25auto merge of #10643 : jorendorff/rust/master, r=alexcrichtonbors-1/+1
2013-11-24auto merge of #10635 : alexcrichton/rust/issue-10626, r=cmrbors-1/+5
This is both useful for performance (otherwise logging is unbuffered), but also useful for correctness. Because when a task is destroyed we can't block the task waiting for the logger to close, loggers are opened with a 'CloseAsynchronously' specification. This causes libuv do defer the call to close() until the next turn of the event loop. If you spin in a tight loop around printing, you never yield control back to the libuv event loop, meaning that you simply enqueue a large number of close requests but nothing is actually closed. This queue ends up never getting closed, meaning that if you keep trying to create handles one will eventually fail, which the runtime will attempt to print the failure, causing mass destruction. Caching will provide better performance as well as prevent creation of too many handles. Closes #10626
2013-11-25std: IPv6 addresses are represented as eight groups of four HEXADECIMAL digitsAndreas Ots-1/+2
2013-11-24auto merge of #10603 : alexcrichton/rust/no-linked-failure, r=brsonbors-2088/+145
The reasons for doing this are: * The model on which linked failure is based is inherently complex * The implementation is also very complex, and there are few remaining who fully understand the implementation * There are existing race conditions in the core context switching function of the scheduler, and possibly others. * It's unclear whether this model of linked failure maps well to a 1:1 threading model Linked failure is often a desired aspect of tasks, but we would like to take a much more conservative approach in re-implementing linked failure if at all. Closes #8674 Closes #8318 Closes #8863
2013-11-24Cache a task's stderr loggerAlex Crichton-1/+5
This is both useful for performance (otherwise logging is unbuffered), but also useful for correctness. Because when a task is destroyed we can't block the task waiting for the logger to close, loggers are opened with a 'CloseAsynchronously' specification. This causes libuv do defer the call to close() until the next turn of the event loop. If you spin in a tight loop around printing, you never yield control back to the libuv event loop, meaning that you simply enqueue a large number of close requests but nothing is actually closed. This queue ends up never getting closed, meaning that if you keep trying to create handles one will eventually fail, which the runtime will attempt to print the failure, causing mass destruction. Caching will provide better performance as well as prevent creation of too many handles. Closes #10626
2013-11-24Remove linked failure from the runtimeAlex Crichton-2088/+145
The reasons for doing this are: * The model on which linked failure is based is inherently complex * The implementation is also very complex, and there are few remaining who fully understand the implementation * There are existing race conditions in the core context switching function of the scheduler, and possibly others. * It's unclear whether this model of linked failure maps well to a 1:1 threading model Linked failure is often a desired aspect of tasks, but we would like to take a much more conservative approach in re-implementing linked failure if at all. Closes #8674 Closes #8318 Closes #8863
2013-11-24Fix spelling of "vacuum" in one of the abort quotes.Jason Orendorff-1/+1
2013-11-25std::trie: Fix find_mut for non-present keysJannis Harder-1/+12
Make TrieMap/TrieSet's find_mut check the key for external nodes. Without this find_mut sometimes returns a reference to another key when querying for a non-present key.
2013-11-24Implement cmp traits for Rc<T> and add a ptr_eq method.Léo Testard-0/+55
2013-11-24std::rt: Fix crate_map on Win64klutzy-1/+6
2013-11-24std::rt: Fix record_stack_bounds on win64klutzy-2/+2
2013-11-24std: Fix transmute error on win64klutzy-1/+1
2013-11-24std::libc: Simplify win32/win64 type definitionsklutzy-164/+30
2013-11-24std::libc: Remove TCHAR typesklutzy-20/+17
2013-11-23auto merge of #10514 : sfackler/rust/mut, r=cmrbors-325/+346
This is based off of @blake2-ppc's work on #9429. That PR bitrotted and I haven't been able to contact the original author so I decided to take up the cause. Overview ====== `Mut` encapsulates a mutable, non-nullable slot. The `Cell` type is currently used to do this, but `Cell` is much more commonly used as a workaround for the inability to move values into non-once functions. `Mut` provides a more robust API. `Mut` duplicates the semantics of borrowed pointers with enforcement at runtime instead of compile time. ```rust let x = Mut::new(0); { // make some immutable borrows let p = x.borrow(); let y = *p.get() + 10; // multiple immutable borrows are allowed simultaneously let p2 = x.borrow(); // this would throw a runtime failure // let p_mut = x.borrow_mut(); } // now we can mutably borrow let p = x.borrow_mut(); *p.get() = 10; ``` `borrow` returns a `Ref` type and `borrow_mut` returns a `RefMut` type, both of which are simple smart pointer types with a single method, `get`, which returns a reference to the wrapped data. This also allows `RcMut<T>` to be deleted, as it can be replaced with `Rc<Mut<T>>`. Changes ====== I've done things a little bit differently than the original proposal. * I've added `try_borrow` and `try_borrow_mut` methods that return `Option<Ref<T>>` and `Option<RefMut<T>>` respectively instead of failing on a borrow check failure. I'm not totally sure when that'd be useful, but I don't see any reason to not put them in and @cmr requested them. * `ReadPtr` and `WritePtr` have been renamed to `Ref` and `RefMut` respectively, as `Ref` is to `ref foo` and `RefMut` is to `ref mut foo` as `Mut` is to `mut foo`. * `get` on `MutRef` now takes `&self` instead of `&mut self` for consistency with `&mut`. As @alexcrichton pointed, out this violates soundness by allowing aliasing `&mut` references. * `Cell` is being left as is. It solves a different problem than `Mut` is designed to solve. * There are no longer methods implemented for `Mut<Option<T>>`. Since `Cell` isn't going away, there's less of a need for these, and I didn't feel like they provided a huge benefit, especially as that kind of `impl` is very uncommon in the standard library. Open Questions ============ * `Cell` should now be used exclusively for movement into closures. Should this be enforced by reducing its API to `new` and `take`? It seems like this use case will be completely going away once the transition to `proc` and co. finishes. * Should there be `try_map` and `try_map_mut` methods along with `map` and `map_mut`?
2013-11-23Move mutable::Mut to cell::RefCellSteven Fackler-335/+320
2013-11-22auto merge of #10611 : cmr/rust/ascii_flesh, r=pcwaltonbors-0/+68
These are super boring. I can add tests if really desired, but they'd be long and even more boring than the methods.
2013-11-23Add ctype-likes to AsciiCorey Richardson-0/+68
2013-11-22Add Rc::from_mutSteven Fackler-0/+17
2013-11-22More Mut testsSteven Fackler-0/+9
2013-11-22Strip down Cell functionalitySteven Fackler-59/+3
2013-11-22Change Mut::map to Mut::withSteven Fackler-19/+19
2013-11-22Make MutRef more consistent with &mutSteven Fackler-9/+9
2013-11-22Cell -> Mut switch in commSteven Fackler-20/+24
2013-11-22Move Rc tests away from CellSteven Fackler-7/+7
2013-11-22Remove RcMutSteven Fackler-237/+0
Rc<Mut<T>> should be used instead
2013-11-22Introduce Mut<T> to libstdSteven Fackler-0/+299
Based off of blake2-ppc's work in #9429.
2013-11-22auto merge of #10612 : pnkfelix/rust/remove-cut-and-pasted-rt-fixme, r=pcwaltonbors-1/+0
I cannot tell whether the original comment was unsure about the arithmetic calculations, or if it was unsure about the assumptions being made about the alignment of the current allocation pointer. The arithmetic calculation looks fine to me, though. This technique is documented e.g. in Henry Warren's "Hacker's Delight" (section 3-1). (I am sure one can find it elsewhere too, its not an obscure property.)
2013-11-22The original fixme #2699 was removed back in PR #6053.Felix S. Klock II-1/+0
I cannot tell whether the original comment was unsure about the arithmetic calculations, or if it was unsure about the assumptions being made about the alignment of the current allocation pointer. The arithmetic calculation looks fine to me, though. This technique is documented e.g. in Henry Warren's "Hacker's Delight" (section 3-1). (I am sure one can find it elsewhere too, its not an obscure property.)
2013-11-22auto merge of #10610 : thestinger/rust/breakpoint, r=pnkfelixbors-0/+4
This can be used to grab the attention of a debugger, and unlike `abort` execution can be resumed.
2013-11-22add a breakpoint intrinsic for debuggingDaniel Micay-0/+4
This can be used to grab the attention of a debugger, and unlike `abort` execution can be resumed.
2013-11-22auto merge of #10582 : g3xzh/rust/master, r=cmrbors-2/+70
More new benchmark tests. some of them are benchmarking `starts_with` and `ends_with`. Let me know if I am missing something. Thanks in advance.
2013-11-22Add more benchmark tests to vec.rsg3xzh-2/+70
New benchmark tests in vec.rs: `push`, `starts_with_same_vector`, `starts_with_single_element`, `starts_with_diff_one_element_end`, `ends_with_same_vector`, `ends_with_single_element`, `ends_with_diff_one_element_beginning` and `contains_last_element`
2013-11-21auto merge of #10588 : huonw/rust/un@mutilate-task_rng, r=alexcrichtonbors-30/+43
Replace with some unsafe code by storing a pointer into TLS-owned heap data.
2013-11-22std::rand: move TaskRng off @mut.Huon Wilson-30/+43
Replace with some unsafe code by storing a pointer into TLS-owned heap data.
2013-11-21`std::ptr::read_ptr` now takes `*T` instead of `*mut T`Ziad Hatahet-3/+3
Closes #10579
2013-11-20auto merge of #10576 : thestinger/rust/gc, r=pcwaltonbors-0/+100
This isn't very useful yet, but it does replace most functionality of `@T`. The `Mut<T>` type will make it unnecessary to have a `GcMut<T>` so I haven't included one. Obviously it doesn't work for trait objects but that needs to be figured out for `Rc<T>` too.
2013-11-19add an initial `Gc<T>` stub with the APIDaniel Micay-0/+100
2013-11-19Remove NonCopyable::newSteven Fackler-6/+0
The issue that required it has been fixed.