Commit graph

2832 commits

Author SHA1 Message Date
Brian Anderson
3c9e393354 std::rt: Run local storage cleanup and the box annihilator inside the try/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-03 14:43:16 -07:00
bors
18e3db7392 auto merge of #8246 : stepancheg/rust/contains-key, r=thestinger
Map::contains_key can be implemented with Map::find.

Remove several implementations of contains_key.
2013-08-03 13:40:49 -07:00
bors
800dbffa69 auto merge of #8219 : sstewartgallus/rust/fix_dynamic_lib, r=graydon
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-03 10:04:58 -07:00
bors
34101d2320 auto merge of #8213 : kballard/rust/fd-limit, r=brson
Revert the workaround 49b72bd and instead bump the fd limit on OS X.
2013-08-03 07:46:53 -07:00
Huon Wilson
c852a5bb68 std: expose the keyed HashMap constructor, for runtime-less use.
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-03 21:00:32 +10:00
bors
39fafd655a auto merge of #8204 : kballard/rust/str-into-owned, r=graydon
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-03 02:10:54 -07:00
Huon Wilson
1992765dd3 std: add benchmark for vec.mut_iter. 2013-08-03 03:13:13 -04:00
Huon Wilson
fbb7cd32c3 std: use ptr.offset where possible in the vec iterator.
Closes #8212.
2013-08-03 03:13:11 -04:00
Kevin Ballard
54e685d4fd option: mutate() and mutate_default() should return bool
Fixes #8047.
2013-08-03 03:11:11 -04:00
toddaaro
1f9c392389 fixed the buffer to make it a more reasonable size 2013-08-03 03:09:23 -04:00
toddaaro
eab749a5f3 modified logging function to truncate output and adjusted error output formatting tests to be compatible with both the new and old runtimes 2013-08-03 03:09:04 -04:00
Daniel Micay
b41d04763e make for parse as foreach does
Closes #6997
2013-08-03 03:00:42 -04:00
Daniel Micay
b3ad685f7f replace all remaining for with foreach or do 2013-08-03 03:00:42 -04:00
Patrick Walton
9457ebee55 librustc: Disallow "unsafe" for external functions 2013-08-02 21:57:59 -07:00
Kevin Ballard
2001cc043b Bump fd limit on macos when running rt tests
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-02 21:20:15 -07:00
Kevin Ballard
70d2be0cec Revert "std::rt: Use a constant 4 threads for multithreaded sched tests"
This workaround was less than ideal. A better solution is to raise the
fd limit.

This reverts commit 49b72bdd77.
2013-08-02 21:18:32 -07:00
Stepan Koltsov
cf9e9b21d5 Add default implementation of Map::contains_key function
Map::contains_key can be implemented with Map::find.

Remove several implementations of contains_key.
2013-08-03 05:54:05 +04:00
Stepan Koltsov
9046516444 Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddr
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-03 02:06:24 +04:00
Ben Blum
43fecf3556 Add an assert_may_sleep() check on every context switch. 2013-08-02 17:31:45 -04:00
Ben Blum
92f60f4365 Don't fail from kill signals if already unwinding. 2013-08-02 17:31:45 -04:00
Ben Blum
bd35798773 (cleanup) Use more do...finally in extra::sync. 2013-08-02 17:31:45 -04:00
Ben Blum
d30cca46e6 Fix embarrassing bug where 'unkillable' would unwind improperly when it receives a kill signal. 2013-08-02 17:31:45 -04:00
Ben Blum
cde6ad3992 Fix nasty double-free bug where a newrt chan could get killed after rescheduling but before suppressing_finalize. 2013-08-02 17:31:44 -04:00
Ben Blum
be7738bfa1 Add SendDeferred trait and use it to fix #8214. 2013-08-02 17:31:44 -04:00
blake2-ppc
0504d7e57b std: Speed up str::is_utf8
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)
2013-08-02 23:20:57 +02:00
bors
f1c1f92d0c auto merge of #8221 : brson/rust/single-threaded, r=graydon
This is the last major runtime feature needed for the transition to the new scheduler.
2013-08-02 10:52:50 -07:00
bors
986df44753 auto merge of #8195 : bblum/rust/task-cleanup, r=brson
In the first commit it is obvious why some of the barriers can be changed to ```Relaxed```, but it is not as obvious for the once I changed in ```kill.rs```. The rationale for those is documented as part of the documenting commit.

