Root/package/mtd/src/crc32.h

1#ifndef CRC32_H
2#define CRC32_H
3
4#include <stdint.h>
5
6extern const uint32_t crc32_table[256];
7
8/* Return a 32-bit CRC of the contents of the buffer. */
9
10static inline uint32_t
11crc32(uint32_t val, const void *ss, int len)
12{
13    const unsigned char *s = ss;
14    while (--len >= 0)
15        val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
16    return val;
17}
18
19static inline unsigned int crc32buf(char *buf, size_t len)
20{
21    return crc32(0xFFFFFFFF, buf, len);
22}
23
24
25
26#endif
27

Archive Download this file



interactive