Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/libbb/crc32.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/libbb/crc32.c
r1765 r2725 13 13 * endian = 1: big-endian 14 14 * endian = 0: little-endian 15 * 16 * Licensed under GPLv2, see file LICENSE in this source tree. 15 17 */ 16 18 17 19 #include "libbb.h" 18 20 19 uint32_t *crc32_filltable(uint32_t *crc_table, int endian) 21 uint32_t *global_crc32_table; 22 23 uint32_t* FAST_FUNC crc32_filltable(uint32_t *crc_table, int endian) 20 24 { 21 25 uint32_t polynomial = endian ? 0x04c11db7 : 0xedb88320; … … 39 43 return crc_table - 256; 40 44 } 45 46 uint32_t FAST_FUNC crc32_block_endian1(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) 47 { 48 const void *end = (uint8_t*)buf + len; 49 50 while (buf != end) { 51 val = (val << 8) ^ crc_table[(val >> 24) ^ *(uint8_t*)buf]; 52 buf = (uint8_t*)buf + 1; 53 } 54 return val; 55 } 56 57 uint32_t FAST_FUNC crc32_block_endian0(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) 58 { 59 const void *end = (uint8_t*)buf + len; 60 61 while (buf != end) { 62 val = crc_table[(uint8_t)val ^ *(uint8_t*)buf] ^ (val >> 8); 63 buf = (uint8_t*)buf + 1; 64 } 65 return val; 66 }
Note:
See TracChangeset
for help on using the changeset viewer.