about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2011-11-16 16:13:43 -0800
committerNiko Matsakis <niko@alum.mit.edu>2011-11-16 16:13:43 -0800
commit809ca13bfa79211aebeef3491f1553ee22fde45b (patch)
treea9cdd661b25fd090c4443d30fbd0569cfad2d40c /src
parentc22ad0752f9bbe5dc8c9deae99a10b3fc5c8e1e3 (diff)
downloadrust-809ca13bfa79211aebeef3491f1553ee22fde45b.tar.gz
rust-809ca13bfa79211aebeef3491f1553ee22fde45b.zip
fix minor merge errors
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs31
-rw-r--r--src/lib/macos_os.rs28
2 files changed, 28 insertions, 31 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 8497a742b60..e2d8811a4ad 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -5394,17 +5394,17 @@ fn c_stack_tys(ccx: @crate_ctxt,
 //
 fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
     fn build_shim_fn(lcx: @local_ctxt,
-                     link_name: str,
                      native_item: @ast::native_item,
                      llshimfn: ValueRef,
                      cc: uint) {
+        let lname = link_name(native_item);
         let ccx = lcx_ccx(lcx);
         let span = native_item.span;
         let id = native_item.id;
         let tys = c_stack_tys(ccx, span, id);
 
         // Declare the "prototype" for the base function F:
-        let llbasefn = decl_fn(ccx.llmod, link_name, cc, tys.base_fn_ty);
+        let llbasefn = decl_fn(ccx.llmod, lname, cc, tys.base_fn_ty);
 
         // Declare the body of the shim function:
         let fcx = new_fn_ctxt(lcx, span, llshimfn);
@@ -5432,13 +5432,6 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
         finish_fn(fcx, lltop);
     }
 
-    fn select_link_name(user_name: option::t<str>, rust_name: str) -> str {
-        ret alt user_name {
-          some(n) { n }
-          none. { rust_name }
-        };
-    }
-
     let ccx = lcx_ccx(lcx);
     let cc: uint = lib::llvm::LLVMCCallConv;
     alt native_mod.abi {
@@ -5450,12 +5443,11 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
     for native_item in native_mod.items {
       alt native_item.node {
         ast::native_item_ty. {}
-        ast::native_item_fn(name, fn_decl, _) {
+        ast::native_item_fn(fn_decl, _) {
           let id = native_item.id;
           alt ccx.item_ids.find(id) {
             some(llshimfn) {
-              let link_name = select_link_name(name, native_item.ident);
-              build_shim_fn(lcx, link_name, native_item, llshimfn, cc);
+              build_shim_fn(lcx, native_item, llshimfn, cc);
             }
 
             none. {
@@ -5753,16 +5745,20 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, _path: [str], name: str,
 
 fn item_path(item: @ast::item) -> [str] { ret [item.ident]; }
 
+fn link_name(i: @ast::native_item) -> str {
+    alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
+      none. { ret i.ident; }
+      option::some(ln) { ret ln; }
+    }
+}
+
+
 fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, &&pt: [str],
                        _v: vt<[str]>) {
     alt i.node {
       ast::native_item_fn(_, _) {
         if !ccx.obj_methods.contains_key(i.id) {
-            let name = i.ident;
-            alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
-              none. { }
-              option::some(ln) { name = ln; }
-            }
+            let name = link_name(i);
             register_native_fn(ccx, i.span, pt, name, i.id);
         }
       }
@@ -6163,6 +6159,5 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
 // indent-tabs-mode: nil
 // c-basic-offset: 4
 // buffer-file-coding-system: utf-8-unix
-// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
 // End:
 //
diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs
index f0caed83ac5..8ffe9f7b961 100644
--- a/src/lib/macos_os.rs
+++ b/src/lib/macos_os.rs
@@ -47,18 +47,18 @@ native mod libc {
 }
 
 mod libc_constants {
-    const O_RDONLY: int   = 0i32;
-    const O_WRONLY: int   = 1i32;
-    const O_RDWR: int     = 2i32;
-    const O_APPEND: int   = 8i32;
-    const O_CREAT: int    = 512i32;
-    const O_EXCL: int     = 2048i32;
-    const O_TRUNC: int    = 1024i32;
-    const O_TEXT: int     = 0i32;    // nonexistent in darwin libc
-    const O_BINARY: int   = 0i32;    // nonexistent in darwin libc
-
-    const S_IRUSR: uint   = 256u32;
-    const S_IWUSR: uint   = 128u32;
+    const O_RDONLY: c_int   = 0i32;
+    const O_WRONLY: c_int   = 1i32;
+    const O_RDWR: c_int     = 2i32;
+    const O_APPEND: c_int   = 8i32;
+    const O_CREAT: c_int    = 512i32;
+    const O_EXCL: c_int     = 2048i32;
+    const O_TRUNC: c_int    = 1024i32;
+    const O_TEXT: c_int     = 0i32;    // nonexistent in darwin libc
+    const O_BINARY: c_int   = 0i32;    // nonexistent in darwin libc
+
+    const S_IRUSR: unsigned = 256u32;
+    const S_IWUSR: unsigned = 128u32;
 }
 
 fn pipe() -> {in: fd_t, out: fd_t} {
@@ -92,7 +92,9 @@ native mod rustrt {
 
 fn getcwd() -> str { ret rustrt::rust_getcwd(); }
 
-native "cdecl" mod mac_libc = "" {
+#[link_name = ""]
+#[abi = "cdecl"]
+native mod mac_libc {
     fn _NSGetExecutablePath(buf: str::sbuf,
                             bufsize: *mutable uint32_t) -> c_int;
 }