2 * Copyright (C) 2004 Joakim Tjernlund
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 /* These are carefully optimized mem*() functions for PPC written in C.
9 * Don't muck around with these function without checking the generated
11 * It is possible to optimize these significantly more by using specific
12 * data cache instructions(mainly dcbz). However that requires knownledge
13 * about the CPU's cache line size.
16 * The cache instructions on MPC8xx CPU's are buggy(they don't update
17 * the DAR register when causing a DTLB Miss/Error) and cannot be
18 * used on 8xx CPU's without a kernel patch to work around this
24 /* Experimentally off - libc_hidden_proto(memcpy) */
26 /* Experimentally off - libc_hidden_proto(memmove) */
27 void *memmove(void *to, const void *from, size_t n)
29 unsigned long rem, chunks, tmp1, tmp2;
30 unsigned char *tmp_to;
31 unsigned char *tmp_from = (unsigned char *)from;
33 if (tmp_from >= (unsigned char *)to)
34 return memcpy(to, from, n);
40 rem = (unsigned long )tmp_to % 4;
45 /* make gcc to load all data, then store it */
46 tmp1 = *(unsigned long *)(tmp_from-4);
48 tmp2 = *(unsigned long *)tmp_from;
49 *(unsigned long *)(tmp_to-4) = tmp1;
51 *(unsigned long *)tmp_to = tmp2;
56 *(unsigned long *)(tmp_to-4) = *(unsigned long *)(tmp_from-4);
63 *--tmp_to = *--tmp_from;
71 *--tmp_to = *--tmp_from;
78 libc_hidden_def(memmove)