libcore: Remove vec::to_ptr in favor of vec::unsafe::to_ptr. Closes #1829.
This commit is contained in:
parent
d3331bce98
commit
362f23641a
|
@ -988,7 +988,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
|
|||
let n_args = llvm::LLVMCountParamTypes(ty) as uint;
|
||||
let args: [TypeRef] = vec::init_elt::<TypeRef>(n_args, 0 as TypeRef);
|
||||
unsafe {
|
||||
llvm::LLVMGetParamTypes(ty, vec::to_ptr(args));
|
||||
llvm::LLVMGetParamTypes(ty, vec::unsafe::to_ptr(args));
|
||||
}
|
||||
s += tys_str(names, outer, args);
|
||||
s += ") -> ";
|
||||
|
@ -1000,7 +1000,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
|
|||
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
|
||||
let elts: [TypeRef] = vec::init_elt::<TypeRef>(n_elts, 0 as TypeRef);
|
||||
unsafe {
|
||||
llvm::LLVMGetStructElementTypes(ty, vec::to_ptr(elts));
|
||||
llvm::LLVMGetStructElementTypes(ty, vec::unsafe::to_ptr(elts));
|
||||
}
|
||||
s += tys_str(names, outer, elts);
|
||||
s += "}";
|
||||
|
@ -1043,7 +1043,7 @@ fn float_width(llt: TypeRef) -> uint {
|
|||
fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] unsafe {
|
||||
let args = vec::init_elt(llvm::LLVMCountParamTypes(fn_ty) as uint,
|
||||
0 as TypeRef);
|
||||
llvm::LLVMGetParamTypes(fn_ty, vec::to_ptr(args));
|
||||
llvm::LLVMGetParamTypes(fn_ty, vec::unsafe::to_ptr(args));
|
||||
ret args;
|
||||
}
|
||||
|
||||
|
|
|
@ -4428,7 +4428,7 @@ fn create_main_wrapper(ccx: crate_ctxt, sp: span, main_llfn: ValueRef,
|
|||
let args = [rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint),
|
||||
llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map];
|
||||
let result = unsafe {
|
||||
llvm::LLVMBuildCall(bld, start, vec::to_ptr(args),
|
||||
llvm::LLVMBuildCall(bld, start, vec::unsafe::to_ptr(args),
|
||||
args.len() as c_uint, noname())
|
||||
};
|
||||
llvm::LLVMBuildRet(bld, result);
|
||||
|
|
|
@ -41,7 +41,7 @@ fn AggregateRet(cx: block, RetVals: [ValueRef]) {
|
|||
assert (!cx.terminated);
|
||||
cx.terminated = true;
|
||||
unsafe {
|
||||
llvm::LLVMBuildAggregateRet(B(cx), vec::to_ptr(RetVals),
|
||||
llvm::LLVMBuildAggregateRet(B(cx), vec::unsafe::to_ptr(RetVals),
|
||||
RetVals.len() as c_uint);
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: [ValueRef],
|
|||
str::connect(vec::map(Args, {|a|val_str(cx.ccx().tn, a)}),
|
||||
", ")];
|
||||
unsafe {
|
||||
llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args),
|
||||
llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint, Then, Catch,
|
||||
noname());
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: [ValueRef],
|
|||
assert (!cx.terminated);
|
||||
cx.terminated = true;
|
||||
unsafe {
|
||||
let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args),
|
||||
let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint,
|
||||
Then, Catch, noname());
|
||||
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
||||
|
@ -331,7 +331,7 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
|
|||
fn GEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]) -> ValueRef {
|
||||
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
|
||||
unsafe {
|
||||
ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::to_ptr(Indices),
|
||||
ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices),
|
||||
Indices.len() as c_uint, noname());
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]) ->
|
|||
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
|
||||
unsafe {
|
||||
ret llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
|
||||
vec::to_ptr(Indices),
|
||||
vec::unsafe::to_ptr(Indices),
|
||||
Indices.len() as c_uint,
|
||||
noname());
|
||||
}
|
||||
|
@ -496,7 +496,8 @@ fn Phi(cx: block, Ty: TypeRef, vals: [ValueRef], bbs: [BasicBlockRef])
|
|||
assert vals.len() == bbs.len();
|
||||
let phi = EmptyPhi(cx, Ty);
|
||||
unsafe {
|
||||
llvm::LLVMAddIncoming(phi, vec::to_ptr(vals), vec::to_ptr(bbs),
|
||||
llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals),
|
||||
vec::unsafe::to_ptr(bbs),
|
||||
vals.len() as c_uint);
|
||||
ret phi;
|
||||
}
|
||||
|
@ -547,7 +548,7 @@ fn add_comment(bcx: block, text: str) {
|
|||
fn Call(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
|
||||
if cx.unreachable { ret _UndefReturn(cx, Fn); }
|
||||
unsafe {
|
||||
ret llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
||||
ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint, noname());
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +556,7 @@ fn Call(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
|
|||
fn FastCall(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
|
||||
if cx.unreachable { ret _UndefReturn(cx, Fn); }
|
||||
unsafe {
|
||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint, noname());
|
||||
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
||||
ret v;
|
||||
|
@ -566,7 +567,7 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: [ValueRef],
|
|||
Conv: CallConv) -> ValueRef {
|
||||
if cx.unreachable { ret _UndefReturn(cx, Fn); }
|
||||
unsafe {
|
||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint, noname());
|
||||
lib::llvm::SetInstructionCallConv(v, Conv);
|
||||
ret v;
|
||||
|
@ -642,7 +643,7 @@ fn Trap(cx: block) {
|
|||
assert (T as int != 0);
|
||||
let Args: [ValueRef] = [];
|
||||
unsafe {
|
||||
llvm::LLVMBuildCall(b, T, vec::to_ptr(Args),
|
||||
llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint, noname());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import ctypes::unsigned;
|
||||
import vec::to_ptr;
|
||||
import vec::unsafe::to_ptr;
|
||||
import std::map::hashmap;
|
||||
import syntax::ast;
|
||||
import driver::session;
|
||||
|
@ -805,28 +805,28 @@ fn C_zero_byte_arr(size: uint) -> ValueRef unsafe {
|
|||
let i = 0u;
|
||||
let elts: [ValueRef] = [];
|
||||
while i < size { elts += [C_u8(0u)]; i += 1u; }
|
||||
ret llvm::LLVMConstArray(T_i8(), vec::to_ptr(elts),
|
||||
ret llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts),
|
||||
elts.len() as unsigned);
|
||||
}
|
||||
|
||||
fn C_struct(elts: [ValueRef]) -> ValueRef unsafe {
|
||||
ret llvm::LLVMConstStruct(vec::to_ptr(elts), elts.len() as unsigned,
|
||||
False);
|
||||
ret llvm::LLVMConstStruct(vec::unsafe::to_ptr(elts),
|
||||
elts.len() as unsigned, False);
|
||||
}
|
||||
|
||||
fn C_named_struct(T: TypeRef, elts: [ValueRef]) -> ValueRef unsafe {
|
||||
ret llvm::LLVMConstNamedStruct(T, vec::to_ptr(elts),
|
||||
ret llvm::LLVMConstNamedStruct(T, vec::unsafe::to_ptr(elts),
|
||||
elts.len() as unsigned);
|
||||
}
|
||||
|
||||
fn C_array(ty: TypeRef, elts: [ValueRef]) -> ValueRef unsafe {
|
||||
ret llvm::LLVMConstArray(ty, vec::to_ptr(elts),
|
||||
ret llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts),
|
||||
elts.len() as unsigned);
|
||||
}
|
||||
|
||||
fn C_bytes(bytes: [u8]) -> ValueRef unsafe {
|
||||
ret llvm::LLVMConstString(
|
||||
unsafe::reinterpret_cast(vec::to_ptr(bytes)),
|
||||
unsafe::reinterpret_cast(vec::unsafe::to_ptr(bytes)),
|
||||
bytes.len() as unsigned, False);
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ fn llfn_arg_tys(ft: TypeRef) -> {inputs: [TypeRef], output: TypeRef} {
|
|||
let out_ty = llvm::LLVMGetReturnType(ft);
|
||||
let n_args = llvm::LLVMCountParamTypes(ft);
|
||||
let args = vec::init_elt(n_args as uint, 0 as TypeRef);
|
||||
unsafe { llvm::LLVMGetParamTypes(ft, vec::to_ptr(args)); }
|
||||
unsafe { llvm::LLVMGetParamTypes(ft, vec::unsafe::to_ptr(args)); }
|
||||
{inputs: args, output: out_ty}
|
||||
}
|
||||
|
||||
|
|
|
@ -2017,7 +2017,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_from_cstr() unsafe {
|
||||
let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
||||
let b = vec::to_ptr(a);
|
||||
let b = vec::unsafe::to_ptr(a);
|
||||
let c = from_cstr(b);
|
||||
assert (c == "AAAAAAA");
|
||||
}
|
||||
|
@ -2025,7 +2025,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_from_cstr_len() unsafe {
|
||||
let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
||||
let b = vec::to_ptr(a);
|
||||
let b = vec::unsafe::to_ptr(a);
|
||||
let c = from_cstr_len(b, 3u);
|
||||
assert (c == "AAA");
|
||||
}
|
||||
|
|
|
@ -1068,13 +1068,6 @@ fn windowed <TT: copy> (nn: uint, xx: [TT]) -> [[TT]] {
|
|||
ret ww;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: to_ptr
|
||||
|
||||
FIXME: We don't need this wrapper
|
||||
*/
|
||||
unsafe fn to_ptr<T>(v: [T]) -> *T { ret unsafe::to_ptr(v); }
|
||||
|
||||
/*
|
||||
Function: as_buf
|
||||
|
||||
|
@ -1159,8 +1152,8 @@ mod u8 {
|
|||
let a_len = len(a);
|
||||
let b_len = len(b);
|
||||
let n = math::min(a_len, b_len) as ctypes::size_t;
|
||||
let r = libc::memcmp(to_ptr(a) as *libc::c_void,
|
||||
to_ptr(b) as *libc::c_void, n) as int;
|
||||
let r = libc::memcmp(unsafe::to_ptr(a) as *libc::c_void,
|
||||
unsafe::to_ptr(b) as *libc::c_void, n) as int;
|
||||
|
||||
if r != 0 { r } else {
|
||||
if a_len == b_len {
|
||||
|
@ -1253,7 +1246,7 @@ mod tests {
|
|||
fn test_unsafe_ptrs() unsafe {
|
||||
// Test on-stack copy-from-buf.
|
||||
let a = [1, 2, 3];
|
||||
let ptr = to_ptr(a);
|
||||
let ptr = unsafe::to_ptr(a);
|
||||
let b = unsafe::from_buf(ptr, 3u);
|
||||
assert (len(b) == 3u);
|
||||
assert (b[0] == 1);
|
||||
|
@ -1262,7 +1255,7 @@ mod tests {
|
|||
|
||||
// Test on-heap copy-from-buf.
|
||||
let c = [1, 2, 3, 4, 5];
|
||||
ptr = to_ptr(c);
|
||||
ptr = unsafe::to_ptr(c);
|
||||
let d = unsafe::from_buf(ptr, 5u);
|
||||
assert (len(d) == 5u);
|
||||
assert (d[0] == 1);
|
||||
|
|
Loading…
Reference in New Issue