diff options
Diffstat (limited to 'Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C')
| -rw-r--r-- | Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C new file mode 100644 index 0000000..8039f11 --- /dev/null +++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C @@ -0,0 +1,23 @@ +#include "memmove.h"
+
+void *__rt_memmove(void *a, const void *b, size_t n)
+/* copy memory taking care of overlap */
+/* Relies on sizeof(int)=sizeof(void *) and byte addressing.
+ Also that memory does not wrap round for direction test. */
+{
+ /* do it fast if word aligned ... */
+ if ((((int)a | (int)b | (int)n) & 3) == 0)
+ { int *wa,*wb;
+ n >>= 2;
+ if (a < (void *)b)
+ for (wa = (int *)a, wb = (int *)b; n-- > 0;) *wa++ = *wb++;
+ else for (wa = n+(int *)a, wb = n+(int *)b; n-- > 0;) *--wa = *--wb;
+ }
+ else
+ { char *ca,*cb;
+ if (a < (void *)b)
+ for (ca = (char *)a, cb = (char *)b; n-- > 0;) *ca++ = *cb++;
+ else for (ca = n+(char *)a, cb = n+(char *)b; n-- > 0;) *--ca = *--cb;
+ }
+ return a;
+}
|
