1 #ifndef _BLACKFIN_STRING_H_
2 #define _BLACKFIN_STRING_H_
4 #include <linux/types.h>
6 #ifdef __KERNEL__ /* only set these up for kernel code */
8 #define __HAVE_ARCH_STRCPY
9 extern inline char *strcpy(char *dest
, const char *src
)
14 __asm__
__volatile__ (
20 : "+&a" (dest
), "+&a" (src
), "=&d" (temp
)
27 #define __HAVE_ARCH_STRNCPY
28 extern inline char *strncpy(char *dest
, const char *src
, size_t n
)
36 __asm__
__volatile__ (
44 "if ! cc jump 1b (bp);"
47 /* if src is shorter than n, we need to null pad bytes now */
56 : "+&a" (dest
), "+&a" (src
), "+&da" (n
), "=&d" (temp
)
63 #define __HAVE_ARCH_STRCMP
64 extern inline int strcmp(const char *cs
, const char *ct
)
66 /* need to use int's here so the char's in the assembly don't get
67 * sign extended incorrectly when we don't want them to be
71 __asm__
__volatile__ (
73 "%2 = B[%0++] (Z);" /* get *cs */
74 "%3 = B[%1++] (Z);" /* get *ct */
75 "CC = %2 == %3;" /* compare a byte */
76 "if ! cc jump 2f;" /* not equal, break out */
77 "CC = %2;" /* at end of cs? */
78 "if cc jump 1b (bp);" /* no, keep going */
79 "jump.s 3f;" /* strings are equal */
81 "%2 = %2 - %3;" /* *cs - *ct */
83 : "+&a" (cs
), "+&a" (ct
), "=&d" (__res1
), "=&d" (__res2
)
90 #define __HAVE_ARCH_STRNCMP
91 extern inline int strncmp(const char *cs
, const char *ct
, size_t count
)
93 /* need to use int's here so the char's in the assembly don't get
94 * sign extended incorrectly when we don't want them to be
101 __asm__
__volatile__ (
103 "%3 = B[%0++] (Z);" /* get *cs */
104 "%4 = B[%1++] (Z);" /* get *ct */
105 "CC = %3 == %4;" /* compare a byte */
106 "if ! cc jump 3f;" /* not equal, break out */
107 "CC = %3;" /* at end of cs? */
108 "if ! cc jump 4f;" /* yes, all done */
109 "%2 += -1;" /* no, adjust count */
111 "if ! cc jump 1b;" /* more to do, keep going */
113 "%3 = 0;" /* strings are equal */
116 "%3 = %3 - %4;" /* *cs - *ct */
118 : "+&a" (cs
), "+&a" (ct
), "+&da" (count
), "=&d" (__res1
), "=&d" (__res2
)
125 #define __HAVE_ARCH_MEMSET
126 extern void *memset(void *s
, int c
, size_t count
);
127 #define __HAVE_ARCH_MEMCPY
128 extern void *memcpy(void *d
, const void *s
, size_t count
);
129 #define __HAVE_ARCH_MEMCMP
130 extern int memcmp(const void *, const void *, __kernel_size_t
);
131 #define __HAVE_ARCH_MEMCHR
132 extern void *memchr(const void *s
, int c
, size_t n
);
133 #define __HAVE_ARCH_MEMMOVE
134 extern void *memmove(void *dest
, const void *src
, size_t count
);
136 #endif /*__KERNEL__*/
137 #endif /* _BLACKFIN_STRING_H_ */