summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-08-14 19:18:24 -0400
committerGitHub <noreply@github.com>2018-08-14 19:18:24 -0400
commit40d24bb085a1a0bd11f7cf4dd87c52de529302ca (patch)
tree79a015d785f110b572fad85cd7aed70e3f50b260 /tests
parentbb6a1205a0e81271bf90aec33d33e2e3ca0ae7d1 (diff)
parent6e7d9bebd8c95a8ca7088cf02c17aea811d20783 (diff)
Auto merge of #1366 - gnzlbg:vec, r=emiliov0.38.0
Map vector types to arrays and pass them by value This PR maps vector types to arrays and passes them by value (that is, they are passed to C as `[T; N]`. This already allows defining them as a blacklisted opaque type, such that the user can provide its own definition from e.g. `std::arch`. A subsequent PR should map vector types to unit structs with a private member: ```rust #[repr(align(16))] pub struct __m128([f32; 4]); ``` to make their alignment at least be correct. This should allow transmuting `std::arch` types to these types properly. Once that is done, we probably want to detect the canonical vector types (e.g. `__m128`) and pull in the type from `std`/`core`::arch instead.
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/vector.rs16
-rw-r--r--tests/headers/vector.hpp6
2 files changed, 19 insertions, 3 deletions
diff --git a/tests/expectations/tests/vector.rs b/tests/expectations/tests/vector.rs
index 357b9ef4..86a9d737 100644
--- a/tests/expectations/tests/vector.rs
+++ b/tests/expectations/tests/vector.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@@ -32,3 +35,10 @@ fn bindgen_test_layout_foo() {
)
);
}
+pub type __m128 = [f32; 4usize];
+pub type __m128d = [f64; 2usize];
+pub type __m128i = [::std::os::raw::c_longlong; 2usize];
+extern "C" {
+ #[link_name = "\u{1}_Z3fooDv2_xDv2_d"]
+ pub fn foo(arg1: __m128i, arg2: __m128d) -> __m128;
+}
diff --git a/tests/headers/vector.hpp b/tests/headers/vector.hpp
index 4707f77f..173aa022 100644
--- a/tests/headers/vector.hpp
+++ b/tests/headers/vector.hpp
@@ -1,3 +1,9 @@
struct foo {
__attribute__((__vector_size__(1 * sizeof(long long)))) long long mMember;
};
+
+typedef float __m128 __attribute__ ((__vector_size__ (16)));
+typedef double __m128d __attribute__((__vector_size__(16)));
+typedef long long __m128i __attribute__((__vector_size__(16)));
+
+__m128 foo(__m128i, __m128d);