You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
diff --git a/src/zix/digest.c b/src/zix/digest.c
|
|
index 889cfde..00b9fcf 100644
|
|
--- a/src/zix/digest.c
|
|
+++ b/src/zix/digest.c
|
|
@@ -38,10 +38,12 @@ zix_digest_add(uint32_t hash, const void* const buf, const size_t len)
|
|
{
|
|
const uint8_t* str = (const uint8_t*)buf;
|
|
|
|
+#ifdef __x86_64__
|
|
for (size_t i = 0; i < (len / sizeof(uint64_t)); ++i) {
|
|
hash = (uint32_t)_mm_crc32_u64(hash, *(const uint64_t*)str);
|
|
str += sizeof(uint64_t);
|
|
}
|
|
+#endif
|
|
if (len & sizeof(uint32_t)) {
|
|
hash = _mm_crc32_u32(hash, *(const uint32_t*)str);
|
|
str += sizeof(uint32_t);
|
|
@@ -57,6 +59,7 @@ zix_digest_add(uint32_t hash, const void* const buf, const size_t len)
|
|
return hash;
|
|
}
|
|
|
|
+#ifdef __x86_64__
|
|
ZIX_API uint32_t
|
|
zix_digest_add_64(uint32_t hash, const void* const buf, const size_t len)
|
|
{
|
|
@@ -72,12 +75,17 @@ zix_digest_add_64(uint32_t hash, const void* const buf, const size_t len)
|
|
|
|
return hash;
|
|
}
|
|
+#endif
|
|
|
|
ZIX_API uint32_t
|
|
zix_digest_add_ptr(const uint32_t hash, const void* const ptr)
|
|
{
|
|
#if UINTPTR_MAX == UINT64_MAX
|
|
- return (uint32_t)_mm_crc32_u64(hash, (uintptr_t)ptr);
|
|
+ #ifdef __x86_64__
|
|
+ return (uint32_t)_mm_crc32_u64(hash, (uintptr_t)ptr);
|
|
+ #else
|
|
+ return (uint32_t)_mm_crc32_u32(hash, (uintptr_t)ptr);
|
|
+ #endif
|
|
#else
|
|
return _mm_crc32_u32(hash, (uintptr_t)ptr);
|
|
#endif
|