//---------------------------------------------------------------------------
int strlen (const char *s)
{
const char *sc;
for (sc = s; *sc != '\0'; ++sc)
{
}
return sc - s;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int strcmp (const char *cs, const char *ct)
{
signed char __res;
while (1)
{
if ((__res = *cs - *ct++) != 0 || !*cs++)
break;
}
return __res;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int strncmp (const char *cs, const char *ct, int count)
{
signed char __res = 0;
while (count)
{
//dbg_print("*cs = %c, *ct = %c, count = %d\n", *cs, *ct, count);
if ((__res = *cs - *ct++) != 0 || !*cs++)
break;
count--;
}
return __res;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void * memset (void *s, int c, int count)
{
char *xs = s;
while (count--)
*xs++ = c;
return s;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void * memcpy (void *dest, const void *src, int count)
{
char *tmp = dest;
const char *s = src;
while (count--)
*tmp++ = *s++;
return dest;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int memcmp (const void *cs, const void *ct, int count)
{
const unsigned char *su1, *su2;
int res = 0;
for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
if ((res = *su1 - *su2) != 0)
break;
return res;
}
//---------------------------------------------------------------------------