Commit Graph

3487 Commits

Author SHA1 Message Date
bors
88b0b511be auto merge of #9578 : alexcrichton/rust/un-ignore-libuv-process-tests, r=brson
Closes #9341
2013-10-01 17:41:29 -07:00
Alex Crichton
02cbfce0b3 Move the rt::io::process tests to run-pass
Closes #9341
2013-10-01 17:04:17 -07:00
Daniel Micay
c9d4ad07c4 remove the float type
It is simply defined as `f64` across every platform right now.

A use case hasn't been presented for a `float` type defined as the
highest precision floating point type implemented in hardware on the
platform. Performance-wise, using the smallest precision correct for the
use case greatly saves on cache space and allows for fitting more
numbers into SSE/AVX registers.

If there was a use case, this could be implemented as simply a type
alias or a struct thanks to `#[cfg(...)]`.

Closes #6592

The mailing list thread, for reference:

https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-10-01 14:54:10 -04:00
bors
12404aaadd auto merge of #9644 : alexcrichton/rust/clarify, r=huonw
It was a little ambiguous before how explicitl positional parameters and
implicit positional parameters intermingled, and this clarifies how the two
intermingle. This also updates a little bit of documentation/code examples
elsewhere as well.
2013-10-01 06:26:31 -07:00
bors
d6c3b67348 auto merge of #9576 : FlaPer87/rust/issue/9125, r=alexcrichton
Fixes #9125
2013-10-01 02:06:32 -07:00
Alex Crichton
dec37051dd Merge fall out of removing fmt! 2013-10-01 00:06:51 -07:00
Flavio Percoco
d379ff474f Update std::task::mod docstring 2013-10-01 09:03:04 +02:00
Alex Crichton
a8ba31dbf3 std: Remove usage of fmt! 2013-09-30 23:21:18 -07:00
Alex Crichton
23cb72b459 Clarify format! implicit positional references
It was a little ambiguous before how explicitl positional parameters and
implicit positional parameters intermingled, and this clarifies how the two
intermingle. This also updates a little bit of documentation/code examples
elsewhere as well.
2013-09-30 20:16:23 -07:00
bors
8174618a05 auto merge of #9619 : toffaletti/rust/mmap, r=huonw 2013-09-30 05:01:23 -07:00
Jason Toffaletti
b617569583 reduce heap allocations for MemoryMap 2013-09-29 23:05:40 -07:00
klutzy
f4f6b951d7 std::rt::uv::net: Enable tests on Win32
Closes #8815.
2013-09-30 13:56:55 +09:00
Alex Crichton
c687f6fa92 Put a newline after each logging message 2013-09-29 12:39:49 -07:00
bors
c635fba748 auto merge of #9583 : blake2-ppc/rust/connect-vec, r=huonw
std::vec: Sane implementations for connect_vec and concat_vec

Avoid unnecessary copying of subvectors, and calculate the needed space
beforehand. These implementations are simple but better than the
previous.

Also only implement it once, for all `Vector<T>` using:

    impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V]

Closes #9581
2013-09-28 07:31:02 -07:00
bors
4d81e38512 auto merge of #9574 : FlaPer87/rust/suppress_warnings, r=metajack
Small change that suppresses a warning because of an unused import.
2013-09-27 23:51:03 -07:00
bors
c151d371fc auto merge of #9562 : alexcrichton/rust/snapshots, r=thestinger 2013-09-27 21:56:04 -07:00
blake2-ppc
3709aa78d8 std::vec: Remove functions concat, connect
std::vec::{concat, connect, concat_slices, connect_slices} are replaced
by the already existing trait methods .concat_vec() and .connect_vec().
2013-09-28 05:56:49 +02:00
bors
4a2f8ba8c9 auto merge of #9559 : sfackler/rust/more-visibility, r=alexcrichton 2013-09-27 20:31:05 -07:00
blake2-ppc
24a4d0daf0 std::vec: Sane implementations for connect_vec and concat_vec
Avoid unnecessary copying of subvectors, and calculate the needed space
beforehand. These implementations are simple but better than the
previous.

Also only implement it once, for all `Vector<T>` using:

    impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V]

performance improved according to the bench test:

    before
    test vec::bench::concat ... bench: 74818 ns/iter (+/- 408)
    test vec::bench::connect ... bench: 87066 ns/iter (+/- 376)

    after
    test vec::bench::concat ... bench: 17724 ns/iter (+/- 126)
    test vec::bench::connect ... bench: 18353 ns/iter (+/- 691)

Closes #9581
2013-09-28 05:25:18 +02:00
blake2-ppc
5444f601dc std::vec: Add benchmark for .concat_vec and .connect_vec 2013-09-28 04:53:46 +02:00
bors
3ae895360c auto merge of #9557 : blake2-ppc/rust/vec-lifetime-token, r=thestinger
std::vec: Use a valid value as lifetime dummy in iterator

The current implementation uses `&v[0]` for the lifetime struct field,
but that is a dangling pointer for iterators derived from zero-length
slices.

