continue to annotate functions as unsafe where neccessary

This commit is contained in:
Niko Matsakis 2011-10-10 15:16:55 -07:00 committed by Brian Anderson
parent f2cd33df72
commit 85da98db4a
6 changed files with 22 additions and 23 deletions

View File

@ -43,7 +43,7 @@ fn llvm_err(sess: session::session, msg: str) {
}
}
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
fn link_intrinsics(sess: session::session, llmod: ModuleRef) unsafe {
let path = alt filesearch::search(
sess.filesearch(),
bind filesearch::pick_file("intrinsics.bc", _)) {
@ -90,7 +90,8 @@ mod write {
} else { stem = str::substr(output_path, 0u, dot_pos as uint); }
ret stem + "." + extension;
}
fn run_passes(sess: session::session, llmod: ModuleRef, output: str) {
fn run_passes(sess: session::session, llmod: ModuleRef, output: str)
unsafe {
let opts = sess.get_opts();
if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); }
link_intrinsics(sess, llmod);

View File

@ -925,7 +925,7 @@ fn type_to_str(names: type_names, ty: TypeRef) -> str {
}
fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
str {
str unsafe {
if names.type_has_name(ty) { ret names.get_name(ty); }
@ -1003,7 +1003,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
}
}
fn float_width(llt: TypeRef) -> uint {
fn float_width(llt: TypeRef) -> uint unsafe {
ret alt llvm::LLVMGetTypeKind(llt) {
1 { 32u }
2 { 64u }
@ -1013,24 +1013,22 @@ fn float_width(llt: TypeRef) -> uint {
};
}
fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] {
fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] unsafe {
let args = vec::init_elt(0 as TypeRef, llvm::LLVMCountParamTypes(fn_ty));
unsafe {
llvm::LLVMGetParamTypes(fn_ty, vec::to_ptr(args));
}
llvm::LLVMGetParamTypes(fn_ty, vec::to_ptr(args));
ret args;
}
/* Memory-managed interface to target data. */
resource target_data_res(TD: TargetDataRef) {
resource target_data_res(TD: TargetDataRef) unsafe {
llvm::LLVMDisposeTargetData(TD);
}
type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
fn mk_target_data(string_rep: str) -> target_data {
fn mk_target_data(string_rep: str) -> target_data unsafe {
let lltd =
str::as_buf(string_rep, {|buf| llvm::LLVMCreateTargetData(buf) });
ret {lltd: lltd, dtor: @target_data_res(lltd)};
@ -1038,39 +1036,39 @@ fn mk_target_data(string_rep: str) -> target_data {
/* Memory-managed interface to pass managers. */
resource pass_manager_res(PM: PassManagerRef) {
resource pass_manager_res(PM: PassManagerRef) unsafe {
llvm::LLVMDisposePassManager(PM);
}
type pass_manager = {llpm: PassManagerRef, dtor: @pass_manager_res};
fn mk_pass_manager() -> pass_manager {
fn mk_pass_manager() -> pass_manager unsafe {
let llpm = llvm::LLVMCreatePassManager();
ret {llpm: llpm, dtor: @pass_manager_res(llpm)};
}
/* Memory-managed interface to object files. */
resource object_file_res(ObjectFile: ObjectFileRef) {
resource object_file_res(ObjectFile: ObjectFileRef) unsafe {
llvm::LLVMDisposeObjectFile(ObjectFile);
}
type object_file = {llof: ObjectFileRef, dtor: @object_file_res};
fn mk_object_file(llmb: MemoryBufferRef) -> object_file {
fn mk_object_file(llmb: MemoryBufferRef) -> object_file unsafe {
let llof = llvm::LLVMCreateObjectFile(llmb);
ret {llof: llof, dtor: @object_file_res(llof)};
}
/* Memory-managed interface to section iterators. */
resource section_iter_res(SI: SectionIteratorRef) {
resource section_iter_res(SI: SectionIteratorRef) unsafe {
llvm::LLVMDisposeSectionIterator(SI);
}
type section_iter = {llsi: SectionIteratorRef, dtor: @section_iter_res};
fn mk_section_iter(llof: ObjectFileRef) -> section_iter {
fn mk_section_iter(llof: ObjectFileRef) -> section_iter unsafe {
let llsi = llvm::LLVMGetSections(llof);
ret {llsi: llsi, dtor: @section_iter_res(llsi)};
}

View File

@ -70,7 +70,7 @@ fn run(handle: handle, lib_path: str, prog: str, args: [str],
ret {status: status, out: output, err: errput};
}
fn writeclose(fd: int, s: option::t<str>) {
fn writeclose(fd: int, s: option::t<str>) unsafe {
if option::is_some(s) {
let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
writer.write_str(option::get(s));

View File

@ -5,7 +5,7 @@ import std::unsafe;
type pair = {mutable fst: int, mutable snd: int};
#[test]
fn test() {
fn test() unsafe {
let p = {mutable fst: 10, mutable snd: 20};
let pptr: *mutable pair = ptr::addr_of(p);
let iptr: *mutable int = unsafe::reinterpret_cast(pptr);

View File

@ -23,7 +23,7 @@ fn test_leaks() {
fn test_leaks() { }
#[test]
fn test_pipes() {
fn test_pipes() unsafe {
let pipe_in = os::pipe();
let pipe_out = os::pipe();
let pipe_err = os::pipe();
@ -45,14 +45,14 @@ fn test_pipes() {
log actual;
assert (expected == actual);
fn writeclose(fd: int, s: str) {
fn writeclose(fd: int, s: str) unsafe {
let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
writer.write_str(s);
os::libc::close(fd);
}
fn readclose(fd: int) -> str {
fn readclose(fd: int) -> str unsafe {
// Copied from run::program_output
let file = os::fd_FILE(fd);
let reader = io::new_reader(io::FILE_buf_reader(file, option::none));
@ -67,7 +67,7 @@ fn test_pipes() {
}
#[test]
fn waitpid() {
fn waitpid() unsafe {
let pid = run::spawn_process("false", [], 0, 0, 0);
let status = run::waitpid(pid);
assert status == 1;

View File

@ -1,4 +1,4 @@
import std::sys;
#[test]
fn last_os_error() { log sys::rustrt::last_os_error(); }
fn last_os_error() unsafe { log sys::rustrt::last_os_error(); }