1
Fork 0
rust/tests/ui/issues/issue-2214.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
961 B
Rust
Raw Normal View History

//@ run-pass
//@ ignore-wasm32 wasi-libc does not have lgamma
2019-04-24 09:26:33 -07:00
//@ ignore-sgx no libc
use std::ffi::{c_double, c_int};
2020-09-01 17:12:52 -04:00
use std::mem;
fn to_c_int(v: &mut isize) -> &mut c_int {
2020-09-01 17:12:52 -04:00
unsafe { mem::transmute_copy(&v) }
}
fn lgamma(n: c_double, value: &mut isize) -> c_double {
2013-01-23 16:29:31 -08:00
unsafe {
return m::lgamma(n, to_c_int(value));
}
}
mod m {
use std::ffi::{c_double, c_int};
2020-09-01 17:12:52 -04:00
extern "C" {
2020-10-27 13:10:31 +00:00
#[cfg(all(unix, not(target_os = "vxworks")))]
#[link_name="lgamma_r"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
#[cfg(windows)]
2020-09-01 17:12:52 -04:00
#[link_name = "lgamma"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
#[cfg(target_os = "vxworks")]
2020-09-01 17:12:52 -04:00
#[link_name = "lgamma"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
}
}
pub fn main() {
2020-09-01 17:12:52 -04:00
let mut y: isize = 5;
let x: &mut isize = &mut y;
assert_eq!(lgamma(1.0 as c_double, x), 0.0 as c_double);
}