Example:

    let v: [int, ..0] = [];  println!("{:?}", v.iter())

    std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128}

To replace this parameter, use a field of type `Option<&'self ()>`
that is simply initialized with `None`, but still allows the iterator to
have a lifetime parameter.
2013-09-27 19:16:05 -07:00
bors
67394f20eb auto merge of #9552 : brson/rust/0.9-pre, r=alexcrichton 2013-09-27 13:51:07 -07:00
Flavio Percoco
d7e8f4cb03 Suppress warning by removing unused import 2013-09-27 21:36:14 +02:00
bors
10e7f12daf auto merge of #9550 : alexcrichton/rust/remove-printf, r=thestinger
The 0.8 release was cut, down with printf!
2013-09-27 08:21:23 -07:00
Alex Crichton
46aaf5128d Register new snapshots 2013-09-27 00:44:32 -07:00
Erick Tryzelaar
b1ee87f402 std: simplify vec.with_c_str
This also fixes a bug in `vec.with_c_str_unchecked` where we
were not calling `.to_c_str_unchecked()` for long strings.
2013-09-26 22:49:10 -07:00
Erick Tryzelaar
2d878033fd std: add micro optimization to vec.with_c_str_unchecked
before:

test c_str::bench::bench_with_c_str_unchecked_long ... bench: 361 ns/iter (+/- 9)
test c_str::bench::bench_with_c_str_unchecked_medium ... bench: 75 ns/iter (+/- 2)
test c_str::bench::bench_with_c_str_unchecked_short ... bench: 60 ns/iter (+/- 9)

after:

test c_str::bench::bench_with_c_str_unchecked_long ... bench: 362 ns/iter (+/-
test c_str::bench::bench_with_c_str_unchecked_medium ... bench: 30 ns/iter (+/- 7)
test c_str::bench::bench_with_c_str_unchecked_short ... bench: 12 ns/iter (+/- 4)
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
4868273d97 std: Up vec.with_c_str's stack buffer to 128
This matches @graydon's recommendation.
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
ca66b81283 std: Remove an unnecessary comment from c_str
The documentation for `.with_c_str()` already says that the pointer
will be deallocated before returning from the function.
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
e02d1eb171 std: Micro-optimize vec.with_c_str for short vectors
This now makes it unsafe to save the pointer returned by .with_c_str
as that pointer now may be pointing at a stack allocated array.

I arbitrarily chose 32 bytes as the length of the stack vector, and
so it might not be the most optimal size.

before:

test c_str::bench::bench_with_c_str_long ... bench: 539 ns/iter (+/- 91)
test c_str::bench::bench_with_c_str_medium ... bench: 97 ns/iter (+/- 2)
test c_str::bench::bench_with_c_str_short ... bench: 70 ns/iter (+/- 5)

after:

test c_str::bench::bench_with_c_str_long ... bench: 542 ns/iter (+/- 13)
test c_str::bench::bench_with_c_str_medium ... bench: 53 ns/iter (+/- 6)
test c_str::bench::bench_with_c_str_short ... bench: 19 ns/iter (+/- 0)
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
410a96cc79 std: Add benchmarks to c_str 2013-09-26 22:20:40 -07:00
Erick Tryzelaar
2a9e763304 std: implement Container for CString 2013-09-26 22:20:39 -07:00
Erick Tryzelaar
0bdc99d81f std: removed some warnings in tests. 2013-09-26 22:20:39 -07:00
Erick Tryzelaar
4834661c66 std and rustc: Convert users of c_str to use .with_c_str 2013-09-26 22:20:39 -07:00
Steven Fackler
fe9b1e29fc Visibility fixes 2013-09-26 22:01:33 -07:00
blake2-ppc
c0e1c09783 std::vec: Use a valid value as lifetime dummy in iterator
The current implementation uses `&v[0]` for the lifetime struct field,
but that is a dangling pointer for iterators derived from zero-length
slices.

Example:

    let v: [int, ..0] = [];  println!("{:?}", v.iter())

    std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128}