Also the last commit is a temporary hack to prevent kill signals from being received in taskgroup cleanup code, which could be fixed in a more principled way once the old runtime is gone.
2013-08-02 07:31:52 -07:00
bors
af97339771 auto merge of #8193 : cmr/rust/linux-errno, r=graydon 2013-08-02 05:49:53 -07:00
bors
dbde42e59e auto merge of #8175 : brson/rust/nodbg, r=graydon
This stuff is ancient, unused, and tied to oldsched
2013-08-02 01:13:51 -07:00
Brian Anderson
c3fa411459 std: Implement SingleThreaded spawn mode for newsched 2013-08-02 00:26:45 -07:00
Steven Stewart-Gallus
2047026fef Fix calling destructor on uninitialized dynamic library crash.
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.
2013-08-01 23:41:33 -07:00
Daniel Micay
234acad404 replace range with an external iterator 2013-08-02 00:51:14 -04:00
Kevin Ballard
aa94dfa625 str: Add method .into_owned(self) -> ~str to Str
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.
2013-08-01 15:54:58 -07:00
toddaaro
8e98eabce5 modified local to include an implementation for try_unsafe_borrow::<Task> so that the log methods will work 2013-08-01 15:38:48 -07:00
toddaaro
1d82fe5aea fixed incorrect handling of returned scheduler option and restructed scheduler functions slightly 2013-08-01 15:18:29 -07:00
toddaaro
a5f55b3ead minor tweaks - unboxed the coroutine so that it is no longer a ~ pointer inside the task struct, and also added an assert to verify that send is never called inside scheduler context as it is undefined (BROKEN) if that happens 2013-08-01 15:17:19 -07:00
toddaaro
997719c13d Fixed a race where a scheduler configured to only run tasks pinned to it would "bounch" a regular task in and out of the work queue without allowing a different scheduler to run it. 2013-08-01 15:16:01 -07:00
Ben Blum
37f385e44b Have linked failure tests run on the new scheduler instead of requiring RUST_NEWRT to test. 2013-08-01 15:16:01 -07:00
toddaaro
f7eed22387 A major refactoring that changes the way the runtime uses TLS. In the
old design the TLS held the scheduler struct, and the scheduler struct
held the active task. This posed all sorts of weird problems due to
how we wanted to use the contents of TLS. The cleaner approach is to
leave the active task in TLS and have the task hold the scheduler. To
make this work out the scheduler has to run inside a regular task, and
then once that is the case the context switching code is massively
simplified, as instead of three possible paths there is only one. The
logical flow is also easier to follow, as the scheduler struct acts
somewhat like a "token" indicating what is active.

These changes also necessitated changing a large number of runtime
tests, and rewriting most of the runtime testing helpers.

Polish level is "low", as I will very soon start on more scheduler
changes that will require wiping the polish off. That being said there
should be sufficient comments around anything complex to make this
entirely respectable as a standalone commit.
2013-08-01 15:14:00 -07:00
Ben Blum
963d37e821 Temporary workaround to prevent taskgroup cleanup code from failing without an exception handler. 2013-08-01 17:07:31 -04:00
Ben Blum
aeaed77301 Make a forgotten assert in comm be cfg(test)-dependent 2013-08-01 16:52:37 -04:00
Ben Blum
036a6d2f00 Document task killing design and relaxed barrier rationale. 2013-08-01 16:52:37 -04:00
Ben Blum
880246618b Relax some atomic barriers. Loosen up all that tension. There, doesn't that feel good? 2013-08-01 16:52:37 -04:00
bors
82b24559e6 auto merge of #8190 : thestinger/rust/for, r=thestinger 2013-08-01 12:52:29 -07:00
Corey Richardson
2b026718c3 Add a boatload of Linux x86/x86-64/arm errnos 2013-08-01 15:37:01 -04:00
Daniel Micay
94f1a5d6f8 migrate to foreach 2013-08-01 15:28:45 -04:00
blake2-ppc
78cde5b9fb std: Change Times trait to use do instead of for
Change the former repetition::

    for 5.times { }

to::

    do 5.times { }

.times() cannot be broken with `break` or `return` anymore; for those
cases, use a numerical range loop instead.
2013-08-01 16:54:22 +02:00
blake2-ppc
7e210a8129 std: Replace for with do { .. } expr in std::gc
Change all users of old-style for with internal iterators to using
`do`-loops.

The code in stackwalk.rs does not actually implement the
looping protocol (no break on return false).

The code in gc.rs does not use loop breaks, nor does any code using it.

We remove the capacity to break from the loops in std::gc and implement
the walks using `do { .. }` expressions.

No behavior change.
2013-08-01 16:54:22 +02:00
blake2-ppc
e5a64f2add std: Remove the internal iterator methods from trait Set
.intersection(), .union() etc methods in trait std::container::Set use
internal iters. Remove these methods from the trait.

I reported issue #8154 for the reinstatement of iterator-based set algebra
methods to the Set trait.

For bitv and treemap, that lack Iterator implementations of set
operations, preserve them as methods directly on the types themselves.

