summaryrefslogtreecommitdiffstats
path: root/src/test/run-make/wasm-abi
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/run-make/wasm-abi
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/run-make/wasm-abi')
-rw-r--r--src/test/run-make/wasm-abi/Makefile7
-rw-r--r--src/test/run-make/wasm-abi/foo.js22
-rw-r--r--src/test/run-make/wasm-abi/foo.rs87
3 files changed, 0 insertions, 116 deletions
diff --git a/src/test/run-make/wasm-abi/Makefile b/src/test/run-make/wasm-abi/Makefile
deleted file mode 100644
index e713ca187..000000000
--- a/src/test/run-make/wasm-abi/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-include ../../run-make-fulldeps/tools.mk
-
-# only-wasm32-bare
-
-all:
- $(RUSTC) foo.rs --target wasm32-unknown-unknown
- $(NODE) foo.js $(TMPDIR)/foo.wasm
diff --git a/src/test/run-make/wasm-abi/foo.js b/src/test/run-make/wasm-abi/foo.js
deleted file mode 100644
index 9e9a65401..000000000
--- a/src/test/run-make/wasm-abi/foo.js
+++ /dev/null
@@ -1,22 +0,0 @@
-const fs = require('fs');
-const process = require('process');
-const assert = require('assert');
-const buffer = fs.readFileSync(process.argv[2]);
-
-const m = new WebAssembly.Module(buffer);
-const i = new WebAssembly.Instance(m, {
- host: {
- two_i32: () => [100, 101],
- two_i64: () => [102n, 103n],
- two_f32: () => [104, 105],
- two_f64: () => [106, 107],
- mishmash: () => [108, 109, 110, 111n, 112, 113],
- }
-});
-
-assert.deepEqual(i.exports.return_two_i32(), [1, 2])
-assert.deepEqual(i.exports.return_two_i64(), [3, 4])
-assert.deepEqual(i.exports.return_two_f32(), [5, 6])
-assert.deepEqual(i.exports.return_two_f64(), [7, 8])
-assert.deepEqual(i.exports.return_mishmash(), [9, 10, 11, 12, 13, 14])
-i.exports.call_imports();
diff --git a/src/test/run-make/wasm-abi/foo.rs b/src/test/run-make/wasm-abi/foo.rs
deleted file mode 100644
index 0678eb3ff..000000000
--- a/src/test/run-make/wasm-abi/foo.rs
+++ /dev/null
@@ -1,87 +0,0 @@
-#![crate_type = "cdylib"]
-#![deny(warnings)]
-#![feature(wasm_abi)]
-
-#[repr(C)]
-#[derive(PartialEq, Debug)]
-pub struct TwoI32 {
- pub a: i32,
- pub b: i32,
-}
-
-#[no_mangle]
-pub extern "wasm" fn return_two_i32() -> TwoI32 {
- TwoI32 { a: 1, b: 2 }
-}
-
-#[repr(C)]
-#[derive(PartialEq, Debug)]
-pub struct TwoI64 {
- pub a: i64,
- pub b: i64,
-}
-
-#[no_mangle]
-pub extern "wasm" fn return_two_i64() -> TwoI64 {
- TwoI64 { a: 3, b: 4 }
-}
-
-#[repr(C)]
-#[derive(PartialEq, Debug)]
-pub struct TwoF32 {
- pub a: f32,
- pub b: f32,
-}
-
-#[no_mangle]
-pub extern "wasm" fn return_two_f32() -> TwoF32 {
- TwoF32 { a: 5., b: 6. }
-}
-
-#[repr(C)]
-#[derive(PartialEq, Debug)]
-pub struct TwoF64 {
- pub a: f64,
- pub b: f64,
-}
-
-#[no_mangle]
-pub extern "wasm" fn return_two_f64() -> TwoF64 {
- TwoF64 { a: 7., b: 8. }
-}
-
-#[repr(C)]
-#[derive(PartialEq, Debug)]
-pub struct Mishmash {
- pub a: f64,
- pub b: f32,
- pub c: i32,
- pub d: i64,
- pub e: TwoI32,
-}
-
-#[no_mangle]
-pub extern "wasm" fn return_mishmash() -> Mishmash {
- Mishmash { a: 9., b: 10., c: 11, d: 12, e: TwoI32 { a: 13, b: 14 } }
-}
-
-#[link(wasm_import_module = "host")]
-extern "wasm" {
- fn two_i32() -> TwoI32;
- fn two_i64() -> TwoI64;
- fn two_f32() -> TwoF32;
- fn two_f64() -> TwoF64;
- fn mishmash() -> Mishmash;
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn call_imports() {
- assert_eq!(two_i32(), TwoI32 { a: 100, b: 101 });
- assert_eq!(two_i64(), TwoI64 { a: 102, b: 103 });
- assert_eq!(two_f32(), TwoF32 { a: 104., b: 105. });
- assert_eq!(two_f64(), TwoF64 { a: 106., b: 107. });
- assert_eq!(
- mishmash(),
- Mishmash { a: 108., b: 109., c: 110, d: 111, e: TwoI32 { a: 112, b: 113 } }
- );
-}