]> git.lizzy.rs Git - rust.git/commitdiff
Fix the test to use explicit argument types
authorSimonas Kazlauskas <git@kazlauskas.me>
Thu, 2 Jun 2016 14:18:11 +0000 (17:18 +0300)
committerSimonas Kazlauskas <git@kazlauskas.me>
Thu, 2 Jun 2016 17:09:59 +0000 (20:09 +0300)
Hopefully this pacifies the 32bit windows. Apparently there’s an ABI out there that not only allows
non-64 bit variadic arguments, but also has differing ABI for them!

Good thing all variadic functions are unsafe.

src/test/run-pass/variadic-ffi.rs

index fad360329ffd8520cc6f5a428f632ac9ac035848..0131563d36d35e05838561731a5ca21c156b7fbd 100644 (file)
@@ -10,7 +10,7 @@
 
 #[link(name = "rust_test_helpers")]
 extern {
-    fn rust_interesting_average(_: i64, ...) -> f64;
+    fn rust_interesting_average(_: u64, ...) -> f64;
 }
 
 pub fn main() {
@@ -21,18 +21,18 @@ pub fn main() {
 
     // Call with direct arguments
     unsafe {
-        assert_eq!(rust_interesting_average(1, 10, 10.0) as i64, 20);
+        assert_eq!(rust_interesting_average(1, 10i64, 10.0f64) as i64, 20);
     }
 
     // Call with named arguments, variable number of them
-    let (x1, x2, x3, x4) = (10, 10.0, 20, 20.0);
+    let (x1, x2, x3, x4) = (10i64, 10.0f64, 20i64, 20.0f64);
     unsafe {
         assert_eq!(rust_interesting_average(2, x1, x2, x3, x4) as i64, 30);
     }
 
     // A function that takes a function pointer
-    unsafe fn call(fp: unsafe extern fn(i64, ...) -> f64) {
-        let (x1, x2, x3, x4) = (10, 10.0, 20, 20.0);
+    unsafe fn call(fp: unsafe extern fn(u64, ...) -> f64) {
+        let (x1, x2, x3, x4) = (10i64, 10.0f64, 20i64, 20.0f64);
         assert_eq!(fp(2, x1, x2, x3, x4) as i64, 30);
     }
 
@@ -40,7 +40,7 @@ unsafe fn call(fp: unsafe extern fn(i64, ...) -> f64) {
         call(rust_interesting_average);
 
         // Make a function pointer, pass indirectly
-        let x: unsafe extern fn(i64, ...) -> f64 = rust_interesting_average;
+        let x: unsafe extern fn(u64, ...) -> f64 = rust_interesting_average;
         call(x);
     }
 }