Files
scc/runtime/libcore/include/core_mem.h
zzy d88fa3b8d3 feat: rename core types to scc prefix for consistency
Updated type names from `core_*` to `scc_*` across lex_parser and stream modules to maintain naming consistency within the SCC codebase. This includes changes to function signatures and internal usage of types like `core_probe_stream_t`, `core_pos_t`, and `cstring_t` to their `scc_*` counterparts.
2025-12-11 13:00:29 +08:00

57 lines
1.0 KiB
C

#ifndef __SCC_CORE_MEM_H__
#define __SCC_CORE_MEM_H__
#include "core_type.h"
void *scc_memcpy(void *dest, const void *src, usize n);
void *scc_memmove(void *dest, const void *src, usize n);
void *scc_memset(void *s, int c, usize n);
int scc_memcmp(const void *s1, const void *s2, usize n);
/**
* @brief 使用FNV-1a进行 C 字符串哈希
*
* @param s
* @return u32
*/
static inline u32 scc_strhash32(const char *s) {
u32 hash = 2166136261u; // FNV-1a偏移基础值
while (*s) {
hash ^= *s++;
hash *= 16777619u;
}
return hash;
}
/**
* @brief 获取 C 字符串长度
*
* @param str
* @return usize
*/
static inline usize scc_strlen(const char *str) {
usize len = 0;
while (*str) {
len++;
str++;
}
return len;
}
/**
* @brief 比较两个 C 字符串
*
* @param s1
* @param s2
* @return int
*/
static inline int scc_strcmp(const char *s1, const char *s2) {
while (*s1 && *s2 && *s1 == *s2) {
s1++;
s2++;
}
return *s1 - *s2;
}
#endif /* __SCC_CORE_MEM_H__ */