about summary refs log tree commit diff
path: root/src/rt/rust_test_helpers.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-04-01 17:47:38 -0700
committerBrian Anderson <banderson@mozilla.com>2013-04-17 15:49:19 -0700
commita5ddc009829bef149a9e2f127e80609589604443 (patch)
treee6da486757709a0abcb279f5bf6e52fd2d3f9545 /src/rt/rust_test_helpers.cpp
parent7cd681684f96c0f59468346384f6f5c5a04a7ff5 (diff)
downloadrust-a5ddc009829bef149a9e2f127e80609589604443.tar.gz
rust-a5ddc009829bef149a9e2f127e80609589604443.zip
rustc: Use an out pointer to return structs in x86 C ABI. #5347
This Adds a bunch of tests for passing and returning structs
of various sizes to C. It fixes the struct return rules on unix,
and on windows for structs of size > 8 bytes. Struct passing
on unix for structs under a certain size appears to still be broken.
Diffstat (limited to 'src/rt/rust_test_helpers.cpp')
-rw-r--r--src/rt/rust_test_helpers.cpp102
1 files changed, 82 insertions, 20 deletions
diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp
index 2c8026f159e..64966bd3454 100644
--- a/src/rt/rust_test_helpers.cpp
+++ b/src/rt/rust_test_helpers.cpp
@@ -30,26 +30,6 @@ rust_dbg_extern_identity_u64(uint64_t u) {
     return u;
 }
 
-struct TwoU64s {
-    uint64_t one;
-    uint64_t two;
-};
-
-extern "C" CDECL TwoU64s
-rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
-    return u;
-}
-
-struct TwoDoubles {
-    double one;
-    double two;
-};
-
-extern "C" CDECL TwoDoubles
-rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
-    return u;
-}
-
 extern "C" CDECL double
 rust_dbg_extern_identity_double(double u) {
     return u;
@@ -103,3 +83,85 @@ rust_dbg_call(dbg_callback cb, void *data) {
 }
 
 extern "C" CDECL void rust_dbg_do_nothing() { }
+
+struct TwoU8s {
+    uint8_t one;
+    uint8_t two;
+};
+
+extern "C" CDECL TwoU8s
+rust_dbg_extern_return_TwoU8s() {
+    struct TwoU8s s;
+    s.one = 10;
+    s.two = 20;
+    return s;
+}
+
+extern "C" CDECL TwoU8s
+rust_dbg_extern_identity_TwoU8s(TwoU8s u) {
+    return u;
+}
+
+struct TwoU16s {
+    uint16_t one;
+    uint16_t two;
+};
+
+extern "C" CDECL TwoU16s
+rust_dbg_extern_return_TwoU16s() {
+    struct TwoU16s s;
+    s.one = 10;
+    s.two = 20;
+    return s;
+}
+
+extern "C" CDECL TwoU16s
+rust_dbg_extern_identity_TwoU16s(TwoU16s u) {
+    return u;
+}
+
+struct TwoU32s {
+    uint32_t one;
+    uint32_t two;
+};
+
+extern "C" CDECL TwoU32s
+rust_dbg_extern_return_TwoU32s() {
+    struct TwoU32s s;
+    s.one = 10;
+    s.two = 20;
+    return s;
+}
+
+extern "C" CDECL TwoU32s
+rust_dbg_extern_identity_TwoU32s(TwoU32s u) {
+    return u;
+}
+
+struct TwoU64s {
+    uint64_t one;
+    uint64_t two;
+};
+
+extern "C" CDECL TwoU64s
+rust_dbg_extern_return_TwoU64s() {
+    struct TwoU64s s;
+    s.one = 10;
+    s.two = 20;
+    return s;
+}
+
+extern "C" CDECL TwoU64s
+rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
+    return u;
+}
+
+struct TwoDoubles {
+    double one;
+    double two;
+};
+
+extern "C" CDECL TwoDoubles
+rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
+    return u;
+}