Commit da5a126
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 <[email protected]>1 parent 40f9705 commit da5a126
1 file changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2627 | 2627 | | |
2628 | 2628 | | |
2629 | 2629 | | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
2630 | 2636 | | |
2631 | 2637 | | |
2632 | | - | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
2633 | 2641 | | |
2634 | 2642 | | |
2635 | 2643 | | |
2636 | 2644 | | |
2637 | 2645 | | |
| 2646 | + | |
| 2647 | + | |
2638 | 2648 | | |
2639 | 2649 | | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
2640 | 2655 | | |
2641 | 2656 | | |
2642 | 2657 | | |
| |||
0 commit comments