To replace this parameter, use a field of type `Option<&'self ()>`
that is simply initialized with `None`, but still allows the iterator to
have a lifetime parameter.
2013-09-27 06:06:13 +02:00
Brian Anderson
99c1fb8c66 Update version numbers to 0.9-pre 2013-09-26 18:18:42 -07:00
bors
1434b4bfca auto merge of #9261 : alexcrichton/rust/logging, r=huonw
This lifts various restrictions on the runtime, for example the character limit
when logging a message. Right now the old debug!-style macros still involve
allocating (because they use fmt! syntax), but the new debug2! macros don't
involve allocating at all (unless the formatter for a type requires allocation.
2013-09-26 17:11:13 -07:00
Alex Crichton
409182de6d Update the compiler to not use printf/printfln 2013-09-26 17:05:59 -07:00
bors
c486634118 auto merge of #9507 : brson/rust/sched, r=alexcrichton
This also includes a fix for yielding from single-threaded schedulers where the scheduler would stop working before its work queue was empty. Fixes the deadlocks that this patch had previously.
2013-09-26 10:46:15 -07:00
bors
6f991a2441 auto merge of #9506 : sfackler/rust/visibility, r=alexcrichton 2013-09-26 09:21:09 -07:00
bors
930f7790fb auto merge of #9497 : pnkfelix/rust/fsk-7752-use-fcnptr-for-glob-errfunc, r=cmr
Fix #7752.

~~(The glob API is a little funky; I tried to make a small test for it, which I'll add to the end of this description, and its not clear whether globfree is supposed to free solely the structure allocated by glob itself, or if it is going to try to free more than that.)~~ (The previous note was a user-error: I was misusing the CString API.)

Anyway, this seems to work in terms of calling errfunc where expected.)

```rust
#[allow(unused_imports)];
use std::libc::types::os::arch::c95::{c_char, c_int, size_t};
use std::libc::funcs::posix01::glob;
use std::libc::types::os::common::posix01::glob_t;
use std::libc::consts::os::posix01::{GLOB_APPEND, GLOB_DOOFFS, GLOB_ERR,
                                     GLOB_MARK, GLOB_NOCHECK, GLOB_NOSORT,
                                     GLOB_NOESCAPE, GLOB_NOSPACE,
                                     GLOB_ABORTED, GLOB_NOMATCH};
use std::ptr;
use std::c_str;

#[fixed_stack_segment]
fn main() {
    let mut g = glob_t {
        gl_pathc:  0, // size_t,
        __unused1: 0, // c_int,
        gl_offs:   2, // size_t,
        __unused2: 0, // c_int,
        gl_pathv:  ptr::null(), // **c_char,

        __unused3: ptr::null(), // *c_void,

        __unused4: ptr::null(), // *c_void,
        __unused5: ptr::null(), // *c_void,
        __unused6: ptr::null(), // *c_void,
        __unused7: ptr::null(), // *c_void,
        __unused8: ptr::null(), // *c_void,
    };

    extern "C" fn errfunc(_epath: *c_char, _errno: int) -> int {
        println!("errfunc called");
        return 0;
    }

    struct Reduced { pathc: size_t, offs: size_t, pathv: **c_char, }
    impl Reduced {
        fn from(g: &glob_t) -> Reduced {
            Reduced {pathc: g.gl_pathc, offs: g.gl_offs, pathv: g.gl_pathv}
        }
    }

    do ("*.rs/*").with_c_str |pat| {
        println!("calling glob");
        unsafe { glob::glob(pat, GLOB_DOOFFS, errfunc, &mut g); }
        println!("After glob call");

        println!("g: {:?}", Reduced::from(&g));
        for i in range(0, g.gl_pathc as int) {
            unsafe {
                let p : **c_char = ptr::offset(g.gl_pathv, g.gl_offs as int + i);
                let x = c_str::CString::new(*p, false);
                match x.as_str() {
                    Some(s) => {
                        println!("gl_pathc[{:d}]: {:?}", i, s);
                    }
                    None => {
                        println!("gl_pathc[{:d}]: unvalid", i);
                    }
                }
            }
        }
    }

    println!("calling globfree on g: {:?}", g);
    unsafe { glob::globfree(&mut g); }
    println!("after globfree call");

}

```
2013-09-26 04:16:03 -07:00
bors
a268a1c4bb auto merge of #9490 : alexcrichton/rust/issue-9487, r=cmr
If there's no TLS key just yet, then there's nothing to unsafely borrow, so
continue returning None. This prevents causing the runtime to abort itself when
logging before the runtime is fully initialized.

Closes #9487

r? @brson
2013-09-26 00:30:57 -07:00
bors
5adfa10387 auto merge of #9404 : blake2-ppc/rust/result-map-opt, r=cmr
std::result: Remove function `map_opt`.

This function has never had any users in the tree, so this is my
initiative to remove this function.
2013-09-25 22:30:53 -07:00
Brian Anderson
d209717ddd std::rt: Implement task yielding. Fix a starvation problem 2013-09-25 20:05:56 -07:00
Marvin Löbel
e94b3fae39 Moved StrSlice doc comments from impl to trait.
Moved OwnedStr doc comments from impl to trait.
Added a few #[inline] hints.

The doc comment changes make the source a bit harder to read, as
documentation and implementation no longer live right next to each
other. But this way they at least appear in the docs.
2013-09-26 04:44:36 +02:00
Steven Fackler
d8957e6332 Some struct visibility fixes 2013-09-25 19:42:02 -07:00
Alex Crichton
eb2b25dd6d Refactor the logging system for fewer allocations
This lifts various restrictions on the runtime, for example the character limit
when logging a message. Right now the old debug!-style macros still involve
allocating (because they use fmt! syntax), but the new debug2! macros don't
involve allocating at all (unless the formatter for a type requires allocation.
2013-09-25 16:30:05 -07:00
Felix S. Klock II
48b4b1f52c errfunc ptr is nullable, so use Option as part of interface to glob (#7752). 2013-09-25 23:38:59 +02:00
Alex Crichton
f648690234 rustdoc: Strip hidden docs by default. 2013-09-25 14:27:43 -07:00