For HashSet, these methods are replaced by the present .union_iter()
etc.
2013-08-01 16:54:22 +02:00
blake2-ppc
b18bd785ec std: Replace for with do { .. } expr where internal iterators are used 2013-08-01 16:54:22 +02:00
blake2-ppc
6d7a0c8cbc std: Use do blocks instead of for with .iter_bytes() 2013-08-01 16:54:22 +02:00
bors
fe28ac6891 auto merge of #8164 : brson/rust/noportset, r=pcwalton
...haredChan.
2013-08-01 07:46:38 -07:00
bors
18d124b9b5 auto merge of #8158 : bblum/rust/task-cleanup, r=brson
r? @brson
2013-08-01 06:01:39 -07:00
bors
9824d90ffd auto merge of #8155 : stepancheg/rust/unit-zero, r=alexcrichton 2013-08-01 04:19:35 -07:00
Daniel Micay
1fc4db2d08 migrate many for loops to foreach 2013-08-01 05:34:55 -04:00
bors
8ec70ae5de auto merge of #8162 : thestinger/rust/no-copy, r=brson 2013-07-31 22:52:31 -07:00
Daniel Micay
dabd476203 make in and foreach get treated as keywords 2013-08-01 00:21:13 -04:00
Brian Anderson
05eff5f731 extra: Remove dbg module and rt support code
This stuff is ancient, unused, and tied to oldsched
2013-07-31 18:51:57 -07:00
Brian Anderson
ebd14c92f8 std: Remove PortSet. Not supported by new scheduler. Replace uses with SharedChan. 2013-07-31 14:59:49 -07:00
bors
ef87e2cc96 auto merge of #8151 : sanxiyn/rust/atomicrmw, r=cmr
#8039 broke ARM build, and nothing uses these yet.
2013-07-31 14:58:20 -07:00
Ben Blum
bc7cee7bbf Move atomically to unstable::sync, and document what it actually does. Close #7872. 2013-07-31 14:37:22 -04:00
Ben Blum
2e6dc161b6 Give tasks useful names. #2891 2013-07-31 14:37:22 -04:00
Stepan Koltsov
a5912736be Implement Zero for unit 2013-07-31 18:19:26 +04:00
Seo Sanghyeon
428ea7d7ce Revert atomicrmw {max, min, umax, umin} 2013-07-31 19:44:20 +09:00
bors
8b7e241e02 auto merge of #8139 : brson/rust/rm-old-task-apis, r=pcwalton
This removes a bunch of options from the task builder interface that are irrelevant to the new scheduler and were generally unused anyway. It also bumps the stack size of new scheduler tasks so that there's enough room to run rustc and changes the interface to `Thread` to not implicitly join threads on destruction, but instead require an explicit, and mandatory, call to `join`.
2013-07-31 02:10:24 -07:00
bors
8a737b5020 auto merge of #8138 : Dretch/rust/posix-path-push, r=pcwalton
\ is allowed inside file names on linux, for example my system has a file at:

`/run/udev/firmware-missing/intel-ucode\x2f06-3a-09`
2013-07-31 00:22:21 -07:00
bors
5633a5363b auto merge of #8008 : bblum/rust/select, r=brson
Main logic in ```Implement select() for new runtime pipes.```. The guts of the ```PortOne::try_recv()``` implementation are now split up across several functions, ```optimistic_check```, ```block_on```, and ```recv_ready```.

There is one weird FIXME I left open here, in the "implement select" commit -- an assertion I couldn't get to work in the receive path, on an invariant that for some reason doesn't hold with ```SharedPort```. Still investigating this.
2013-07-30 18:58:17 -07:00
Brian Anderson
33df9fc1d0 std: Remove foreign_stack_size spawn option. Irrelevant to future FFI changes 2013-07-30 17:10:23 -07:00
Brian Anderson
8f835d42d7 std: Remove get_task function. Unused 2013-07-30 17:10:21 -07:00
bors
6534b4d4ce auto merge of #8115 : bjz/rust/num-traits, r=brson
Continues #4819
2013-07-30 17:10:19 -07:00
Gareth Smith
de0092c48e No longer treat \ as a path separator on posix systems. 2013-07-30 23:43:39 +01:00
Brian Anderson
81dda9d9cb std: Remove CurrentScheduler spawn mode. Unused 2013-07-30 14:23:46 -07:00
Brian Anderson
08480e4fda std: Remove ExistingScheduler spawn mode. Unused 2013-07-30 14:23:46 -07:00
Brian Anderson
5d2b8d4372 std: Remove PlatformThread spawn mode. Obsolete 2013-07-30 14:23:45 -07:00
Brian Anderson
85fd75ac47 std: Remove ThreadPerTask spawn mode. Unimplemented 2013-07-30 14:23:45 -07:00
Brian Anderson
cb9ee7f5be std: Remove ManualThreads spawn mode 2013-07-30 14:23:45 -07:00
Brian Anderson
0144c83213 std::rt: Change Thread interface to require an explicit join
Makes it more obvious what's going on
2013-07-30 14:23:44 -07:00
Brian Anderson
7265cc6530 std::rt: Use 2MB stacks
Seems to be around the minimum needed by rustc without split stacks
2013-07-30 14:17:56 -07:00
blake2-ppc
8f9014c159 std: Mark the static constants in str.rs as private
static variables are pub by default, which is not reflected in our code
(we need to use priv).
2013-07-30 19:34:54 +02:00
Ben Blum
6b75e92afe UnsafeArc methods return unsafe pointers, so are not themselves unsafe. 2013-07-30 13:19:26 -04:00
Ben Blum
fa8102ab4a Unkillable is not unsafe. Close #7832. 2013-07-30 13:19:25 -04:00
Ben Blum
9675cd311a (cleanup) Fix unimplemented message for kill_all in newsched. 2013-07-30 13:19:25 -04:00
Ben Blum
3f6b4c24ec Add a better-for-testing optimistic_check() for pipes with cfg(test). 2013-07-30 13:19:25 -04:00
Ben Blum
cccfa8acc4 Add test cases for select 2013-07-30 13:19:25 -04:00
Ben Blum
f34fadd126 Implement select() for new runtime pipes. 2013-07-30 13:19:25 -04:00
blake2-ppc
aa89325cb0 std: Add from_bytes test for utf-8 using codepoints above 0xffff 2013-07-30 19:16:12 +02:00
blake2-ppc
b4ff95599a std: Deny overlong encodings in UTF-8
An 'overlong encoding' is a codepoint encoded non-minimally using the
utf-8 format. Denying these enforce each codepoint to have only one
valid representation in utf-8.

