Ver Fonte

jit.rs: When emitting bytes, mark writing as unaligned

To avoid cargo printing debug assertions about misaligned pointer
dereferences when JIT-compiling programs for the tests, fix the way we
write the bytes to explicitly tell rustc we may have misaligned
accesses. No functional change.

Related: #77

Suggested-by: Ben Kimock <kimockb@gmail.com>
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Quentin Monnet há 2 anos atrás
pai
commit
0da60cf99a
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      src/jit.rs

+ 1 - 1
src/jit.rs

@@ -79,7 +79,7 @@ macro_rules! emit_bytes {
         assert!($jit.offset + size <= $jit.contents.len());
         unsafe {
             let mut ptr = $jit.contents.as_ptr().add($jit.offset) as *mut $t;
-            *ptr = $data;
+            ptr.write_unaligned($data);
         }
         $jit.offset += size;
     }}