Commit Graph

20740 Commits

Author SHA1 Message Date
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
Dmitry Ermolov
ef7e94550c Fix comment. 2013-07-31 00:08:53 +04:00
Dmitry Ermolov
ed0f014935 Fix opts_str.
opt_val doesn't not fail! for missing options.

Closes #6492
2013-07-30 23:26:52 +04:00
Dmitry Ermolov
0ed8713d79 Modify test to expose issue #6492. 2013-07-30 23:23:19 +04:00
bors
436d9fa45d auto merge of #8133 : blake2-ppc/rust/overlong-utf8, r=cmr
Fix is_utf8 and UTF-8 char width functions to deny non-canonical 'overlong encodings' in UTF-8.

We address the function is_utf8 to make it more strict and correct, but no changes are made to the handling of invalid UTF-8.

Fixes issue #3787
2013-07-30 12:16:20 -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
bors
0068bd73e0 auto merge of #8131 : Seldaek/rust/getopt_usage_newline, r=brson
It makes things ugly when the last thing you print is the usage() output, resulting in something like:

```
$ rust run foo.rs -h
Lala

Options:
    -h --help           display this help and exit
    -V --version        output version information and exit

$ prompt
```
2013-07-30 10:28:18 -07: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
Jordi Boggiano
f7ebab4403 Do not enforce two newlines after the options 2013-07-30 18:40:01 +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
bors
7fc8c14c1b auto merge of #8082 : Kimundi/rust/master, r=huonw
Also renamed bytes_iter to byte_iter to match other iterators
2013-07-30 05:13:17 -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
bors
c124f21af5 auto merge of #8110 : brson/rust/no-rebuild, r=bblum
...oses #8101
2013-07-30 03:25:19 -07:00
bors
d75ab4a5d7 auto merge of #8107 : michaelwoerister/rust/end_of_spanned, r=cmr
Contiunation of naming cleanup in `libsyntax::ast`:
```rust
ast::node_id => ast::NodeId
ast::local_crate => ast::LOCAL_CRATE
ast::crate_node_id => ast::CRATE_NODE_ID
ast::blk_check_mode => ast::BlockCheckMode
ast::ty_field => ast::TypeField
ast::ty_method => ast::TypeMethod
```
Also moved span field directly into `TypeField` struct and cleaned up overlooked `ast::CrateConfig` renamings from last pull request.

Cheers,
Michael
2013-07-30 01:37:17 -07: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
bors
e94e4d51ca auto merge of #8120 : blake2-ppc/rust/iterator-fixes, r=thestinger
Implement RandomAccessIterator (RAI) where possible, for Iterator adaptors such as Map, Enumerate, Peek, Skip, Take, Cycle, where the adapted iterator is already RAI, and for collections where it is relevant (ringbuf and bitv).

After discussion with thestinger, remove the RAI impl for VecMutIterator, we cannot soundly provide mutable access with this trait.

Implement Extendable everywhere FromIterator is already implemented.

Fixes issue #8108.
2013-07-29 19:04:22 -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
ae09d95160 extra: Add .rev_iter() for bitv 2013-07-30 02:48:40 +02:00
blake2-ppc
5307d3674e std: Implement Extendable for hashmap, str and trie 2013-07-30 02:32:38 +02:00
blake2-ppc
f8ae526f70 extra: Implement iterator::Extendable 2013-07-30 02:06:49 +02:00
blake2-ppc
f68621326e extra: Implement RandomAccessIterator for RingBuf 2013-07-30 01:48:17 +02:00
blake2-ppc
2f10d1e295 extra: Implement DoubleEnded and RandomAccess iterators for bitv 2013-07-30 01:48:17 +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
Brian Anderson
ceba95ced2 mk: Add NO_BENCH variable for turning off the --bench flag 2013-07-29 12:43:45 -07:00
Brian Anderson
ac2cd14867 mk: Rename CTEST_BENCH to TEST_BENCH
The CTEST prefix is specifically related to the compiletest driver
2013-07-29 12:38:12 -07:00