aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/lib/memcpy.c
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@uclinux.org>2011-03-28 02:53:37 -0400
committerGreg Ungerer <gerg@uclinux.org>2011-05-23 20:03:49 -0400
commit66d83ab32aec5d84d707d4d72717b9468ec33a96 (patch)
tree09a7748e0980fd99b6925a92ad5af53c87638a53 /arch/m68k/lib/memcpy.c
parentd10ed2f5383cc6e6b7649f03540b8cb1838d5f67 (diff)
m68k: remove duplicate memcpy() implementation
Merging the mmu and non-mmu directories we ended up with duplicate implementations of memcpy(). One is a little more optimized for the >= 68020 case, but that can easily be inserted into a single implementation of memcpy(). Clean up the exporting of this symbol too, otherwise we end up exporting it twice on a no-mmu build. Signed-off-by: Greg Ungerer <gerg@uclinux.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k/lib/memcpy.c')
-rw-r--r--arch/m68k/lib/memcpy.c128
1 files changed, 73 insertions, 55 deletions
diff --git a/arch/m68k/lib/memcpy.c b/arch/m68k/lib/memcpy.c
index b50dbcad4746..62182c81e91c 100644
--- a/arch/m68k/lib/memcpy.c
+++ b/arch/m68k/lib/memcpy.c
@@ -1,62 +1,80 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file COPYING in the main directory of this archive
4 * for more details.
5 */
1 6
2#include <linux/types.h> 7#include <linux/module.h>
8#include <linux/string.h>
3 9
4void * memcpy(void * to, const void * from, size_t n) 10void *memcpy(void *to, const void *from, size_t n)
5{ 11{
6#ifdef CONFIG_COLDFIRE 12 void *xto = to;
7 void *xto = to; 13 size_t temp, temp1;
8 size_t temp;
9 14
10 if (!n) 15 if (!n)
11 return xto; 16 return xto;
12 if ((long) to & 1) 17 if ((long)to & 1) {
13 { 18 char *cto = to;
14 char *cto = to; 19 const char *cfrom = from;
15 const char *cfrom = from; 20 *cto++ = *cfrom++;
16 *cto++ = *cfrom++; 21 to = cto;
17 to = cto; 22 from = cfrom;
18 from = cfrom; 23 n--;
19 n--; 24 }
20 } 25 if (n > 2 && (long)to & 2) {
21 if (n > 2 && (long) to & 2) 26 short *sto = to;
22 { 27 const short *sfrom = from;
23 short *sto = to; 28 *sto++ = *sfrom++;
24 const short *sfrom = from; 29 to = sto;
25 *sto++ = *sfrom++; 30 from = sfrom;
26 to = sto; 31 n -= 2;
27 from = sfrom; 32 }
28 n -= 2; 33 temp = n >> 2;
29 } 34 if (temp) {
30 temp = n >> 2; 35 long *lto = to;
31 if (temp) 36 const long *lfrom = from;
32 { 37#if defined(__mc68020__) || defined(__mc68030__) || \
33 long *lto = to; 38 defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__)
34 const long *lfrom = from; 39 asm volatile (
35 for (; temp; temp--) 40 " movel %2,%3\n"
36 *lto++ = *lfrom++; 41 " andw #7,%3\n"
37 to = lto; 42 " lsrl #3,%2\n"
38 from = lfrom; 43 " negw %3\n"
39 } 44 " jmp %%pc@(1f,%3:w:2)\n"
40 if (n & 2) 45 "4: movel %0@+,%1@+\n"
41 { 46 " movel %0@+,%1@+\n"
42 short *sto = to; 47 " movel %0@+,%1@+\n"
43 const short *sfrom = from; 48 " movel %0@+,%1@+\n"
44 *sto++ = *sfrom++; 49 " movel %0@+,%1@+\n"
45 to = sto; 50 " movel %0@+,%1@+\n"
46 from = sfrom; 51 " movel %0@+,%1@+\n"
47 } 52 " movel %0@+,%1@+\n"
48 if (n & 1) 53 "1: dbra %2,4b\n"
49 { 54 " clrw %2\n"
50 char *cto = to; 55 " subql #1,%2\n"
51 const char *cfrom = from; 56 " jpl 4b"
52 *cto = *cfrom; 57 : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
53 } 58 : "0" (lfrom), "1" (lto), "2" (temp));
54 return xto;
55#else 59#else
56 const char *c_from = from; 60 for (; temp; temp--)
57 char *c_to = to; 61 *lto++ = *lfrom++;
58 while (n-- > 0)
59 *c_to++ = *c_from++;
60 return((void *) to);
61#endif 62#endif
63 to = lto;
64 from = lfrom;
65 }
66 if (n & 2) {
67 short *sto = to;
68 const short *sfrom = from;
69 *sto++ = *sfrom++;
70 to = sto;
71 from = sfrom;
72 }
73 if (n & 1) {
74 char *cto = to;
75 const char *cfrom = from;
76 *cto = *cfrom;
77 }
78 return xto;
62} 79}
80EXPORT_SYMBOL(memcpy);