[libc] Fix embedded version of bcmp / memcmp
authorGuillaume Chatelet <gchatelet@google.com>
Fri, 14 Oct 2022 13:09:28 +0000 (13:09 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Fri, 14 Oct 2022 13:09:53 +0000 (13:09 +0000)
libc/src/string/memory_utils/bcmp_implementations.h
libc/src/string/memory_utils/memcmp_implementations.h

index 2b74464..9d9ad2b 100644 (file)
@@ -24,7 +24,7 @@ namespace __llvm_libc {
 inline_bcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
 #pragma nounroll
   for (size_t offset = 0; offset < count; ++offset)
-    if (auto value = generic::Bcmp<1>::block(p1, p2))
+    if (auto value = generic::Bcmp<1>::block(p1 + offset, p2 + offset))
       return value;
   return BcmpReturnType::ZERO();
 }
index faddebc..af85afa 100644 (file)
@@ -24,7 +24,7 @@ namespace __llvm_libc {
 inline_memcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
 #pragma nounroll
   for (size_t offset = 0; offset < count; ++offset)
-    if (auto value = generic::Memcmp<1>::block(p1, p2))
+    if (auto value = generic::Memcmp<1>::block(p1 + offset, p2 + offset))
       return value;
   return MemcmpReturnType::ZERO();
 }