An example is byte sequence 0xE0 0x80 0x80 which could be interpreted as
U+0, but it's an overlong encoding since the canonical form is just
0x00.

Another example is 0xE0 0x80 0xAF which was previously accepted and is
an overlong encoding of the solidus "/". Directory traversal characters
like / and . form the most compelling argument for why this commit is
security critical.

Factor out common UTF-8 decoding expressions as macros. This commit will
partly duplicate UTF-8 decoding, so it is now present in both
fn is_utf8() and .char_range_at(); the latter using an assumption of
a valid str.
2013-07-30 19:16:12 +02:00
blake2-ppc
6dd185930d std: Disallow bytes 0xC0, 0xC1 (192, 193) in utf-8
Bytes 0xC0, 0xC1 can only be used to start 2-byte codepoint encodings,
that are 'overlong encodings' of codepoints below 128.

The reference given in a comment -- https://tools.ietf.org/html/rfc3629
-- does in fact already exclude these bytes, so no additional comment
should be needed in the code.
2013-07-30 17:25:29 +02:00
bors
576f395ddf auto merge of #8121 : thestinger/rust/offset, r=alexcrichton
Closes #8118, #7136

~~~rust
extern mod extra;

use std::vec;
use std::ptr;

fn bench_from_elem(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = vec::from_elem(1024, 0u8);
    }
}

fn bench_set_memory(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let mut v: ~[u8] = vec::with_capacity(1024);
        unsafe {
            let vp = vec::raw::to_mut_ptr(v);
            ptr::set_memory(vp, 0, 1024);
            vec::raw::set_len(&mut v, 1024);
        }
    }
}

fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = ~[0u8, ..1024];
    }
}
~~~

Before:

    test bench_from_elem ... bench: 415 ns/iter (+/- 17)
    test bench_set_memory ... bench: 85 ns/iter (+/- 4)
    test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)

After:

    test bench_from_elem ... bench: 84 ns/iter (+/- 2)
    test bench_set_memory ... bench: 84 ns/iter (+/- 5)
    test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 07:01:19 -07:00
Marvin Löbel
e33fca9ffe Added str::char_offset_iter() and str::rev_char_offset_iter()
Renamed bytes_iter to byte_iter to match other iterators
Refactored str Iterators to use DoubleEnded Iterators and typedefs instead of wrapper structs
Reordered the Iterator section
Whitespace fixup
Moved clunky `each_split_within` function to the one place in the tree where it's actually needed
Replaced all block doccomments in str with line doccomments
2013-07-30 12:55:48 +02:00
Daniel Micay
ef870d37a5 implement pointer arithmetic with GEP
Closes #8118, #7136

~~~rust
extern mod extra;

use std::vec;
use std::ptr;

fn bench_from_elem(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = vec::from_elem(1024, 0u8);
    }
}

fn bench_set_memory(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let mut v: ~[u8] = vec::with_capacity(1024);
        unsafe {
            let vp = vec::raw::to_mut_ptr(v);
            ptr::set_memory(vp, 0, 1024);
            vec::raw::set_len(&mut v, 1024);
        }
    }
}

fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = ~[0u8, ..1024];
    }
}
~~~

Before:

    test bench_from_elem ... bench: 415 ns/iter (+/- 17)
    test bench_set_memory ... bench: 85 ns/iter (+/- 4)
    test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)

After:

    test bench_from_elem ... bench: 84 ns/iter (+/- 2)
    test bench_set_memory ... bench: 84 ns/iter (+/- 5)
    test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 02:50:31 -04:00
