#if defined(LOONGARCH_CRC)
#include "zbuild.h"
#include "zmemory.h"
+#include "zutil.h"
+#include "crc32.h"
#include <stdint.h>
#include <larchintrin.h>
return crc ^ 0xffffffff;
}
+
+/* Note: Based on generic crc32_fold_* implementation with functable call replaced by direct call. */
+Z_INTERNAL void crc32_fold_copy_loongarch64(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) {
+ crc->value = crc32_loongarch64(crc->value, src, len);
+ memcpy(dst, src, len);
+}
+
+Z_INTERNAL void crc32_fold_loongarch64(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) {
+ Z_UNUSED(init_crc);
+ crc->value = crc32_loongarch64(crc->value, src, len);
+}
+
#endif
#ifdef LOONGARCH_CRC
uint32_t crc32_loongarch64(uint32_t crc, const uint8_t *buf, size_t len);
+void crc32_fold_copy_loongarch64(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len);
+void crc32_fold_loongarch64(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc);
#endif
#ifdef LOONGARCH_LSX
# if defined(LOONGARCH_CRC)
# undef native_crc32
# define native_crc32 crc32_loongarch64
+# undef native_crc32_fold
+# define native_crc32_fold crc32_fold_loongarch64
+# undef native_crc32_fold_copy
+# define native_crc32_fold_copy crc32_fold_copy_loongarch64
# endif
# if defined(LOONGARCH_LSX) && defined(__loongarch_sx)
# undef native_slide_hash
#ifdef LOONGARCH_CRC
if (cf.loongarch.has_crc) {
ft.crc32 = crc32_loongarch64;
+ ft.crc32_fold = &crc32_fold_loongarch64;
+ ft.crc32_fold_copy = &crc32_fold_copy_loongarch64;
}
#endif
#ifdef LOONGARCH_LSX