]> git.lizzy.rs Git - rust.git/blob - src/test/ui/c-stack-returning-int64.rs
Rollup merge of #61207 - taiki-e:arbitrary_self_types-lifetime-elision-2, r=Centril
[rust.git] / src / test / ui / c-stack-returning-int64.rs
1 // run-pass
2 // ignore-wasm32-bare no libc to test with
3 // ignore-sgx no libc
4
5 #![feature(rustc_private)]
6
7 extern crate libc;
8
9 use std::ffi::CString;
10
11 mod mlibc {
12     use libc::{c_char, c_long, c_longlong};
13
14     extern {
15         pub fn atol(x: *const c_char) -> c_long;
16         pub fn atoll(x: *const c_char) -> c_longlong;
17     }
18 }
19
20 fn atol(s: String) -> isize {
21     let c = CString::new(s).unwrap();
22     unsafe { mlibc::atol(c.as_ptr()) as isize }
23 }
24
25 fn atoll(s: String) -> i64 {
26     let c = CString::new(s).unwrap();
27     unsafe { mlibc::atoll(c.as_ptr()) as i64 }
28 }
29
30 pub fn main() {
31     assert_eq!(atol("1024".to_string()) * 10, atol("10240".to_string()));
32     assert_eq!((atoll("11111111111111111".to_string()) * 10),
33              atoll("111111111111111110".to_string()));
34 }