Erick Tryzelaar
91d6c60bed
fix various warnings
2013-08-30 15:10:55 -07:00
Alex Crichton
e3662b1880
Remove offset_inbounds for an unsafe offset function
2013-08-27 23:22:52 -07:00
Patrick Walton
5c3504799d
librustc: Remove &const
and *const
from the language.
...
They are still present as part of the borrow check.
2013-08-27 18:46:51 -07:00
bors
9e1e152091
auto merge of #8596 : vadimcn/rust/master, r=alexcrichton
...
This resolves issue #908 .
Notable changes:
- On Windows, LLVM integrated assembler emits bad stack unwind tables when segmented stacks are enabled. However, unwind info directives in the assembly output are correct, so we generate assembly first and then run it through an external assembler, just like it is already done for Android builds.
- Linker is invoked via "g++" command instead of "gcc": g++ passes the appropriate magic parameters to the linker, which ensure correct registration of stack unwind tables in dynamic libraries.
2013-08-22 21:06:25 -07:00
Vadim Chugunov
12ecdb6381
Enabled unit tests in std and extra.
2013-08-22 20:02:20 -07:00
Niko Matsakis
ffb6404c5a
Adjust callbacks in the libraries for the new type of extern fns
...
cc #3678
2013-08-21 10:50:42 -04:00
bors
3bc6858428
auto merge of #8551 : huonw/rust/speling, r=alexcrichton
...
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-18 05:11:58 -07:00
Erick Tryzelaar
be86bc81a7
Fix warnings in tests
2013-08-17 08:41:35 -07:00
bors
680eb71564
auto merge of #8532 : kballard/rust/cstr-cleanup, r=erickt
...
Implement interior null checking in `.to_c_str()`, among other changes.
2013-08-16 06:02:14 -07:00
Huon Wilson
abe94f9b4d
doc: correct spelling in documentation.
2013-08-16 15:41:28 +10:00
Daniel Micay
062747b9c9
ptr: inline the Clone implementation
2013-08-15 21:12:34 -04:00
Kevin Ballard
03ef71e262
Add ToCStr method .with_c_str()
...
.with_c_str() is a replacement for the old .as_c_str(), to avoid
unnecessary boilerplate.
Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-15 01:33:10 -07:00
Alex Crichton
930885d5e5
Forbid pub/priv where it has no effect
...
Closes #5495
2013-08-12 23:20:46 -07:00
Daniel Micay
0cb0ef2ca5
fix build with the new snapshot compiler
2013-08-12 17:37:46 -04:00
Erick Tryzelaar
a54476b0aa
Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls
2013-08-07 14:10:39 -07:00
Daniel Micay
55f3d04101
vec: use offset_inbounds
for iterators
...
This allows LLVM to optimize vector iterators to an `getelementptr` and
`icmp` pair, instead of `getelementptr` and *two* comparisons.
Code snippet:
~~~
fn foo(xs: &mut [f64]) {
for x in xs.mut_iter() {
*x += 10.0;
}
}
~~~
LLVM IR at stage0:
~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
%2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
%3 = load double** %2, align 8
%4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
%5 = load i64* %4, align 8
%6 = ptrtoint double* %3 to i64
%7 = and i64 %5, -8
%8 = add i64 %7, %6
%9 = inttoptr i64 %8 to double*
%10 = icmp eq double* %3, %9
%11 = icmp eq double* %3, null
%or.cond6 = or i1 %10, %11
br i1 %or.cond6, label %match_case, label %match_else
match_else: ; preds = %"function top level", %match_else
%12 = phi double* [ %13, %match_else ], [ %3, %"function top level" ]
%13 = getelementptr double* %12, i64 1
%14 = load double* %12, align 8
%15 = fadd double %14, 1.000000e+01
store double %15, double* %12, align 8
%16 = icmp eq double* %13, %9
%17 = icmp eq double* %13, null
%or.cond = or i1 %16, %17
br i1 %or.cond, label %match_case, label %match_else
match_case: ; preds = %match_else, %"function top level"
ret void
}
~~~
Optimized LLVM IR at stage1/stage2:
~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
%2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
%3 = load double** %2, align 8
%4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
%5 = load i64* %4, align 8
%6 = lshr i64 %5, 3
%7 = getelementptr inbounds double* %3, i64 %6
%8 = icmp eq i64 %6, 0
%9 = icmp eq double* %3, null
%or.cond6 = or i1 %8, %9
br i1 %or.cond6, label %match_case, label %match_else
match_else: ; preds = %"function top level", %match_else
%.sroa.0.0.in7 = phi double* [ %10, %match_else ], [ %3, %"function top level" ]
%10 = getelementptr inbounds double* %.sroa.0.0.in7, i64 1
%11 = load double* %.sroa.0.0.in7, align 8
%12 = fadd double %11, 1.000000e+01
store double %12, double* %.sroa.0.0.in7, align 8
%13 = icmp eq double* %10, %7
br i1 %13, label %match_case, label %match_else
match_case: ; preds = %match_else, %"function top level"
ret void
}
~~~
2013-08-06 23:54:24 -04:00
Daniel Micay
7d115c9420
add an intrinsic for inbounds GEP
2013-08-06 23:41:20 -04:00
Erick Tryzelaar
5eaa4d1d2f
Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls
2013-08-06 16:21:02 -07:00
blake2-ppc
ea9c5c405e
std: Remove uint::iterate, replaced by range
2013-08-06 04:05:08 +02:00
Erick Tryzelaar
3c94b5044c
Merge remote-tracking branch 'remotes/origin/master' into str-remove-null
2013-08-04 16:23:41 -07:00
Erick Tryzelaar
bd908d4c0e
std and rustc: explicitly pass c strings to c functions
...
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-04 15:45:16 -07:00
Erick Tryzelaar
3102b1797e
std: replace str::as_c_str with std::c_str
2013-08-04 14:13:17 -07:00
Daniel Micay
9f74217d80
register snapshots
2013-08-03 21:09:28 -04: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
Erick Tryzelaar
7af56bb921
std: move StrUtil::as_c_str into StrSlice
2013-07-23 16:56:22 -07:00
bors
3514a5af06
auto merge of #7857 : blake2-ppc/rust/fix-test-warnings, r=alexcrichton
...
Fix warnings that only show up when compiling the tests for libstd, libextra and one in librusti. Only trivial changes.
2013-07-18 20:55:38 -07:00
bors
559d2ef925
auto merge of #7842 : thestinger/rust/closure, r=huonw
2013-07-18 08:37:39 -07:00
blake2-ppc
ff9b75f26d
Fix warnings in libstd and librusti tests
2013-07-18 02:18:56 +02:00
Patrick Walton
99b33f7219
librustc: Remove all uses of "copy".
2013-07-17 14:57:51 -07:00
Daniel Micay
0bc204e74d
rm unnecessary stage0 zero_memory
fn
2013-07-17 14:08:54 -04:00
=Mark Sinclair
294999c350
Added overloaded Add and Sub traits for pointer arithmetic
...
Implemented ptr arithmetic for *T and *mut T. Tests passing
2013-07-10 06:34:00 -04:00
Daniel Micay
6f5be9063d
ptr: optimize {swap,replace,read}_ptr
2013-07-09 22:44:11 -04:00
Niko Matsakis
59083d2c6a
Address nits by @catamorphism
2013-07-08 13:55:10 -04:00
Niko Matsakis
ba13482dfa
update ptr intrinsics and rewrite vec routines to be more correct.
...
In particular, it is not valid to go around passing uninitialized or zero'd
memory as arguments. Rust should generally be free to assume that the arguments
it gets are valid input values, but the output of intrinsics::uninit() and
intrinsics::init() are not (e.g., an @T is just null, leading to an error
if we should try to increment the ref count).
2013-07-08 13:53:44 -04:00
Huon Wilson
cdea73cf5b
Convert vec::{as_imm_buf, as_mut_buf} to methods.
2013-07-04 00:46:50 +10:00
Alex Crichton
b29c368674
Removing a lot of usage of '&const'
2013-06-29 08:35:48 -07:00
James Miller
3bc4d1a120
Remove all #[cfg(stage0)]-protected code
...
New snapshot means this can all go. Also removes places that have
comments that say they are workarounds for stage0 errors.
2013-06-21 02:43:02 +12:00
Graydon Hoare
d904c72af8
replace #[inline(always)] with #[inline]. r=burningtree.
2013-06-18 14:48:48 -07:00
Daniel Micay
fbae011ad1
fix the docstring for copy_nonoverlapping_memory
2013-06-11 19:06:01 -04:00
Daniel Micay
107e371bf0
fix the ptr::set_memory docstring
2013-06-11 17:48:44 -04:00
Huon Wilson
98ba91f81b
remove unused import warnings
2013-06-09 02:22:23 +10:00
Daniel Micay
8bcefef2f2
libc: omit memcpy, memmove and memset
...
LLVM provides these functions as intrinsics, and will generate calls to
libc when appropriate. They are exposed in the `ptr` module as
`copy_nonoverlapping_memory`, `copy_memory` and `set_memory`.
2013-06-06 15:18:45 -04:00
Daniel Micay
e900dba28a
rename the Ptr trait to RawPtr
...
Closes #6607
2013-06-03 13:50:29 -04:00
Daniel Micay
454133127a
ptr: split out borrowed pointer utilities
...
The ptr module is intended to be for raw pointers.
Closes #3111
2013-06-02 19:24:33 -04:00
Daniel Micay
042618da7b
ptr: replace unnecessary unsafe code
2013-05-31 11:32:27 -04:00
Daniel Micay
29aba8033a
mv the raw pointer {swap,replace}_ptr to std::ptr
2013-05-31 10:31:26 -04:00
Alex Crichton
007651cd26
Require documentation by default for libstd
...
Adds documentation for various things that I understand.
Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-30 01:02:55 -05:00
Patrick Walton
206ab89629
librustc: Stop reexporting the standard modules from prelude.
2013-05-29 19:04:53 -07:00
Alex Crichton
b04c40bb1c
Silence various warnings throughout test modules
2013-05-28 15:27:35 -05:00
Daniel Micay
e6c04dea03
fix casts on 32-bit
2013-05-27 18:14:00 -04:00