bors
8695bc74a0 auto merge of #7223 : steveklabnik/rust/vec_initial_docs, r=pcwalton
Let's explain more of what this module is about, not just 'vectors.'
2013-07-29 23:49:23 -07:00
blake2-ppc
99490ad5ba std: Remove macro in vec that's only used once 2013-07-30 02:52:01 +02:00
blake2-ppc
5307d3674e std: Implement Extendable for hashmap, str and trie 2013-07-30 02:32:38 +02:00
blake2-ppc
2ff84124f0 std: Remove RandomAccessIterator impl for VecMutIterator
The RandomAccessIterator implementation is not sound for the mutable vec
iterator, and makes it easy to duplicate &mut element pointers.
2013-07-30 01:48:17 +02:00
blake2-ppc
66fccdb295 std: Tests for RandomAccessIterators 2013-07-30 01:48:17 +02:00
blake2-ppc
630627c3d4 std: Implement RandomAccessIterator for iterator adaptors
Implement RAI where possible for iterator adaptors such as Map,
Enumerate, Skip, Take, Zip, Cycle (all of the requiring that the adapted
iterator also implements RAI).
2013-07-30 01:48:17 +02:00
blake2-ppc
5d4af58c1d iterator: implement size_hint() for FlatMap 2013-07-30 01:48:17 +02:00
blake2-ppc
4b2931c90f iterator: implement DoubleEndedIterator for FlatMap 2013-07-30 01:48:17 +02:00
Brendan Zabarauskas
4f65fc7ef2 Improve std::num module description, and fix some formatting 2013-07-30 08:59:43 +10:00
Brendan Zabarauskas
b6ea0538a9 Add some missing method wrappers to std::num 2013-07-30 08:58:46 +10:00
bors
bb996bf92e auto merge of #8090 : blake2-ppc/rust/iterator-adaptor-names, r=pcwalton
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 15:49:18 -07:00
bors
d34016d109 auto merge of #8109 : blake2-ppc/rust/extern-fn-clone, r=thestinger
Implement Clone and DeepClone for functions with 0 to 8 arguments.  `extern fn()` is implicitly copyable so it's simple, except there is no way to implement it generically over #n function arguments.

Allows deriving of Clone on structs containing `extern "Rust" fn`.
2013-07-29 14:01:24 -07:00
Steve Klabnik
538fbc38c9 Adding an initial description to vec.rs.
Let's explain more of what this module is about, not just 'vectors.'
2013-07-29 16:18:41 -04:00
Ben Blum
7326bc879e Optimize try_recv to not require the two context switches when data is available. 2013-07-29 16:04:16 -04:00
Ben Blum
1137fbd9ab Remove ChanOneHack/PortOneHack extra allocation 2013-07-29 16:04:16 -04:00
blake2-ppc
11aad20cf8 std: Implement Clone and DeepClone for extern "Rust" fn
Implement Clone and DeepClone for functions with 0 to 8 arguments.
2013-07-29 19:43:21 +02:00
bors
8413d4769f auto merge of #8085 : mrordinaire/rust/percent-p, r=huonw
pull request for #8011
2013-07-29 05:40:26 -07:00
Do Nhat Minh
79f1052b19 Added %p directive to fmt!, which expects *T as argument 2013-07-29 20:34:01 +08:00
blake2-ppc
4b45f47881 std: Rename Iterator adaptor types to drop the -Iterator suffix
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 04:20:56 +02:00
blake2-ppc
4849a42bf6 std: Implement FromIterator for ~str
FromIterator initially only implemented for Iterator<char>, which is the
type of the main iterator.
2013-07-29 02:40:28 +02:00
jmgrosen
a0f0f3012e Refactored vec and str iterators to remove prefixes 2013-07-28 13:37:35 -07:00
Stepan Koltsov
b92d1ea723 ReaderUtil::each_byte shouldn't include EOF byte -- Issue #5056 2013-07-28 16:53:00 +04:00
bors
5842ab36b8 auto merge of #8087 : Aatch/rust/atomics, r=huonw
Adds a fence operation to close #8061

Also adds static initializers to for atomic types. Since the fields are private, you aren't able to have `static mut` variables that are an atomic type. Each atomic type's initializer starts at a 0-value (so unset for `AtomicFlag` and false for `AtomicBool`).
2013-07-28 03:55:22 -07:00
James Miller
639819f3d9 Fix spelling errors 2013-07-28 20:45:23 +12:00
James Miller
5c7e016700 Add static initializers for atomics 2013-07-28 20:26:49 +12:00
James Miller
4a1a0fbed5 Add an atomic fence intrinsic 2013-07-28 20:26:49 +12:00
bors
20454da2db auto merge of #8069 : erickt/rust/maikklein, r=erickt
Good evening,

