LoGin 4fda81ce81
使得DragonOS kernel 能为riscv64编译通过(尚未能启动) (#457)
* 使得DragonOS kernel 能为riscv64编译通过(尚未能启动)

* 修正了系统调用号声明不正确的问题,同时添加了编译配置文档
2023-11-25 12:07:39 +08:00

62 lines
1.4 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(const char *FirstPart, const char *SecondPart);
char *strncpy(char *restrict d, const char *restrict s, size_t n);
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);
/**
* @brief 拼接两个字符串将src接到dest末尾
*
* @param dest 目标串
* @param src 源串
* @return char*
*/
char *strcat(char *dest, const char *src);