summaryrefslogtreecommitdiff
path: root/test/mem.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-01 19:13:24 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-01 19:13:24 -0800
commitc8cbfbeb8d1cc108bbb0f1a7f145a50c06059c0e (patch)
tree92423d6d4a10fe5e3bba371ac8b053fbbf698225 /test/mem.cpp
parentc0a332693eceec4171c4e2fef30924e4f22771fc (diff)
downloadbinaryen-c8cbfbeb8d1cc108bbb0f1a7f145a50c06059c0e.tar.gz
binaryen-c8cbfbeb8d1cc108bbb0f1a7f145a50c06059c0e.tar.bz2
binaryen-c8cbfbeb8d1cc108bbb0f1a7f145a50c06059c0e.zip
add mem test
Diffstat (limited to 'test/mem.cpp')
-rw-r--r--test/mem.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/mem.cpp b/test/mem.cpp
new file mode 100644
index 000000000..a48d2e3d2
--- /dev/null
+++ b/test/mem.cpp
@@ -0,0 +1,29 @@
+#include <stdint.h>
+#include <emscripten.h>
+
+extern "C" {
+
+int EMSCRIPTEN_KEEPALIVE loadi8(size_t addr) { return ((int8_t*)addr)[0]; }
+int EMSCRIPTEN_KEEPALIVE loadi16(size_t addr) { return ((int16_t*)addr)[0]; }
+int EMSCRIPTEN_KEEPALIVE loadi32(size_t addr) { return ((int32_t*)addr)[0]; }
+
+int EMSCRIPTEN_KEEPALIVE loadu8(size_t addr) { return ((uint8_t*)addr)[0]; }
+int EMSCRIPTEN_KEEPALIVE loadu16(size_t addr) { return ((uint16_t*)addr)[0]; }
+int EMSCRIPTEN_KEEPALIVE loadu32(size_t addr) { return ((uint32_t*)addr)[0]; }
+
+double EMSCRIPTEN_KEEPALIVE loadf32(size_t addr) { return ((float*)addr)[0]; }
+double EMSCRIPTEN_KEEPALIVE loadf64(size_t addr) { return ((double*)addr)[0]; }
+
+void EMSCRIPTEN_KEEPALIVE storei8(size_t addr, int8_t v) { ((int8_t*)addr)[0] = v; }
+void EMSCRIPTEN_KEEPALIVE storei16(size_t addr, int16_t v) { ((int16_t*)addr)[0] = v; }
+void EMSCRIPTEN_KEEPALIVE storei32(size_t addr, int32_t v) { ((int32_t*)addr)[0] = v; }
+
+void EMSCRIPTEN_KEEPALIVE storeu8(size_t addr, uint8_t v) { ((uint8_t*)addr)[0] = v; }
+void EMSCRIPTEN_KEEPALIVE storeu16(size_t addr, uint16_t v) { ((uint16_t*)addr)[0] = v; }
+void EMSCRIPTEN_KEEPALIVE storeu32(size_t addr, uint32_t v) { ((uint32_t*)addr)[0] = v; }
+
+void EMSCRIPTEN_KEEPALIVE storef32(size_t addr, float v) { ((float*)addr)[0] = v; }
+void EMSCRIPTEN_KEEPALIVE storef64(size_t addr, double v) { ((double*)addr)[0] = v; }
+
+}
+