aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/string.h
diff options
context:
space:
mode:
authorRobin Getz <robin.getz@analog.com>2010-05-03 13:23:20 -0400
committerMike Frysinger <vapier@gentoo.org>2010-05-22 14:19:09 -0400
commit479ba6035862a9c08ce4351c7fff8926fde4ede5 (patch)
tree93a6419ffdfd38056f26d4362de450f79af044b3 /arch/blackfin/include/asm/string.h
parent80fcdb959343ab9e0ee95c11b5ea47c44a2c3004 (diff)
Blackfin: move string functions to normal lib/ assembly
Since 'extern inline' doesn't work correctly in the context of the Linux kernel (too many overriding defines), move the string functions to normal lib/ assembly files (like the existing mem funcs). This avoids the forced inline all over the kernel and allows us to place them constantly in L1. This also avoids some module failures when gcc inserts calls to string functions but the kernel build system doesn't fully consult the library archives. Signed-off-by: Robin Getz <robin.getz@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/include/asm/string.h')
-rw-r--r--arch/blackfin/include/asm/string.h113
1 files changed, 4 insertions, 109 deletions
diff --git a/arch/blackfin/include/asm/string.h b/arch/blackfin/include/asm/string.h
index d7f0ccb418c3..423c099aa988 100644
--- a/arch/blackfin/include/asm/string.h
+++ b/arch/blackfin/include/asm/string.h
@@ -12,121 +12,16 @@
12#ifdef __KERNEL__ /* only set these up for kernel code */ 12#ifdef __KERNEL__ /* only set these up for kernel code */
13 13
14#define __HAVE_ARCH_STRCPY 14#define __HAVE_ARCH_STRCPY
15extern inline char *strcpy(char *dest, const char *src) 15extern char *strcpy(char *dest, const char *src);
16{
17 char *xdest = dest;
18 char temp = 0;
19
20 __asm__ __volatile__ (
21 "1:"
22 "%2 = B [%1++] (Z);"
23 "B [%0++] = %2;"
24 "CC = %2;"
25 "if cc jump 1b (bp);"
26 : "+&a" (dest), "+&a" (src), "=&d" (temp)
27 :
28 : "memory", "CC");
29
30 return xdest;
31}
32 16
33#define __HAVE_ARCH_STRNCPY 17#define __HAVE_ARCH_STRNCPY
34extern inline char *strncpy(char *dest, const char *src, size_t n) 18extern char *strncpy(char *dest, const char *src, size_t n);
35{
36 char *xdest = dest;
37 char temp = 0;
38
39 if (n == 0)
40 return xdest;
41
42 __asm__ __volatile__ (
43 "1:"
44 "%3 = B [%1++] (Z);"
45 "B [%0++] = %3;"
46 "CC = %3;"
47 "if ! cc jump 2f;"
48 "%2 += -1;"
49 "CC = %2 == 0;"
50 "if ! cc jump 1b (bp);"
51 "jump 4f;"
52 "2:"
53 /* if src is shorter than n, we need to null pad bytes now */
54 "%3 = 0;"
55 "3:"
56 "%2 += -1;"
57 "CC = %2 == 0;"
58 "if cc jump 4f;"
59 "B [%0++] = %3;"
60 "jump 3b;"
61 "4:"
62 : "+&a" (dest), "+&a" (src), "+&da" (n), "=&d" (temp)
63 :
64 : "memory", "CC");
65
66 return xdest;
67}
68 19
69#define __HAVE_ARCH_STRCMP 20#define __HAVE_ARCH_STRCMP
70extern inline int strcmp(const char *cs, const char *ct) 21extern int strcmp(const char *cs, const char *ct);
71{
72 /* need to use int's here so the char's in the assembly don't get
73 * sign extended incorrectly when we don't want them to be
74 */
75 int __res1, __res2;
76
77 __asm__ __volatile__ (
78 "1:"
79 "%2 = B[%0++] (Z);" /* get *cs */
80 "%3 = B[%1++] (Z);" /* get *ct */
81 "CC = %2 == %3;" /* compare a byte */
82 "if ! cc jump 2f;" /* not equal, break out */
83 "CC = %2;" /* at end of cs? */
84 "if cc jump 1b (bp);" /* no, keep going */
85 "jump.s 3f;" /* strings are equal */
86 "2:"
87 "%2 = %2 - %3;" /* *cs - *ct */
88 "3:"
89 : "+&a" (cs), "+&a" (ct), "=&d" (__res1), "=&d" (__res2)
90 :
91 : "memory", "CC");
92
93 return __res1;
94}
95 22
96#define __HAVE_ARCH_STRNCMP 23#define __HAVE_ARCH_STRNCMP
97extern inline int strncmp(const char *cs, const char *ct, size_t count) 24extern int strncmp(const char *cs, const char *ct, size_t count);
98{
99 /* need to use int's here so the char's in the assembly don't get
100 * sign extended incorrectly when we don't want them to be
101 */
102 int __res1, __res2;
103
104 if (!count)
105 return 0;
106
107 __asm__ __volatile__ (
108 "1:"
109 "%3 = B[%0++] (Z);" /* get *cs */
110 "%4 = B[%1++] (Z);" /* get *ct */
111 "CC = %3 == %4;" /* compare a byte */
112 "if ! cc jump 3f;" /* not equal, break out */
113 "CC = %3;" /* at end of cs? */
114 "if ! cc jump 4f;" /* yes, all done */
115 "%2 += -1;" /* no, adjust count */
116 "CC = %2 == 0;"
117 "if ! cc jump 1b;" /* more to do, keep going */
118 "2:"
119 "%3 = 0;" /* strings are equal */
120 "jump.s 4f;"
121 "3:"
122 "%3 = %3 - %4;" /* *cs - *ct */
123 "4:"
124 : "+&a" (cs), "+&a" (ct), "+&da" (count), "=&d" (__res1), "=&d" (__res2)
125 :
126 : "memory", "CC");
127
128 return __res1;
129}
130 25
131#define __HAVE_ARCH_MEMSET 26#define __HAVE_ARCH_MEMSET
132extern void *memset(void *s, int c, size_t count); 27extern void *memset(void *s, int c, size_t count);