20 #ifndef KERNEL_UTILITIES_LIB_H 21 #define KERNEL_UTILITIES_LIB_H 25 #include "pedigree/kernel/compiler.h" 26 #include "pedigree/kernel/processor/types.h" 31 #if defined(X86_COMMON) || defined(HOSTED_X86_COMMON) || defined(UTILITY_LINUX) 36 #define NOTHROW noexcept 46 #define StringLength(x) \ 47 (IS_CONSTANT(x) ? __builtin_strlen((x)) : _StringLength(x)) 52 EXPORTED_PUBLIC char *StringCopyN(
char *dest,
const char *src,
size_t len);
55 StringCompareN(
const char *p1,
const char *p2,
size_t n)
PURE;
57 const char *p1,
const char *p2,
size_t n,
size_t *offset)
PURE;
59 EXPORTED_PUBLIC char *StringConcatN(
char *dest,
const char *src,
size_t n);
64 const char *str,
size_t len,
const char *search,
size_t slen)
PURE;
65 EXPORTED_PUBLIC int VStringFormat(
char *buf,
const char *fmt, va_list arg);
69 StringToUnsignedLong(const
char *nptr,
char const **endptr,
int base);
77 StringMatchN(const
char *p1, const
char *p2,
size_t n) PURE;
79 const
char *p1, const
char *p2,
size_t n,
size_t *offset) PURE;
83 #if !defined(__cplusplus) || defined(IMPLEMENTING_LOG_FORMAT_FUNCTIONS) 96 const char *s1,
const char *s2,
int sensitive,
size_t length,
102 EXPORTED_PUBLIC void *DoubleWordSet(
void *buf,
unsigned int c,
size_t len);
103 EXPORTED_PUBLIC void *QuadWordSet(
void *buf,
unsigned long long c,
size_t len);
104 EXPORTED_PUBLIC void *ForwardMemoryCopy(
void *s1,
const void *s2,
size_t n);
107 MemoryCompare(
const void *p1,
const void *p2,
size_t len)
PURE;
111 SDirectoryName(
const char *path,
char *buf,
size_t buflen)
PURE;
113 SBaseName(
const char *path,
char *buf,
size_t buflen)
PURE;
125 void random_seed(uint64_t seed);
134 #ifndef UTILITY_LINUX 145 uint8_t checksum(
const uint8_t *pMemory,
size_t sMemory);
148 uint16_t checksum16(
const uint8_t *pMemory,
size_t sMemory);
151 uint32_t checksum32(
const uint8_t *pMemory,
size_t sMemory);
154 uint32_t checksum32_naive(
const uint8_t *pMemory,
size_t sMemory);
157 uint32_t checksumPage(uintptr_t address);
160 uint32_t elfHash(
const char *buffer,
size_t length);
163 uint32_t jenkinsHash(
const char *buffer,
size_t length);
166 uint32_t spookyHash(
const char *buffer,
size_t length);
167 uint64_t spookyHash64(
const char *buffer,
size_t length);
168 void spookyHash128(
const char *buffer,
size_t length, uint64_t *h1, uint64_t *h2);
177 #include "pedigree/kernel/utilities/cpp.h" 180 #endif // KERNEL_UTILITIES_LIB_H
#define FORMAT(type, idx, first)