aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh/string.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-sh/string.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-sh/string.h')
-rw-r--r--include/asm-sh/string.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/include/asm-sh/string.h b/include/asm-sh/string.h
new file mode 100644
index 000000000000..3e0cff04caec
--- /dev/null
+++ b/include/asm-sh/string.h
@@ -0,0 +1,127 @@
1#ifndef __ASM_SH_STRING_H
2#define __ASM_SH_STRING_H
3
4/*
5 * Copyright (C) 1999 Niibe Yutaka
6 * But consider these trivial functions to be public domain.
7 */
8
9#define __HAVE_ARCH_STRCPY
10static __inline__ char *strcpy(char *__dest, const char *__src)
11{
12 register char *__xdest = __dest;
13 unsigned long __dummy;
14
15 __asm__ __volatile__("1:\n\t"
16 "mov.b @%1+, %2\n\t"
17 "mov.b %2, @%0\n\t"
18 "cmp/eq #0, %2\n\t"
19 "bf/s 1b\n\t"
20 " add #1, %0\n\t"
21 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
22 : "0" (__dest), "1" (__src)
23 : "memory", "t");
24
25 return __xdest;
26}
27
28#define __HAVE_ARCH_STRNCPY
29static __inline__ char *strncpy(char *__dest, const char *__src, size_t __n)
30{
31 register char *__xdest = __dest;
32 unsigned long __dummy;
33
34 if (__n == 0)
35 return __xdest;
36
37 __asm__ __volatile__(
38 "1:\n"
39 "mov.b @%1+, %2\n\t"
40 "mov.b %2, @%0\n\t"
41 "cmp/eq #0, %2\n\t"
42 "bt/s 2f\n\t"
43 " cmp/eq %5,%1\n\t"
44 "bf/s 1b\n\t"
45 " add #1, %0\n"
46 "2:"
47 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
48 : "0" (__dest), "1" (__src), "r" (__src+__n)
49 : "memory", "t");
50
51 return __xdest;
52}
53
54#define __HAVE_ARCH_STRCMP
55static __inline__ int strcmp(const char *__cs, const char *__ct)
56{
57 register int __res;
58 unsigned long __dummy;
59
60 __asm__ __volatile__(
61 "mov.b @%1+, %3\n"
62 "1:\n\t"
63 "mov.b @%0+, %2\n\t"
64 "cmp/eq #0, %3\n\t"
65 "bt 2f\n\t"
66 "cmp/eq %2, %3\n\t"
67 "bt/s 1b\n\t"
68 " mov.b @%1+, %3\n\t"
69 "add #-2, %1\n\t"
70 "mov.b @%1, %3\n\t"
71 "sub %3, %2\n"
72 "2:"
73 : "=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
74 : "0" (__cs), "1" (__ct)
75 : "t");
76
77 return __res;
78}
79
80#define __HAVE_ARCH_STRNCMP
81static __inline__ int strncmp(const char *__cs, const char *__ct, size_t __n)
82{
83 register int __res;
84 unsigned long __dummy;
85
86 if (__n == 0)
87 return 0;
88
89 __asm__ __volatile__(
90 "mov.b @%1+, %3\n"
91 "1:\n\t"
92 "mov.b @%0+, %2\n\t"
93 "cmp/eq %6, %0\n\t"
94 "bt/s 2f\n\t"
95 " cmp/eq #0, %3\n\t"
96 "bt/s 3f\n\t"
97 " cmp/eq %3, %2\n\t"
98 "bt/s 1b\n\t"
99 " mov.b @%1+, %3\n\t"
100 "add #-2, %1\n\t"
101 "mov.b @%1, %3\n"
102 "2:\n\t"
103 "sub %3, %2\n"
104 "3:"
105 :"=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
106 : "0" (__cs), "1" (__ct), "r" (__cs+__n)
107 : "t");
108
109 return __res;
110}
111
112#define __HAVE_ARCH_MEMSET
113extern void *memset(void *__s, int __c, size_t __count);
114
115#define __HAVE_ARCH_MEMCPY
116extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
117
118#define __HAVE_ARCH_MEMMOVE
119extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
120
121#define __HAVE_ARCH_MEMCHR
122extern void *memchr(const void *__s, int __c, size_t __n);
123
124#define __HAVE_ARCH_STRLEN
125extern size_t strlen(const char *);
126
127#endif /* __ASM_SH_STRING_H */