void* VOS_MemCpy(void *pDst, const void *pSrc, unsigned long ulSize)
{
char *pcDst = (char *)pDst;
char *pcSrc = (char *)pSrc;
unsigned long ulCopySize;
/* 非字对齐的copy */
if ((unsigned long)pcSrc & 0x3)
{
ulCopySize = sizeof(int) - ((unsigned long)pcSrc & 0x3);
ulCopySize = ulSize < ulCopySize ? ulSize : ulCopySize;
while (ulCopySize--)
{
*pcDst = *pcSrc;
pcDst++;
pcSrc++;
ulSize--;
}
}
if (0 == ulSize)
{
return pDst;
}
/* 字copy */
if (ulSize & 0xFFFFFFFC)
{
ulCopySize = ulSize & 0xFFFFFFFC;
ulCopySize = ulSize < ulCopySize ? ulSize : ulCopySize;
while (ulCopySize)
{
*(int *)pcDst = *(int *)pcSrc;
pcDst = pcDst + sizeof(int);
pcSrc = pcSrc + sizeof(int);
ulSize = ulSize - 4;
ulCopySize = ulCopySize - 4;
}
}
if (0 == ulSize)
{
return pDst;
}
/* 剩余非字对齐bytes拷贝 */
ulCopySize = ulSize & 0x3;
while (ulCopySize--)
{
*pcDst = *pcSrc;
pcDst++;
pcSrc++;
}
return pDst;
}