#include "zbuild.h"
#include "crc32_braid_p.h"
#include "crc32_braid_tbl.h"
+#include "crc32_p.h"
/*
A CRC of a message is computed on BRAID_N braids of words in the message, where
len -= 8;
CRC_DO8;
}
- while (len) {
- len--;
- CRC_DO1;
- }
-
- return c;
+ return crc32_copy_small(c, NULL, buf, len, 0);
}
Z_INTERNAL uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, size_t len) {
#include "crc32.h"
#include "crc32_braid_p.h"
#include "crc32_braid_tbl.h"
+#include "crc32_p.h"
#include "x86_intrins.h"
#ifdef X86_VPCLMULQDQ
}
#endif
-static inline uint32_t crc32_copy_small(uint32_t crc, uint8_t *dst, const uint8_t *buf, size_t len, const int COPY) {
- uint32_t c = ~crc;
-
- while (len) {
- len--;
- if (COPY) {
- *dst++ = *buf;
- }
- CRC_DO1;
- }
-
- return ~c;
-}
-
Z_FORCEINLINE static uint32_t crc32_copy_impl(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len, const int COPY) {
size_t copy_len = len;
if (len >= 16) {
}
if (copy_len > 0) {
- crc = crc32_copy_small(crc, dst, src, copy_len, COPY);
+ crc = crc32_copy_small(~crc, dst, src, copy_len, COPY);
src += copy_len;
len -= copy_len;
if (COPY) {
# error "No endian defined"
#endif
-#define CRC_DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
-#define CRC_DO8 CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1
-
/* CRC polynomial. */
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
--- /dev/null
+/* crc32_p.h -- Private inline functions and macros shared with
+ * different computation of the CRC-32 checksum
+ * of a data stream.
+ * Copyright (C) 1995-2011, 2016 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef CRC32_P_H
+#define CRC32_P_H
+
+#define CRC_DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
+#define CRC_DO8 CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1
+
+Z_FORCEINLINE static uint32_t crc32_copy_small(uint32_t crc, uint8_t *dst, const uint8_t *buf, size_t len, const int COPY) {
+ uint32_t c = crc;
+
+ while (len) {
+ len--;
+ if (COPY) {
+ *dst++ = *buf;
+ }
+ CRC_DO1;
+ }
+
+ return ~c;
+}
+
+#endif /* CRC32_P_H */