========================================================================= */
| 200 | |
| 201 | /* ========================================================================= */ |
| 202 | unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len) |
| 203 | { |
| 204 | if (buf == Z_NULL) return 0UL; |
| 205 | |
| 206 | #ifdef DYNAMIC_CRC_TABLE |
| 207 | if (crc_table_empty) |
| 208 | make_crc_table(); |
| 209 | #endif /* DYNAMIC_CRC_TABLE */ |
| 210 | |
| 211 | #ifdef BYFOUR |
| 212 | if (sizeof(void *) == sizeof(ptrdiff_t)) { |
| 213 | z_crc_t endian; |
| 214 | |
| 215 | endian = 1; |
| 216 | if (*((unsigned char *)(&endian))) |
| 217 | return crc32_little(crc, buf, len); |
| 218 | else |
| 219 | return crc32_big(crc, buf, len); |
| 220 | } |
| 221 | #endif /* BYFOUR */ |
| 222 | crc = crc ^ 0xffffffffUL; |
| 223 | while (len >= 8) { |
| 224 | DO8; |
| 225 | len -= 8; |
| 226 | } |
| 227 | if (len) do { |
| 228 | DO1; |
| 229 | } while (--len); |
| 230 | return crc ^ 0xffffffffUL; |
| 231 | } |
| 232 | |
| 233 | #ifdef BYFOUR |
| 234 |
no test coverage detected