]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/i486/bits/string.h
1 /* Optimized, inlined string functions. i486 version.
2 Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 # error "Never use <bits/string.h> directly; include <string.h> instead."
24 /* The ix86 processors can access unaligned multi-byte variables. */
25 #define _STRING_ARCH_unaligned 1
28 /* We only provide optimizations if the user selects them and if
30 #if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \
31 && defined __GNUC__ && __GNUC__ >= 2 && !__BOUNDED_POINTERS__
33 #ifndef __STRING_INLINE
35 # define __STRING_INLINE inline
37 # define __STRING_INLINE extern __inline
41 /* The macros are used in some of the optimized implementations below. */
42 #define __STRING_SMALL_GET16(src, idx) \
43 (((src)[idx + 1] << 8) | (src)[idx])
44 #define __STRING_SMALL_GET32(src, idx) \
45 ((((src)[idx + 3] << 8 | (src)[idx + 2]) << 8 \
46 | (src)[idx + 1]) << 8 | (src)[idx])
49 /* Copy N bytes of SRC to DEST. */
50 #define _HAVE_STRING_ARCH_memcpy 1
51 #define memcpy(dest, src, n) \
52 (__extension__ (__builtin_constant_p (n) \
53 ? __memcpy_c (dest, src, n) \
54 : __memcpy_g (dest, src, n)))
55 #define __memcpy_c(dest, src, n) \
59 ? __memcpy_by4 (dest, src, n) \
61 ? __memcpy_by2 (dest, src, n) \
62 : __memcpy_g (dest, src, n))))
64 __STRING_INLINE
void *__memcpy_by4 (void *__dest
, __const
void *__src
,
67 __STRING_INLINE
void *
68 __memcpy_by4 (void *__dest
, __const
void *__src
, size_t __n
)
70 register unsigned long int __d0
, __d1
;
71 register void *__tmp
= __dest
;
80 : "=&r" (__d0
), "=&r" (__tmp
), "=&r" (__src
), "=&r" (__d1
)
81 : "1" (__tmp
), "2" (__src
), "3" (__n
/ 4)
86 __STRING_INLINE
void *__memcpy_by2 (void *__dest
, __const
void *__src
,
89 __STRING_INLINE
void *
90 __memcpy_by2 (void *__dest
, __const
void *__src
, size_t __n
)
92 register unsigned long int __d0
, __d1
;
93 register void *__tmp
= __dest
;
96 "jz 2f\n" /* only a word */
107 : "=&q" (__d0
), "=&r" (__tmp
), "=&r" (__src
), "=&r" (__d1
)
108 : "1" (__tmp
), "2" (__src
), "3" (__n
/ 2)
113 __STRING_INLINE
void *__memcpy_g (void *__dest
, __const
void *__src
,
116 __STRING_INLINE
void *
117 __memcpy_g (void *__dest
, __const
void *__src
, size_t __n
)
119 register unsigned long int __d0
, __d1
, __d2
;
120 register void *__tmp
= __dest
;
132 : "=&c" (__d0
), "=&D" (__d1
), "=&S" (__d2
)
133 : "0" (__n
), "1" (__tmp
), "2" (__src
)
138 #define _HAVE_STRING_ARCH_memmove 1
139 #ifndef _FORCE_INLINES
140 /* Copy N bytes of SRC to DEST, guaranteeing
141 correct behavior for overlapping strings. */
142 __STRING_INLINE
void *
143 memmove (void *__dest
, __const
void *__src
, size_t __n
)
145 register unsigned long int __d0
, __d1
, __d2
;
146 register void *__tmp
= __dest
;
151 : "=&c" (__d0
), "=&S" (__d1
), "=&D" (__d2
)
152 : "0" (__n
), "1" (__src
), "2" (__tmp
)
159 : "=&c" (__d0
), "=&S" (__d1
), "=&D" (__d2
)
160 : "0" (__n
), "1" (__n
- 1 + (__const
char *) __src
),
161 "2" (__n
- 1 + (char *) __tmp
)
167 /* Compare N bytes of S1 and S2. */
168 #define _HAVE_STRING_ARCH_memcmp 1
169 #ifndef _FORCE_INLINES
171 /* gcc has problems to spill registers when using PIC. */
173 memcmp (__const
void *__s1
, __const
void *__s2
, size_t __n
)
175 register unsigned long int __d0
, __d1
, __d2
;
185 : "=a" (__res
), "=&S" (__d0
), "=&D" (__d1
), "=&c" (__d2
)
186 : "0" (0), "1" (__s1
), "2" (__s2
), "3" (__n
)
193 /* Set N bytes of S to C. */
194 #define _HAVE_STRING_ARCH_memset 1
195 #define memset(s, c, n) \
196 (__extension__ (__builtin_constant_p (n) && (n) <= 16 \
198 ? __memset_c1 (s, c) \
199 : __memset_gc (s, c, n)) \
200 : (__builtin_constant_p (c) \
201 ? (__builtin_constant_p (n) \
202 ? __memset_ccn (s, c, n) \
203 : memset (s, c, n)) \
204 : (__builtin_constant_p (n) \
205 ? __memset_gcn (s, c, n) \
206 : memset (s, c, n)))))
208 #define __memset_c1(s, c) ({ void *__s = (s); \
209 *((unsigned char *) __s) = (unsigned char) (c); \
212 #define __memset_gc(s, c, n) \
213 ({ void *__s = (s); \
216 unsigned short int __usi; \
217 unsigned char __uc; \
219 unsigned int __c = ((unsigned int) ((unsigned char) (c))) * 0x01010101; \
221 /* We apply a trick here. `gcc' would implement the following \
222 assignments using immediate operands. But this uses to much \
223 memory (7, instead of 4 bytes). So we force the value in a \
225 if (n == 3 || n >= 5) \
226 __asm__ __volatile__ ("" : "=r" (__c) : "0" (__c)); \
228 /* This `switch' statement will be removed at compile-time. */ \
233 __u = __extension__ ((void *) __u + 4); \
236 __u = __extension__ ((void *) __u + 4); \
239 __u = __extension__ ((void *) __u + 4); \
241 __u->__usi = (unsigned short int) __c; \
242 __u = __extension__ ((void *) __u + 2); \
243 __u->__uc = (unsigned char) __c; \
248 __u = __extension__ ((void *) __u + 4); \
251 __u = __extension__ ((void *) __u + 4); \
254 __u = __extension__ ((void *) __u + 4); \
256 __u->__usi = (unsigned short int) __c; \
261 __u = __extension__ ((void *) __u + 4); \
264 __u = __extension__ ((void *) __u + 4); \
267 __u = __extension__ ((void *) __u + 4); \
269 __u->__uc = (unsigned char) __c; \
274 __u = __extension__ ((void *) __u + 4); \
277 __u = __extension__ ((void *) __u + 4); \
280 __u = __extension__ ((void *) __u + 4); \
289 #define __memset_ccn(s, c, n) \
291 ? __memset_ccn_by4 (s, ((unsigned int) ((unsigned char) (c))) * 0x01010101,\
294 ? __memset_ccn_by2 (s, \
295 ((unsigned int) ((unsigned char) (c))) * 0x01010101,\
299 __STRING_INLINE
void *__memset_ccn_by4 (void *__s
, unsigned int __c
,
302 __STRING_INLINE
void *
303 __memset_ccn_by4 (void *__s
, unsigned int __c
, size_t __n
)
305 register void *__tmp
= __s
;
306 register unsigned long int __d0
;
311 : "=&a" (__c
), "=&D" (__tmp
), "=&c" (__d0
)
312 : "0" ((unsigned int) __c
), "1" (__tmp
), "2" (__n
/ 4)
321 : "=&r" (__c
), "=&r" (__tmp
), "=&r" (__d0
)
322 : "0" ((unsigned int) __c
), "1" (__tmp
), "2" (__n
/ 4)
328 __STRING_INLINE
void *__memset_ccn_by2 (void *__s
, unsigned int __c
,
331 __STRING_INLINE
void *
332 __memset_ccn_by2 (void *__s
, unsigned int __c
, size_t __n
)
334 register unsigned long int __d0
, __d1
;
335 register void *__tmp
= __s
;
341 : "=&a" (__d0
), "=&D" (__tmp
), "=&c" (__d1
)
342 : "0" ((unsigned int) __c
), "1" (__tmp
), "2" (__n
/ 4)
346 ("1:\tmovl %0,(%1)\n\t"
351 : "=&q" (__d0
), "=&r" (__tmp
), "=&r" (__d1
)
352 : "0" ((unsigned int) __c
), "1" (__tmp
), "2" (__n
/ 4)
358 #define __memset_gcn(s, c, n) \
360 ? __memset_gcn_by4 (s, c, n) \
362 ? __memset_gcn_by2 (s, c, n) \
365 __STRING_INLINE
void *__memset_gcn_by4 (void *__s
, int __c
, size_t __n
);
367 __STRING_INLINE
void *
368 __memset_gcn_by4 (void *__s
, int __c
, size_t __n
)
370 register void *__tmp
= __s
;
371 register unsigned long int __d0
;
382 : "=&q" (__c
), "=&r" (__tmp
), "=&r" (__d0
)
383 : "0" ((unsigned int) __c
), "1" (__tmp
), "2" (__n
/ 4)
388 __STRING_INLINE
void *__memset_gcn_by2 (void *__s
, int __c
, size_t __n
);
390 __STRING_INLINE
void *
391 __memset_gcn_by2 (void *__s
, int __c
, size_t __n
)
393 register unsigned long int __d0
, __d1
;
394 register void *__tmp
= __s
;
406 : "=&q" (__d0
), "=&r" (__tmp
), "=&r" (__d1
)
407 : "0" ((unsigned int) __c
), "1" (__tmp
), "2" (__n
/ 4)
413 /* Search N bytes of S for C. */
414 #define _HAVE_STRING_ARCH_memchr 1
415 #ifndef _FORCE_INLINES
416 __STRING_INLINE
void *
417 memchr (__const
void *__s
, int __c
, size_t __n
)
419 register unsigned long int __d0
;
421 register unsigned long int __d1
;
423 register unsigned char *__res
;
431 : "=D" (__res
), "=&c" (__d0
), "=&r" (__d1
)
432 : "a" (__c
), "0" (__s
), "1" (__n
), "2" (1)
441 : "=D" (__res
), "=&c" (__d0
)
442 : "a" (__c
), "0" (__s
), "1" (__n
)
449 #define _HAVE_STRING_ARCH_memrchr 1
450 #ifndef _FORCE_INLINES
451 __STRING_INLINE
void *
452 __memrchr (__const
void *__s
, int __c
, size_t __n
)
454 register unsigned long int __d0
;
456 register unsigned long int __d1
;
458 register void *__res
;
467 : "=D" (__res
), "=&c" (__d0
), "=&r" (__d1
)
468 : "a" (__c
), "0" (__s
+ __n
- 1), "1" (__n
), "2" (-1)
477 : "=D" (__res
), "=&c" (__d0
)
478 : "a" (__c
), "0" (__s
+ __n
- 1), "1" (__n
)
484 # define memrchr(s, c, n) __memrchr (s, c, n)
488 /* Return pointer to C in S. */
489 #define _HAVE_STRING_ARCH_rawmemchr 1
490 __STRING_INLINE
void *__rawmemchr (const void *__s
, int __c
);
492 #ifndef _FORCE_INLINES
493 __STRING_INLINE
void *
494 __rawmemchr (const void *__s
, int __c
)
496 register unsigned long int __d0
;
497 register unsigned char *__res
;
501 : "=D" (__res
), "=&c" (__d0
)
502 : "a" (__c
), "0" (__s
), "1" (0xffffffff)
507 __STRING_INLINE
void *
508 rawmemchr (const void *__s
, int __c
)
510 return __rawmemchr (__s
, __c
);
512 # endif /* use GNU */
516 /* Return the length of S. */
517 #define _HAVE_STRING_ARCH_strlen 1
518 #define strlen(str) \
519 (__extension__ (__builtin_constant_p (str) \
520 ? __builtin_strlen (str) \
522 __STRING_INLINE
size_t __strlen_g (__const
char *__str
);
524 __STRING_INLINE
size_t
525 __strlen_g (__const
char *__str
)
527 register char __dummy
;
528 register __const
char *__tmp
= __str
;
535 : "=r" (__tmp
), "=&q" (__dummy
)
538 return __tmp
- __str
- 1;
542 /* Copy SRC to DEST. */
543 #define _HAVE_STRING_ARCH_strcpy 1
544 #define strcpy(dest, src) \
545 (__extension__ (__builtin_constant_p (src) \
546 ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8 \
547 ? __strcpy_small (dest, src, strlen (src) + 1) \
548 : (char *) memcpy ((char *) dest, \
549 (__const char *) src, \
551 : __strcpy_g (dest, src)))
553 #define __strcpy_small(dest, src, srclen) \
554 (__extension__ ({ char *__dest = (dest); \
557 unsigned short int __usi; \
558 unsigned char __uc; \
560 } *__u = (void *) __dest; \
567 __u->__usi = __STRING_SMALL_GET16 (src, 0); \
570 __u->__usi = __STRING_SMALL_GET16 (src, 0); \
571 __u = __extension__ ((void *) __u + 2); \
575 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
578 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
579 __u = __extension__ ((void *) __u + 4); \
583 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
584 __u = __extension__ ((void *) __u + 4); \
585 __u->__usi = __STRING_SMALL_GET16 (src, 4); \
588 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
589 __u = __extension__ ((void *) __u + 4); \
590 __u->__usi = __STRING_SMALL_GET16 (src, 4); \
591 __u = __extension__ ((void *) __u + 2); \
595 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
596 __u = __extension__ ((void *) __u + 4); \
597 __u->__ui = __STRING_SMALL_GET32 (src, 4); \
602 __STRING_INLINE
char *__strcpy_g (char *__dest
, __const
char *__src
);
604 __STRING_INLINE
char *
605 __strcpy_g (char *__dest
, __const
char *__src
)
607 register char *__tmp
= __dest
;
608 register char __dummy
;
618 : "=&r" (__src
), "=&r" (__tmp
), "=&q" (__dummy
)
619 : "0" (__src
), "1" (__tmp
)
626 # define _HAVE_STRING_ARCH_stpcpy 1
627 /* Copy SRC to DEST. */
628 # define __stpcpy(dest, src) \
629 (__extension__ (__builtin_constant_p (src) \
630 ? (strlen (src) + 1 <= 8 \
631 ? __stpcpy_small (dest, src, strlen (src) + 1) \
632 : __stpcpy_c (dest, src, strlen (src) + 1)) \
633 : __stpcpy_g (dest, src)))
634 # define __stpcpy_c(dest, src, srclen) \
636 ? __mempcpy_by4 (dest, src, srclen) - 1 \
637 : ((srclen) % 2 == 0 \
638 ? __mempcpy_by2 (dest, src, srclen) - 1 \
639 : __mempcpy_byn (dest, src, srclen) - 1))
641 /* In glibc itself we use this symbol for namespace reasons. */
642 # define stpcpy(dest, src) __stpcpy (dest, src)
644 # define __stpcpy_small(dest, src, srclen) \
645 (__extension__ ({ union { \
647 unsigned short int __usi; \
648 unsigned char __uc; \
650 } *__u = (void *) (dest); \
657 __u->__usi = __STRING_SMALL_GET16 (src, 0); \
658 __u = __extension__ ((void *) __u + 1); \
661 __u->__usi = __STRING_SMALL_GET16 (src, 0); \
662 __u = __extension__ ((void *) __u + 2); \
666 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
667 __u = __extension__ ((void *) __u + 3); \
670 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
671 __u = __extension__ ((void *) __u + 4); \
675 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
676 __u = __extension__ ((void *) __u + 4); \
677 __u->__usi = __STRING_SMALL_GET16 (src, 4); \
678 __u = __extension__ ((void *) __u + 1); \
681 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
682 __u = __extension__ ((void *) __u + 4); \
683 __u->__usi = __STRING_SMALL_GET16 (src, 4); \
684 __u = __extension__ ((void *) __u + 2); \
688 __u->__ui = __STRING_SMALL_GET32 (src, 0); \
689 __u = __extension__ ((void *) __u + 4); \
690 __u->__ui = __STRING_SMALL_GET32 (src, 4); \
691 __u = __extension__ ((void *) __u + 3); \
696 __STRING_INLINE
char *__mempcpy_by4 (char *__dest
, __const
char *__src
,
699 __STRING_INLINE
char *
700 __mempcpy_by4 (char *__dest
, __const
char *__src
, size_t __srclen
)
702 register char *__tmp
= __dest
;
703 register unsigned long int __d0
, __d1
;
712 : "=&r" (__d0
), "=r" (__tmp
), "=&r" (__src
), "=&r" (__d1
)
713 : "1" (__tmp
), "2" (__src
), "3" (__srclen
/ 4)
718 __STRING_INLINE
char *__mempcpy_by2 (char *__dest
, __const
char *__src
,
721 __STRING_INLINE
char *
722 __mempcpy_by2 (char *__dest
, __const
char *__src
, size_t __srclen
)
724 register char *__tmp
= __dest
;
725 register unsigned long int __d0
, __d1
;
728 "jz 2f\n" /* only a word */
739 : "=&q" (__d0
), "=r" (__tmp
), "=&r" (__src
), "=&r" (__d1
)
740 : "1" (__tmp
), "2" (__src
), "3" (__srclen
/ 2)
745 __STRING_INLINE
char *__mempcpy_byn (char *__dest
, __const
char *__src
,
748 __STRING_INLINE
char *
749 __mempcpy_byn (char *__dest
, __const
char *__src
, size_t __srclen
)
751 register unsigned long __d0
, __d1
;
752 register char *__tmp
= __dest
;
764 : "=D" (__tmp
), "=&c" (__d0
), "=&S" (__d1
)
765 : "0" (__tmp
), "1" (__srclen
), "2" (__src
)
770 __STRING_INLINE
char *__stpcpy_g (char *__dest
, __const
char *__src
);
772 __STRING_INLINE
char *
773 __stpcpy_g (char *__dest
, __const
char *__src
)
775 register char *__tmp
= __dest
;
776 register char __dummy
;
786 : "=&r" (__src
), "=r" (__tmp
), "=&q" (__dummy
)
787 : "0" (__src
), "1" (__tmp
)
794 /* Copy no more than N characters of SRC to DEST. */
795 #define _HAVE_STRING_ARCH_strncpy 1
796 #define strncpy(dest, src, n) \
797 (__extension__ (__builtin_constant_p (src) \
798 ? ((strlen (src) + 1 >= ((size_t) (n)) \
799 ? (char *) memcpy ((char *) dest, \
800 (__const char *) src, n) \
801 : __strncpy_cg (dest, src, strlen (src) + 1, n))) \
802 : __strncpy_gg (dest, src, n)))
803 #define __strncpy_cg(dest, src, srclen, n) \
804 (((srclen) % 4 == 0) \
805 ? __strncpy_by4 (dest, src, srclen, n) \
806 : (((srclen) % 2 == 0) \
807 ? __strncpy_by2 (dest, src, srclen, n) \
808 : __strncpy_byn (dest, src, srclen, n)))
810 __STRING_INLINE
char *__strncpy_by4 (char *__dest
, __const
char __src
[],
811 size_t __srclen
, size_t __n
);
813 __STRING_INLINE
char *
814 __strncpy_by4 (char *__dest
, __const
char __src
[], size_t __srclen
, size_t __n
)
816 register char *__tmp
= __dest
;
817 register int __dummy1
, __dummy2
;
826 : "=&r" (__dummy1
), "=r" (__tmp
), "=&r" (__src
), "=&r" (__dummy2
)
827 : "1" (__tmp
), "2" (__src
), "3" (__srclen
/ 4)
829 (void) memset (__tmp
, '\0', __n
- __srclen
);
833 __STRING_INLINE
char *__strncpy_by2 (char *__dest
, __const
char __src
[],
834 size_t __srclen
, size_t __n
);
836 __STRING_INLINE
char *
837 __strncpy_by2 (char *__dest
, __const
char __src
[], size_t __srclen
, size_t __n
)
839 register char *__tmp
= __dest
;
840 register int __dummy1
, __dummy2
;
843 "jz 2f\n" /* only a word */
854 : "=&q" (__dummy1
), "=r" (__tmp
), "=&r" (__src
), "=&r" (__dummy2
)
855 : "1" (__tmp
), "2" (__src
), "3" (__srclen
/ 2)
857 (void) memset (__tmp
+ 2, '\0', __n
- __srclen
);
861 __STRING_INLINE
char *__strncpy_byn (char *__dest
, __const
char __src
[],
862 size_t __srclen
, size_t __n
);
864 __STRING_INLINE
char *
865 __strncpy_byn (char *__dest
, __const
char __src
[], size_t __srclen
, size_t __n
)
867 register unsigned long int __d0
, __d1
;
868 register char *__tmp
= __dest
;
880 : "=D" (__tmp
), "=&c" (__d0
), "=&S" (__d1
)
881 : "1" (__srclen
), "0" (__tmp
),"2" (__src
)
883 (void) memset (__tmp
, '\0', __n
- __srclen
);
887 __STRING_INLINE
char *__strncpy_gg (char *__dest
, __const
char *__src
,
890 __STRING_INLINE
char *
891 __strncpy_gg (char *__dest
, __const
char *__src
, size_t __n
)
893 register char *__tmp
= __dest
;
894 register char __dummy
;
912 : "=&r" (__src
), "=&r" (__tmp
), "=&q" (__dummy
), "=&r" (__n
)
913 : "0" (__src
), "1" (__tmp
), "3" (__n
)
920 /* Append SRC onto DEST. */
921 #define _HAVE_STRING_ARCH_strcat 1
922 #define strcat(dest, src) \
923 (__extension__ (__builtin_constant_p (src) \
924 ? __strcat_c (dest, src, strlen (src) + 1) \
925 : __strcat_g (dest, src)))
927 __STRING_INLINE
char *__strcat_c (char *__dest
, __const
char __src
[],
930 __STRING_INLINE
char *
931 __strcat_c (char *__dest
, __const
char __src
[], size_t __srclen
)
934 register unsigned long int __d0
;
935 register char *__tmp
;
938 : "=D" (__tmp
), "=&c" (__d0
)
939 : "0" (__dest
), "1" (0xffffffff), "a" (0)
943 register char *__tmp
= __dest
- 1;
953 (void) memcpy (__tmp
, __src
, __srclen
);
957 __STRING_INLINE
char *__strcat_g (char *__dest
, __const
char *__src
);
959 __STRING_INLINE
char *
960 __strcat_g (char *__dest
, __const
char *__src
)
962 register char *__tmp
= __dest
- 1;
963 register char __dummy
;
976 : "=&q" (__dummy
), "=&r" (__tmp
), "=&r" (__src
)
977 : "1" (__tmp
), "2" (__src
)
983 /* Append no more than N characters from SRC onto DEST. */
984 #define _HAVE_STRING_ARCH_strncat 1
985 #define strncat(dest, src, n) \
986 (__extension__ ({ char *__dest = (dest); \
987 __builtin_constant_p (src) && __builtin_constant_p (n) \
988 ? (strlen (src) < ((size_t) (n)) \
989 ? strcat (__dest, src) \
990 : (memcpy (strchr (__dest, '\0'), \
991 (__const char *) src, n), __dest)) \
992 : __strncat_g (__dest, src, n); }))
994 __STRING_INLINE
char *__strncat_g (char *__dest
, __const
char __src
[],
997 __STRING_INLINE
char *
998 __strncat_g (char *__dest
, __const
char __src
[], size_t __n
)
1000 register char *__tmp
= __dest
;
1001 register char __dummy
;
1003 __asm__ __volatile__
1016 : "=&a" (__dummy
), "=&D" (__tmp
), "=&S" (__src
), "=&r" (__n
)
1017 : "0" (0), "1" (__tmp
), "2" (__src
), "3" (__n
)
1021 __asm__ __volatile__
1038 : "=&q" (__dummy
), "=&r" (__tmp
), "=&r" (__src
), "=&r" (__n
)
1039 : "1" (__tmp
), "2" (__src
), "3" (__n
)
1046 /* Compare S1 and S2. */
1047 #define _HAVE_STRING_ARCH_strcmp 1
1048 #define strcmp(s1, s2) \
1049 (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2) \
1050 && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4) \
1051 && (sizeof ((s2)[0]) != 1 || strlen (s2) >= 4) \
1052 ? memcmp ((__const char *) s1, (__const char *) s2, \
1053 (strlen (s1) < strlen (s2) \
1054 ? strlen (s1) : strlen (s2)) + 1) \
1055 : (__builtin_constant_p (s1) && sizeof ((s1)[0]) == 1 \
1056 && sizeof ((s2)[0]) == 1 && strlen (s1) < 4 \
1057 ? (__builtin_constant_p (s2) && sizeof ((s2)[0]) == 1 \
1058 ? __strcmp_cc (s1, s2, strlen (s1)) \
1059 : __strcmp_cg (s1, s2, strlen (s1))) \
1060 : (__builtin_constant_p (s2) && sizeof ((s1)[0]) == 1 \
1061 && sizeof ((s2)[0]) == 1 && strlen (s2) < 4 \
1062 ? (__builtin_constant_p (s1) \
1063 ? __strcmp_cc (s1, s2, strlen (s2)) \
1064 : __strcmp_gc (s1, s2, strlen (s2))) \
1065 : __strcmp_gg (s1, s2)))))
1067 #define __strcmp_cc(s1, s2, l) \
1068 (__extension__ ({ register int __result = ((unsigned char) (s1)[0] \
1069 - (unsigned char) (s2)[0]); \
1070 if (l > 0 && __result == 0) \
1072 __result = ((unsigned char) (s1)[1] \
1073 - (unsigned char) (s2)[1]); \
1074 if (l > 1 && __result == 0) \
1076 __result = ((unsigned char) (s1)[2] \
1077 - (unsigned char) (s2)[2]); \
1078 if (l > 2 && __result == 0) \
1079 __result = ((unsigned char) (s1)[3] \
1080 - (unsigned char) (s2)[3]); \
1085 #define __strcmp_cg(s1, s2, l1) \
1086 (__extension__ ({ __const unsigned char *__s2 = (unsigned char *) (s2); \
1087 register int __result = (unsigned char) (s1)[0] - __s2[0];\
1088 if (l1 > 0 && __result == 0) \
1090 __result = (unsigned char) (s1)[1] - __s2[1]; \
1091 if (l1 > 1 && __result == 0) \
1093 __result = (unsigned char) (s1)[2] - __s2[2]; \
1094 if (l1 > 2 && __result == 0) \
1095 __result = (unsigned char) (s1)[3] - __s2[3]; \
1100 #define __strcmp_gc(s1, s2, l2) \
1101 (__extension__ ({ __const unsigned char *__s1 = (unsigned char *) (s1); \
1102 register int __result = __s1[0] - (unsigned char) (s2)[0];\
1103 if (l2 > 0 && __result == 0) \
1105 __result = __s1[1] - (unsigned char) (s2)[1]; \
1106 if (l2 > 1 && __result == 0) \
1108 __result = __s1[2] - (unsigned char) (s2)[2]; \
1109 if (l2 > 2 && __result == 0) \
1110 __result = __s1[3] - (unsigned char) (s2)[3]; \
1115 __STRING_INLINE
int __strcmp_gg (__const
char *__s1
, __const
char *__s2
);
1118 __strcmp_gg (__const
char *__s1
, __const
char *__s2
)
1121 __asm__ __volatile__
1137 : "=q" (__res
), "=&r" (__s1
), "=&r" (__s2
)
1138 : "1" (__s1
), "2" (__s2
)
1144 /* Compare N characters of S1 and S2. */
1145 #define _HAVE_STRING_ARCH_strncmp 1
1146 #define strncmp(s1, s2, n) \
1147 (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n)) \
1149 : (__builtin_constant_p (s2) && strlen (s2) < ((size_t) (n))\
1151 : __strncmp_g (s1, s2, n))))
1153 __STRING_INLINE
int __strncmp_g (__const
char *__s1
, __const
char *__s2
,
1157 __strncmp_g (__const
char *__s1
, __const
char *__s2
, size_t __n
)
1160 __asm__ __volatile__
1179 : "=q" (__res
), "=&r" (__s1
), "=&r" (__s2
), "=&r" (__n
)
1180 : "1" (__s1
), "2" (__s2
), "3" (__n
)
1186 /* Find the first occurrence of C in S. */
1187 #define _HAVE_STRING_ARCH_strchr 1
1188 #define strchr(s, c) \
1189 (__extension__ (__builtin_constant_p (c) \
1191 ? (char *) __rawmemchr (s, c) \
1192 : __strchr_c (s, ((c) & 0xff) << 8)) \
1193 : __strchr_g (s, c)))
1195 __STRING_INLINE
char *__strchr_c (__const
char *__s
, int __c
);
1197 __STRING_INLINE
char *
1198 __strchr_c (__const
char *__s
, int __c
)
1200 register unsigned long int __d0
;
1201 register char *__res
;
1202 __asm__ __volatile__
1204 "movb (%0),%%al\n\t"
1205 "cmpb %%ah,%%al\n\t"
1208 "testb %%al,%%al\n\t"
1212 : "=r" (__res
), "=&a" (__d0
)
1213 : "0" (__s
), "1" (__c
)
1218 __STRING_INLINE
char *__strchr_g (__const
char *__s
, int __c
);
1220 __STRING_INLINE
char *
1221 __strchr_g (__const
char *__s
, int __c
)
1223 register unsigned long int __d0
;
1224 register char *__res
;
1225 __asm__ __volatile__
1228 "movb (%0),%%al\n\t"
1229 "cmpb %%ah,%%al\n\t"
1232 "testb %%al,%%al\n\t"
1236 : "=r" (__res
), "=&a" (__d0
)
1237 : "0" (__s
), "1" (__c
)
1243 /* Find the first occurrence of C in S or the final NUL byte. */
1244 #define _HAVE_STRING_ARCH_strchrnul 1
1245 #define __strchrnul(s, c) \
1246 (__extension__ (__builtin_constant_p (c) \
1248 ? (char *) __rawmemchr (s, c) \
1249 : __strchrnul_c (s, ((c) & 0xff) << 8)) \
1250 : __strchrnul_g (s, c)))
1252 __STRING_INLINE
char *__strchrnul_c (__const
char *__s
, int __c
);
1254 __STRING_INLINE
char *
1255 __strchrnul_c (__const
char *__s
, int __c
)
1257 register unsigned long int __d0
;
1258 register char *__res
;
1259 __asm__ __volatile__
1261 "movb (%0),%%al\n\t"
1262 "cmpb %%ah,%%al\n\t"
1265 "testb %%al,%%al\n\t"
1269 : "=r" (__res
), "=&a" (__d0
)
1270 : "0" (__s
), "1" (__c
)
1275 __STRING_INLINE
char *__strchrnul_g (__const
char *__s
, int __c
);
1277 __STRING_INLINE
char *
1278 __strchrnul_g (__const
char *__s
, int __c
)
1280 register unsigned long int __d0
;
1281 register char *__res
;
1282 __asm__ __volatile__
1285 "movb (%0),%%al\n\t"
1286 "cmpb %%ah,%%al\n\t"
1289 "testb %%al,%%al\n\t"
1293 : "=r" (__res
), "=&a" (__d0
)
1294 : "0" (__s
), "1" (__c
)
1299 # define strchrnul(s, c) __strchrnul (s, c)
1303 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
1304 /* Find the first occurrence of C in S. This is the BSD name. */
1305 # define _HAVE_STRING_ARCH_index 1
1306 # define index(s, c) \
1307 (__extension__ (__builtin_constant_p (c) \
1308 ? __strchr_c (s, ((c) & 0xff) << 8) \
1309 : __strchr_g (s, c)))
1313 /* Find the last occurrence of C in S. */
1314 #define _HAVE_STRING_ARCH_strrchr 1
1315 #define strrchr(s, c) \
1316 (__extension__ (__builtin_constant_p (c) \
1317 ? __strrchr_c (s, ((c) & 0xff) << 8) \
1318 : __strrchr_g (s, c)))
1321 __STRING_INLINE
char *__strrchr_c (__const
char *__s
, int __c
);
1323 __STRING_INLINE
char *
1324 __strrchr_c (__const
char *__s
, int __c
)
1326 register unsigned long int __d0
, __d1
;
1327 register char *__res
;
1328 __asm__ __volatile__
1336 : "=d" (__res
), "=&S" (__d0
), "=&a" (__d1
)
1337 : "0" (1), "1" (__s
), "2" (__c
)
1342 __STRING_INLINE
char *__strrchr_g (__const
char *__s
, int __c
);
1344 __STRING_INLINE
char *
1345 __strrchr_g (__const
char *__s
, int __c
)
1347 register unsigned long int __d0
, __d1
;
1348 register char *__res
;
1349 __asm__ __volatile__
1358 : "=d" (__res
), "=&S" (__d0
), "=&a" (__d1
)
1359 : "0" (1), "1" (__s
), "2" (__c
)
1364 __STRING_INLINE
char *__strrchr_c (__const
char *__s
, int __c
);
1366 __STRING_INLINE
char *
1367 __strrchr_c (__const
char *__s
, int __c
)
1369 register unsigned long int __d0
, __d1
;
1370 register char *__res
;
1371 __asm__ __volatile__
1375 "cmpb %%ah,%%al\n\t"
1377 "leal -1(%%esi),%0\n"
1379 "testb %%al,%%al\n\t"
1381 : "=d" (__res
), "=&S" (__d0
), "=&a" (__d1
)
1382 : "0" (0), "1" (__s
), "2" (__c
)
1387 __STRING_INLINE
char *__strrchr_g (__const
char *__s
, int __c
);
1389 __STRING_INLINE
char *
1390 __strrchr_g (__const
char *__s
, int __c
)
1392 register unsigned long int __d0
, __d1
;
1393 register char *__res
;
1394 __asm__ __volatile__
1399 "cmpb %%ah,%%al\n\t"
1401 "leal -1(%%esi),%0\n"
1403 "testb %%al,%%al\n\t"
1405 : "=r" (__res
), "=&S" (__d0
), "=&a" (__d1
)
1406 : "0" (0), "1" (__s
), "2" (__c
)
1413 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
1414 /* Find the last occurrence of C in S. This is the BSD name. */
1415 # define _HAVE_STRING_ARCH_rindex 1
1416 # define rindex(s, c) \
1417 (__extension__ (__builtin_constant_p (c) \
1418 ? __strrchr_c (s, ((c) & 0xff) << 8) \
1419 : __strrchr_g (s, c)))
1423 /* Return the length of the initial segment of S which
1424 consists entirely of characters not in REJECT. */
1425 #define _HAVE_STRING_ARCH_strcspn 1
1426 #define strcspn(s, reject) \
1427 (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1 \
1428 ? ((reject)[0] == '\0' \
1430 : ((reject)[1] == '\0' \
1431 ? __strcspn_c1 (s, (((reject)[0] << 8) & 0xff00)) \
1432 : __strcspn_cg (s, reject, strlen (reject)))) \
1433 : __strcspn_g (s, reject)))
1435 __STRING_INLINE
size_t __strcspn_c1 (__const
char *__s
, int __reject
);
1437 __STRING_INLINE
size_t
1438 __strcspn_c1 (__const
char *__s
, int __reject
)
1440 register unsigned long int __d0
;
1441 register char *__res
;
1442 __asm__ __volatile__
1444 "movb (%0),%%al\n\t"
1446 "cmpb %%ah,%%al\n\t"
1448 "testb %%al,%%al\n\t"
1451 : "=r" (__res
), "=&a" (__d0
)
1452 : "0" (__s
), "1" (__reject
)
1454 return (__res
- 1) - __s
;
1457 __STRING_INLINE
size_t __strcspn_cg (__const
char *__s
, __const
char __reject
[],
1458 size_t __reject_len
);
1460 __STRING_INLINE
size_t
1461 __strcspn_cg (__const
char *__s
, __const
char __reject
[], size_t __reject_len
)
1463 register unsigned long int __d0
, __d1
, __d2
;
1464 register __const
char *__res
;
1465 __asm__ __volatile__
1469 "testb %%al,%%al\n\t"
1476 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
)
1477 : "0" (__s
), "d" (__reject
), "g" (__reject_len
)
1479 return (__res
- 1) - __s
;
1482 __STRING_INLINE
size_t __strcspn_g (__const
char *__s
, __const
char *__reject
);
1485 __STRING_INLINE
size_t
1486 __strcspn_g (__const
char *__s
, __const
char *__reject
)
1488 register unsigned long int __d0
, __d1
, __d2
;
1489 register __const
char *__res
;
1490 __asm__ __volatile__
1496 "leal -1(%%ecx),%%ebx\n"
1499 "testb %%al,%%al\n\t"
1502 "movl %%ebx,%%ecx\n\t"
1507 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
)
1508 : "r" (__reject
), "0" (__s
), "1" (0), "2" (0xffffffff)
1510 return (__res
- 1) - __s
;
1513 __STRING_INLINE
size_t
1514 __strcspn_g (__const
char *__s
, __const
char *__reject
)
1516 register unsigned long int __d0
, __d1
, __d2
, __d3
;
1517 register __const
char *__res
;
1518 __asm__ __volatile__
1522 "leal -1(%%ecx),%%edx\n"
1525 "testb %%al,%%al\n\t"
1527 "movl %%ebx,%%edi\n\t"
1528 "movl %%edx,%%ecx\n\t"
1532 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
), "=&d" (__d3
)
1533 : "0" (__s
), "1" (0), "2" (0xffffffff), "3" (__reject
), "b" (__reject
)
1535 return (__res
- 1) - __s
;
1540 /* Return the length of the initial segment of S which
1541 consists entirely of characters in ACCEPT. */
1542 #define _HAVE_STRING_ARCH_strspn 1
1543 #define strspn(s, accept) \
1544 (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1 \
1545 ? ((accept)[0] == '\0' \
1547 : ((accept)[1] == '\0' \
1548 ? __strspn_c1 (s, (((accept)[0] << 8 ) & 0xff00)) \
1549 : __strspn_cg (s, accept, strlen (accept)))) \
1550 : __strspn_g (s, accept)))
1552 __STRING_INLINE
size_t __strspn_c1 (__const
char *__s
, int __accept
);
1554 __STRING_INLINE
size_t
1555 __strspn_c1 (__const
char *__s
, int __accept
)
1557 register unsigned long int __d0
;
1558 register char *__res
;
1559 /* Please note that __accept never can be '\0'. */
1560 __asm__ __volatile__
1566 : "=r" (__res
), "=&q" (__d0
)
1567 : "0" (__s
), "1" (__accept
)
1569 return (__res
- 1) - __s
;
1572 __STRING_INLINE
size_t __strspn_cg (__const
char *__s
, __const
char __accept
[],
1573 size_t __accept_len
);
1575 __STRING_INLINE
size_t
1576 __strspn_cg (__const
char *__s
, __const
char __accept
[], size_t __accept_len
)
1578 register unsigned long int __d0
, __d1
, __d2
;
1579 register __const
char *__res
;
1580 __asm__ __volatile__
1584 "testb %%al,%%al\n\t"
1591 : "=S" (__res
), "=&d" (__d0
), "=&c" (__d1
), "=&D" (__d2
)
1592 : "0" (__s
), "1" (__accept
), "g" (__accept_len
)
1594 return (__res
- 1) - __s
;
1597 __STRING_INLINE
size_t __strspn_g (__const
char *__s
, __const
char *__accept
);
1600 __STRING_INLINE
size_t
1601 __strspn_g (__const
char *__s
, __const
char *__accept
)
1603 register unsigned long int __d0
, __d1
, __d2
;
1604 register __const
char *__res
;
1605 __asm__ __volatile__
1610 "leal -1(%%ecx),%%ebx\n"
1613 "testb %%al,%%al\n\t"
1615 "movl %%edx,%%edi\n\t"
1616 "movl %%ebx,%%ecx\n\t"
1621 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
)
1622 : "d" (__accept
), "0" (__s
), "1" (0), "2" (0xffffffff), "3" (__accept
)
1624 return (__res
- 1) - __s
;
1627 __STRING_INLINE
size_t
1628 __strspn_g (__const
char *__s
, __const
char *__accept
)
1630 register unsigned long int __d0
, __d1
, __d2
, __d3
;
1631 register __const
char *__res
;
1632 __asm__ __volatile__
1636 "leal -1(%%ecx),%%edx\n"
1639 "testb %%al,%%al\n\t"
1641 "movl %%ebx,%%edi\n\t"
1642 "movl %%edx,%%ecx\n\t"
1646 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
), "=&d" (__d3
)
1647 : "0" (__s
), "1" (0), "2" (0xffffffff), "3" (__accept
), "b" (__accept
)
1649 return (__res
- 1) - __s
;
1654 /* Find the first occurrence in S of any character in ACCEPT. */
1655 #define _HAVE_STRING_ARCH_strpbrk 1
1656 #define strpbrk(s, accept) \
1657 (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1 \
1658 ? ((accept)[0] == '\0' \
1660 : ((accept)[1] == '\0' \
1661 ? strchr (s, (accept)[0]) \
1662 : __strpbrk_cg (s, accept, strlen (accept)))) \
1663 : __strpbrk_g (s, accept)))
1665 __STRING_INLINE
char *__strpbrk_cg (__const
char *__s
, __const
char __accept
[],
1666 size_t __accept_len
);
1668 __STRING_INLINE
char *
1669 __strpbrk_cg (__const
char *__s
, __const
char __accept
[], size_t __accept_len
)
1671 register unsigned long int __d0
, __d1
, __d2
;
1672 register char *__res
;
1673 __asm__ __volatile__
1677 "testb %%al,%%al\n\t"
1688 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
)
1689 : "0" (__s
), "d" (__accept
), "g" (__accept_len
)
1694 __STRING_INLINE
char *__strpbrk_g (__const
char *__s
, __const
char *__accept
);
1697 __STRING_INLINE
char *
1698 __strpbrk_g (__const
char *__s
, __const
char *__accept
)
1700 register unsigned long int __d0
, __d1
, __d2
;
1701 register char *__res
;
1702 __asm__ __volatile__
1704 "movl %%edx,%%edi\n\t"
1708 "leal -1(%%ecx),%%ebx\n"
1711 "testb %%al,%%al\n\t"
1713 "movl %%edx,%%edi\n\t"
1714 "movl %%ebx,%%ecx\n\t"
1723 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&D" (__d2
)
1724 : "d" (__accept
), "0" (__s
), "1" (0), "2" (0xffffffff)
1729 __STRING_INLINE
char *
1730 __strpbrk_g (__const
char *__s
, __const
char *__accept
)
1732 register unsigned long int __d0
, __d1
, __d2
, __d3
;
1733 register char *__res
;
1734 __asm__ __volatile__
1735 ("movl %%ebx,%%edi\n\t"
1739 "leal -1(%%ecx),%%edx\n"
1742 "testb %%al,%%al\n\t"
1744 "movl %%ebx,%%edi\n\t"
1745 "movl %%edx,%%ecx\n\t"
1753 : "=S" (__res
), "=&a" (__d0
), "=&c" (__d1
), "=&d" (__d2
), "=&D" (__d3
)
1754 : "0" (__s
), "1" (0), "2" (0xffffffff), "b" (__accept
)
1761 /* Find the first occurrence of NEEDLE in HAYSTACK. */
1762 #define _HAVE_STRING_ARCH_strstr 1
1763 #define strstr(haystack, needle) \
1764 (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1 \
1765 ? ((needle)[0] == '\0' \
1767 : ((needle)[1] == '\0' \
1768 ? strchr (haystack, (needle)[0]) \
1769 : __strstr_cg (haystack, needle, strlen (needle)))) \
1770 : __strstr_g (haystack, needle)))
1772 /* Please note that this function need not handle NEEDLEs with a
1773 length shorter than two. */
1774 __STRING_INLINE
char *__strstr_cg (__const
char *__haystack
, __const
char __needle
[],
1775 size_t __needle_len
);
1777 __STRING_INLINE
char *
1778 __strstr_cg (__const
char *__haystack
, __const
char __needle
[],
1779 size_t __needle_len
)
1781 register unsigned long int __d0
, __d1
, __d2
;
1782 register char *__res
;
1783 __asm__ __volatile__
1791 "cmpb $0,-1(%%esi)\n\t"
1792 "leal 1(%%eax),%5\n\t"
1794 "xorl %%eax,%%eax\n"
1796 : "=a" (__res
), "=&S" (__d0
), "=&D" (__d1
), "=&c" (__d2
)
1797 : "g" (__needle_len
), "1" (__haystack
), "d" (__needle
)
1802 __STRING_INLINE
char *__strstr_g (__const
char *__haystack
, __const
char *__needle
);
1805 __STRING_INLINE
char *
1806 __strstr_g (__const
char *__haystack
, __const
char *__needle
)
1808 register unsigned long int __d0
, __d1
, __d2
;
1809 register char *__res
;
1810 __asm__ __volatile__
1815 "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
1816 "movl %%ecx,%%ebx\n"
1818 "movl %%edx,%%edi\n\t"
1819 "movl %%esi,%%eax\n\t"
1820 "movl %%ebx,%%ecx\n\t"
1822 "je 2f\n\t" /* also works for empty string, see above */
1823 "cmpb $0,-1(%%esi)\n\t"
1824 "leal 1(%%eax),%%esi\n\t"
1826 "xorl %%eax,%%eax\n"
1829 : "=a" (__res
), "=&c" (__d0
), "=&S" (__d1
), "=&D" (__d2
)
1830 : "0" (0), "1" (0xffffffff), "2" (__haystack
), "3" (__needle
),
1836 __STRING_INLINE
char *
1837 __strstr_g (__const
char *__haystack
, __const
char *__needle
)
1839 register unsigned long int __d0
, __d1
, __d2
, __d3
;
1840 register char *__res
;
1841 __asm__ __volatile__
1845 "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
1846 "movl %%ecx,%%edx\n"
1848 "movl %%ebx,%%edi\n\t"
1849 "movl %%esi,%%eax\n\t"
1850 "movl %%edx,%%ecx\n\t"
1852 "je 2f\n\t" /* also works for empty string, see above */
1853 "cmpb $0,-1(%%esi)\n\t"
1854 "leal 1(%%eax),%%esi\n\t"
1856 "xorl %%eax,%%eax\n"
1858 : "=a" (__res
), "=&c" (__d0
), "=&S" (__d1
), "=&D" (__d2
), "=&d" (__d3
)
1859 : "0" (0), "1" (0xffffffff), "2" (__haystack
), "3" (__needle
),
1867 /* Bit find functions. We define only the i686 version since for the other
1868 processors gcc generates good code. */
1869 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
1871 # define _HAVE_STRING_ARCH_ffs 1
1872 # define ffs(word) (__builtin_constant_p (word) \
1873 ? __builtin_ffs (word) \
1874 : ({ int __cnt, __tmp; \
1875 __asm__ __volatile__ \
1878 : "=&r" (__cnt), "=r" (__tmp) \
1879 : "rm" (word), "1" (-1)); \
1883 # define ffsl(word) ffs(word)
1886 #endif /* BSD || X/Open */
1888 #ifndef _FORCE_INLINES
1889 # undef __STRING_INLINE
1892 #endif /* use string inlines && GNU CC */