Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/libkern.h
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
char *strncpy(char * __restrict, const char * __restrict, size_t); | char *strncpy(char * __restrict, const char * __restrict, size_t); | ||||
size_t strnlen(const char *, size_t); | size_t strnlen(const char *, size_t); | ||||
char *strrchr(const char *, int); | char *strrchr(const char *, int); | ||||
char *strsep(char **, const char *delim); | char *strsep(char **, const char *delim); | ||||
size_t strspn(const char *, const char *); | size_t strspn(const char *, const char *); | ||||
char *strstr(const char *, const char *); | char *strstr(const char *, const char *); | ||||
int strvalid(const char *, size_t); | int strvalid(const char *, size_t); | ||||
extern const uint32_t crc32_tab[]; | |||||
static __inline uint32_t | |||||
crc32_raw(const void *buf, size_t size, uint32_t crc) | |||||
{ | |||||
const uint8_t *p = (const uint8_t *)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); | |||||
} | |||||
uint32_t | |||||
calculate_crc32c(uint32_t crc32c, const unsigned char *buffer, | |||||
unsigned int length); | |||||
#ifdef _KERNEL | |||||
#if defined(__amd64__) || defined(__i386__) | |||||
uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned); | |||||
#endif | |||||
#if defined(__aarch64__) | |||||
uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int); | |||||
#endif | |||||
#endif | |||||
static __inline char * | static __inline char * | ||||
index(const char *p, int ch) | index(const char *p, int ch) | ||||
{ | { | ||||
return (strchr(p, ch)); | return (strchr(p, ch)); | ||||
} | } | ||||
static __inline char * | static __inline char * | ||||
Show All 19 Lines |