diff options
Diffstat (limited to 'test')
m--------- | test/emscripten | 0 | ||||
-rw-r--r-- | test/revision | 2 | ||||
-rw-r--r-- | test/wasm_backend/unaligned.cpp | 70 | ||||
-rw-r--r-- | test/wasm_backend/unaligned.txt | 15 |
4 files changed, 86 insertions, 1 deletions
diff --git a/test/emscripten b/test/emscripten -Subproject 4e7573cc4a455563c78076b8ad6ee254892305b +Subproject eae355d2de1cb66693ef5eaac3381a206dad7a6 diff --git a/test/revision b/test/revision index bed5801ac..208871b67 100644 --- a/test/revision +++ b/test/revision @@ -1 +1 @@ -3193 +3321 diff --git a/test/wasm_backend/unaligned.cpp b/test/wasm_backend/unaligned.cpp new file mode 100644 index 000000000..75f8b419b --- /dev/null +++ b/test/wasm_backend/unaligned.cpp @@ -0,0 +1,70 @@ +#include <stdint.h> +#include <emscripten.h> + +void print(int v) { + int *x = (int*)8; + *x = v; + EM_ASM({ + Module.print("print: " + HEAP32[8>>2]); + }); +} + +char buffer[8]; + +int main() { + { + volatile int16_t* x; + x = (int16_t*)&buffer[0]; + *x = 0x1234; + print(*x); + x = (int16_t*)&buffer[1]; + *x = 0x2345; + print(*x); + } + { + volatile int32_t* x; + x = (int32_t*)&buffer[0]; + *x = 0x12345678; + print(*x); + x = (int32_t*)&buffer[1]; + *x = 0x23456789; + print(*x); + x = (int32_t*)&buffer[2]; + *x = 0x3456789a; + print(*x); + x = (int32_t*)&buffer[3]; + *x = 0x456789ab; + print(*x); + } + { + volatile float* x; + x = (float*)&buffer[0]; + *x = -0x12345678; + print(*x); + x = (float*)&buffer[1]; + *x = -0x12345678; + print(*x); + x = (float*)&buffer[2]; + *x = -0x12345678; + print(*x); + x = (float*)&buffer[3]; + *x = -0x12345678; + print(*x); + } + { + volatile double* x; + x = (double*)&buffer[0]; + *x = -1; + print(*x); + x = (double*)&buffer[1]; + *x = -2; + print(*x); + x = (double*)&buffer[2]; + *x = -3; + print(*x); + x = (double*)&buffer[3]; + *x = -4; + print(*x); + } +} + diff --git a/test/wasm_backend/unaligned.txt b/test/wasm_backend/unaligned.txt new file mode 100644 index 000000000..15ca033cf --- /dev/null +++ b/test/wasm_backend/unaligned.txt @@ -0,0 +1,15 @@ +print: 4660 +print: 9029 +print: 305419896 +print: 591751049 +print: 878082202 +print: 1164413355 +print: -305419904 +print: -305419904 +print: -305419904 +print: -305419904 +print: -1 +print: -2 +print: -3 +print: -4 + |