initial commit

This commit is contained in:
2025-03-11 05:17:34 +08:00
commit e906741ee9
27 changed files with 924 additions and 0 deletions

35
lib/string.c Normal file
View File

@@ -0,0 +1,35 @@
#include <stddef.h>
#include <string.h>
int strcmp(const char *a, const char *b)
{
while (*a != '\0' && *b != '\0') {
if (*a != *b)
return (*a > *b) - (*a < *b);
a++, b++;
}
if (*a == '\0' && *b == '\0')
return 0;
if (*a == '\0')
return -1;
return 1;
}
void *memcpy(void *dest, const void *src, size_t count)
{
void *ret = dest;
for (const byte_t *p = src; count > 0; --count, ++p, ++dest)
*(byte_t *)dest = *p;
return ret;
}
void *memzero(void *start, void *end)
{
void *ret = start;
for (byte_t *p = start; p < (byte_t *)end; ++p)
*p = 0;
return ret;
}