diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 2005-04-28 03:19:50 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2005-04-28 03:19:50 +0000 |
commit | db302d160b8671152b9145d1723f6a3576ecdc27 (patch) | |
tree | 92390dd63c24b9fc3cc68716f30d12f7974b18cb /sys/sys/libkern.h | |
parent | ff7120cae18659d94e6b9097bebac4c3c5767968 (diff) | |
download | src-db302d160b8671152b9145d1723f6a3576ecdc27.tar.gz src-db302d160b8671152b9145d1723f6a3576ecdc27.zip |
Inline functions belong in <sys/libkern.h>, not in <sys/systm.h>.
Move crc32() and crc32_raw() from the latter to the former. Move
the declaration of crc32_tab[] to <sys/libkern.h> as well.
Pointed out by: bde@
Tested on: ia64, sparc64
Notes
Notes:
svn path=/head/; revision=145609
Diffstat (limited to 'sys/sys/libkern.h')
-rw-r--r-- | sys/sys/libkern.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 348a59dc14f7..71afd41f08a0 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -108,6 +108,26 @@ char *strsep(char **, const char *delim); size_t strspn(const char *, const char *); int strvalid(const char *, size_t); +extern uint32_t crc32_tab[]; + +static __inline uint32_t +crc32_raw(const void *buf, size_t size, uint32_t crc) +{ + const uint8_t *p = buf; + + while (size--) + crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + return (crc); +} + +static __inline uint32_t +crc32(const void *buf, size_t size) +{ + uint32_t crc; + + crc = crc32_raw(buf, size, ~0U); + return (crc ^ ~0U); +} static __inline int memcmp(const void *b1, const void *b2, size_t len) |