Skip to content

Commit 2d9ba5d

Browse files
committed
---
yaml --- r: 6327 b: refs/heads/master c: e3699a2 h: refs/heads/master i: 6325: 63ce813 6323: 9839267 6319: 60e714d v: v3
1 parent 986054a commit 2d9ba5d

File tree

2 files changed

+27
-44
lines changed

2 files changed

+27
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d2199e87166e82c394bf7d8c28374287145ff1b7
2+
refs/heads/master: e3699a26368c4582b0825aae6045dabdb50aee5f

trunk/src/comp/middle/trans.rs

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,14 +5396,15 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
53965396
fn build_shim_fn(lcx: @local_ctxt,
53975397
link_name: str,
53985398
native_item: @ast::native_item,
5399-
llshimfn: ValueRef) {
5399+
llshimfn: ValueRef,
5400+
cc: uint) {
54005401
let ccx = lcx_ccx(lcx);
54015402
let span = native_item.span;
54025403
let id = native_item.id;
54035404
let tys = c_stack_tys(ccx, span, id);
54045405

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

54085409
// Declare the body of the shim function:
54095410
let fcx = new_fn_ctxt(lcx, span, llshimfn);
@@ -5439,30 +5440,32 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
54395440
}
54405441

54415442
let ccx = lcx_ccx(lcx);
5443+
let cc: uint = lib::llvm::LLVMCCallConv;
54425444
alt native_mod.abi {
5443-
ast::native_abi_cdecl. {
5444-
for native_item in native_mod.items {
5445-
alt native_item.node {
5446-
ast::native_item_ty. {}
5447-
ast::native_item_fn(name, fn_decl, _) {
5448-
let id = native_item.id;
5449-
alt ccx.item_ids.find(id) {
5450-
some(llshimfn) {
5451-
let link_name = select_link_name(name, native_item.ident);
5452-
build_shim_fn(lcx, link_name, native_item, llshimfn);
5453-
}
5445+
ast::native_abi_rust_intrinsic. { ret; }
5446+
ast::native_abi_cdecl. { cc = lib::llvm::LLVMCCallConv; }
5447+
ast::native_abi_stdcall. { cc = lib::llvm::LLVMX86StdcallCallConv; }
5448+
}
5449+
5450+
for native_item in native_mod.items {
5451+
alt native_item.node {
5452+
ast::native_item_ty. {}
5453+
ast::native_item_fn(name, fn_decl, _) {
5454+
let id = native_item.id;
5455+
alt ccx.item_ids.find(id) {
5456+
some(llshimfn) {
5457+
let link_name = select_link_name(name, native_item.ident);
5458+
build_shim_fn(lcx, link_name, native_item, llshimfn, cc);
5459+
}
54545460

5455-
none. {
5456-
ccx.sess.span_fatal(
5457-
native_item.span,
5458-
"unbound function item in trans_native_mod");
5459-
}
5460-
}
5461-
}
5461+
none. {
5462+
ccx.sess.span_fatal(
5463+
native_item.span,
5464+
"unbound function item in trans_native_mod");
54625465
}
5466+
}
54635467
}
54645468
}
5465-
_ { /* nothing to do for other ABIs */ }
54665469
}
54675470
}
54685471

@@ -5736,7 +5739,8 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
57365739
uses_retptr = true;
57375740
cast_to_i32 = false;
57385741
}
5739-
ast::native_abi_cdecl. {
5742+
5743+
ast::native_abi_cdecl. | ast::native_abi_stdcall. {
57405744
let tys = c_stack_tys(ccx, sp, id);
57415745
let shim_name = name + "__c_stack_shim";
57425746
let llshimfn = decl_internal_cdecl_fn(
@@ -5745,27 +5749,6 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
57455749
ccx.item_symbols.insert(id, shim_name);
57465750
ret;
57475751
}
5748-
ast::native_abi_stdcall. {
5749-
// The name of stdcall functions depend on their argument count
5750-
// so we have to declare them correctly
5751-
let fn_args_tys = ty::ty_fn_args(ccx.tcx, fn_type);
5752-
let fn_ret_ty = ty::ty_fn_ret(ccx.tcx, fn_type);
5753-
let ll_args_tys = [];
5754-
for arg in fn_args_tys {
5755-
let arg_ty = arg.ty;
5756-
check type_has_static_size(ccx, arg_ty);
5757-
ll_args_tys += [type_of(ccx, sp, arg_ty)];
5758-
}
5759-
check type_has_static_size(ccx, fn_ret_ty);
5760-
let ll_ret_ty = type_of(ccx, sp, fn_ret_ty);
5761-
let native_fn_ty = T_fn(ll_args_tys, ll_ret_ty);
5762-
5763-
let llfn = decl_fn(ccx.llmod, name, lib::llvm::LLVMX86StdcallCallConv,
5764-
native_fn_ty);
5765-
ccx.item_ids.insert(id, llfn);
5766-
ccx.item_symbols.insert(id, name);
5767-
ret;
5768-
}
57695752
}
57705753

57715754
let path = path;

0 commit comments

Comments
 (0)