2012-09-05 14:32:05 -05:00
|
|
|
use libc::{c_double, c_int};
|
|
|
|
use f64::*;
|
2012-06-21 18:50:45 -05:00
|
|
|
|
2012-08-02 16:23:04 -05:00
|
|
|
fn to_c_int(v: &mut int) -> &mut c_int unsafe {
|
2012-09-18 19:34:08 -05:00
|
|
|
cast::reinterpret_cast(&v)
|
2012-08-02 16:23:04 -05:00
|
|
|
}
|
|
|
|
|
2012-06-21 18:50:45 -05:00
|
|
|
fn lgamma(n: c_double, value: &mut int) -> c_double {
|
2012-08-03 10:05:04 -05:00
|
|
|
return m::lgamma(n, to_c_int(value));
|
2012-06-21 18:50:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[link_name = "m"]
|
|
|
|
#[abi = "cdecl"]
|
2012-07-03 18:11:00 -05:00
|
|
|
extern mod m {
|
2012-09-21 20:10:45 -05:00
|
|
|
#[legacy_exports];
|
2012-06-21 19:54:56 -05:00
|
|
|
#[cfg(unix)]
|
2012-06-21 18:50:45 -05:00
|
|
|
#[link_name="lgamma_r"] fn lgamma(n: c_double, sign: &mut c_int)
|
|
|
|
-> c_double;
|
2012-06-21 19:54:56 -05:00
|
|
|
#[cfg(windows)]
|
|
|
|
#[link_name="__lgamma_r"] fn lgamma(n: c_double,
|
|
|
|
sign: &mut c_int) -> c_double;
|
|
|
|
|
2012-06-21 18:50:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut y: int = 5;
|
|
|
|
let x: &mut int = &mut y;
|
|
|
|
assert (lgamma(1.0 as c_double, x) == 0.0 as c_double);
|
|
|
|
}
|