[MIPS] Add topology_init.
[linux-2.6/kmemtrace.git] / include / asm-sh / string.h
blob3e0cff04caec8c32adb8c4bcda7a9f209243377d
1 #ifndef __ASM_SH_STRING_H
2 #define __ASM_SH_STRING_H
4 /*
5 * Copyright (C) 1999 Niibe Yutaka
6 * But consider these trivial functions to be public domain.
7 */
9 #define __HAVE_ARCH_STRCPY
10 static __inline__ char *strcpy(char *__dest, const char *__src)
12 register char *__xdest = __dest;
13 unsigned long __dummy;
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");
25 return __xdest;
28 #define __HAVE_ARCH_STRNCPY
29 static __inline__ char *strncpy(char *__dest, const char *__src, size_t __n)
31 register char *__xdest = __dest;
32 unsigned long __dummy;
34 if (__n == 0)
35 return __xdest;
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");
51 return __xdest;
54 #define __HAVE_ARCH_STRCMP
55 static __inline__ int strcmp(const char *__cs, const char *__ct)
57 register int __res;
58 unsigned long __dummy;
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");
77 return __res;
80 #define __HAVE_ARCH_STRNCMP
81 static __inline__ int strncmp(const char *__cs, const char *__ct, size_t __n)
83 register int __res;
84 unsigned long __dummy;
86 if (__n == 0)
87 return 0;
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");
109 return __res;
112 #define __HAVE_ARCH_MEMSET
113 extern void *memset(void *__s, int __c, size_t __count);
115 #define __HAVE_ARCH_MEMCPY
116 extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
118 #define __HAVE_ARCH_MEMMOVE
119 extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
121 #define __HAVE_ARCH_MEMCHR
122 extern void *memchr(const void *__s, int __c, size_t __n);
124 #define __HAVE_ARCH_STRLEN
125 extern size_t strlen(const char *);
127 #endif /* __ASM_SH_STRING_H */