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
This commit is contained in:
blob1807
2025-08-21 05:19:16 +10:00
parent 06179fc736
commit f90d7029b4

View File

@@ -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
}