aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/lib/memset.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/m68k/lib/memset.c')
-rw-r--r--arch/m68k/lib/memset.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c
new file mode 100644
index 000000000000..d55fdb2ee9d3
--- /dev/null
+++ b/arch/m68k/lib/memset.c
@@ -0,0 +1,68 @@
1#include <linux/types.h>
2
3void * memset(void * s, int c, size_t count)
4{
5 void *xs = s;
6 size_t temp, temp1;
7
8 if (!count)
9 return xs;
10 c &= 0xff;
11 c |= c << 8;
12 c |= c << 16;
13 if ((long) s & 1)
14 {
15 char *cs = s;
16 *cs++ = c;
17 s = cs;
18 count--;
19 }
20 if (count > 2 && (long) s & 2)
21 {
22 short *ss = s;
23 *ss++ = c;
24 s = ss;
25 count -= 2;
26 }
27 temp = count >> 2;
28 if (temp)
29 {
30 long *ls = s;
31
32 __asm__ __volatile__("movel %1,%2\n\t"
33 "andw #7,%2\n\t"
34 "lsrl #3,%1\n\t"
35 "negw %2\n\t"
36 "jmp %%pc@(2f,%2:w:2)\n\t"
37 "1:\t"
38 "movel %3,%0@+\n\t"
39 "movel %3,%0@+\n\t"
40 "movel %3,%0@+\n\t"
41 "movel %3,%0@+\n\t"
42 "movel %3,%0@+\n\t"
43 "movel %3,%0@+\n\t"
44 "movel %3,%0@+\n\t"
45 "movel %3,%0@+\n\t"
46 "2:\t"
47 "dbra %1,1b\n\t"
48 "clrw %1\n\t"
49 "subql #1,%1\n\t"
50 "jpl 1b\n\t"
51 : "=a" (ls), "=d" (temp), "=&d" (temp1)
52 : "d" (c), "0" (ls), "1" (temp)
53 );
54 s = ls;
55 }
56 if (count & 2)
57 {
58 short *ss = s;
59 *ss++ = c;
60 s = ss;
61 }
62 if (count & 1)
63 {
64 char *cs = s;
65 *cs = c;
66 }
67 return xs;
68}