Explorar el Código

Fix stride in `memory_equal/compare_zero` giving false positves

The previous stride of 8 assumed `uintptr` size is 8 which isn't the case on 32bit & wasm64p32. Skipping every other set of 4 bytes
blob1807 hace 3 semanas
padre
commit
f90d7029b4
Se han modificado 1 ficheros con 4 adiciones y 4 borrados
  1. 4 4
      base/runtime/internal.odin

+ 4 - 4
base/runtime/internal.odin

@@ -268,8 +268,8 @@ memory_equal :: proc "contextless" (x, y: rawptr, n: int) -> bool {
 			}
 		}
 
-		m = (n-i) / 8 * 8
-		for /**/; i < m; i += 8 {
+		m = (n-i) / size_of(uintptr) * size_of(uintptr)
+		for /**/; i < m; i += size_of(uintptr) {
 			if intrinsics.unaligned_load(cast(^uintptr)&a[i]) != intrinsics.unaligned_load(cast(^uintptr)&b[i]) {
 				return false
 			}
@@ -389,8 +389,8 @@ memory_compare_zero :: proc "contextless" (a: rawptr, n: int) -> int #no_bounds_
 			}
 		}
 
-		m = (n-i) / 8 * 8
-		for /**/; i < m; i += 8 {
+		m = (n-i) / size_of(uintptr) * size_of(uintptr)
+		for /**/; i < m; i += size_of(uintptr) {
 			if intrinsics.unaligned_load(cast(^uintptr)&bytes[i]) != 0 {
 				return 1
 			}