issue-2214.rs 1.1 KB
Newer Older
1 2
// xfail-fast

3 4 5 6 7 8 9 10 11 12
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

13 14 15
use ::core::cast;
use ::core::libc::{c_double, c_int};
use ::core::f64::*;
16

17
fn to_c_int(v: &mut int) -> &mut c_int unsafe {
18
    cast::reinterpret_cast(&v)
19 20
}

21
fn lgamma(n: c_double, value: &mut int) -> c_double {
N
Niko Matsakis 已提交
22
  return m::lgamma(n, to_c_int(value));
23 24 25 26
}

#[link_name = "m"]
#[abi = "cdecl"]
27
extern mod m {
28
    #[cfg(unix)]
29
    #[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int)
30
      -> c_double;
31
    #[cfg(windows)]
32 33
    #[link_name="__lgamma_r"] pub fn lgamma(n: c_double,
                                            sign: &mut c_int) -> c_double;
34

35 36 37 38 39 40
}

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);
41
}