diff options
-rw-r--r-- | arch/m68k/kernel/m68k_ksyms_no.c | 1 | ||||
-rw-r--r-- | arch/m68k/lib/Makefile | 5 | ||||
-rw-r--r-- | arch/m68k/lib/memset.c | 114 | ||||
-rw-r--r-- | arch/m68k/lib/string.c | 61 |
4 files changed, 74 insertions, 107 deletions
diff --git a/arch/m68k/kernel/m68k_ksyms_no.c b/arch/m68k/kernel/m68k_ksyms_no.c index 39fe0a7aec32..346bce63bbf3 100644 --- a/arch/m68k/kernel/m68k_ksyms_no.c +++ b/arch/m68k/kernel/m68k_ksyms_no.c | |||
@@ -36,7 +36,6 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck); | |||
36 | their interface isn't gonna change any time soon now, so | 36 | their interface isn't gonna change any time soon now, so |
37 | it's OK to leave it out of version control. */ | 37 | it's OK to leave it out of version control. */ |
38 | EXPORT_SYMBOL(memcpy); | 38 | EXPORT_SYMBOL(memcpy); |
39 | EXPORT_SYMBOL(memset); | ||
40 | 39 | ||
41 | /* | 40 | /* |
42 | * libgcc functions - functions that are used internally by the | 41 | * libgcc functions - functions that are used internally by the |
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile index ec479a9b9d7b..ac275d5e9e3c 100644 --- a/arch/m68k/lib/Makefile +++ b/arch/m68k/lib/Makefile | |||
@@ -3,12 +3,13 @@ | |||
3 | # Makefile for m68k-specific library files.. | 3 | # Makefile for m68k-specific library files.. |
4 | # | 4 | # |
5 | 5 | ||
6 | lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o memmove.o checksum.o | 6 | lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ |
7 | memset.o memmove.o checksum.o | ||
7 | 8 | ||
8 | ifdef CONFIG_MMU | 9 | ifdef CONFIG_MMU |
9 | lib-y += string.o uaccess.o | 10 | lib-y += string.o uaccess.o |
10 | else | 11 | else |
11 | lib-y += mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \ | 12 | lib-y += mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \ |
12 | memcpy.o memset.o delay.o | 13 | memcpy.o delay.o |
13 | endif | 14 | endif |
14 | 15 | ||
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 | ||
3 | void * memset(void * s, int c, size_t count) | 7 | #include <linux/module.h> |
8 | #include <linux/string.h> | ||
9 | |||
10 | void *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 | } |
75 | EXPORT_SYMBOL(memset); | ||
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c index 711fa743e6be..6d2461237a16 100644 --- a/arch/m68k/lib/string.c +++ b/arch/m68k/lib/string.c | |||
@@ -21,67 +21,6 @@ char *strcat(char *dest, const char *src) | |||
21 | } | 21 | } |
22 | EXPORT_SYMBOL(strcat); | 22 | EXPORT_SYMBOL(strcat); |
23 | 23 | ||
24 | void *memset(void *s, int c, size_t count) | ||
25 | { | ||
26 | void *xs = s; | ||
27 | size_t temp, temp1; | ||
28 | |||
29 | if (!count) | ||
30 | return xs; | ||
31 | c &= 0xff; | ||
32 | c |= c << 8; | ||
33 | c |= c << 16; | ||
34 | if ((long)s & 1) { | ||
35 | char *cs = s; | ||
36 | *cs++ = c; | ||
37 | s = cs; | ||
38 | count--; | ||
39 | } | ||
40 | if (count > 2 && (long)s & 2) { | ||
41 | short *ss = s; | ||
42 | *ss++ = c; | ||
43 | s = ss; | ||
44 | count -= 2; | ||
45 | } | ||
46 | temp = count >> 2; | ||
47 | if (temp) { | ||
48 | long *ls = s; | ||
49 | |||
50 | asm volatile ( | ||
51 | " movel %1,%2\n" | ||
52 | " andw #7,%2\n" | ||
53 | " lsrl #3,%1\n" | ||
54 | " negw %2\n" | ||
55 | " jmp %%pc@(2f,%2:w:2)\n" | ||
56 | "1: movel %3,%0@+\n" | ||
57 | " movel %3,%0@+\n" | ||
58 | " movel %3,%0@+\n" | ||
59 | " movel %3,%0@+\n" | ||
60 | " movel %3,%0@+\n" | ||
61 | " movel %3,%0@+\n" | ||
62 | " movel %3,%0@+\n" | ||
63 | " movel %3,%0@+\n" | ||
64 | "2: dbra %1,1b\n" | ||
65 | " clrw %1\n" | ||
66 | " subql #1,%1\n" | ||
67 | " jpl 1b" | ||
68 | : "=a" (ls), "=d" (temp), "=&d" (temp1) | ||
69 | : "d" (c), "0" (ls), "1" (temp)); | ||
70 | s = ls; | ||
71 | } | ||
72 | if (count & 2) { | ||
73 | short *ss = s; | ||
74 | *ss++ = c; | ||
75 | s = ss; | ||
76 | } | ||
77 | if (count & 1) { | ||
78 | char *cs = s; | ||
79 | *cs = c; | ||
80 | } | ||
81 | return xs; | ||
82 | } | ||
83 | EXPORT_SYMBOL(memset); | ||
84 | |||
85 | void *memcpy(void *to, const void *from, size_t n) | 24 | void *memcpy(void *to, const void *from, size_t n) |
86 | { | 25 | { |
87 | void *xto = to; | 26 | void *xto = to; |