#ifdef ARM_CRC32
uint32_t crc32_armv8(uint32_t crc, const uint8_t *buf, size_t len);
+void crc32_fold_copy_armv8(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len);
+void crc32_fold_armv8(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc);
#endif
#ifdef ARM_SIMD
# if (defined(ARM_CRC32) && defined(__ARM_FEATURE_CRC32))
# undef native_crc32
# define native_crc32 crc32_armv8
+# undef native_crc32_fold
+# define native_crc32_fold crc32_fold_armv8
+# undef native_crc32_fold_copy
+# define native_crc32_fold_copy crc32_fold_copy_armv8
# endif
#endif
* Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
* Copyright (C) 2016 Yang Zhang
* For conditions of distribution and use, see copyright notice in zlib.h
- *
-*/
+ */
#if defined(ARM_CRC32)
#include "acle_intrins.h"
#include "zbuild.h"
+#include "crc32.h"
Z_INTERNAL Z_TARGET_CRC uint32_t crc32_armv8(uint32_t crc, const uint8_t *buf, size_t len) {
Z_REGISTER uint32_t c;
buf += sizeof(uint64_t);
}
- if (len >= sizeof(uint32_t)) {
+ if (len & sizeof(uint32_t)) {
buf4 = *((uint32_t*)buf);
c = __crc32w(c, buf4);
- len -= sizeof(uint32_t);
buf += sizeof(uint32_t);
}
- if (len >= sizeof(uint16_t)) {
+ if (len & sizeof(uint16_t)) {
buf2 = *((uint16_t*)buf);
c = __crc32h(c, buf2);
- len -= sizeof(uint16_t);
buf += sizeof(uint16_t);
}
- if (len) {
+ if (len & sizeof(uint8_t)) {
c = __crc32b(c, *buf);
}
c = ~c;
return c;
}
+
+/* Note: Based on generic crc32_fold_* implementation with functable call replaced by direct call. */
+Z_INTERNAL Z_TARGET_CRC void crc32_fold_copy_armv8(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) {
+ crc->value = crc32_armv8(crc->value, src, len);
+ memcpy(dst, src, len);
+}
+
+Z_INTERNAL Z_TARGET_CRC void crc32_fold_armv8(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) {
+ Z_UNUSED(init_crc);
+ crc->value = crc32_armv8(crc->value, src, len);
+}
+
#endif
#if defined(LOONGARCH_CRC)
#include "zbuild.h"
-#include "zmemory.h"
-#include "zutil.h"
#include "crc32.h"
#include <stdint.h>
-
#include <larchintrin.h>
-Z_INTERNAL uint32_t crc32_loongarch64(uint32_t crc, const uint8_t *buf,
- size_t len) {
+Z_INTERNAL uint32_t crc32_loongarch64(uint32_t crc, const uint8_t *buf, size_t len) {
Z_REGISTER uint32_t c;
Z_REGISTER uint16_t buf2;
Z_REGISTER uint32_t buf4;
return c;
}
-
/* 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);