Rename vec::unsafe to vec::raw
This commit is contained in:
parent
37cf649311
commit
ff54ac8e59
@ -15,7 +15,7 @@ export unsafe;
|
|||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
extern mod rustrt {
|
extern mod rustrt {
|
||||||
fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
|
fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
|
||||||
++v: **vec::unsafe::VecRepr,
|
++v: **vec::raw::VecRepr,
|
||||||
++n: libc::size_t);
|
++n: libc::size_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ impl<T: Copy> @[T]: Add<&[const T],@[T]> {
|
|||||||
|
|
||||||
|
|
||||||
mod unsafe {
|
mod unsafe {
|
||||||
type VecRepr = vec::unsafe::VecRepr;
|
type VecRepr = vec::raw::VecRepr;
|
||||||
type SliceRepr = vec::unsafe::SliceRepr;
|
type SliceRepr = vec::raw::SliceRepr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the length of a vector
|
* Sets the length of a vector
|
||||||
|
@ -28,7 +28,7 @@ fn deflate_buf(buf: &[const u8]) -> ~[u8] {
|
|||||||
ptr::addr_of(outsz),
|
ptr::addr_of(outsz),
|
||||||
lz_norm);
|
lz_norm);
|
||||||
assert res as int != 0;
|
assert res as int != 0;
|
||||||
let out = vec::unsafe::from_buf(res as *u8,
|
let out = vec::raw::from_buf(res as *u8,
|
||||||
outsz as uint);
|
outsz as uint);
|
||||||
libc::free(res);
|
libc::free(res);
|
||||||
move out
|
move out
|
||||||
@ -46,7 +46,7 @@ fn inflate_buf(buf: &[const u8]) -> ~[u8] {
|
|||||||
ptr::addr_of(outsz),
|
ptr::addr_of(outsz),
|
||||||
0);
|
0);
|
||||||
assert res as int != 0;
|
assert res as int != 0;
|
||||||
let out = vec::unsafe::from_buf(res as *u8,
|
let out = vec::raw::from_buf(res as *u8,
|
||||||
outsz as uint);
|
outsz as uint);
|
||||||
libc::free(res);
|
libc::free(res);
|
||||||
move out
|
move out
|
||||||
|
@ -53,11 +53,11 @@ impl<T: Reader> T : ReaderUtil {
|
|||||||
fn read_bytes(len: uint) -> ~[u8] {
|
fn read_bytes(len: uint) -> ~[u8] {
|
||||||
let mut buf = ~[mut];
|
let mut buf = ~[mut];
|
||||||
vec::reserve(buf, len);
|
vec::reserve(buf, len);
|
||||||
unsafe { vec::unsafe::set_len(buf, len); }
|
unsafe { vec::raw::set_len(buf, len); }
|
||||||
|
|
||||||
let count = self.read(buf, len);
|
let count = self.read(buf, len);
|
||||||
|
|
||||||
unsafe { vec::unsafe::set_len(buf, count); }
|
unsafe { vec::raw::set_len(buf, count); }
|
||||||
vec::from_mut(move buf)
|
vec::from_mut(move buf)
|
||||||
}
|
}
|
||||||
fn read_line() -> ~str {
|
fn read_line() -> ~str {
|
||||||
@ -682,7 +682,7 @@ impl MemBuffer: Writer {
|
|||||||
|
|
||||||
let count = uint::max(buf_len, self.pos + v_len);
|
let count = uint::max(buf_len, self.pos + v_len);
|
||||||
vec::reserve(buf, count);
|
vec::reserve(buf, count);
|
||||||
unsafe { vec::unsafe::set_len(buf, count); }
|
unsafe { vec::raw::set_len(buf, count); }
|
||||||
|
|
||||||
vec::u8::memcpy(vec::mut_view(buf, self.pos, count), v, v_len);
|
vec::u8::memcpy(vec::mut_view(buf, self.pos, count), v, v_len);
|
||||||
|
|
||||||
|
@ -265,14 +265,14 @@ fn test() {
|
|||||||
let mut v0 = ~[32000u16, 32001u16, 32002u16];
|
let mut v0 = ~[32000u16, 32001u16, 32002u16];
|
||||||
let mut v1 = ~[0u16, 0u16, 0u16];
|
let mut v1 = ~[0u16, 0u16, 0u16];
|
||||||
|
|
||||||
ptr::memcpy(ptr::mut_offset(vec::unsafe::to_mut_ptr(v1), 1u),
|
ptr::memcpy(ptr::mut_offset(vec::raw::to_mut_ptr(v1), 1u),
|
||||||
ptr::offset(vec::unsafe::to_ptr(v0), 1u), 1u);
|
ptr::offset(vec::raw::to_ptr(v0), 1u), 1u);
|
||||||
assert (v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16);
|
assert (v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16);
|
||||||
ptr::memcpy(vec::unsafe::to_mut_ptr(v1),
|
ptr::memcpy(vec::raw::to_mut_ptr(v1),
|
||||||
ptr::offset(vec::unsafe::to_ptr(v0), 2u), 1u);
|
ptr::offset(vec::raw::to_ptr(v0), 2u), 1u);
|
||||||
assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16);
|
assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16);
|
||||||
ptr::memcpy(ptr::mut_offset(vec::unsafe::to_mut_ptr(v1), 2u),
|
ptr::memcpy(ptr::mut_offset(vec::raw::to_mut_ptr(v1), 2u),
|
||||||
vec::unsafe::to_ptr(v0), 1u);
|
vec::raw::to_ptr(v0), 1u);
|
||||||
assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16);
|
assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ Section: Transforming strings
|
|||||||
*/
|
*/
|
||||||
pure fn to_bytes(s: &str) -> ~[u8] unsafe {
|
pure fn to_bytes(s: &str) -> ~[u8] unsafe {
|
||||||
let mut v: ~[u8] = ::unsafe::transmute(from_slice(s));
|
let mut v: ~[u8] = ::unsafe::transmute(from_slice(s));
|
||||||
vec::unsafe::set_len(v, len(s));
|
vec::raw::set_len(v, len(s));
|
||||||
move v
|
move v
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ pure fn to_bytes(s: &str) -> ~[u8] unsafe {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn byte_slice<T>(s: &str, f: fn(v: &[u8]) -> T) -> T {
|
pure fn byte_slice<T>(s: &str, f: fn(v: &[u8]) -> T) -> T {
|
||||||
do as_buf(s) |p,n| {
|
do as_buf(s) |p,n| {
|
||||||
unsafe { vec::unsafe::form_slice(p, n-1u, f) }
|
unsafe { vec::raw::form_slice(p, n-1u, f) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1996,7 +1996,7 @@ mod unsafe {
|
|||||||
let vbuf = ::unsafe::transmute_mut_unsafe(vbuf);
|
let vbuf = ::unsafe::transmute_mut_unsafe(vbuf);
|
||||||
ptr::memcpy(vbuf, buf as *u8, len)
|
ptr::memcpy(vbuf, buf as *u8, len)
|
||||||
});
|
});
|
||||||
vec::unsafe::set_len(v, len);
|
vec::raw::set_len(v, len);
|
||||||
vec::push(v, 0u8);
|
vec::push(v, 0u8);
|
||||||
|
|
||||||
assert is_utf8(v);
|
assert is_utf8(v);
|
||||||
@ -2054,7 +2054,7 @@ mod unsafe {
|
|||||||
let src = ptr::offset(sbuf, begin);
|
let src = ptr::offset(sbuf, begin);
|
||||||
ptr::memcpy(vbuf, src, end - begin);
|
ptr::memcpy(vbuf, src, end - begin);
|
||||||
}
|
}
|
||||||
vec::unsafe::set_len(v, end - begin);
|
vec::raw::set_len(v, end - begin);
|
||||||
vec::push(v, 0u8);
|
vec::push(v, 0u8);
|
||||||
::unsafe::transmute(move v)
|
::unsafe::transmute(move v)
|
||||||
}
|
}
|
||||||
@ -2118,7 +2118,7 @@ mod unsafe {
|
|||||||
|
|
||||||
/// Sets the length of the string and adds the null terminator
|
/// Sets the length of the string and adds the null terminator
|
||||||
unsafe fn set_len(&v: ~str, new_len: uint) {
|
unsafe fn set_len(&v: ~str, new_len: uint) {
|
||||||
let repr: *vec::unsafe::VecRepr = ::unsafe::reinterpret_cast(&v);
|
let repr: *vec::raw::VecRepr = ::unsafe::reinterpret_cast(&v);
|
||||||
(*repr).fill = new_len + 1u;
|
(*repr).fill = new_len + 1u;
|
||||||
let null = ptr::mut_offset(ptr::mut_addr_of((*repr).data), new_len);
|
let null = ptr::mut_offset(ptr::mut_addr_of((*repr).data), new_len);
|
||||||
*null = 0u8;
|
*null = 0u8;
|
||||||
@ -2128,7 +2128,7 @@ mod unsafe {
|
|||||||
fn test_from_buf_len() {
|
fn test_from_buf_len() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
||||||
let b = vec::unsafe::to_ptr(a);
|
let b = vec::raw::to_ptr(a);
|
||||||
let c = from_buf_len(b, 3u);
|
let c = from_buf_len(b, 3u);
|
||||||
assert (c == ~"AAA");
|
assert (c == ~"AAA");
|
||||||
}
|
}
|
||||||
@ -2940,7 +2940,7 @@ mod tests {
|
|||||||
fn test_from_buf() {
|
fn test_from_buf() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
||||||
let b = vec::unsafe::to_ptr(a);
|
let b = vec::raw::to_ptr(a);
|
||||||
let c = unsafe::from_buf(b);
|
let c = unsafe::from_buf(b);
|
||||||
assert (c == ~"AAAAAAA");
|
assert (c == ~"AAAAAAA");
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
|
|||||||
*ptr::mut_offset(mp, i) = '-' as u8;
|
*ptr::mut_offset(mp, i) = '-' as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec::unsafe::form_slice(ptr::offset(p, i),
|
vec::raw::form_slice(ptr::offset(p, i),
|
||||||
len - i, f)
|
len - i, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ export windowed;
|
|||||||
export as_buf;
|
export as_buf;
|
||||||
export as_mut_buf;
|
export as_mut_buf;
|
||||||
export as_const_buf;
|
export as_const_buf;
|
||||||
export unsafe;
|
export raw;
|
||||||
export u8;
|
export u8;
|
||||||
export extensions;
|
export extensions;
|
||||||
export ConstVector;
|
export ConstVector;
|
||||||
@ -101,7 +101,7 @@ export vec_concat;
|
|||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
extern mod rustrt {
|
extern mod rustrt {
|
||||||
fn vec_reserve_shared(++t: *sys::TypeDesc,
|
fn vec_reserve_shared(++t: *sys::TypeDesc,
|
||||||
++v: **unsafe::VecRepr,
|
++v: **raw::VecRepr,
|
||||||
++n: libc::size_t);
|
++n: libc::size_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
|
|||||||
fn reserve<T>(&v: ~[const T], n: uint) {
|
fn reserve<T>(&v: ~[const T], n: uint) {
|
||||||
// Only make the (slow) call into the runtime if we have to
|
// Only make the (slow) call into the runtime if we have to
|
||||||
if capacity(v) < n {
|
if capacity(v) < n {
|
||||||
let ptr = ptr::addr_of(v) as **unsafe::VecRepr;
|
let ptr = ptr::addr_of(v) as **raw::VecRepr;
|
||||||
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
|
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
|
||||||
ptr, n as size_t);
|
ptr, n as size_t);
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ fn reserve_at_least<T>(&v: ~[const T], n: uint) {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn capacity<T>(&&v: ~[const T]) -> uint {
|
pure fn capacity<T>(&&v: ~[const T]) -> uint {
|
||||||
unsafe {
|
unsafe {
|
||||||
let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v));
|
let repr: **raw::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v));
|
||||||
(**repr).alloc / sys::size_of::<T>()
|
(**repr).alloc / sys::size_of::<T>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,8 +189,8 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
|
|||||||
let mut v = ~[];
|
let mut v = ~[];
|
||||||
unchecked{reserve(v, n_elts);}
|
unchecked{reserve(v, n_elts);}
|
||||||
let mut i: uint = 0u;
|
let mut i: uint = 0u;
|
||||||
while i < n_elts unsafe { unsafe::set(v, i, op(i)); i += 1u; }
|
while i < n_elts unsafe { raw::set(v, i, op(i)); i += 1u; }
|
||||||
unsafe { unsafe::set_len(v, n_elts); }
|
unsafe { raw::set_len(v, n_elts); }
|
||||||
move v
|
move v
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,8 +205,8 @@ pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> ~[T] {
|
|||||||
unchecked{reserve(v, n_elts)}
|
unchecked{reserve(v, n_elts)}
|
||||||
let mut i: uint = 0u;
|
let mut i: uint = 0u;
|
||||||
unsafe { // because unsafe::set is unsafe
|
unsafe { // because unsafe::set is unsafe
|
||||||
while i < n_elts { unsafe::set(v, i, t); i += 1u; }
|
while i < n_elts { raw::set(v, i, t); i += 1u; }
|
||||||
unsafe { unsafe::set_len(v, n_elts); }
|
unsafe { raw::set_len(v, n_elts); }
|
||||||
}
|
}
|
||||||
move v
|
move v
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ fn shift<T>(&v: ~[T]) -> T {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let mut rr;
|
let mut rr;
|
||||||
{
|
{
|
||||||
let vv = unsafe::to_ptr(vv);
|
let vv = raw::to_ptr(vv);
|
||||||
rr <- *vv;
|
rr <- *vv;
|
||||||
|
|
||||||
for uint::range(1, ln) |i| {
|
for uint::range(1, ln) |i| {
|
||||||
@ -486,7 +486,7 @@ fn shift<T>(&v: ~[T]) -> T {
|
|||||||
push(v, move r);
|
push(v, move r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe::set_len(vv, 0);
|
raw::set_len(vv, 0);
|
||||||
|
|
||||||
move rr
|
move rr
|
||||||
}
|
}
|
||||||
@ -509,7 +509,7 @@ fn consume<T>(+v: ~[T], f: fn(uint, +T)) unsafe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe::set_len(v, 0);
|
raw::set_len(v, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +T)) unsafe {
|
fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +T)) unsafe {
|
||||||
@ -520,7 +520,7 @@ fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +T)) unsafe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe::set_len(v, 0);
|
raw::set_len(v, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the last element from a vector and return it
|
/// Remove the last element from a vector and return it
|
||||||
@ -532,7 +532,7 @@ fn pop<T>(&v: ~[const T]) -> T {
|
|||||||
let valptr = ptr::mut_addr_of(v[ln - 1u]);
|
let valptr = ptr::mut_addr_of(v[ln - 1u]);
|
||||||
unsafe {
|
unsafe {
|
||||||
let val <- *valptr;
|
let val <- *valptr;
|
||||||
unsafe::set_len(v, ln - 1u);
|
raw::set_len(v, ln - 1u);
|
||||||
move val
|
move val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ fn swap_remove<T>(&v: ~[const T], index: uint) -> T {
|
|||||||
let valptr = ptr::mut_addr_of(v[index]);
|
let valptr = ptr::mut_addr_of(v[index]);
|
||||||
*valptr <-> val;
|
*valptr <-> val;
|
||||||
}
|
}
|
||||||
unsafe::set_len(v, ln - 1);
|
raw::set_len(v, ln - 1);
|
||||||
move val
|
move val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ fn swap_remove<T>(&v: ~[const T], index: uint) -> T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn push<T>(&v: ~[const T], +initval: T) {
|
fn push<T>(&v: ~[const T], +initval: T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v));
|
let repr: **raw::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v));
|
||||||
let fill = (**repr).fill;
|
let fill = (**repr).fill;
|
||||||
if (**repr).alloc > fill {
|
if (**repr).alloc > fill {
|
||||||
push_fast(v, move initval);
|
push_fast(v, move initval);
|
||||||
@ -578,7 +578,7 @@ fn push<T>(&v: ~[const T], +initval: T) {
|
|||||||
// This doesn't bother to make sure we have space.
|
// This doesn't bother to make sure we have space.
|
||||||
#[inline(always)] // really pretty please
|
#[inline(always)] // really pretty please
|
||||||
unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
|
unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
|
||||||
let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v));
|
let repr: **raw::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v));
|
||||||
let fill = (**repr).fill;
|
let fill = (**repr).fill;
|
||||||
(**repr).fill += sys::size_of::<T>();
|
(**repr).fill += sys::size_of::<T>();
|
||||||
let p = ptr::addr_of((**repr).data);
|
let p = ptr::addr_of((**repr).data);
|
||||||
@ -597,7 +597,7 @@ fn push_all<T: Copy>(&v: ~[const T], rhs: &[const T]) {
|
|||||||
reserve(v, v.len() + rhs.len());
|
reserve(v, v.len() + rhs.len());
|
||||||
|
|
||||||
for uint::range(0u, rhs.len()) |i| {
|
for uint::range(0u, rhs.len()) |i| {
|
||||||
push(v, unsafe { unsafe::get(rhs, i) })
|
push(v, unsafe { raw::get(rhs, i) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ fn push_all_move<T>(&v: ~[const T], -rhs: ~[const T]) {
|
|||||||
push(v, move x);
|
push(v, move x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe::set_len(rhs, 0);
|
raw::set_len(rhs, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ fn truncate<T>(&v: ~[const T], newlen: uint) {
|
|||||||
for uint::range(newlen, oldlen) |i| {
|
for uint::range(newlen, oldlen) |i| {
|
||||||
let _dropped <- *ptr::offset(p, i);
|
let _dropped <- *ptr::offset(p, i);
|
||||||
}
|
}
|
||||||
unsafe::set_len(v, newlen);
|
raw::set_len(v, newlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,7 +660,7 @@ fn dedup<T: Eq>(&v: ~[const T]) unsafe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// last_written < next_to_read == ln
|
// last_written < next_to_read == ln
|
||||||
unsafe::set_len(v, last_written + 1);
|
raw::set_len(v, last_written + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1786,7 +1786,7 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Unsafe operations
|
/// Unsafe operations
|
||||||
mod unsafe {
|
mod raw {
|
||||||
// FIXME: This should have crate visibility (#1893 blocks that)
|
// FIXME: This should have crate visibility (#1893 blocks that)
|
||||||
/// The internal representation of a vector
|
/// The internal representation of a vector
|
||||||
type VecRepr = {
|
type VecRepr = {
|
||||||
@ -1936,8 +1936,8 @@ mod u8 {
|
|||||||
let b_len = len(*b);
|
let b_len = len(*b);
|
||||||
let n = uint::min(a_len, b_len) as libc::size_t;
|
let n = uint::min(a_len, b_len) as libc::size_t;
|
||||||
let r = unsafe {
|
let r = unsafe {
|
||||||
libc::memcmp(unsafe::to_ptr(*a) as *libc::c_void,
|
libc::memcmp(raw::to_ptr(*a) as *libc::c_void,
|
||||||
unsafe::to_ptr(*b) as *libc::c_void, n) as int
|
raw::to_ptr(*b) as *libc::c_void, n) as int
|
||||||
};
|
};
|
||||||
|
|
||||||
if r != 0 { r } else {
|
if r != 0 { r } else {
|
||||||
@ -1984,7 +1984,7 @@ mod u8 {
|
|||||||
assert dst.len() >= count;
|
assert dst.len() >= count;
|
||||||
assert src.len() >= count;
|
assert src.len() >= count;
|
||||||
|
|
||||||
unsafe { vec::unsafe::memcpy(dst, src, count) }
|
unsafe { vec::raw::memcpy(dst, src, count) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1997,7 +1997,7 @@ mod u8 {
|
|||||||
assert dst.len() >= count;
|
assert dst.len() >= count;
|
||||||
assert src.len() >= count;
|
assert src.len() >= count;
|
||||||
|
|
||||||
unsafe { vec::unsafe::memmove(dst, src, count) }
|
unsafe { vec::raw::memmove(dst, src, count) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2076,8 +2076,8 @@ mod tests {
|
|||||||
unsafe {
|
unsafe {
|
||||||
// Test on-stack copy-from-buf.
|
// Test on-stack copy-from-buf.
|
||||||
let a = ~[1, 2, 3];
|
let a = ~[1, 2, 3];
|
||||||
let mut ptr = unsafe::to_ptr(a);
|
let mut ptr = raw::to_ptr(a);
|
||||||
let b = unsafe::from_buf(ptr, 3u);
|
let b = raw::from_buf(ptr, 3u);
|
||||||
assert (len(b) == 3u);
|
assert (len(b) == 3u);
|
||||||
assert (b[0] == 1);
|
assert (b[0] == 1);
|
||||||
assert (b[1] == 2);
|
assert (b[1] == 2);
|
||||||
@ -2085,8 +2085,8 @@ mod tests {
|
|||||||
|
|
||||||
// Test on-heap copy-from-buf.
|
// Test on-heap copy-from-buf.
|
||||||
let c = ~[1, 2, 3, 4, 5];
|
let c = ~[1, 2, 3, 4, 5];
|
||||||
ptr = unsafe::to_ptr(c);
|
ptr = raw::to_ptr(c);
|
||||||
let d = unsafe::from_buf(ptr, 5u);
|
let d = raw::from_buf(ptr, 5u);
|
||||||
assert (len(d) == 5u);
|
assert (len(d) == 5u);
|
||||||
assert (d[0] == 1);
|
assert (d[0] == 1);
|
||||||
assert (d[1] == 2);
|
assert (d[1] == 2);
|
||||||
@ -2869,9 +2869,9 @@ mod tests {
|
|||||||
fn to_mut_no_copy() {
|
fn to_mut_no_copy() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let x = ~[1, 2, 3];
|
let x = ~[1, 2, 3];
|
||||||
let addr = unsafe::to_ptr(x);
|
let addr = raw::to_ptr(x);
|
||||||
let x_mut = to_mut(x);
|
let x_mut = to_mut(x);
|
||||||
let addr_mut = unsafe::to_ptr(x_mut);
|
let addr_mut = raw::to_ptr(x_mut);
|
||||||
assert addr == addr_mut;
|
assert addr == addr_mut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2880,9 +2880,9 @@ mod tests {
|
|||||||
fn from_mut_no_copy() {
|
fn from_mut_no_copy() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let x = ~[mut 1, 2, 3];
|
let x = ~[mut 1, 2, 3];
|
||||||
let addr = unsafe::to_ptr(x);
|
let addr = raw::to_ptr(x);
|
||||||
let x_imm = from_mut(x);
|
let x_imm = from_mut(x);
|
||||||
let addr_imm = unsafe::to_ptr(x_imm);
|
let addr_imm = raw::to_ptr(x_imm);
|
||||||
assert addr == addr_imm;
|
assert addr == addr_imm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ fn round_up_to(base: uint, align: uint) -> uint {
|
|||||||
// in it.
|
// in it.
|
||||||
unsafe fn destroy_chunk(chunk: Chunk) {
|
unsafe fn destroy_chunk(chunk: Chunk) {
|
||||||
let mut idx = 0;
|
let mut idx = 0;
|
||||||
let buf = vec::unsafe::to_ptr(chunk.data);
|
let buf = vec::raw::to_ptr(chunk.data);
|
||||||
let fill = chunk.fill;
|
let fill = chunk.fill;
|
||||||
|
|
||||||
while idx < fill {
|
while idx < fill {
|
||||||
@ -156,7 +156,7 @@ impl &Arena {
|
|||||||
// start, n_bytes, align, head.fill);
|
// start, n_bytes, align, head.fill);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
ptr::offset(vec::unsafe::to_ptr(head.data), start)
|
ptr::offset(vec::raw::to_ptr(head.data), start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ impl &Arena {
|
|||||||
// start, n_bytes, align, head.fill);
|
// start, n_bytes, align, head.fill);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let buf = vec::unsafe::to_ptr(head.data);
|
let buf = vec::raw::to_ptr(head.data);
|
||||||
return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
|
return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -968,7 +968,7 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData,
|
|||||||
let stream_handle_ptr =
|
let stream_handle_ptr =
|
||||||
(*socket_data_ptr).stream_handle_ptr;
|
(*socket_data_ptr).stream_handle_ptr;
|
||||||
let write_buf_vec = ~[ uv::ll::buf_init(
|
let write_buf_vec = ~[ uv::ll::buf_init(
|
||||||
vec::unsafe::to_ptr(raw_write_data),
|
vec::raw::to_ptr(raw_write_data),
|
||||||
vec::len(raw_write_data)) ];
|
vec::len(raw_write_data)) ];
|
||||||
let write_buf_vec_ptr = ptr::addr_of(write_buf_vec);
|
let write_buf_vec_ptr = ptr::addr_of(write_buf_vec);
|
||||||
let result_po = core::comm::Port::<TcpWriteResult>();
|
let result_po = core::comm::Port::<TcpWriteResult>();
|
||||||
@ -1103,7 +1103,7 @@ extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t,
|
|||||||
log(debug, fmt!("tcp on_read_cb nread: %d", nread as int));
|
log(debug, fmt!("tcp on_read_cb nread: %d", nread as int));
|
||||||
let reader_ch = (*socket_data_ptr).reader_ch;
|
let reader_ch = (*socket_data_ptr).reader_ch;
|
||||||
let buf_base = uv::ll::get_base_from_buf(buf);
|
let buf_base = uv::ll::get_base_from_buf(buf);
|
||||||
let new_bytes = vec::unsafe::from_buf(buf_base, nread as uint);
|
let new_bytes = vec::raw::from_buf(buf_base, nread as uint);
|
||||||
core::comm::send(reader_ch, result::Ok(new_bytes));
|
core::comm::send(reader_ch, result::Ok(new_bytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,7 +749,7 @@ unsafe fn accept(server: *libc::c_void, client: *libc::c_void)
|
|||||||
|
|
||||||
unsafe fn write<T>(req: *uv_write_t, stream: *T,
|
unsafe fn write<T>(req: *uv_write_t, stream: *T,
|
||||||
buf_in: *~[uv_buf_t], cb: *u8) -> libc::c_int {
|
buf_in: *~[uv_buf_t], cb: *u8) -> libc::c_int {
|
||||||
let buf_ptr = vec::unsafe::to_ptr(*buf_in);
|
let buf_ptr = vec::raw::to_ptr(*buf_in);
|
||||||
let buf_cnt = vec::len(*buf_in) as i32;
|
let buf_cnt = vec::len(*buf_in) as i32;
|
||||||
return rustrt::rust_uv_write(req as *libc::c_void,
|
return rustrt::rust_uv_write(req as *libc::c_void,
|
||||||
stream as *libc::c_void,
|
stream as *libc::c_void,
|
||||||
@ -1046,7 +1046,7 @@ mod test {
|
|||||||
as *request_wrapper;
|
as *request_wrapper;
|
||||||
let buf_base = get_base_from_buf(buf);
|
let buf_base = get_base_from_buf(buf);
|
||||||
let buf_len = get_len_from_buf(buf);
|
let buf_len = get_len_from_buf(buf);
|
||||||
let bytes = vec::unsafe::from_buf(buf_base, buf_len as uint);
|
let bytes = vec::raw::from_buf(buf_base, buf_len as uint);
|
||||||
let read_chan = *((*client_data).read_chan);
|
let read_chan = *((*client_data).read_chan);
|
||||||
let msg_from_server = str::from_bytes(bytes);
|
let msg_from_server = str::from_bytes(bytes);
|
||||||
core::comm::send(read_chan, msg_from_server);
|
core::comm::send(read_chan, msg_from_server);
|
||||||
@ -1122,7 +1122,7 @@ mod test {
|
|||||||
// struct that we'd cast to a void* and store as the
|
// struct that we'd cast to a void* and store as the
|
||||||
// data field in our uv_connect_t struct
|
// data field in our uv_connect_t struct
|
||||||
let req_str_bytes = str::to_bytes(req_str);
|
let req_str_bytes = str::to_bytes(req_str);
|
||||||
let req_msg_ptr: *u8 = vec::unsafe::to_ptr(req_str_bytes);
|
let req_msg_ptr: *u8 = vec::raw::to_ptr(req_str_bytes);
|
||||||
log(debug, fmt!("req_msg ptr: %u", req_msg_ptr as uint));
|
log(debug, fmt!("req_msg ptr: %u", req_msg_ptr as uint));
|
||||||
let req_msg = ~[
|
let req_msg = ~[
|
||||||
buf_init(req_msg_ptr, vec::len(req_str_bytes))
|
buf_init(req_msg_ptr, vec::len(req_str_bytes))
|
||||||
@ -1221,7 +1221,7 @@ mod test {
|
|||||||
buf_base as uint,
|
buf_base as uint,
|
||||||
buf_len as uint,
|
buf_len as uint,
|
||||||
nread));
|
nread));
|
||||||
let bytes = vec::unsafe::from_buf(buf_base, buf_len);
|
let bytes = vec::raw::from_buf(buf_base, buf_len);
|
||||||
let request_str = str::from_bytes(bytes);
|
let request_str = str::from_bytes(bytes);
|
||||||
|
|
||||||
let client_data = get_data_for_uv_handle(
|
let client_data = get_data_for_uv_handle(
|
||||||
@ -1370,7 +1370,7 @@ mod test {
|
|||||||
let server_write_req_ptr = ptr::addr_of(server_write_req);
|
let server_write_req_ptr = ptr::addr_of(server_write_req);
|
||||||
|
|
||||||
let resp_str_bytes = str::to_bytes(server_resp_msg);
|
let resp_str_bytes = str::to_bytes(server_resp_msg);
|
||||||
let resp_msg_ptr: *u8 = vec::unsafe::to_ptr(resp_str_bytes);
|
let resp_msg_ptr: *u8 = vec::raw::to_ptr(resp_str_bytes);
|
||||||
log(debug, fmt!("resp_msg ptr: %u", resp_msg_ptr as uint));
|
log(debug, fmt!("resp_msg ptr: %u", resp_msg_ptr as uint));
|
||||||
let resp_msg = ~[
|
let resp_msg = ~[
|
||||||
buf_init(resp_msg_ptr, vec::len(resp_str_bytes))
|
buf_init(resp_msg_ptr, vec::len(resp_str_bytes))
|
||||||
|
@ -1105,7 +1105,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
|
|||||||
let n_args = llvm::LLVMCountParamTypes(ty) as uint;
|
let n_args = llvm::LLVMCountParamTypes(ty) as uint;
|
||||||
let args = vec::from_elem(n_args, 0 as TypeRef);
|
let args = vec::from_elem(n_args, 0 as TypeRef);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMGetParamTypes(ty, vec::unsafe::to_ptr(args));
|
llvm::LLVMGetParamTypes(ty, vec::raw::to_ptr(args));
|
||||||
}
|
}
|
||||||
s += tys_str(names, outer, args);
|
s += tys_str(names, outer, args);
|
||||||
s += ~") -> ";
|
s += ~") -> ";
|
||||||
@ -1117,7 +1117,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
|
|||||||
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
|
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
|
||||||
let elts = vec::from_elem(n_elts, 0 as TypeRef);
|
let elts = vec::from_elem(n_elts, 0 as TypeRef);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMGetStructElementTypes(ty, vec::unsafe::to_ptr(elts));
|
llvm::LLVMGetStructElementTypes(ty, vec::raw::to_ptr(elts));
|
||||||
}
|
}
|
||||||
s += tys_str(names, outer, elts);
|
s += tys_str(names, outer, elts);
|
||||||
s += ~"}";
|
s += ~"}";
|
||||||
@ -1167,7 +1167,7 @@ fn float_width(llt: TypeRef) -> uint {
|
|||||||
fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] unsafe {
|
fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] unsafe {
|
||||||
let args = vec::from_elem(llvm::LLVMCountParamTypes(fn_ty) as uint,
|
let args = vec::from_elem(llvm::LLVMCountParamTypes(fn_ty) as uint,
|
||||||
0 as TypeRef);
|
0 as TypeRef);
|
||||||
llvm::LLVMGetParamTypes(fn_ty, vec::unsafe::to_ptr(args));
|
llvm::LLVMGetParamTypes(fn_ty, vec::raw::to_ptr(args));
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ fn get_metadata_section(os: os,
|
|||||||
vlen);
|
vlen);
|
||||||
let minsz = uint::min(vlen, csz);
|
let minsz = uint::min(vlen, csz);
|
||||||
let mut version_ok = false;
|
let mut version_ok = false;
|
||||||
do vec::unsafe::form_slice(cvbuf, minsz) |buf0| {
|
do vec::raw::form_slice(cvbuf, minsz) |buf0| {
|
||||||
version_ok = (buf0 ==
|
version_ok = (buf0 ==
|
||||||
encoder::metadata_encoding_version);
|
encoder::metadata_encoding_version);
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ fn get_metadata_section(os: os,
|
|||||||
let cvbuf1 = ptr::offset(cvbuf, vlen);
|
let cvbuf1 = ptr::offset(cvbuf, vlen);
|
||||||
debug!("inflating %u bytes of compressed metadata",
|
debug!("inflating %u bytes of compressed metadata",
|
||||||
csz - vlen);
|
csz - vlen);
|
||||||
do vec::unsafe::form_slice(cvbuf1, csz-vlen) |buf| {
|
do vec::raw::form_slice(cvbuf1, csz-vlen) |buf| {
|
||||||
let inflated = flate::inflate_buf(buf);
|
let inflated = flate::inflate_buf(buf);
|
||||||
found = move Some(@(move inflated));
|
found = move Some(@(move inflated));
|
||||||
}
|
}
|
||||||
|
@ -2018,7 +2018,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
|
|||||||
let args = ~[rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint),
|
let args = ~[rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint),
|
||||||
llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map];
|
llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map];
|
||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
llvm::LLVMBuildCall(bld, start, vec::unsafe::to_ptr(args),
|
llvm::LLVMBuildCall(bld, start, vec::raw::to_ptr(args),
|
||||||
args.len() as c_uint, noname())
|
args.len() as c_uint, noname())
|
||||||
};
|
};
|
||||||
llvm::LLVMBuildRet(bld, result);
|
llvm::LLVMBuildRet(bld, result);
|
||||||
|
@ -87,7 +87,7 @@ fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
|
|||||||
assert (!cx.terminated);
|
assert (!cx.terminated);
|
||||||
cx.terminated = true;
|
cx.terminated = true;
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildAggregateRet(B(cx), vec::unsafe::to_ptr(RetVals),
|
llvm::LLVMBuildAggregateRet(B(cx), vec::raw::to_ptr(RetVals),
|
||||||
RetVals.len() as c_uint);
|
RetVals.len() as c_uint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
|
|||||||
~", "));
|
~", "));
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "invoke");
|
count_insn(cx, "invoke");
|
||||||
llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
llvm::LLVMBuildInvoke(B(cx), Fn, vec::raw::to_ptr(Args),
|
||||||
Args.len() as c_uint, Then, Catch,
|
Args.len() as c_uint, Then, Catch,
|
||||||
noname());
|
noname());
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
|
|||||||
cx.terminated = true;
|
cx.terminated = true;
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "fastinvoke");
|
count_insn(cx, "fastinvoke");
|
||||||
let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::raw::to_ptr(Args),
|
||||||
Args.len() as c_uint,
|
Args.len() as c_uint,
|
||||||
Then, Catch, noname());
|
Then, Catch, noname());
|
||||||
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
||||||
@ -424,7 +424,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
|
|||||||
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
|
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "gep");
|
count_insn(cx, "gep");
|
||||||
return llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices),
|
return llvm::LLVMBuildGEP(B(cx), Pointer, vec::raw::to_ptr(Indices),
|
||||||
Indices.len() as c_uint, noname());
|
Indices.len() as c_uint, noname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
|
|||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "inboundsgep");
|
count_insn(cx, "inboundsgep");
|
||||||
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
|
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
|
||||||
vec::unsafe::to_ptr(Indices),
|
vec::raw::to_ptr(Indices),
|
||||||
Indices.len() as c_uint,
|
Indices.len() as c_uint,
|
||||||
noname());
|
noname());
|
||||||
}
|
}
|
||||||
@ -619,8 +619,8 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
|
|||||||
let phi = EmptyPhi(cx, Ty);
|
let phi = EmptyPhi(cx, Ty);
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "addincoming");
|
count_insn(cx, "addincoming");
|
||||||
llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals),
|
llvm::LLVMAddIncoming(phi, vec::raw::to_ptr(vals),
|
||||||
vec::unsafe::to_ptr(bbs),
|
vec::raw::to_ptr(bbs),
|
||||||
vals.len() as c_uint);
|
vals.len() as c_uint);
|
||||||
return phi;
|
return phi;
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
|
|||||||
if cx.unreachable { return _UndefReturn(cx, Fn); }
|
if cx.unreachable { return _UndefReturn(cx, Fn); }
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "fastcall");
|
count_insn(cx, "fastcall");
|
||||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::raw::to_ptr(Args),
|
||||||
Args.len() as c_uint, noname());
|
Args.len() as c_uint, noname());
|
||||||
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
||||||
return v;
|
return v;
|
||||||
@ -701,7 +701,7 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
|
|||||||
if cx.unreachable { return _UndefReturn(cx, Fn); }
|
if cx.unreachable { return _UndefReturn(cx, Fn); }
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "callwithconv");
|
count_insn(cx, "callwithconv");
|
||||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::raw::to_ptr(Args),
|
||||||
Args.len() as c_uint, noname());
|
Args.len() as c_uint, noname());
|
||||||
lib::llvm::SetInstructionCallConv(v, Conv);
|
lib::llvm::SetInstructionCallConv(v, Conv);
|
||||||
return v;
|
return v;
|
||||||
@ -789,7 +789,7 @@ fn Trap(cx: block) {
|
|||||||
let Args: ~[ValueRef] = ~[];
|
let Args: ~[ValueRef] = ~[];
|
||||||
unsafe {
|
unsafe {
|
||||||
count_insn(cx, "trap");
|
count_insn(cx, "trap");
|
||||||
llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args),
|
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args),
|
||||||
Args.len() as c_uint, noname());
|
Args.len() as c_uint, noname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use vec::unsafe::to_ptr;
|
use vec::raw::to_ptr;
|
||||||
use std::map::{HashMap,Set};
|
use std::map::{HashMap,Set};
|
||||||
use syntax::{ast, ast_map};
|
use syntax::{ast, ast_map};
|
||||||
use driver::session;
|
use driver::session;
|
||||||
@ -1052,7 +1052,7 @@ fn C_zero_byte_arr(size: uint) -> ValueRef unsafe {
|
|||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
let mut elts: ~[ValueRef] = ~[];
|
let mut elts: ~[ValueRef] = ~[];
|
||||||
while i < size { vec::push(elts, C_u8(0u)); i += 1u; }
|
while i < size { vec::push(elts, C_u8(0u)); i += 1u; }
|
||||||
return llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts),
|
return llvm::LLVMConstArray(T_i8(), vec::raw::to_ptr(elts),
|
||||||
elts.len() as c_uint);
|
elts.len() as c_uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1069,19 +1069,19 @@ fn C_named_struct(T: TypeRef, elts: &[ValueRef]) -> ValueRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn C_array(ty: TypeRef, elts: ~[ValueRef]) -> ValueRef unsafe {
|
fn C_array(ty: TypeRef, elts: ~[ValueRef]) -> ValueRef unsafe {
|
||||||
return llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts),
|
return llvm::LLVMConstArray(ty, vec::raw::to_ptr(elts),
|
||||||
elts.len() as c_uint);
|
elts.len() as c_uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe {
|
fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe {
|
||||||
return llvm::LLVMConstString(
|
return llvm::LLVMConstString(
|
||||||
unsafe::reinterpret_cast(&vec::unsafe::to_ptr(bytes)),
|
unsafe::reinterpret_cast(&vec::raw::to_ptr(bytes)),
|
||||||
bytes.len() as c_uint, True);
|
bytes.len() as c_uint, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C_bytes_plus_null(bytes: ~[u8]) -> ValueRef unsafe {
|
fn C_bytes_plus_null(bytes: ~[u8]) -> ValueRef unsafe {
|
||||||
return llvm::LLVMConstString(
|
return llvm::LLVMConstString(
|
||||||
unsafe::reinterpret_cast(&vec::unsafe::to_ptr(bytes)),
|
unsafe::reinterpret_cast(&vec::raw::to_ptr(bytes)),
|
||||||
bytes.len() as c_uint, False);
|
bytes.len() as c_uint, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ fn lli1(bval: bool) -> ValueRef {
|
|||||||
C_bool(bval)
|
C_bool(bval)
|
||||||
}
|
}
|
||||||
fn llmdnode(elems: ~[ValueRef]) -> ValueRef unsafe {
|
fn llmdnode(elems: ~[ValueRef]) -> ValueRef unsafe {
|
||||||
llvm::LLVMMDNode(vec::unsafe::to_ptr(elems),
|
llvm::LLVMMDNode(vec::raw::to_ptr(elems),
|
||||||
vec::len(elems) as libc::c_uint)
|
vec::len(elems) as libc::c_uint)
|
||||||
}
|
}
|
||||||
fn llunused() -> ValueRef {
|
fn llunused() -> ValueRef {
|
||||||
|
@ -11,7 +11,7 @@ extern mod libc {
|
|||||||
fn strlen(str: ~str) -> uint unsafe {
|
fn strlen(str: ~str) -> uint unsafe {
|
||||||
// C string is terminated with a zero
|
// C string is terminated with a zero
|
||||||
let bytes = str::to_bytes(str) + ~[0u8];
|
let bytes = str::to_bytes(str) + ~[0u8];
|
||||||
return libc::my_strlen(vec::unsafe::to_ptr(bytes));
|
return libc::my_strlen(vec::raw::to_ptr(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user