This is a superset of @MaikKlein's #7969 commit, that I've fixed up to compile. I had a couple commits I wanted to do on top of @MaikKlein's work that I didn't want to bitrot.
2013-07-28 00:19:21 -07:00
Erick Tryzelaar
b147d70b08 std: cleanup imports in result::tests 2013-07-27 23:42:53 -07:00
Erick Tryzelaar
3478589b99 std and rustc: cleanup uses of result methods 2013-07-27 23:42:53 -07:00
Erick Tryzelaar
ea106f72f7 core: correct the casing of result::{Ok,Err} in the docs 2013-07-27 23:42:53 -07:00
Erick Tryzelaar
796b3371f9 std: Put the option tests into a tests submodule 2013-07-27 23:42:53 -07:00
Erick Tryzelaar
03a16dbb8e std: fix the casing of option::{Some,None} in the docs 2013-07-27 23:41:10 -07:00
Erick Tryzelaar
2a68c719f4 to_either + fixes 2013-07-27 23:41:09 -07:00
Erick Tryzelaar
aad53cb6e2 cleanup .map and .map_err 2013-07-27 23:41:09 -07:00
maikklein
9dc1de4c9e cleanup .get and .get_err 2013-07-27 23:41:09 -07:00
maikklein
f6bcf5d5f1 cleanup .chain and .chain_err + fixing other files 2013-07-27 23:41:09 -07:00
Erick Tryzelaar
e308167a2f cleanup .unwrap and .unwrap_err fixing io tests 2013-07-27 23:41:09 -07:00
Erick Tryzelaar
4eb95f6d1c cleanup .iter and .iter_err 2013-07-27 23:41:09 -07:00
Erick Tryzelaar
225f1c760d cleanup get_ref 2013-07-27 23:41:09 -07:00
Steven Stewart-Gallus
39b3a0561f Fix nits. 2013-07-27 22:06:29 -07:00
Steven Stewart-Gallus
d0b7515aed Change concurrency primitives to standard naming conventions
To be more specific:

`UPPERCASETYPE` was changed to `UppercaseType`
`type_new` was changed to `Type::new`
`type_function(value)` was changed to `value.method()`
2013-07-27 22:06:29 -07:00
bors
3078e83c3f auto merge of #8076 : omasanori/rust/cleanup, r=huonw
A cleanup suggested on #7922.
2013-07-27 20:13:22 -07:00
bors
82b29ae5a5 auto merge of #7864 : brson/rust/start-on-main-thread, r=brson
Applications that need to use the GUI can override start and set up the runtime using
this function.
2013-07-27 18:25:24 -07:00
Brian Anderson
34a27db8bf std::rt: Add start_on_main_thread function
Applications that need to use the GUI can override start and set up the runtime using
this function.
2013-07-27 17:36:14 -07:00
bors
b027c5fce3 auto merge of #8074 : thestinger/rust/iterator, r=cmr
d7c9bb4 r=alexcrichton
7ae17e0 r=huonw
2013-07-27 16:37:27 -07:00
Daniel Micay
fe955e7b06 iterator: add an Extendable trait 2013-07-27 17:42:10 -04:00
Daniel Micay
ffe549daf5 vec: replace some as_mut_buf with to_mut_ptr 2013-07-27 17:30:29 -04:00
blake2-ppc
7ae17e0964 Remove dummy type parameters from iterator adaptors
With the recent fixes to method resolution, we can now remove the
dummy type parameters used as crutches in the iterator module.

For example, the zip adaptor type is just ZipIterator<T, U> now.
2013-07-27 14:37:55 -04:00
Daniel Micay
d7c9bb4b68 vec: add mut_slice_{to,from}
Closes #8066
2013-07-27 14:36:52 -04:00
Daniel Micay
d6bc438bbc make RandomAccessIterator inherit from Iterator 2013-07-27 14:36:52 -04:00
bors
5157e05049 auto merge of #8036 : sfackler/rust/container-impls, r=msullivan
A couple of implementations of Container::is_empty weren't exactly
self.len() == 0 so I left them alone (e.g. Treemap).
2013-07-27 11:16:31 -07:00
bors
15310ba7c2 auto merge of #8040 : luqmana/rust/rtn, r=brson
Implements various missing tcp & udp methods.. Also fixes handling ipv4-mapped/compatible ipv6 addresses and addresses the XXX on `status_to_maybe_uv_error`.

r? @brson
2013-07-27 01:49:35 -07:00
OGINO Masanori
8d654fc41d Remove unnecessary #[path = "***/mod.rs"] lines.
Fixes #7922.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-07-27 15:53:30 +09:00
bors
4989799799 auto merge of #7986 : alexcrichton/rust/raw-repr, r=brson
This moves the raw struct layout of closures, vectors, boxes, and strings into a
new `unstable::raw` module. This is meant to be a centralized location to find
information for the layout of these values.

As safe method, `unwrap`, is provided to convert a rust value to its raw
representation. Unsafe methods to convert back are not provided because they are
rarely used and too numerous to write an implementation for each (not much of a
common pattern).

This is progress on #6790. I tried to get a nice interface for a trait to implement in the raw module, but I was unable to come up with one. The hard part is that there are so many different directions to go from one way to another that it's difficult to find a pattern to follow to implement a trait with. Someone else might have some better luck though.
2013-07-26 19:46:36 -07:00
Alex Crichton
5aaaca0c6a Consolidate raw representations of rust values
This moves the raw struct layout of closures, vectors, boxes, and strings into a
new `unstable::raw` module. This is meant to be a centralized location to find
information for the layout of these values.

