2007-04-02 15:03:33 +02:00
|
|
|
|
#include "types.h"
|
|
|
|
|
|
2007-04-02 15:17:40 +02:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* Copie un octet une ou plusieurs fois en m<>moire */
|
|
|
|
|
void memset(void *dst, u8 val, u32 count,u32 size)
|
2007-04-02 15:03:33 +02:00
|
|
|
|
{
|
2007-04-02 15:17:40 +02:00
|
|
|
|
u8 *temp;
|
|
|
|
|
for(temp = (u8 *)dst; count != 0; count--)
|
|
|
|
|
{
|
|
|
|
|
temp+=size;
|
|
|
|
|
*temp = val;
|
|
|
|
|
}
|
2007-04-02 15:03:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-02 15:17:40 +02:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* Copie une portion de m<>moire vers une autre */
|
|
|
|
|
void memcpy(void *src, void *dst, u32 count, u32 size)
|
2007-04-02 15:03:33 +02:00
|
|
|
|
{
|
2007-04-02 15:17:40 +02:00
|
|
|
|
char *s, *d;
|
2007-04-02 15:03:33 +02:00
|
|
|
|
u32 i;
|
2007-04-02 15:17:40 +02:00
|
|
|
|
s = (u8*) src;
|
|
|
|
|
d = (u8*) dst;
|
|
|
|
|
for(i=0;i<count;i++){
|
|
|
|
|
*(d+i*size) = *(s+i);
|
2007-04-02 15:03:33 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-02 15:17:40 +02:00
|
|
|
|
/*******************************************************************************/
|
2007-04-02 15:03:33 +02:00
|
|
|
|
|
2007-04-02 15:17:40 +02:00
|
|
|
|
/* Compare 2 portions de m<>moire */
|
|
|
|
|
u32 memcmp(void *src, void *dst, u32 count, u32 size)
|
2007-04-02 15:03:33 +02:00
|
|
|
|
{
|
2007-04-02 15:17:40 +02:00
|
|
|
|
const u8 *mem1 = (const u8 *)src;
|
|
|
|
|
const u8 *mem2 = (const u8 *)dst;
|
|
|
|
|
for(; count != 0; count--)
|
|
|
|
|
{
|
|
|
|
|
if(*mem1 != *mem2)
|
|
|
|
|
return *mem1 - *mem2;
|
|
|
|
|
mem1+=size;
|
|
|
|
|
mem2+=size;
|
|
|
|
|
}
|
2007-04-02 15:03:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-02 15:17:40 +02:00
|
|
|
|
/*******************************************************************************/
|