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 __SPARC_STRING_H__
10 #define __SPARC_STRING_H__
14 /* Really, userland/ksyms should not see any of this stuff. */
18 extern void __memmove(void *,const void *,__kernel_size_t
);
20 #ifndef EXPORT_SYMTAB_STROPS
22 /* First the mem*() things. */
23 #define __HAVE_ARCH_MEMMOVE
25 #define memmove(_to, _from, _n) \
28 __memmove(_t, (_from), (_n)); \
32 #define __HAVE_ARCH_MEMCPY
33 #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
35 #define __HAVE_ARCH_MEMSET
36 #define memset(s, c, count) __builtin_memset(s, c, count)
38 #define __HAVE_ARCH_MEMSCAN
41 #define memscan(__arg0, __char, __arg2) \
43 extern void *__memscan_zero(void *, size_t); \
44 extern void *__memscan_generic(void *, int, size_t); \
45 void *__retval, *__addr = (__arg0); \
46 size_t __size = (__arg2); \
48 if(__builtin_constant_p(__char) && !(__char)) \
49 __retval = __memscan_zero(__addr, __size); \
51 __retval = __memscan_generic(__addr, (__char), __size); \
56 #define __HAVE_ARCH_MEMCMP
57 extern int memcmp(const void *,const void *,__kernel_size_t
);
59 /* Now the str*() stuff... */
60 #define __HAVE_ARCH_STRLEN
61 extern __kernel_size_t
strlen(const char *);
63 #define __HAVE_ARCH_STRNCMP
65 extern int __strncmp(const char *, const char *, __kernel_size_t
);
67 static inline int __constant_strncmp(const char *src
, const char *dest
, __kernel_size_t count
)
72 case 1: return (src
[0] - dest
[0]);
73 case 2: retval
= (src
[0] - dest
[0]);
75 retval
= (src
[1] - dest
[1]);
77 case 3: retval
= (src
[0] - dest
[0]);
78 if(!retval
&& src
[0]) {
79 retval
= (src
[1] - dest
[1]);
81 retval
= (src
[2] - dest
[2]);
84 case 4: retval
= (src
[0] - dest
[0]);
85 if(!retval
&& src
[0]) {
86 retval
= (src
[1] - dest
[1]);
87 if(!retval
&& src
[1]) {
88 retval
= (src
[2] - dest
[2]);
89 if (!retval
&& src
[2])
90 retval
= (src
[3] - dest
[3]);
94 case 5: retval
= (src
[0] - dest
[0]);
95 if(!retval
&& src
[0]) {
96 retval
= (src
[1] - dest
[1]);
97 if(!retval
&& src
[1]) {
98 retval
= (src
[2] - dest
[2]);
99 if (!retval
&& src
[2]) {
100 retval
= (src
[3] - dest
[3]);
101 if (!retval
&& src
[3])
102 retval
= (src
[4] - dest
[4]);
108 retval
= (src
[0] - dest
[0]);
109 if(!retval
&& src
[0]) {
110 retval
= (src
[1] - dest
[1]);
111 if(!retval
&& src
[1]) {
112 retval
= (src
[2] - dest
[2]);
113 if(!retval
&& src
[2])
114 retval
= __strncmp(src
+3,dest
+3,count
-3);
122 #define strncmp(__arg0, __arg1, __arg2) \
123 (__builtin_constant_p(__arg2) ? \
124 __constant_strncmp(__arg0, __arg1, __arg2) : \
125 __strncmp(__arg0, __arg1, __arg2))
127 #endif /* !EXPORT_SYMTAB_STROPS */
129 #endif /* __KERNEL__ */
131 #endif /* !(__SPARC_STRING_H__) */