2022-08-03 15:13:01 +08:00

54 lines
1.2 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.

#pragma once
#include "glib.h"
/**
* @brief 拷贝整个字符串
*
* @param dst 目标地址
* @param src 源地址
* @return char* 目标字符串
*/
char *strcpy(char *dst, const char *src);
//计算字符串的长度经过测试该版本比采用repne/scasb汇编的运行速度快16.8%左右)
static inline int strlen(const char *s)
{
if (s == NULL)
return 0;
register int __res = 0;
while (s[__res] != '\0')
{
++__res;
}
return __res;
}
/**
* @brief 测量字符串的长度
*
* @param src 字符串
* @param maxlen 最大长度
* @return long
*/
long strnlen(const char *src, unsigned long maxlen);
/*
比较字符串 FirstPart and SecondPart
FirstPart = SecondPart => 0
FirstPart > SecondPart => 1
FirstPart < SecondPart => -1
*/
int strcmp(char *FirstPart, char *SecondPart);
char *strncpy(char *dst, const char *src, long count);
long strncpy_from_user(char *dst, const char *src, unsigned long size);
/**
* @brief 测量来自用户空间的字符串的长度,会检验地址空间是否属于用户空间
* @param src
* @param maxlen
* @return long
*/
long strnlen_user(const char *src, unsigned long maxlen);