- 在 `core_mem.h` 中新增 `smcc_strlen` 函数,用于计算字符串长度 - 调整 `VEC` 宏定义参数,移除冗余的 name 参数,增强结构体声明一致性 - 修改 `cstring_from_cstr` 返回值字段顺序,保持代码风格统一 - 在 `libcore.h` 中增加日志相关宏定义的保护判断,防止重复定义冲突
38 lines
833 B
C
38 lines
833 B
C
#ifndef __SMCC_CORE_MEM_H__
|
|
#define __SMCC_CORE_MEM_H__
|
|
|
|
#include "core_type.h"
|
|
|
|
void *smcc_memcpy(void *dest, const void *src, usize n);
|
|
void *smcc_memmove(void *dest, const void *src, usize n);
|
|
void *smcc_memset(void *s, int c, usize n);
|
|
int smcc_memcmp(const void *s1, const void *s2, usize n);
|
|
|
|
static inline u32 smcc_strhash32(const char *s) {
|
|
u32 hash = 2166136261u; // FNV-1a偏移基础值
|
|
while (*s) {
|
|
hash ^= *s++;
|
|
hash *= 16777619u;
|
|
}
|
|
return hash;
|
|
}
|
|
|
|
static inline usize smcc_strlen(const char *str) {
|
|
usize len = 0;
|
|
while (*str) {
|
|
len++;
|
|
str++;
|
|
}
|
|
return len;
|
|
}
|
|
|
|
static inline int smcc_strcmp(const char *s1, const char *s2) {
|
|
while (*s1 && *s2 && *s1 == *s2) {
|
|
s1++;
|
|
s2++;
|
|
}
|
|
return *s1 - *s2;
|
|
}
|
|
|
|
#endif /* __SMCC_CORE_MEM_H__ */
|