As safe method, `repr`, is provided to convert a rust value to its raw
representation. Unsafe methods to convert back are not provided because they are
rarely used and too numerous to write an implementation for each (not much of a
common pattern).
2013-07-26 09:53:03 -07:00
bors
15ab6fde7f auto merge of #8039 : Xazax-hun/rust/master, r=brson
Added some more atomic operations. https://github.com/mozilla/rust/issues/7421
2013-07-26 08:02:06 -07:00
Luqman Aden
df67942dcc libstd: Tests for {peer, socket}_name. 2013-07-26 05:02:53 -04:00
Luqman Aden
037bf3757c libstd: Implement some missing udp methods. 2013-07-25 22:21:46 -04:00
Luqman Aden
a5c6b85091 libstd: Implement some missing tcp methods. 2013-07-25 19:42:19 -04:00
Luqman Aden
005ea3b173 libstd: Add ToStr impl for IpAddr. 2013-07-25 18:27:18 -04:00
Steven Fackler
feb18fe8da Added default impls for container methods
A couple of implementations of Container::is_empty weren't exactly
self.len() == 0 so I left them alone (e.g. Treemap).
2013-07-25 15:17:30 -07:00
bors
0012b5008b auto merge of #8030 : thestinger/rust/iterator, r=huonw 2013-07-25 13:49:43 -07:00
Luqman Aden
d6e1a6b237 libstd: Get rid of duplication in {peer, socket}_name and remove extra *. 2013-07-25 15:50:19 -04:00
bors
4cf30729f0 auto merge of #8026 : poiru/rust/issue-8024, r=alexcrichton
Closes #8024.
2013-07-25 05:22:44 -07:00
bors
906264b50f auto merge of #8015 : msullivan/rust/default-methods, r=nikomatsakis
Lots of changes to vtable resolution, handling of super/self method calls in default methods. Fix a lot of trait inheritance bugs.

r? @nikomatsakis
2013-07-25 03:07:44 -07:00
Luqman Aden
e2bb32bea1 libstd: Handle IPv4-Mapped/Compatible IPv6 addresses. 2013-07-25 05:57:52 -04:00
Luqman Aden
ac40d5323d libstd: Fix errors when rtdebug! is not a noop. 2013-07-25 05:57:52 -04:00
Luqman Aden
61e741cf71 libstd: Implement {peer, socket}_name for new rt tcp & udp. 2013-07-25 05:57:52 -04:00
Gábor Horváth
7cc8f4bae0 Added some more atomic operations. 2013-07-25 10:46:31 +02:00
Alex Crichton
7fd23e4fe2 Convert uses of transmute which don't need it 2013-07-24 23:12:28 -07:00
bors
467d381d3a auto merge of #7931 : blake2-ppc/rust/chain-mut-ref, r=pcwalton
First, clean up the uses of "None" and "Some" to always use consistent title case matching the variant names.

Add .chain_mut_ref() which is a missing method. A use case example for this method is extraction of an optional value from an Option\<Container\> value.
2013-07-24 19:25:38 -07:00
Daniel Micay
4517e39125 rm default method lint
default methods are enabled by default, so there's not much point in
keeping around a lint to report them as being experimental
2013-07-24 18:44:16 -04:00
bors
330378d1a1 auto merge of #7996 : erickt/rust/cleanup-strs, r=erickt
This is a cleanup pull request that does:

