2012-07-06 23:52:31 -05:00
|
|
|
#[link(name = "externcallback",
|
|
|
|
vers = "0.1")];
|
|
|
|
|
|
|
|
#[crate_type = "lib"];
|
2012-09-24 19:29:20 -05:00
|
|
|
#[legacy_exports];
|
2012-07-06 23:52:31 -05:00
|
|
|
|
|
|
|
extern mod rustrt {
|
2012-09-21 20:10:45 -05:00
|
|
|
#[legacy_exports];
|
2012-07-06 23:52:31 -05:00
|
|
|
fn rust_dbg_call(cb: *u8,
|
|
|
|
data: libc::uintptr_t) -> libc::uintptr_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fact(n: uint) -> uint {
|
2012-08-22 19:24:52 -05:00
|
|
|
debug!("n = %?", n);
|
2012-07-06 23:52:31 -05:00
|
|
|
rustrt::rust_dbg_call(cb, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
|
|
|
if data == 1u {
|
|
|
|
data
|
|
|
|
} else {
|
|
|
|
fact(data - 1u) * data
|
|
|
|
}
|
|
|
|
}
|