smcc/lib/rt/rt_string.h
ZZY 8d97fe896c chore: 更新 .gitignore 文件
- 添加 docs 文件夹到忽略列表,以忽略 Doxygen 生成的文件
- 保持原有的忽略规则不变
2025-04-05 23:11:39 +08:00

68 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file rt_string.h
* @brief 运行时字符串与内存操作
*
* 提供基本的内存操作和字符串处理函数实现
*/
#ifndef __SMCC_RT_STRING_H__
#define __SMCC_RT_STRING_H__
#include "std/rt_api_def.h"
/** @defgroup memory_operations 内存操作 */
/**
* @brief 内存区域比较
* @param s1 第一个内存区域指针
* @param s2 第二个内存区域指针
* @param n 比较的字节数
* @return 差异值(<0: s1<s2, 0: 相等, >0: s1>s2
*/
int rt_memcmp(const void* s1, const void* s2, rt_size_t n);
/**
* @brief 安全内存拷贝(要求内存区域不重叠)
* @param dest 目标内存地址restrict修饰
* @param src 源内存地址restrict修饰
* @param n 拷贝的字节数
* @return 目标内存地址
*/
void* rt_memcpy(void* restrict dest, const void* restrict src, rt_size_t n);
/**
* @brief 内存区域填充
* @param s 目标内存地址
* @param c 填充字节值转换为unsigned char
* @param n 填充的字节数
* @return 原始内存地址
*/
void* rt_memset(void* dest, int val, rt_size_t n);
/** @defgroup string_operations 字符串操作 */
/**
* @brief 字符串比较
* @param s1 第一个字符串指针
* @param s2 第二个字符串指针
* @return 差异值(<0: s1<s2, 0: 相等, >0: s1>s2
*/
int rt_strcmp(const char* s1, const char* s2);
/**
* @brief 计算字符串长度
* @param s 字符串指针
* @return 字符串长度(不含终止符)
*/
rt_size_t rt_strlen(const char* s);
/**
* @brief 计算字符串哈希值
* @param s 输入字符串
* @return 32位无符号哈希值
* @note 使用FNV-1a哈希算法实现
*/
u32_t rt_strhash(const char* s);
#endif // __SMCC_RT_STRING_H__