1#ifndef __ASM_SH_STRING_H
2#define __ASM_SH_STRING_H
3
4
5
6
7
8
9
10
11#ifdef __KERNEL__
12
13#define __HAVE_ARCH_STRCPY
14static inline char *strcpy(char *__dest, const char *__src)
15{
16 register char *__xdest = __dest;
17 unsigned long __dummy;
18
19 __asm__ __volatile__("1:\n\t"
20 "mov.b @%1+, %2\n\t"
21 "mov.b %2, @%0\n\t"
22 "cmp/eq #0, %2\n\t"
23 "bf/s 1b\n\t"
24 " add #1, %0\n\t"
25 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
26 : "0" (__dest), "1" (__src)
27 : "memory", "t");
28
29 return __xdest;
30}
31
32#define __HAVE_ARCH_STRNCPY
33static inline char *strncpy(char *__dest, const char *__src, size_t __n)
34{
35 register char *__xdest = __dest;
36 unsigned long __dummy;
37
38 if (__n == 0)
39 return __xdest;
40
41 __asm__ __volatile__(
42 "1:\n"
43 "mov.b @%1+, %2\n\t"
44 "mov.b %2, @%0\n\t"
45 "cmp/eq #0, %2\n\t"
46 "bt/s 2f\n\t"
47 " cmp/eq %5,%1\n\t"
48 "bf/s 1b\n\t"
49 " add #1, %0\n"
50 "2:"
51 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
52 : "0" (__dest), "1" (__src), "r" (__src+__n)
53 : "memory", "t");
54
55 return __xdest;
56}
57
58#define __HAVE_ARCH_STRCMP
59static inline int strcmp(const char *__cs, const char *__ct)
60{
61 register int __res;
62 unsigned long __dummy;
63
64 __asm__ __volatile__(
65 "mov.b @%1+, %3\n"
66 "1:\n\t"
67 "mov.b @%0+, %2\n\t"
68 "cmp/eq #0, %3\n\t"
69 "bt 2f\n\t"
70 "cmp/eq %2, %3\n\t"
71 "bt/s 1b\n\t"
72 " mov.b @%1+, %3\n\t"
73 "add #-2, %1\n\t"
74 "mov.b @%1, %3\n\t"
75 "sub %3, %2\n"
76 "2:"
77 : "=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
78 : "0" (__cs), "1" (__ct)
79 : "t");
80
81 return __res;
82}
83
84#define __HAVE_ARCH_STRNCMP
85static inline int strncmp(const char *__cs, const char *__ct, size_t __n)
86{
87 register int __res;
88 unsigned long __dummy;
89
90 if (__n == 0)
91 return 0;
92
93 __asm__ __volatile__(
94 "mov.b @%1+, %3\n"
95 "1:\n\t"
96 "mov.b @%0+, %2\n\t"
97 "cmp/eq %6, %0\n\t"
98 "bt/s 2f\n\t"
99 " cmp/eq #0, %3\n\t"
100 "bt/s 3f\n\t"
101 " cmp/eq %3, %2\n\t"
102 "bt/s 1b\n\t"
103 " mov.b @%1+, %3\n\t"
104 "add #-2, %1\n\t"
105 "mov.b @%1, %3\n"
106 "2:\n\t"
107 "sub %3, %2\n"
108 "3:"
109 :"=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
110 : "0" (__cs), "1" (__ct), "r" (__cs+__n)
111 : "t");
112
113 return __res;
114}
115
116#undef __HAVE_ARCH_MEMSET
117extern void *memset(void *__s, int __c, size_t __count);
118
119#undef __HAVE_ARCH_MEMCPY
120extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
121
122#undef __HAVE_ARCH_MEMMOVE
123extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
124
125#undef __HAVE_ARCH_MEMCHR
126extern void *memchr(const void *__s, int __c, size_t __n);
127
128#undef __HAVE_ARCH_STRLEN
129extern size_t strlen(const char *);
130
131
132extern int strcasecmp(const char *, const char *);
133
134#else
135
136
137
138
139
140
141#define __HAVE_ARCH_STRCPY 1
142#define __HAVE_ARCH_STRNCPY 1
143#define __HAVE_ARCH_STRCAT 1
144#define __HAVE_ARCH_STRNCAT 1
145#define __HAVE_ARCH_STRCMP 1
146#define __HAVE_ARCH_STRNCMP 1
147#define __HAVE_ARCH_STRNICMP 1
148#define __HAVE_ARCH_STRCHR 1
149#define __HAVE_ARCH_STRRCHR 1
150#define __HAVE_ARCH_STRSTR 1
151#define __HAVE_ARCH_STRLEN 1
152#define __HAVE_ARCH_STRNLEN 1
153#define __HAVE_ARCH_MEMSET 1
154#define __HAVE_ARCH_MEMCPY 1
155#define __HAVE_ARCH_MEMMOVE 1
156#define __HAVE_ARCH_MEMSCAN 1
157#define __HAVE_ARCH_MEMCMP 1
158#define __HAVE_ARCH_MEMCHR 1
159#define __HAVE_ARCH_STRTOK 1
160
161#endif
162#endif
163