* removes `os::as_c_charp`
* moves `str::as_buf` and `str::as_c_str` into `StrSlice`
* converts some functions from `StrSlice::as_buf` to `StrSlice::as_c_str`
* renames `StrSlice::as_buf` to `StrSlice::as_imm_buf` (and adds `StrSlice::as_mut_buf` to match `vec.rs`.
* renames `UniqueStr::as_bytes_with_null_consume` to `UniqueStr::to_bytes`
* and other misc cleanups and minor optimizations
2013-07-24 13:25:36 -07:00
Birunthan Mohanathas
f73bb2bfe6 Implement std::num::Zero for bool
Closes #8024.
2013-07-24 22:54:32 +03:00
Erick Tryzelaar
9a950802ed std: str.as_bytes_with_null_consume() => str.to_bytes_with_null() 2013-07-24 12:33:49 -07:00
bors
f132401a0b auto merge of #7982 : thestinger/rust/iterator, r=thestinger
f0f4dcc r=huonw
25e9c4c r=graydon
a87c2d1 r=brson
16f369d r=cmr
9f05cc8 r=bstrie
e858055 r=huonw
5d80938 r=thestinger
05d03e7 r=cmr
8f86fa3 r=thestinger
2013-07-24 08:52:36 -07:00
Daniel Micay
4a2d22bdb1 fix compilation on macos/windows 2013-07-24 09:45:21 -04:00
Stepan Koltsov
c50d3e3fca ToStr for HashMap does not need value to implement Eq or Hash 2013-07-24 09:45:21 -04:00
Brian Anderson
6c88e46d4d std:rt: args module is not used by win/mac. #7951 2013-07-24 09:45:20 -04:00
Birunthan Mohanathas
d047cf1ec6 Change 'print(fmt!(...))' to printf!/printfln! in src/lib* 2013-07-24 09:45:20 -04:00
Daniel Micay
626bb5a866 add a RandomAccessIterator trait 2013-07-24 09:45:20 -04:00
bors
51028532d7 auto merge of #7993 : Xazax-hun/rust/master, r=bblum
Added missing memory orderings for atomic types. https://github.com/mozilla/rust/issues/7422
2013-07-24 06:37:36 -07:00
bors
7f96eb58d2 auto merge of #7980 : graydon/rust/misc-benchmarks, r=catamorphism
Some machinery for enabling #[bench] benchmarks in std and some examples showing how to write them.
2013-07-23 22:46:39 -07:00
Michael Sullivan
a0f8540c95 Fix some impls such that all supertraits are actually implemented. 2013-07-23 17:06:32 -07:00
Michael Sullivan
4b9759e20f Add a to_owned_vec method to IteratorUtil. 2013-07-23 17:06:32 -07:00
Erick Tryzelaar
9c3679a9a2 std: make str::append move self
This eliminates a copy and fixes a FIXME.
2013-07-23 16:57:00 -07:00
Erick Tryzelaar
bbedbc0450 std: inline str::with_capacity and vec::with_capacity 2013-07-23 16:57:00 -07:00
Erick Tryzelaar
cced3c9013 std: simplify str::as_imm_buf and vec::as_{imm,mut}_buf 2013-07-23 16:57:00 -07:00
Erick Tryzelaar
037a5b1af4 str: move as_mut_buf into OwnedStr, and make it self 2013-07-23 16:56:58 -07:00
Erick Tryzelaar
2dd3c44a56 std: remove a malloc from os::fill_charp_buf 2013-07-23 16:56:23 -07:00
Erick Tryzelaar
31b77aecfc std: remove str::to_owned and str::raw::slice_bytes_owned 2013-07-23 16:56:23 -07:00
Erick Tryzelaar
cc9666f68f std: rename str.as_buf to as_imm_buf, add str.as_mut_buf 2013-07-23 16:56:22 -07:00
Erick Tryzelaar
3b818edeba std and extra: use as_c_str instead of as_buf in a couple places
These uses are assuming the strings are null terminated, so it
should be using `as_c_str` instead of `as_buf`
2013-07-23 16:56:22 -07:00
Erick Tryzelaar
cf75330807 std: add test for str::as_c_str 2013-07-23 16:56:22 -07:00
Erick Tryzelaar
7af56bb921 std: move StrUtil::as_c_str into StrSlice 2013-07-23 16:56:22 -07:00
Erick Tryzelaar
9fdec67a67 std: move str::as_buf into StrSlice 2013-07-23 16:56:22 -07:00
Erick Tryzelaar
cfd89c4075 std: remove os::as_c_charp 2013-07-23 16:56:22 -07:00
Erick Tryzelaar
9ad815e063 std: rename str.as_bytes_with_null_consume to str.to_bytes_with_null 2013-07-23 16:56:17 -07:00
Graydon Hoare
978e5d94bc std: wrap "long" utf8 lines. 2013-07-23 16:02:14 -07:00
Gábor Horváth
1ce14116cc Added missing memory orderings for atomic types. 2013-07-23 12:34:40 +02:00
bors
0a5d1a1b81 auto merge of #7875 : sstewartgallus/rust/fubar, r=alexcrichton 2013-07-22 23:13:41 -07:00
bors
ff34064aa3 auto merge of #7916 : olsonjeffery/rust/newrt_timer, r=brson
My first bit of newsched IO work. Pretty simple and limited in scope.

the RtioTimer trait only has a `sleep(msecs: u64)` method, for now. Taking requests on what else ought to be here.

oh yeah: this resolves #6435
2013-07-22 17:28:35 -07:00
Graydon Hoare
d9c0634536 std: various additional language benchmarks in util. 2013-07-22 16:56:11 -07:00
Graydon Hoare
ca5ed4cc49 std: add benchmark for allocating-and-dropping a struct with a dtor. 2013-07-22 16:56:11 -07:00
Graydon Hoare
9f7e364d3a std: add #[bench] benchmarks for num::strconv 2013-07-22 16:56:11 -07:00
Graydon Hoare
d9776236c8 std: add #[bench] benchmarks for rand. 2013-07-22 16:56:10 -07:00
Graydon Hoare
3d5fb470fb std: add #[bench] benchmarks for global and local heaps. 2013-07-22 16:56:10 -07:00
Graydon Hoare
e5cbede103 std: add preliminary str benchmark. 2013-07-22 16:56:10 -07:00
Graydon Hoare
786318f61b std: add #[cfg(test)] reference to extra so we can benchmark libstd. 2013-07-22 16:56:10 -07:00