2 * Copyright 2004-2008 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
7 #ifndef _BLACKFIN_STRING_H_
8 #define _BLACKFIN_STRING_H_
10 #include <linux/types.h>
12 #ifdef __KERNEL__ /* only set these up for kernel code */
14 #define __HAVE_ARCH_STRCPY
15 extern inline char *strcpy(char *dest
, const char *src
)
20 __asm__
__volatile__ (
26 : "+&a" (dest
), "+&a" (src
), "=&d" (temp
)
33 #define __HAVE_ARCH_STRNCPY
34 extern inline char *strncpy(char *dest
, const char *src
, size_t n
)
42 __asm__
__volatile__ (
50 "if ! cc jump 1b (bp);"
53 /* if src is shorter than n, we need to null pad bytes now */
62 : "+&a" (dest
), "+&a" (src
), "+&da" (n
), "=&d" (temp
)
69 #define __HAVE_ARCH_STRCMP
70 extern inline int strcmp(const char *cs
, const char *ct
)
72 /* need to use int's here so the char's in the assembly don't get
73 * sign extended incorrectly when we don't want them to be
77 __asm__
__volatile__ (
79 "%2 = B[%0++] (Z);" /* get *cs */
80 "%3 = B[%1++] (Z);" /* get *ct */
81 "CC = %2 == %3;" /* compare a byte */
82 "if ! cc jump 2f;" /* not equal, break out */
83 "CC = %2;" /* at end of cs? */
84 "if cc jump 1b (bp);" /* no, keep going */
85 "jump.s 3f;" /* strings are equal */
87 "%2 = %2 - %3;" /* *cs - *ct */
89 : "+&a" (cs
), "+&a" (ct
), "=&d" (__res1
), "=&d" (__res2
)
96 #define __HAVE_ARCH_STRNCMP
97 extern inline int strncmp(const char *cs
, const char *ct
, size_t count
)
99 /* need to use int's here so the char's in the assembly don't get
100 * sign extended incorrectly when we don't want them to be
107 __asm__
__volatile__ (
109 "%3 = B[%0++] (Z);" /* get *cs */
110 "%4 = B[%1++] (Z);" /* get *ct */
111 "CC = %3 == %4;" /* compare a byte */
112 "if ! cc jump 3f;" /* not equal, break out */
113 "CC = %3;" /* at end of cs? */
114 "if ! cc jump 4f;" /* yes, all done */
115 "%2 += -1;" /* no, adjust count */
117 "if ! cc jump 1b;" /* more to do, keep going */
119 "%3 = 0;" /* strings are equal */
122 "%3 = %3 - %4;" /* *cs - *ct */
124 : "+&a" (cs
), "+&a" (ct
), "+&da" (count
), "=&d" (__res1
), "=&d" (__res2
)
131 #define __HAVE_ARCH_MEMSET
132 extern void *memset(void *s
, int c
, size_t count
);
133 #define __HAVE_ARCH_MEMCPY
134 extern void *memcpy(void *d
, const void *s
, size_t count
);
135 #define __HAVE_ARCH_MEMCMP
136 extern int memcmp(const void *, const void *, __kernel_size_t
);
137 #define __HAVE_ARCH_MEMCHR
138 extern void *memchr(const void *s
, int c
, size_t n
);
139 #define __HAVE_ARCH_MEMMOVE
140 extern void *memmove(void *dest
, const void *src
, size_t count
);
142 #endif /*__KERNEL__*/
143 #endif /* _BLACKFIN_STRING_H_ */