]> git.lizzy.rs Git - rust.git/blob - src/test/ui/numbers-arithmetic/i128-ffi.rs
Rollup merge of #61207 - taiki-e:arbitrary_self_types-lifetime-elision-2, r=Centril
[rust.git] / src / test / ui / numbers-arithmetic / i128-ffi.rs
1 // run-pass
2 #![allow(improper_ctypes)]
3
4 // MSVC doesn't support 128 bit integers, and other Windows
5 // C compilers have very inconsistent views on how the ABI
6 // should look like.
7
8 // ignore-windows
9 // ignore-32bit
10
11 #[link(name = "rust_test_helpers", kind = "static")]
12 extern "C" {
13     fn identity(f: u128) -> u128;
14     fn square(f: i128) -> i128;
15     fn sub(f: i128, f: i128) -> i128;
16 }
17
18 fn main() {
19     unsafe {
20         let a = 0x734C_C2F2_A521;
21         let b = 0x33EE_0E2A_54E2_59DA_A0E7_8E41;
22         let b_out = identity(b);
23         assert_eq!(b, b_out);
24         let a_square = square(a);
25         assert_eq!(b, a_square as u128);
26         let k = 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210;
27         let k_d = 0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420;
28         let k_out = sub(k_d, k);
29         assert_eq!(k, k_out);
30     }
31 }