diff options
| author | bors <bors@rust-lang.org> | 2013-06-06 19:40:32 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-06-06 19:40:32 -0700 |
| commit | 74d9de7abdceb2cb11a5e8a79eaec6ea2c70ea35 (patch) | |
| tree | 5a0897f86c7921289969d19a0fff597708acf947 /src/libstd/ptr.rs | |
| parent | 5d2cadbfea34ebbd0d83495833395b005380f2ec (diff) | |
| parent | 8bcefef2f2747dc7b2f48ba7924101dc70492cf0 (diff) | |
| download | rust-74d9de7abdceb2cb11a5e8a79eaec6ea2c70ea35.tar.gz rust-74d9de7abdceb2cb11a5e8a79eaec6ea2c70ea35.zip | |
auto merge of #6979 : thestinger/rust/libc, r=brson
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`. @graydon: r?
Diffstat (limited to 'src/libstd/ptr.rs')
| -rw-r--r-- | src/libstd/ptr.rs | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index c656a3eef62..c8e2f58d801 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -20,22 +20,6 @@ use unstable::intrinsics; #[cfg(not(test))] use cmp::{Eq, Ord}; use uint; -#[cfg(stage0)] -pub mod libc_ { - use libc::c_void; - use libc; - - #[nolink] - #[abi = "cdecl"] - pub extern { - #[rust_stack] - unsafe fn memset(dest: *mut c_void, - c: libc::c_int, - len: libc::size_t) - -> *c_void; - } -} - /// Calculate the offset from a pointer #[inline(always)] pub fn offset<T>(ptr: *T, count: uint) -> *T { @@ -178,13 +162,6 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u memcpy64(dst, src as *T, count as u64); } -#[inline(always)] -#[cfg(stage0)] -pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) { - let n = count * sys::size_of::<T>(); - libc_::memset(dst as *mut c_void, c as libc::c_int, n as size_t); -} - /** * Invokes memset on the specified pointer, setting `count` bytes of memory * starting at `dst` to `c`. @@ -601,6 +578,7 @@ pub mod ptr_tests { } #[test] + #[cfg(not(stage0))] fn test_set_memory() { let mut xs = [0u8, ..20]; let ptr = vec::raw::to_mut_ptr(xs); |
