[PATCH] powerpc: Add ibm,pft-size to iSeries device tree
[linux-2.6/mini2440.git] / include / asm-m68k / string.h
blob6c59215b285e0b9ab1d57c69bc582767edb9e483
1 #ifndef _M68K_STRING_H_
2 #define _M68K_STRING_H_
4 #include <asm/setup.h>
5 #include <asm/page.h>
7 #define __HAVE_ARCH_STRCPY
8 static inline char * strcpy(char * dest,const char *src)
10 char *xdest = dest;
12 __asm__ __volatile__
13 ("1:\tmoveb %1@+,%0@+\n\t"
14 "jne 1b"
15 : "=a" (dest), "=a" (src)
16 : "0" (dest), "1" (src) : "memory");
17 return xdest;
20 #define __HAVE_ARCH_STRNCPY
21 static inline char * strncpy(char *dest, const char *src, size_t n)
23 char *xdest = dest;
25 if (n == 0)
26 return xdest;
28 __asm__ __volatile__
29 ("1:\tmoveb %1@+,%0@+\n\t"
30 "jeq 2f\n\t"
31 "subql #1,%2\n\t"
32 "jne 1b\n\t"
33 "2:"
34 : "=a" (dest), "=a" (src), "=d" (n)
35 : "0" (dest), "1" (src), "2" (n)
36 : "memory");
37 return xdest;
40 #define __HAVE_ARCH_STRCAT
41 static inline char * strcat(char * dest, const char * src)
43 char *tmp = dest;
45 while (*dest)
46 dest++;
47 while ((*dest++ = *src++))
50 return tmp;
53 #define __HAVE_ARCH_STRNCAT
54 static inline char * strncat(char *dest, const char *src, size_t count)
56 char *tmp = dest;
58 if (count) {
59 while (*dest)
60 dest++;
61 while ((*dest++ = *src++)) {
62 if (--count == 0) {
63 *dest++='\0';
64 break;
69 return tmp;
72 #define __HAVE_ARCH_STRCHR
73 static inline char * strchr(const char * s, int c)
75 const char ch = c;
77 for(; *s != ch; ++s)
78 if (*s == '\0')
79 return( NULL );
80 return( (char *) s);
83 /* strstr !! */
85 #define __HAVE_ARCH_STRLEN
86 static inline size_t strlen(const char * s)
88 const char *sc;
89 for (sc = s; *sc != '\0'; ++sc) ;
90 return(sc - s);
93 /* strnlen !! */
95 #define __HAVE_ARCH_STRCMP
96 static inline int strcmp(const char * cs,const char * ct)
98 char __res;
100 __asm__
101 ("1:\tmoveb %0@+,%2\n\t" /* get *cs */
102 "cmpb %1@+,%2\n\t" /* compare a byte */
103 "jne 2f\n\t" /* not equal, break out */
104 "tstb %2\n\t" /* at end of cs? */
105 "jne 1b\n\t" /* no, keep going */
106 "jra 3f\n\t" /* strings are equal */
107 "2:\tsubb %1@-,%2\n\t" /* *cs - *ct */
108 "3:"
109 : "=a" (cs), "=a" (ct), "=d" (__res)
110 : "0" (cs), "1" (ct));
111 return __res;
114 #define __HAVE_ARCH_STRNCMP
115 static inline int strncmp(const char * cs,const char * ct,size_t count)
117 char __res;
119 if (!count)
120 return 0;
121 __asm__
122 ("1:\tmovb %0@+,%3\n\t" /* get *cs */
123 "cmpb %1@+,%3\n\t" /* compare a byte */
124 "jne 3f\n\t" /* not equal, break out */
125 "tstb %3\n\t" /* at end of cs? */
126 "jeq 4f\n\t" /* yes, all done */
127 "subql #1,%2\n\t" /* no, adjust count */
128 "jne 1b\n\t" /* more to do, keep going */
129 "2:\tmoveq #0,%3\n\t" /* strings are equal */
130 "jra 4f\n\t"
131 "3:\tsubb %1@-,%3\n\t" /* *cs - *ct */
132 "4:"
133 : "=a" (cs), "=a" (ct), "=d" (count), "=d" (__res)
134 : "0" (cs), "1" (ct), "2" (count));
135 return __res;
138 #define __HAVE_ARCH_MEMSET
139 extern void *memset(void *, int, __kernel_size_t);
140 #define memset(d, c, n) __builtin_memset(d, c, n)
142 #define __HAVE_ARCH_MEMCPY
143 extern void *memcpy(void *, const void *, __kernel_size_t);
144 #define memcpy(d, s, n) __builtin_memcpy(d, s, n)
146 #define __HAVE_ARCH_MEMMOVE
147 extern void *memmove(void *, const void *, __kernel_size_t);
149 #define __HAVE_ARCH_MEMCMP
150 extern int memcmp(const void *, const void *, __kernel_size_t);
151 #define memcmp(d, s, n) __builtin_memcmp(d, s, n)
153 #endif /* _M68K_STRING_H_ */