BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
00d70be
Branches
Tags
master
mips_sys
fw
memcpy.c
implemented IP + ICMP, fixed ARP (padding overwriting stack)
Stefan Schuermans
commited
00d70be
at 2012-03-24 13:58:46
memcpy.c
Blame
History
Raw
#include "memcpy.h" /** * @brief copy memory * @param[in] dest pointer to destination buffer * @param[in] src pointer to source data * @param[in] sz size of data to copy */ void memcpy(void *dest, const void *src, unsigned int sz) { unsigned int *dest4; const unsigned int *src4; unsigned int sz4; unsigned char *dest1; const unsigned char *src1; // word aligned memory addresses -> fast copy if (((unsigned int)dest & 3) == 0 && ((unsigned int)src & 3) == 0) { dest4 = dest; src4 = src; for (sz4 = sz >> 2; sz4 > 0; --sz4) *dest4++ = *src4++; dest = dest4; src = src4; sz -= sz4; // there might still be a few bytes to copy now } // safe and slow fallback: copy byte-wise dest1 = dest; src1 = src; for ( ; sz > 0; --sz) *dest1++ = *src1++; }