LibC: Implement stpcpy since gcc seems to need it

gcc seems to optimize some calls to strcpy to stpcpy
This commit is contained in:
Bananymous 2023-09-30 20:58:19 +03:00
parent d883d212b1
commit 38320018dc
1 changed files with 9 additions and 3 deletions

View File

@ -62,12 +62,18 @@ int strcmp(const char* s1, const char* s2)
return *u1 - *u2;
}
char* strcpy(char* __restrict__ dest, const char* __restrict__ src)
char* stpcpy(char* __restrict__ dest, const char* __restrict__ src)
{
size_t i;
for (i = 0; src[i]; i++)
size_t i = 0;
for (; src[i]; i++)
dest[i] = src[i];
dest[i] = '\0';
return &dest[i];
}
char* strcpy(char* __restrict__ dest, const char* __restrict__ src)
{
stpcpy(dest, src);
return dest;
}