aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/lib/memset.c
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@uclinux.org>2011-03-28 02:48:00 -0400
committerGreg Ungerer <gerg@uclinux.org>2011-05-23 20:03:49 -0400
commitd10ed2f5383cc6e6b7649f03540b8cb1838d5f67 (patch)
treeb2ee2537f23e452df1d98a88877ae28f7e3264fa /arch/m68k/lib/memset.c
parent80160de89d0a7c9a93dfe91eef2b448cbc380cd0 (diff)
m68k: remove duplicate memset() implementation
Merging the mmu and non-mmu directories we ended up with duplicate implementations of memset(). One is a little more optimized for the >= 68020 case, but that can easily be inserted into a single implementation of memset(). 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/memset.c')
-rw-r--r--arch/m68k/lib/memset.c114
1 files changed, 71 insertions, 43 deletions
diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c
index 1389bf455633..f649e6a2e644 100644
--- a/arch/m68k/lib/memset.c
+++ b/arch/m68k/lib/memset.c
@@ -1,47 +1,75 @@
1#include <linux/types.h> 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 */
2 6
3void * memset(void * s, int c, size_t count) 7#include <linux/module.h>
8#include <linux/string.h>
9
10void *memset(void *s, int c, size_t count)
4{ 11{
5 void *xs = s; 12 void *xs = s;
6 size_t temp; 13 size_t temp;
7 14
8 if (!count) 15 if (!count)
9 return xs; 16 return xs;
10 c &= 0xff; 17 c &= 0xff;
11 c |= c << 8; 18 c |= c << 8;
12 c |= c << 16; 19 c |= c << 16;
13 if ((long) s & 1) 20 if ((long)s & 1) {
14 { 21 char *cs = s;
15 char *cs = s; 22 *cs++ = c;
16 *cs++ = c; 23 s = cs;
17 s = cs; 24 count--;
18 count--; 25 }
19 } 26 if (count > 2 && (long)s & 2) {
20 if (count > 2 && (long) s & 2) 27 short *ss = s;
21 { 28 *ss++ = c;
22 short *ss = s; 29 s = ss;
23 *ss++ = c; 30 count -= 2;
24 s = ss; 31 }
25 count -= 2; 32 temp = count >> 2;
26 } 33 if (temp) {
27 temp = count >> 2; 34 long *ls = s;
28 if (temp) 35#if defined(__mc68020__) || defined(__mc68030__) || \
29 { 36 defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__)
30 long *ls = s; 37 size_t temp1;
31 for (; temp; temp--) 38 asm volatile (
32 *ls++ = c; 39 " movel %1,%2\n"
33 s = ls; 40 " andw #7,%2\n"
34 } 41 " lsrl #3,%1\n"
35 if (count & 2) 42 " negw %2\n"
36 { 43 " jmp %%pc@(2f,%2:w:2)\n"
37 short *ss = s; 44 "1: movel %3,%0@+\n"
38 *ss++ = c; 45 " movel %3,%0@+\n"
39 s = ss; 46 " movel %3,%0@+\n"
40 } 47 " movel %3,%0@+\n"
41 if (count & 1) 48 " movel %3,%0@+\n"
42 { 49 " movel %3,%0@+\n"
43 char *cs = s; 50 " movel %3,%0@+\n"
44 *cs = c; 51 " movel %3,%0@+\n"
45 } 52 "2: dbra %1,1b\n"
46 return xs; 53 " clrw %1\n"
54 " subql #1,%1\n"
55 " jpl 1b"
56 : "=a" (ls), "=d" (temp), "=&d" (temp1)
57 : "d" (c), "0" (ls), "1" (temp));
58#else
59 for (; temp; temp--)
60 *ls++ = c;
61#endif
62 s = ls;
63 }
64 if (count & 2) {
65 short *ss = s;
66 *ss++ = c;
67 s = ss;
68 }
69 if (count & 1) {
70 char *cs = s;
71 *cs = c;
72 }
73 return xs;
47} 74}
75EXPORT_SYMBOL(memset);