luxos/Kernel/library/stdlib/mem_ops.c

43 lines
664 B
C
Raw Normal View History

/*
* mem_ops.c
*
* Created on: Aug 27, 2011
* Author: Tiberiu
*/
#include <types.h>
void *memcpy(void *dest, const void *src, uint32 count)
{
uint8* d = (uint8*) dest;
const uint8* s = (const uint8*) src;
while (count-- != 0)
*d++ = *s++;
return dest;
}
int32 memcmp(const void *s1, const void *s2, uint32 count)
{
const uint8 *us1 = (const uint8*) s1;
const uint8 *us2 = (const uint8*) s2;
while (count-- != 0)
{
if (*us1 != *us2) return (*us1 < *us2) ? -1 : 1;
us1++; us2++;
}
return 0;
}
void *memset(void *dest, uint8 val, uint32 count)
{
uint8 *temp = (uint8 *)dest;
while (count-- != 0)
*temp++ = val;
return dest;
}