xref: /DragonOS/kernel/src/common/string.h (revision 01c18c64b14b4ebabd98fa92c587c26874275eb1)
1 #pragma once
2 #include "glib.h"
3 
4 // 计算字符串的长度(经过测试,该版本比采用repne/scasb汇编的运行速度快16.8%左右)
5 static inline int strlen(const char *s) {
6   if (s == NULL)
7     return 0;
8   register int __res = 0;
9   while (s[__res] != '\0') {
10     ++__res;
11   }
12   return __res;
13 }
14