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) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 64545f7ec766..da9447a6950d 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -143,28 +143,6 @@ void panic(const char *, ...) __dead2 __printflike(1, 2); void cpu_boot(int); void cpu_rootconf(void); - -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); -} - void critical_enter(void); void critical_exit(void); void init_param1(void);