Commit 5ebc4cf
committed
Fix floats on Wasm
On wasm32, terms are aligned by 4 bytes. `memory_heap_allocation` returns a pointer for `n` terms.
We used float_term_t to create an union between a term and float. However, floats are aligned to 8 bytes which made
casting between union and term pointers unsafe.
We replaced union usage to `memcpy` which allows unaligned memory access. The true solution would be to return
correctly aligned memory from memory_heap_alloc but fix for that would need a lot more testing.
Signed-off-by: Jakub Gonet <jakub.gonet@swmansion.com>1 parent 33736a0 commit 5ebc4cf
1 file changed
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2331 | 2331 | | |
2332 | 2332 | | |
2333 | 2333 | | |
2334 | | - | |
2335 | | - | |
2336 | | - | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
2337 | 2337 | | |
2338 | 2338 | | |
2339 | 2339 | | |
2340 | 2340 | | |
2341 | 2341 | | |
2342 | | - | |
2343 | | - | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
2344 | 2346 | | |
2345 | 2347 | | |
2346 | 2348 | | |
| |||
0 commit comments