1 #ifndef _M68K_STRING_H_
2 #define _M68K_STRING_H_
7 #define __HAVE_ARCH_STRCPY
8 static inline char * strcpy(char * dest
,const char *src
)
13 ("1:\tmoveb %1@+,%0@+\n\t"
15 : "=a" (dest
), "=a" (src
)
16 : "0" (dest
), "1" (src
) : "memory");
20 #define __HAVE_ARCH_STRNCPY
21 static inline char * strncpy(char *dest
, const char *src
, size_t n
)
29 ("1:\tmoveb %1@+,%0@+\n\t"
34 : "=a" (dest
), "=a" (src
), "=d" (n
)
35 : "0" (dest
), "1" (src
), "2" (n
)
40 #define __HAVE_ARCH_STRCAT
41 static inline char * strcat(char * dest
, const char * src
)
47 while ((*dest
++ = *src
++))
53 #define __HAVE_ARCH_STRNCAT
54 static inline char * strncat(char *dest
, const char *src
, size_t count
)
61 while ((*dest
++ = *src
++)) {
72 #define __HAVE_ARCH_STRCHR
73 static inline char * strchr(const char * s
, int c
)
85 #define __HAVE_ARCH_STRLEN
86 static inline size_t strlen(const char * s
)
89 for (sc
= s
; *sc
!= '\0'; ++sc
) ;
95 #define __HAVE_ARCH_STRCMP
96 static inline int strcmp(const char * cs
,const char * ct
)
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 */
109 : "=a" (cs
), "=a" (ct
), "=d" (__res
)
110 : "0" (cs
), "1" (ct
));
114 #define __HAVE_ARCH_STRNCMP
115 static inline int strncmp(const char * cs
,const char * ct
,size_t count
)
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 */
131 "3:\tsubb %1@-,%3\n\t" /* *cs - *ct */
133 : "=a" (cs
), "=a" (ct
), "=d" (count
), "=d" (__res
)
134 : "0" (cs
), "1" (ct
), "2" (count
));
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_ */