rust/src/test/auxiliary/extern-crosscrate-source.rs

25 lines
469 B
Rust
Raw Normal View History

#[link(name = "externcallback",
vers = "0.1")];
#[crate_type = "lib"];
#[legacy_exports];
extern mod rustrt {
#[legacy_exports];
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);
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
}
}