Skip to content

Commit 809ca13

Browse files
committed
fix minor merge errors
1 parent c22ad07 commit 809ca13

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

src/comp/middle/trans.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -5394,17 +5394,17 @@ fn c_stack_tys(ccx: @crate_ctxt,
53945394
//
53955395
fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
53965396
fn build_shim_fn(lcx: @local_ctxt,
5397-
link_name: str,
53985397
native_item: @ast::native_item,
53995398
llshimfn: ValueRef,
54005399
cc: uint) {
5400+
let lname = link_name(native_item);
54015401
let ccx = lcx_ccx(lcx);
54025402
let span = native_item.span;
54035403
let id = native_item.id;
54045404
let tys = c_stack_tys(ccx, span, id);
54055405

54065406
// Declare the "prototype" for the base function F:
5407-
let llbasefn = decl_fn(ccx.llmod, link_name, cc, tys.base_fn_ty);
5407+
let llbasefn = decl_fn(ccx.llmod, lname, cc, tys.base_fn_ty);
54085408

54095409
// Declare the body of the shim function:
54105410
let fcx = new_fn_ctxt(lcx, span, llshimfn);
@@ -5432,13 +5432,6 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
54325432
finish_fn(fcx, lltop);
54335433
}
54345434

5435-
fn select_link_name(user_name: option::t<str>, rust_name: str) -> str {
5436-
ret alt user_name {
5437-
some(n) { n }
5438-
none. { rust_name }
5439-
};
5440-
}
5441-
54425435
let ccx = lcx_ccx(lcx);
54435436
let cc: uint = lib::llvm::LLVMCCallConv;
54445437
alt native_mod.abi {
@@ -5450,12 +5443,11 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
54505443
for native_item in native_mod.items {
54515444
alt native_item.node {
54525445
ast::native_item_ty. {}
5453-
ast::native_item_fn(name, fn_decl, _) {
5446+
ast::native_item_fn(fn_decl, _) {
54545447
let id = native_item.id;
54555448
alt ccx.item_ids.find(id) {
54565449
some(llshimfn) {
5457-
let link_name = select_link_name(name, native_item.ident);
5458-
build_shim_fn(lcx, link_name, native_item, llshimfn, cc);
5450+
build_shim_fn(lcx, native_item, llshimfn, cc);
54595451
}
54605452

54615453
none. {
@@ -5753,16 +5745,20 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, _path: [str], name: str,
57535745

57545746
fn item_path(item: @ast::item) -> [str] { ret [item.ident]; }
57555747

5748+
fn link_name(i: @ast::native_item) -> str {
5749+
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
5750+
none. { ret i.ident; }
5751+
option::some(ln) { ret ln; }
5752+
}
5753+
}
5754+
5755+
57565756
fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, &&pt: [str],
57575757
_v: vt<[str]>) {
57585758
alt i.node {
57595759
ast::native_item_fn(_, _) {
57605760
if !ccx.obj_methods.contains_key(i.id) {
5761-
let name = i.ident;
5762-
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
5763-
none. { }
5764-
option::some(ln) { name = ln; }
5765-
}
5761+
let name = link_name(i);
57665762
register_native_fn(ccx, i.span, pt, name, i.id);
57675763
}
57685764
}
@@ -6163,6 +6159,5 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
61636159
// indent-tabs-mode: nil
61646160
// c-basic-offset: 4
61656161
// buffer-file-coding-system: utf-8-unix
6166-
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
61676162
// End:
61686163
//

src/lib/macos_os.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ native mod libc {
4747
}
4848

4949
mod libc_constants {
50-
const O_RDONLY: int = 0i32;
51-
const O_WRONLY: int = 1i32;
52-
const O_RDWR: int = 2i32;
53-
const O_APPEND: int = 8i32;
54-
const O_CREAT: int = 512i32;
55-
const O_EXCL: int = 2048i32;
56-
const O_TRUNC: int = 1024i32;
57-
const O_TEXT: int = 0i32; // nonexistent in darwin libc
58-
const O_BINARY: int = 0i32; // nonexistent in darwin libc
59-
60-
const S_IRUSR: uint = 256u32;
61-
const S_IWUSR: uint = 128u32;
50+
const O_RDONLY: c_int = 0i32;
51+
const O_WRONLY: c_int = 1i32;
52+
const O_RDWR: c_int = 2i32;
53+
const O_APPEND: c_int = 8i32;
54+
const O_CREAT: c_int = 512i32;
55+
const O_EXCL: c_int = 2048i32;
56+
const O_TRUNC: c_int = 1024i32;
57+
const O_TEXT: c_int = 0i32; // nonexistent in darwin libc
58+
const O_BINARY: c_int = 0i32; // nonexistent in darwin libc
59+
60+
const S_IRUSR: unsigned = 256u32;
61+
const S_IWUSR: unsigned = 128u32;
6262
}
6363

6464
fn pipe() -> {in: fd_t, out: fd_t} {
@@ -92,7 +92,9 @@ native mod rustrt {
9292

9393
fn getcwd() -> str { ret rustrt::rust_getcwd(); }
9494

95-
native "cdecl" mod mac_libc = "" {
95+
#[link_name = ""]
96+
#[abi = "cdecl"]
97+
native mod mac_libc {
9698
fn _NSGetExecutablePath(buf: str::sbuf,
9799
bufsize: *mutable uint32_t) -> c_int;
98100
}

0 commit comments

Comments
 (0)