Add a morestack_addr (temporary) intrinsic
This commit is contained in:
parent
a02ab41b65
commit
b999973c0f
3 changed files with 24 additions and 0 deletions
|
@ -993,6 +993,16 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
||||||
lv_temporary),
|
lv_temporary),
|
||||||
arg_vals(~[frameaddress_val]), ignore);
|
arg_vals(~[frameaddress_val]), ignore);
|
||||||
}
|
}
|
||||||
|
~"morestack_addr" => {
|
||||||
|
// XXX This is a hack to grab the address of this particular
|
||||||
|
// native function. There should be a general in-language
|
||||||
|
// way to do this
|
||||||
|
let llfty = type_of_fn(bcx.ccx(), ~[], ty::mk_nil(bcx.tcx()));
|
||||||
|
let morestack_addr = decl_cdecl_fn(
|
||||||
|
bcx.ccx().llmod, ~"__morestack", llfty);
|
||||||
|
let morestack_addr = PointerCast(bcx, morestack_addr, T_ptr(T_nil()));
|
||||||
|
Store(bcx, morestack_addr, fcx.llretptr);
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Could we make this an enum rather than a string? does it get
|
// Could we make this an enum rather than a string? does it get
|
||||||
// checked earlier?
|
// checked earlier?
|
||||||
|
|
|
@ -2590,6 +2590,9 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
||||||
});
|
});
|
||||||
(0u, ~[arg(ast::by_ref, fty)], ty::mk_nil(tcx))
|
(0u, ~[arg(ast::by_ref, fty)], ty::mk_nil(tcx))
|
||||||
}
|
}
|
||||||
|
~"morestack_addr" => {
|
||||||
|
(0u, ~[], ty::mk_nil_ptr(tcx))
|
||||||
|
}
|
||||||
other => {
|
other => {
|
||||||
tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" +
|
tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" +
|
||||||
other + ~"`");
|
other + ~"`");
|
||||||
|
|
11
src/test/run-pass/morestack-address.rs
Normal file
11
src/test/run-pass/morestack-address.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#[nolink]
|
||||||
|
#[abi = "rust-intrinsic"]
|
||||||
|
extern mod rusti {
|
||||||
|
fn morestack_addr() -> *();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let addr = rusti::morestack_addr();
|
||||||
|
assert addr.is_not_null();
|
||||||
|
error!("%?", addr);
|
||||||
|
}
|
Loading…
Reference in a new issue