1 /* $Id: string.h,v 1.14 1998/10/20 03:09:18 jj Exp $
2 * string.h: External definitions for optimized assembly string
3 * routines for the Linux Kernel.
5 * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
9 #ifndef __SPARC64_STRING_H__
10 #define __SPARC64_STRING_H__
12 /* Really, userland/ksyms should not see any of this stuff. */
18 extern void __memmove(void *,const void *,__kernel_size_t
);
19 extern __kernel_size_t
__memcpy(void *,const void *,__kernel_size_t
);
20 extern __kernel_size_t
__memcpy_short(void *,const void *,__kernel_size_t
,long,long);
21 extern __kernel_size_t
__memcpy_entry(void *,const void *,__kernel_size_t
,long,long);
22 extern __kernel_size_t
__memcpy_16plus(void *,const void *,__kernel_size_t
,long,long);
23 extern __kernel_size_t
__memcpy_384plus(void *,const void *,__kernel_size_t
,long,long);
24 extern __kernel_size_t
__memset(void *,int,__kernel_size_t
);
26 #ifndef EXPORT_SYMTAB_STROPS
28 /* First the mem*() things. */
29 #define __HAVE_ARCH_BCOPY
30 #define __HAVE_ARCH_MEMMOVE
33 #define memmove(_to, _from, _n) \
36 __memmove(_t, (_from), (_n)); \
40 #define __HAVE_ARCH_MEMCPY
42 extern inline void *__constant_memcpy(void *to
, const void *from
, __kernel_size_t n
)
46 __builtin_memcpy(to
, from
, n
);
48 __memcpy(to
, from
, n
);
54 extern inline void *__nonconstant_memcpy(void *to
, const void *from
, __kernel_size_t n
)
56 __memcpy(to
, from
, n
);
61 #define memcpy(t, f, n) \
62 (__builtin_constant_p(n) ? \
63 __constant_memcpy((t),(f),(n)) : \
64 __nonconstant_memcpy((t),(f),(n)))
66 #define __HAVE_ARCH_MEMSET
68 extern inline void *__constant_memset(void *s
, char c
, __kernel_size_t count
)
70 extern __kernel_size_t
__bzero(void *, __kernel_size_t
);
75 __memset(s
, c
, count
);
79 extern inline void *__nonconstant_memset(void *s
, char c
, __kernel_size_t count
)
81 __memset(s
, c
, count
);
86 #define memset(s, c, count) \
87 (__builtin_constant_p(c) ? \
88 __constant_memset((s), (c), (count)) : \
89 __nonconstant_memset((s), (c), (count)))
91 #define __HAVE_ARCH_MEMSCAN
94 #define memscan(__arg0, __char, __arg2) \
96 extern void *__memscan_zero(void *, size_t); \
97 extern void *__memscan_generic(void *, int, size_t); \
98 void *__retval, *__addr = (__arg0); \
99 size_t __size = (__arg2); \
101 if(__builtin_constant_p(__char) && !(__char)) \
102 __retval = __memscan_zero(__addr, __size); \
104 __retval = __memscan_generic(__addr, (__char), __size); \
109 #define __HAVE_ARCH_MEMCMP
111 /* Now the str*() stuff... */
112 #define __HAVE_ARCH_STRLEN
114 extern __kernel_size_t
__strlen(const char *);
116 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 91
117 extern __kernel_size_t
strlen(const char *);
119 /* Ugly but it works around a bug in our original sparc64-linux-gcc. */
121 #define strlen(__arg0) \
122 ({ int __strlen_res = __strlen(__arg0) + 1; \
128 #define __HAVE_ARCH_STRNCMP
130 extern int __strncmp(const char *, const char *, __kernel_size_t
);
132 extern inline int __constant_strncmp(const char *src
, const char *dest
, __kernel_size_t count
)
137 case 1: return (src
[0] - dest
[0]);
138 case 2: retval
= (src
[0] - dest
[0]);
139 if(!retval
&& src
[0])
140 retval
= (src
[1] - dest
[1]);
142 case 3: retval
= (src
[0] - dest
[0]);
143 if(!retval
&& src
[0]) {
144 retval
= (src
[1] - dest
[1]);
145 if(!retval
&& src
[1])
146 retval
= (src
[2] - dest
[2]);
149 case 4: retval
= (src
[0] - dest
[0]);
150 if(!retval
&& src
[0]) {
151 retval
= (src
[1] - dest
[1]);
152 if(!retval
&& src
[1]) {
153 retval
= (src
[2] - dest
[2]);
154 if (!retval
&& src
[2])
155 retval
= (src
[3] - dest
[3]);
159 case 5: retval
= (src
[0] - dest
[0]);
160 if(!retval
&& src
[0]) {
161 retval
= (src
[1] - dest
[1]);
162 if(!retval
&& src
[1]) {
163 retval
= (src
[2] - dest
[2]);
164 if (!retval
&& src
[2]) {
165 retval
= (src
[3] - dest
[3]);
166 if (!retval
&& src
[3])
167 retval
= (src
[4] - dest
[4]);
173 retval
= (src
[0] - dest
[0]);
174 if(!retval
&& src
[0]) {
175 retval
= (src
[1] - dest
[1]);
176 if(!retval
&& src
[1]) {
177 retval
= (src
[2] - dest
[2]);
178 if(!retval
&& src
[2])
179 retval
= __strncmp(src
+3,dest
+3,count
-3);
187 #define strncmp(__arg0, __arg1, __arg2) \
188 (__builtin_constant_p(__arg2) ? \
189 __constant_strncmp(__arg0, __arg1, __arg2) : \
190 __strncmp(__arg0, __arg1, __arg2))
192 #endif /* !EXPORT_SYMTAB_STROPS */
194 #endif /* __KERNEL__ */
196 #endif /* !(__SPARC64_STRING_H__) */