summary refs log tree commit diff
path: root/src/libstd/ptr.rs
AgeCommit message (Collapse)AuthorLines
2013-09-18Register new snapshotsAlex Crichton-83/+4
2013-09-12implement raw pointer comparisons in librustcDaniel Micay-4/+64
This is mostly for consistency, as you can now compare raw pointers in constant expressions or without the standard library. It also reduces the number of `ptrtoint` instructions in the IR, making tracking down culprits of what's usually an anti-pattern easier.
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-1/+1
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2013-08-30fix various warningsErick Tryzelaar-0/+1
2013-08-27Remove offset_inbounds for an unsafe offset functionAlex Crichton-76/+22
2013-08-27librustc: Remove `&const` and `*const` from the language.Patrick Walton-32/+114
They are still present as part of the borrow check.
2013-08-22auto merge of #8596 : vadimcn/rust/master, r=alexcrichtonbors-2/+0
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-22Enabled unit tests in std and extra.Vadim Chugunov-2/+0
2013-08-21Adjust callbacks in the libraries for the new type of extern fnsNiko Matsakis-0/+41
cc #3678
2013-08-18auto merge of #8551 : huonw/rust/speling, r=alexcrichtonbors-1/+1
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-17Fix warnings in testsErick Tryzelaar-1/+1
2013-08-16auto merge of #8532 : kballard/rust/cstr-cleanup, r=ericktbors-4/+4
Implement interior null checking in `.to_c_str()`, among other changes.
2013-08-16doc: correct spelling in documentation.Huon Wilson-1/+1
2013-08-15ptr: inline the Clone implementationDaniel Micay-0/+1
2013-08-15Add ToCStr method .with_c_str()Kevin Ballard-4/+4
.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-12Forbid pub/priv where it has no effectAlex Crichton-4/+4
Closes #5495
2013-08-12fix build with the new snapshot compilerDaniel Micay-22/+0
2013-08-07Merge remote-tracking branch 'remotes/origin/master' into ↵Erick Tryzelaar-0/+41
remove-str-trailing-nulls
2013-08-06vec: use `offset_inbounds` for iteratorsDaniel Micay-1/+20
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-06add an intrinsic for inbounds GEPDaniel Micay-0/+22
2013-08-06Merge remote-tracking branch 'remotes/origin/master' into ↵Erick Tryzelaar-4/+3
remove-str-trailing-nulls
2013-08-06std: Remove uint::iterate, replaced by `range`blake2-ppc-4/+3
2013-08-04Merge remote-tracking branch 'remotes/origin/master' into str-remove-nullErick Tryzelaar-26/+0
2013-08-04std and rustc: explicitly pass c strings to c functionsErick Tryzelaar-47/+54
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-04std: replace str::as_c_str with std::c_strErick Tryzelaar-11/+12
2013-08-03register snapshotsDaniel Micay-26/+0
2013-07-30implement pointer arithmetic with GEPDaniel Micay-21/+46
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-23std: move StrUtil::as_c_str into StrSliceErick Tryzelaar-10/+6
2013-07-18auto merge of #7857 : blake2-ppc/rust/fix-test-warnings, r=alexcrichtonbors-3/+4
Fix warnings that only show up when compiling the tests for libstd, libextra and one in librusti. Only trivial changes.
2013-07-18auto merge of #7842 : thestinger/rust/closure, r=huonwbors-28/+6
2013-07-18Fix warnings in libstd and librusti testsblake2-ppc-3/+4
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-2/+9
2013-07-17rm unnecessary stage0 `zero_memory` fnDaniel Micay-28/+6
2013-07-10Added overloaded Add and Sub traits for pointer arithmetic=Mark Sinclair-0/+96
Implemented ptr arithmetic for *T and *mut T. Tests passing
2013-07-09ptr: optimize {swap,replace,read}_ptrDaniel Micay-6/+6
2013-07-08Address nits by @catamorphismNiko Matsakis-1/+1
2013-07-08update ptr intrinsics and rewrite vec routines to be more correct.Niko Matsakis-0/+50
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-04Convert vec::{as_imm_buf, as_mut_buf} to methods.Huon Wilson-1/+1
2013-06-29Removing a lot of usage of '&const'Alex Crichton-9/+9
2013-06-21Remove all #[cfg(stage0)]-protected codeJames Miller-63/+6
New snapshot means this can all go. Also removes places that have comments that say they are workarounds for stage0 errors.
2013-06-18replace #[inline(always)] with #[inline]. r=burningtree.Graydon Hoare-37/+37
2013-06-11fix the docstring for copy_nonoverlapping_memoryDaniel Micay-9/+25
2013-06-11fix the ptr::set_memory docstringDaniel Micay-4/+4
2013-06-09remove unused import warningsHuon Wilson-2/+0
2013-06-06libc: omit memcpy, memmove and memsetDaniel Micay-23/+1
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-03rename the Ptr trait to RawPtrDaniel Micay-3/+3
Closes #6607
2013-06-02ptr: split out borrowed pointer utilitiesDaniel Micay-46/+0
The ptr module is intended to be for raw pointers. Closes #3111
2013-05-31ptr: replace unnecessary unsafe codeDaniel Micay-58/+18
2013-05-31mv the raw pointer {swap,replace}_ptr to std::ptrDaniel Micay-0/+31
2013-05-30Require documentation by default for libstdAlex Crichton-0/+29
Adds documentation for various things that I understand. Adds #[allow(missing_doc)] for lots of things that I don't understand.