X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcrc%2Fcrc.h;h=6338000e23d937e5628f7a8191ceaf8d2e38a17c;hp=24511993db81ef9c71f4670dcf6f9b3ab7fb6673;hb=cbd27e92c3e00e004b50ac998d131e52ac1290ea;hpb=456d13116b61c1a9fa2ace8816dbbe9b759ac9e2 diff --git a/ccan/crc/crc.h b/ccan/crc/crc.h index 24511993..6338000e 100644 --- a/ccan/crc/crc.h +++ b/ccan/crc/crc.h @@ -29,11 +29,13 @@ * as 0 the first time, and the current crc result from then on. * * Example: + * #include + * ... * // Check that iovec has the crc we expect (Castagnoli version) - * bool check_crc(uint32_t expected, const struct iovec *iov, int iovcnt) + * static bool check_crc(uint32_t expected, const struct iovec *iov, int l) * { * uint32_t crc = 0; - * while (iovcnt >= 0) { + * while (l >= 0) { * crc = crc32c(crc, iov->iov_base, iov->iov_len); * iov++; * } @@ -52,10 +54,10 @@ uint32_t crc32c(uint32_t start_crc, const void *buf, size_t size); * * Example: * // This dumb code only handles Castagnoli, so assert that here. - * void check_user_crc_table(const uint32_t *usertab) + * static void check_user_crc_table(const uint32_t *usertab) * { * const uint32_t *ctab = crc32c_table(); - * if (!ieee_tab || memcmp(ieee_tab, usertab, 1024) != 0) + * if (!ctab || memcmp(ctab, usertab, 1024) != 0) * abort(); * } */ @@ -80,4 +82,25 @@ uint32_t crc32_ieee(uint32_t start_crc, const void *buf, size_t size); * See crc32c_table() for details. */ const uint32_t *crc32_ieee_table(void); + +/** + * crc64_iso - ISO 3309 + * @start_crc: the initial crc (usually 0) + * @buf: pointer to bytes + * @size: length of buffer + * + * 64 bit CRC checksum using polynomial + * X^64 + X^4 + X^3 + X^1 + X^0 + * + * See crc32c() for details. + */ +uint64_t crc64_iso(uint64_t start_crc, const void *buf, size_t size); + +/** + * crc64_iso_table - Get the ISO 3309 CRC table + * + * See crc32c_table() for details. + */ +const uint64_t *crc64_iso_table(void); + #endif /* CCAN_CRC_H */