summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-08-04std and rustc: explicitly pass c strings to c functionsErick Tryzelaar-91/+108
When strings lose their trailing null, this pattern will become dangerous: let foo = "bar"; let foo_ptr: *u8 = &foo[0]; Instead we should use c_strs to handle this correctly.
2013-08-05Implemented iterator for TrieMapDmitry Ermolov-0/+96
Closes #5506.
2013-08-04Remove old tests and code for `select`Brian Anderson-152/+2
Not compatible with newsched
2013-08-04std::rt: Remove the test for context()Brian Anderson-10/+0
This is no longer testable once newsched is turned on
2013-08-04std::rt: Don't allow schedulers to exit before handling all messagesBrian Anderson-0/+10
Every time run_sched_once performs a 'scheduling action' it needs to guarantee that it runs at least one more time, so enqueue another run_sched_once callback. The primary reason it needs to do this is because not all async callbacks are guaranteed to run, it's only guaranteed that *a* callback will run after enqueing one - some may get dropped. At the moment this means we wastefully create lots of callbacks to ensure that there will *definitely* be a callback queued up to continue running the scheduler. The logic really needs to be tightened up here.
2013-08-04std::rt: 3MB stacks!Brian Anderson-2/+2
rustc needs *even more* megabytes when run without optimizations
2013-08-04std::rt: Run the tests for Local in a bare threadBrian Anderson-36/+45
Otherwise interferes with the existing runtime
2013-08-04std::rt: Improve the error message when the thread-local ptr is nullBrian Anderson-11/+15
Also fix some incorrect comments and variable names.
2013-08-04std: replace str::as_c_str with std::c_strErick Tryzelaar-185/+403
2013-08-04std: remove str::from_bytes_with_nullErick Tryzelaar-82/+0
2013-08-04std: add test for str::as_c_strErick Tryzelaar-0/+23
2013-08-04std: cleanup os and str testsErick Tryzelaar-28/+28
2013-08-04std: remove str::NullTerminatedStrErick Tryzelaar-55/+2
2013-08-04std: rewrite run::with_{argv,envp,dirp} to copy C stringsErick Tryzelaar-44/+59
2013-08-04std: add str.to_c_str()Erick Tryzelaar-1/+27
2013-08-04std: minor cleanupErick Tryzelaar-3/+3
2013-08-04Fixed str::raw::push_byteSteven Fackler-1/+8
It was previously pushing the byte on top of the string's null terminator. I added a test to make sure it doesn't break in the future.
2013-08-04auto merge of #8243 : stepancheg/rust/ipv, r=brsonbors-148/+142
multicast functions now take IpAddr (without port), because they dont't need port. Uv* types renamed: * UvIpAddr -> UvSocketAddr * UvIpv4 -> UvIpv4SocketAddr * UvIpv6 -> UvIpv6SocketAddr "Socket address" is a common name for (ip-address, port) pair (e.g. in sockaddr_in struct). P. S. Are there any backward compatibility concerns? What is std::rt module, is it a part of public API?
2013-08-04auto merge of #8237 : blake2-ppc/rust/faster-utf8, r=brsonbors-35/+67
Use unchecked vec indexing since the vector bounds are checked by the loop. Iterators are not easy to use in this case since we skip 1-4 bytes each lap. This part of the commit speeds up is_utf8 for ASCII input. Check codepoint ranges by checking the byte ranges manually instead of computing a full decoding for multibyte encodings. This is easy to read and corresponds to the UTF-8 syntax in the RFC. No changes to what we accept. A comment notes that surrogate halves are accepted. Before: test str::bench::is_utf8_100_ascii ... bench: 165 ns/iter (+/- 3) test str::bench::is_utf8_100_multibyte ... bench: 218 ns/iter (+/- 5) After: test str::bench::is_utf8_100_ascii ... bench: 130 ns/iter (+/- 1) test str::bench::is_utf8_100_multibyte ... bench: 156 ns/iter (+/- 3) An improvement upon the previous pull #8133
2013-08-04std: implement Total{Ord,Eq} for pointers.Huon Wilson-2/+49
2013-08-04syntax: make #[deriving(TotalOrd)] lazy.Huon Wilson-1/+0
Previously it would call: f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...)) (where s/of1 = 'self/other field 1', and f was std::cmp::lexical_ordering) This meant that every .cmp subcall got evaluated when calling a derived TotalOrd.cmp. This corrects this to use let test = sf1.cmp(&of1); if test == Equal { let test = sf2.cmp(&of2); if test == Equal { // ... } else { test } } else { test } This gives a lexical ordering by short-circuiting on the first comparison that is not Equal.
2013-08-03std: Remove gc and stackwalkBrian Anderson-444/+0
These are both obsoleted by the forthcoming new GC.
2013-08-03auto merge of #8264 : thestinger/rust/snapshot, r=Aatchbors-263/+232
2013-08-03auto merge of #8269 : brson/rust/fix-task-cleanup, r=brsonbors-27/+22
...y/catch And before collect_failure. These are both running user dtors and need to be handled in the task try/catch block and before the final task cleanup code.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-231/+231
this has been replaced by `for`
2013-08-03register snapshotsDaniel Micay-32/+1
2013-08-03std::rt: Run local storage cleanup and the box annihilator inside the try/catchBrian Anderson-27/+22
And before collect_failure. These are both running user dtors and need to be handled in the task try/catch block and before the final task cleanup code.
2013-08-03auto merge of #8246 : stepancheg/rust/contains-key, r=thestingerbors-17/+5
Map::contains_key can be implemented with Map::find. Remove several implementations of contains_key.
2013-08-03auto merge of #8219 : sstewartgallus/rust/fix_dynamic_lib, r=graydonbors-36/+70
A test case was also created for this situation to prevent the problem occuring again. A similar problem was also fixed for the symbol method. There was some minor code cleanup. I am unsatisfied with using /dev/null as an invalid dynamic library. It is not cross platform.
2013-08-03auto merge of #8213 : kballard/rust/fd-limit, r=brsonbors-4/+83
Revert the workaround 49b72bd and instead bump the fd limit on OS X.
2013-08-03std: expose the keyed HashMap constructor, for runtime-less use.Huon Wilson-28/+26
The `new` constructor uses the task-local RNG to retrieve seeds for the two key values, which requires the runtime. Exposing a constructor that takes the keys directly allows HashMaps to be used in programs that wish to avoid the runtime.
2013-08-03auto merge of #8204 : kballard/rust/str-into-owned, r=graydonbors-0/+12
The method .into_owned() is meant to be used as an optimization when you need to get a ~str from a Str, but don't want to unnecessarily copy it if it's already a ~str. This is meant to ease functions that look like fn foo<S: Str>(strs: &[S]) Previously they could work with the strings as slices using .as_slice(), but producing ~str required copying the string, even if the vector turned out be a &[~str] already. I don't have any concrete uses for this yet, since the one conversion I've done to `&[S]` so far (see PR #8203) didn't actually need owned strings. But having this here may make using `Str` more attractive. It also may be worth adding an `into_managed()` function, but that one is less obviously useful than `into_owned()`.
2013-08-03std: add benchmark for vec.mut_iter.Huon Wilson-0/+13
2013-08-03std: use ptr.offset where possible in the vec iterator.Huon Wilson-8/+38
Closes #8212.
2013-08-03option: mutate() and mutate_default() should return boolKevin Ballard-5/+24
Fixes #8047.
2013-08-03fixed the buffer to make it a more reasonable sizetoddaaro-1/+1
2013-08-03modified logging function to truncate output and adjusted error output ↵toddaaro-0/+10
formatting tests to be compatible with both the new and old runtimes
2013-08-03make `for` parse as `foreach` doesDaniel Micay-1/+3
Closes #6997
2013-08-03replace all remaining `for` with `foreach` or `do`Daniel Micay-70/+94
2013-08-02librustc: Disallow "unsafe" for external functionsPatrick Walton-623/+539
2013-08-02Bump fd limit on macos when running rt testsKevin Ballard-0/+78
OS X defaults the ulimit for open files to 256 for programs launched from the Terminal (GUI apps get a higher default). Unfortunately this is too low for the rt tests, which deliberately overcommit and create a lot of threads (which means a lot of schedulers, and each scheduler needs at least 2 fds). By calling sysctl() and setrlimit() we can bump the fd limit up to the maximum allowed (on stock OS X it's 10240). Fixes #7772.
2013-08-02Revert "std::rt: Use a constant 4 threads for multithreaded sched tests"Kevin Ballard-4/+5
This workaround was less than ideal. A better solution is to raise the fd limit. This reverts commit 49b72bdd77916e27aaf95909516702c1450f11ac.
2013-08-03Add default implementation of Map::contains_key functionStepan Koltsov-17/+5
Map::contains_key can be implemented with Map::find. Remove several implementations of contains_key.
2013-08-03Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddrStepan Koltsov-148/+142
multicast functions now take IpAddr (without port), because they dont't need port. Uv* types renamed: * UvIpAddr -> UvSocketAddr * UvIpv4 -> UvIpv4SocketAddr * UvIpv6 -> UvIpv6SocketAddr "Socket address" is a common name for (ip-address, port) pair (e.g. in sockaddr_in struct).
2013-08-02Add an assert_may_sleep() check on every context switch.Ben Blum-0/+4
2013-08-02Don't fail from kill signals if already unwinding.Ben Blum-3/+3
2013-08-02(cleanup) Use more do...finally in extra::sync.Ben Blum-0/+6
2013-08-02Fix embarrassing bug where 'unkillable' would unwind improperly when it ↵Ben Blum-2/+44
receives a kill signal.
2013-08-02Fix nasty double-free bug where a newrt chan could get killed after ↵Ben Blum-2/+7
rescheduling but before suppressing_finalize.
2013-08-02Add SendDeferred trait and use it to fix #8214.Ben Blum-24/+157