mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Add a morestack_addr (temporary) intrinsic
This commit is contained in:
@@ -993,6 +993,16 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
||||
lv_temporary),
|
||||
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
|
||||
// checked earlier?
|
||||
|
||||
@@ -2590,6 +2590,9 @@ fn arg(m: ast::rmode, ty: ty::t) -> ty::arg {
|
||||
});
|
||||
(0u, ~[arg(ast::by_ref, fty)], ty::mk_nil(tcx))
|
||||
}
|
||||
~"morestack_addr" => {
|
||||
(0u, ~[], ty::mk_nil_ptr(tcx))
|
||||
}
|
||||
other => {
|
||||
tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" +
|
||||
other + ~"`");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user