]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-2214.rs
Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup
[rust.git] / src / test / ui / issues / issue-2214.rs
1 // run-pass
2 // ignore-wasm32-bare no libc to test ffi with
3 // ignore-sgx no libc
4 #![feature(rustc_private)]
5
6 extern crate libc;
7
8 use std::mem;
9 use libc::{c_double, c_int};
10
11 fn to_c_int(v: &mut isize) -> &mut c_int {
12     unsafe {
13         mem::transmute_copy(&v)
14     }
15 }
16
17 fn lgamma(n: c_double, value: &mut isize) -> c_double {
18     unsafe {
19         return m::lgamma(n, to_c_int(value));
20     }
21 }
22
23 mod m {
24     use libc::{c_double, c_int};
25
26     #[link_name = "m"]
27     extern {
28         #[cfg(any(all(unix, not(target_os = "vxworks")), target_os = "cloudabi"))]
29         #[link_name="lgamma_r"]
30         pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
31         #[cfg(windows)]
32         #[link_name="lgamma"]
33         pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
34         #[cfg(target_os = "vxworks")]
35         #[link_name="lgamma"]
36         pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
37     }
38 }
39
40 pub fn main() {
41   let mut y: isize = 5;
42   let x: &mut isize = &mut y;
43   assert_eq!(lgamma(1.0 as c_double, x), 0.0 as c_double);
44 }