diff options
author | Greg Ungerer <gerg@uclinux.org> | 2011-02-03 06:58:39 -0500 |
---|---|---|
committer | Greg Ungerer <gerg@uclinux.org> | 2011-02-15 18:43:16 -0500 |
commit | 982cd252ca0b63c11fe398c09c6f2b41217c78c0 (patch) | |
tree | fac6b90f443fdb1654c58ae86b1921f3e2a33aa3 /arch | |
parent | f9d693d237a173915fcfbd86b28753f93b7d142f (diff) |
m68knommu: add optimize memmove() function
Add an m68k/coldfire optimized memmove() function for the m68knommu arch.
This is the same function as used by m68k. Simple speed tests show this
is faster once buffers are larger than 4 bytes, and significantly faster
on much larger buffers (4 times faster above about 100 bytes).
This also goes part of the way to fixing a regression caused by commit
ea61bc461d09e8d331a307916530aaae808c72a2 ("m68k/m68knommu: merge MMU and
non-MMU string.h"), which breaks non-coldfire non-mmu builds (which is
the 68x328 and 68360 families). They currently have no memmove() fucntion
defined, since there was none in the m68knommu/lib functions.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/m68k/include/asm/string.h | 2 | ||||
-rw-r--r-- | arch/m68knommu/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/m68knommu/lib/memmove.c | 105 |
3 files changed, 107 insertions, 2 deletions
diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h index ffc3c3f61243..32198454da70 100644 --- a/arch/m68k/include/asm/string.h +++ b/arch/m68k/include/asm/string.h | |||
@@ -99,10 +99,10 @@ static inline int strcmp(const char *cs, const char *ct) | |||
99 | : "+a" (cs), "+a" (ct), "=d" (res)); | 99 | : "+a" (cs), "+a" (ct), "=d" (res)); |
100 | return res; | 100 | return res; |
101 | } | 101 | } |
102 | #endif /* CONFIG_COLDFIRE */ | ||
102 | 103 | ||
103 | #define __HAVE_ARCH_MEMMOVE | 104 | #define __HAVE_ARCH_MEMMOVE |
104 | extern void *memmove(void *, const void *, __kernel_size_t); | 105 | extern void *memmove(void *, const void *, __kernel_size_t); |
105 | #endif /* CONFIG_COLDFIRE */ | ||
106 | 106 | ||
107 | #define memcmp(d, s, n) __builtin_memcmp(d, s, n) | 107 | #define memcmp(d, s, n) __builtin_memcmp(d, s, n) |
108 | 108 | ||
diff --git a/arch/m68knommu/lib/Makefile b/arch/m68knommu/lib/Makefile index d94d709665aa..32d852e586d7 100644 --- a/arch/m68knommu/lib/Makefile +++ b/arch/m68knommu/lib/Makefile | |||
@@ -4,4 +4,4 @@ | |||
4 | 4 | ||
5 | lib-y := ashldi3.o ashrdi3.o lshrdi3.o \ | 5 | lib-y := ashldi3.o ashrdi3.o lshrdi3.o \ |
6 | muldi3.o mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \ | 6 | muldi3.o mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \ |
7 | checksum.o memcpy.o memset.o delay.o | 7 | checksum.o memcpy.o memmove.o memset.o delay.o |
diff --git a/arch/m68knommu/lib/memmove.c b/arch/m68knommu/lib/memmove.c new file mode 100644 index 000000000000..b3dcfe9dab7e --- /dev/null +++ b/arch/m68knommu/lib/memmove.c | |||
@@ -0,0 +1,105 @@ | |||
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 | */ | ||
6 | |||
7 | #define __IN_STRING_C | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/string.h> | ||
11 | |||
12 | void *memmove(void *dest, const void *src, size_t n) | ||
13 | { | ||
14 | void *xdest = dest; | ||
15 | size_t temp; | ||
16 | |||
17 | if (!n) | ||
18 | return xdest; | ||
19 | |||
20 | if (dest < src) { | ||
21 | if ((long)dest & 1) { | ||
22 | char *cdest = dest; | ||
23 | const char *csrc = src; | ||
24 | *cdest++ = *csrc++; | ||
25 | dest = cdest; | ||
26 | src = csrc; | ||
27 | n--; | ||
28 | } | ||
29 | if (n > 2 && (long)dest & 2) { | ||
30 | short *sdest = dest; | ||
31 | const short *ssrc = src; | ||
32 | *sdest++ = *ssrc++; | ||
33 | dest = sdest; | ||
34 | src = ssrc; | ||
35 | n -= 2; | ||
36 | } | ||
37 | temp = n >> 2; | ||
38 | if (temp) { | ||
39 | long *ldest = dest; | ||
40 | const long *lsrc = src; | ||
41 | temp--; | ||
42 | do | ||
43 | *ldest++ = *lsrc++; | ||
44 | while (temp--); | ||
45 | dest = ldest; | ||
46 | src = lsrc; | ||
47 | } | ||
48 | if (n & 2) { | ||
49 | short *sdest = dest; | ||
50 | const short *ssrc = src; | ||
51 | *sdest++ = *ssrc++; | ||
52 | dest = sdest; | ||
53 | src = ssrc; | ||
54 | } | ||
55 | if (n & 1) { | ||
56 | char *cdest = dest; | ||
57 | const char *csrc = src; | ||
58 | *cdest = *csrc; | ||
59 | } | ||
60 | } else { | ||
61 | dest = (char *)dest + n; | ||
62 | src = (const char *)src + n; | ||
63 | if ((long)dest & 1) { | ||
64 | char *cdest = dest; | ||
65 | const char *csrc = src; | ||
66 | *--cdest = *--csrc; | ||
67 | dest = cdest; | ||
68 | src = csrc; | ||
69 | n--; | ||
70 | } | ||
71 | if (n > 2 && (long)dest & 2) { | ||
72 | short *sdest = dest; | ||
73 | const short *ssrc = src; | ||
74 | *--sdest = *--ssrc; | ||
75 | dest = sdest; | ||
76 | src = ssrc; | ||
77 | n -= 2; | ||
78 | } | ||
79 | temp = n >> 2; | ||
80 | if (temp) { | ||
81 | long *ldest = dest; | ||
82 | const long *lsrc = src; | ||
83 | temp--; | ||
84 | do | ||
85 | *--ldest = *--lsrc; | ||
86 | while (temp--); | ||
87 | dest = ldest; | ||
88 | src = lsrc; | ||
89 | } | ||
90 | if (n & 2) { | ||
91 | short *sdest = dest; | ||
92 | const short *ssrc = src; | ||
93 | *--sdest = *--ssrc; | ||
94 | dest = sdest; | ||
95 | src = ssrc; | ||
96 | } | ||
97 | if (n & 1) { | ||
98 | char *cdest = dest; | ||
99 | const char *csrc = src; | ||
100 | *--cdest = *--csrc; | ||
101 | } | ||
102 | } | ||
103 | return xdest; | ||
104 | } | ||
105 | EXPORT_SYMBOL(memmove); | ||