Back to index

glibc  2.9
string.h
Go to the documentation of this file.
00001 /* Optimized, inlined string functions.  i486 version.
00002    Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2004,2007
00003        Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _STRING_H
00022 # error "Never use <bits/string.h> directly; include <string.h> instead."
00023 #endif
00024 
00025 /* The ix86 processors can access unaligned multi-byte variables.  */
00026 #define _STRING_ARCH_unaligned     1
00027 
00028 
00029 /* We only provide optimizations if the user selects them and if
00030    GNU CC is used.  */
00031 #if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \
00032     && defined __GNUC__ && __GNUC__ >= 2 && !__BOUNDED_POINTERS__
00033 
00034 #ifndef __STRING_INLINE
00035 # ifndef __extern_inline
00036 #  define __STRING_INLINE inline
00037 # else
00038 #  define __STRING_INLINE __extern_inline
00039 # endif
00040 #endif
00041 
00042 /* The macros are used in some of the optimized implementations below.  */
00043 #define __STRING_SMALL_GET16(src, idx) \
00044   ((((__const unsigned char *) (src))[idx + 1] << 8)                        \
00045    | ((__const unsigned char *) (src))[idx])
00046 #define __STRING_SMALL_GET32(src, idx) \
00047   (((((__const unsigned char *) (src))[idx + 3] << 8                        \
00048      | ((__const unsigned char *) (src))[idx + 2]) << 8                     \
00049     | ((__const unsigned char *) (src))[idx + 1]) << 8                      \
00050    | ((__const unsigned char *) (src))[idx])
00051 
00052 
00053 /* Copy N bytes of SRC to DEST.  */
00054 #define _HAVE_STRING_ARCH_memcpy 1
00055 #define memcpy(dest, src, n) \
00056   (__extension__ (__builtin_constant_p (n)                                  \
00057                 ? __memcpy_c ((dest), (src), (n))                           \
00058                 : __memcpy_g ((dest), (src), (n))))
00059 #define __memcpy_c(dest, src, n) \
00060   ((n) == 0                                                          \
00061    ? (dest)                                                          \
00062    : (((n) % 4 == 0)                                                 \
00063       ? __memcpy_by4 (dest, src, n)                                         \
00064       : (((n) % 2 == 0)                                                     \
00065         ? __memcpy_by2 (dest, src, n)                                       \
00066         : __memcpy_g (dest, src, n))))
00067 
00068 __STRING_INLINE void *__memcpy_by4 (void *__dest, __const void *__src,
00069                                 size_t __n);
00070 
00071 __STRING_INLINE void *
00072 __memcpy_by4 (void *__dest, __const void *__src, size_t __n)
00073 {
00074   register unsigned long int __d0, __d1;
00075   register void *__tmp = __dest;
00076   __asm__ __volatile__
00077     ("1:\n\t"
00078      "movl    (%2),%0\n\t"
00079      "leal    4(%2),%2\n\t"
00080      "movl    %0,(%1)\n\t"
00081      "leal    4(%1),%1\n\t"
00082      "decl    %3\n\t"
00083      "jnz     1b"
00084      : "=&r" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1)
00085      : "1" (__tmp), "2" (__src), "3" (__n / 4)
00086      : "memory", "cc");
00087   return __dest;
00088 }
00089 
00090 __STRING_INLINE void *__memcpy_by2 (void *__dest, __const void *__src,
00091                                 size_t __n);
00092 
00093 __STRING_INLINE void *
00094 __memcpy_by2 (void *__dest, __const void *__src, size_t __n)
00095 {
00096   register unsigned long int __d0, __d1;
00097   register void *__tmp = __dest;
00098   __asm__ __volatile__
00099     ("shrl    $1,%3\n\t"
00100      "jz      2f\n"                 /* only a word */
00101      "1:\n\t"
00102      "movl    (%2),%0\n\t"
00103      "leal    4(%2),%2\n\t"
00104      "movl    %0,(%1)\n\t"
00105      "leal    4(%1),%1\n\t"
00106      "decl    %3\n\t"
00107      "jnz     1b\n"
00108      "2:\n\t"
00109      "movw    (%2),%w0\n\t"
00110      "movw    %w0,(%1)"
00111      : "=&q" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1)
00112      : "1" (__tmp), "2" (__src), "3" (__n / 2)
00113      : "memory", "cc");
00114   return __dest;
00115 }
00116 
00117 __STRING_INLINE void *__memcpy_g (void *__dest, __const void *__src,
00118                               size_t __n);
00119 
00120 __STRING_INLINE void *
00121 __memcpy_g (void *__dest, __const void *__src, size_t __n)
00122 {
00123   register unsigned long int __d0, __d1, __d2;
00124   register void *__tmp = __dest;
00125   __asm__ __volatile__
00126     ("cld\n\t"
00127      "shrl    $1,%%ecx\n\t"
00128      "jnc     1f\n\t"
00129      "movsb\n"
00130      "1:\n\t"
00131      "shrl    $1,%%ecx\n\t"
00132      "jnc     2f\n\t"
00133      "movsw\n"
00134      "2:\n\t"
00135      "rep; movsl"
00136      : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2),
00137        "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest)
00138      : "0" (__n), "1" (__tmp), "2" (__src),
00139        "m" ( *(struct { __extension__ char __x[__n]; } *)__src)
00140      : "cc");
00141   return __dest;
00142 }
00143 
00144 #define _HAVE_STRING_ARCH_memmove 1
00145 #ifndef _FORCE_INLINES
00146 /* Copy N bytes of SRC to DEST, guaranteeing
00147    correct behavior for overlapping strings.  */
00148 #define memmove(dest, src, n) __memmove_g (dest, src, n)
00149 
00150 __STRING_INLINE void *__memmove_g (void *, __const void *, size_t)
00151      __asm__ ("memmove");
00152 
00153 __STRING_INLINE void *
00154 __memmove_g (void *__dest, __const void *__src, size_t __n)
00155 {
00156   register unsigned long int __d0, __d1, __d2;
00157   register void *__tmp = __dest;
00158   if (__dest < __src)
00159     __asm__ __volatile__
00160       ("cld\n\t"
00161        "rep; movsb"
00162        : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2),
00163         "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest)
00164        : "0" (__n), "1" (__src), "2" (__tmp),
00165         "m" ( *(struct { __extension__ char __x[__n]; } *)__src));
00166   else
00167     __asm__ __volatile__
00168       ("std\n\t"
00169        "rep; movsb\n\t"
00170        "cld"
00171        : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2),
00172         "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest)
00173        : "0" (__n), "1" (__n - 1 + (__const char *) __src),
00174         "2" (__n - 1 + (char *) __tmp),
00175         "m" ( *(struct { __extension__ char __x[__n]; } *)__src));
00176   return __dest;
00177 }
00178 #endif
00179 
00180 /* Compare N bytes of S1 and S2.  */
00181 #define _HAVE_STRING_ARCH_memcmp 1
00182 #ifndef _FORCE_INLINES
00183 # ifndef __PIC__
00184 /* gcc has problems to spill registers when using PIC.  */
00185 __STRING_INLINE int
00186 memcmp (__const void *__s1, __const void *__s2, size_t __n)
00187 {
00188   register unsigned long int __d0, __d1, __d2;
00189   register int __res;
00190   __asm__ __volatile__
00191     ("cld\n\t"
00192      "testl %3,%3\n\t"
00193      "repe; cmpsb\n\t"
00194      "je      1f\n\t"
00195      "sbbl    %0,%0\n\t"
00196      "orl     $1,%0\n"
00197      "1:"
00198      : "=&a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2)
00199      : "0" (0), "1" (__s1), "2" (__s2), "3" (__n),
00200        "m" ( *(struct { __extension__ char __x[__n]; } *)__s1),
00201        "m" ( *(struct { __extension__ char __x[__n]; } *)__s2)
00202      : "cc");
00203   return __res;
00204 }
00205 # endif
00206 #endif
00207 
00208 /* Set N bytes of S to C.  */
00209 #define _HAVE_STRING_ARCH_memset 1
00210 #define _USE_STRING_ARCH_memset 1
00211 #define memset(s, c, n) \
00212   (__extension__ (__builtin_constant_p (n) && (n) <= 16                     \
00213                 ? ((n) == 1                                          \
00214                    ? __memset_c1 ((s), (c))                                 \
00215                    : __memset_gc ((s), (c), (n)))                           \
00216                 : (__builtin_constant_p (c)                                 \
00217                    ? (__builtin_constant_p (n)                       \
00218                      ? __memset_ccn ((s), (c), (n))                         \
00219                      : memset ((s), (c), (n)))                       \
00220                    : (__builtin_constant_p (n)                       \
00221                      ? __memset_gcn ((s), (c), (n))                         \
00222                      : memset ((s), (c), (n))))))
00223 
00224 #define __memset_c1(s, c) ({ void *__s = (s);                               \
00225                           *((unsigned char *) __s) = (unsigned char) (c);  \
00226                           __s; })
00227 
00228 #define __memset_gc(s, c, n) \
00229   ({ void *__s = (s);                                                       \
00230      union {                                                         \
00231        unsigned int __ui;                                            \
00232        unsigned short int __usi;                                     \
00233        unsigned char __uc;                                           \
00234      } *__u = __s;                                                   \
00235      unsigned int __c = ((unsigned int) ((unsigned char) (c))) * 0x01010101;  \
00236                                                                      \
00237      /* We apply a trick here.  `gcc' would implement the following         \
00238        assignments using immediate operands.  But this uses to much         \
00239        memory (7, instead of 4 bytes).  So we force the value in a          \
00240        registers.  */                                                       \
00241      if ((n) == 3 || (n) >= 5)                                              \
00242        __asm__ __volatile__ ("" : "=r" (__c) : "0" (__c));                  \
00243                                                                      \
00244      /* This `switch' statement will be removed at compile-time.  */        \
00245      switch (n)                                                             \
00246        {                                                             \
00247        case 15:                                                             \
00248         __u->__ui = __c;                                             \
00249         __u = __extension__ ((void *) __u + 4);                      \
00250        case 11:                                                             \
00251         __u->__ui = __c;                                             \
00252         __u = __extension__ ((void *) __u + 4);                      \
00253        case 7:                                                              \
00254         __u->__ui = __c;                                             \
00255         __u = __extension__ ((void *) __u + 4);                      \
00256        case 3:                                                              \
00257         __u->__usi = (unsigned short int) __c;                              \
00258         __u = __extension__ ((void *) __u + 2);                      \
00259         __u->__uc = (unsigned char) __c;                             \
00260         break;                                                              \
00261                                                                      \
00262        case 14:                                                             \
00263         __u->__ui = __c;                                             \
00264         __u = __extension__ ((void *) __u + 4);                      \
00265        case 10:                                                             \
00266         __u->__ui = __c;                                             \
00267         __u = __extension__ ((void *) __u + 4);                      \
00268        case 6:                                                              \
00269         __u->__ui = __c;                                             \
00270         __u = __extension__ ((void *) __u + 4);                      \
00271        case 2:                                                              \
00272         __u->__usi = (unsigned short int) __c;                              \
00273         break;                                                              \
00274                                                                      \
00275        case 13:                                                             \
00276         __u->__ui = __c;                                             \
00277         __u = __extension__ ((void *) __u + 4);                      \
00278        case 9:                                                              \
00279         __u->__ui = __c;                                             \
00280         __u = __extension__ ((void *) __u + 4);                      \
00281        case 5:                                                              \
00282         __u->__ui = __c;                                             \
00283         __u = __extension__ ((void *) __u + 4);                      \
00284        case 1:                                                              \
00285         __u->__uc = (unsigned char) __c;                             \
00286         break;                                                              \
00287                                                                      \
00288        case 16:                                                             \
00289         __u->__ui = __c;                                             \
00290         __u = __extension__ ((void *) __u + 4);                      \
00291        case 12:                                                             \
00292         __u->__ui = __c;                                             \
00293         __u = __extension__ ((void *) __u + 4);                      \
00294        case 8:                                                              \
00295         __u->__ui = __c;                                             \
00296         __u = __extension__ ((void *) __u + 4);                      \
00297        case 4:                                                              \
00298         __u->__ui = __c;                                             \
00299        case 0:                                                              \
00300         break;                                                              \
00301        }                                                             \
00302                                                                      \
00303      __s; })
00304 
00305 #define __memset_ccn(s, c, n) \
00306   (((n) % 4 == 0)                                                    \
00307    ? __memset_ccn_by4 (s, ((unsigned int) ((unsigned char) (c))) * 0x01010101,\
00308                      n)                                              \
00309    : (((n) % 2 == 0)                                                 \
00310       ? __memset_ccn_by2 (s,                                                \
00311                        ((unsigned int) ((unsigned char) (c))) * 0x01010101,\
00312                         n)                                           \
00313       : memset (s, c, n)))
00314 
00315 __STRING_INLINE void *__memset_ccn_by4 (void *__s, unsigned int __c,
00316                                    size_t __n);
00317 
00318 __STRING_INLINE void *
00319 __memset_ccn_by4 (void *__s, unsigned int __c, size_t __n)
00320 {
00321   register void *__tmp = __s;
00322   register unsigned long int __d0;
00323 #ifdef __i686__
00324   __asm__ __volatile__
00325     ("cld\n\t"
00326      "rep; stosl"
00327      : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0),
00328        "=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00329      : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
00330      : "cc");
00331 #else
00332   __asm__ __volatile__
00333     ("1:\n\t"
00334      "movl    %0,(%1)\n\t"
00335      "addl    $4,%1\n\t"
00336      "decl    %2\n\t"
00337      "jnz     1b\n"
00338      : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0),
00339        "=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00340      : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
00341      : "cc");
00342 #endif
00343   return __s;
00344 }
00345 
00346 __STRING_INLINE void *__memset_ccn_by2 (void *__s, unsigned int __c,
00347                                    size_t __n);
00348 
00349 __STRING_INLINE void *
00350 __memset_ccn_by2 (void *__s, unsigned int __c, size_t __n)
00351 {
00352   register unsigned long int __d0, __d1;
00353   register void *__tmp = __s;
00354 #ifdef __i686__
00355   __asm__ __volatile__
00356     ("cld\n\t"
00357      "rep; stosl\n"
00358      "stosw"
00359      : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1),
00360        "=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00361      : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
00362      : "cc");
00363 #else
00364   __asm__ __volatile__
00365     ("1:\tmovl       %0,(%1)\n\t"
00366      "leal    4(%1),%1\n\t"
00367      "decl    %2\n\t"
00368      "jnz     1b\n"
00369      "movw    %w0,(%1)"
00370      : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1),
00371        "=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00372      : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
00373      : "cc");
00374 #endif
00375   return __s;
00376 }
00377 
00378 #define __memset_gcn(s, c, n) \
00379   (((n) % 4 == 0)                                                    \
00380    ? __memset_gcn_by4 (s, c, n)                                             \
00381    : (((n) % 2 == 0)                                                 \
00382       ? __memset_gcn_by2 (s, c, n)                                   \
00383       : memset (s, c, n)))
00384 
00385 __STRING_INLINE void *__memset_gcn_by4 (void *__s, int __c, size_t __n);
00386 
00387 __STRING_INLINE void *
00388 __memset_gcn_by4 (void *__s, int __c, size_t __n)
00389 {
00390   register void *__tmp = __s;
00391   register unsigned long int __d0;
00392   __asm__ __volatile__
00393     ("movb    %b0,%h0\n"
00394      "pushw   %w0\n\t"
00395      "shll    $16,%0\n\t"
00396      "popw    %w0\n"
00397      "1:\n\t"
00398      "movl    %0,(%1)\n\t"
00399      "addl    $4,%1\n\t"
00400      "decl    %2\n\t"
00401      "jnz     1b\n"
00402      : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0),
00403        "=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00404      : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
00405      : "cc");
00406   return __s;
00407 }
00408 
00409 __STRING_INLINE void *__memset_gcn_by2 (void *__s, int __c, size_t __n);
00410 
00411 __STRING_INLINE void *
00412 __memset_gcn_by2 (void *__s, int __c, size_t __n)
00413 {
00414   register unsigned long int __d0, __d1;
00415   register void *__tmp = __s;
00416   __asm__ __volatile__
00417     ("movb    %b0,%h0\n\t"
00418      "pushw   %w0\n\t"
00419      "shll    $16,%0\n\t"
00420      "popw    %w0\n"
00421      "1:\n\t"
00422      "movl    %0,(%1)\n\t"
00423      "leal    4(%1),%1\n\t"
00424      "decl    %2\n\t"
00425      "jnz     1b\n"
00426      "movw    %w0,(%1)"
00427      : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1),
00428        "=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00429      : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
00430      : "cc");
00431   return __s;
00432 }
00433 
00434 
00435 /* Search N bytes of S for C.  */
00436 #define _HAVE_STRING_ARCH_memchr 1
00437 #ifndef _FORCE_INLINES
00438 __STRING_INLINE void *
00439 memchr (__const void *__s, int __c, size_t __n)
00440 {
00441   register unsigned long int __d0;
00442 #ifdef __i686__
00443   register unsigned long int __d1;
00444 #endif
00445   register unsigned char *__res;
00446   if (__n == 0)
00447     return NULL;
00448 #ifdef __i686__
00449   __asm__ __volatile__
00450     ("cld\n\t"
00451      "repne; scasb\n\t"
00452      "cmovne %2,%0"
00453      : "=D" (__res), "=&c" (__d0), "=&r" (__d1)
00454      : "a" (__c), "0" (__s), "1" (__n), "2" (1),
00455        "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00456      : "cc");
00457 #else
00458   __asm__ __volatile__
00459     ("cld\n\t"
00460      "repne; scasb\n\t"
00461      "je      1f\n\t"
00462      "movl    $1,%0\n"
00463      "1:"
00464      : "=D" (__res), "=&c" (__d0)
00465      : "a" (__c), "0" (__s), "1" (__n),
00466        "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00467      : "cc");
00468 #endif
00469   return __res - 1;
00470 }
00471 #endif
00472 
00473 #define _HAVE_STRING_ARCH_memrchr 1
00474 #ifndef _FORCE_INLINES
00475 __STRING_INLINE void *__memrchr (__const void *__s, int __c, size_t __n);
00476 
00477 __STRING_INLINE void *
00478 __memrchr (__const void *__s, int __c, size_t __n)
00479 {
00480   register unsigned long int __d0;
00481 # ifdef __i686__
00482   register unsigned long int __d1;
00483 # endif
00484   register void *__res;
00485   if (__n == 0)
00486     return NULL;
00487 # ifdef __i686__
00488   __asm__ __volatile__
00489     ("std\n\t"
00490      "repne; scasb\n\t"
00491      "cmovne %2,%0\n\t"
00492      "cld\n\t"
00493      "incl %0"
00494      : "=D" (__res), "=&c" (__d0), "=&r" (__d1)
00495      : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1),
00496        "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00497      : "cc");
00498 # else
00499   __asm__ __volatile__
00500     ("std\n\t"
00501      "repne; scasb\n\t"
00502      "je 1f\n\t"
00503      "orl $-1,%0\n"
00504      "1:\tcld\n\t"
00505      "incl %0"
00506      : "=D" (__res), "=&c" (__d0)
00507      : "a" (__c), "0" (__s + __n - 1), "1" (__n),
00508        "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
00509      : "cc");
00510 # endif
00511   return __res;
00512 }
00513 # ifdef __USE_GNU
00514 #  define memrchr(s, c, n) __memrchr ((s), (c), (n))
00515 # endif
00516 #endif
00517 
00518 /* Return pointer to C in S.  */
00519 #define _HAVE_STRING_ARCH_rawmemchr 1
00520 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
00521 
00522 #ifndef _FORCE_INLINES
00523 __STRING_INLINE void *
00524 __rawmemchr (const void *__s, int __c)
00525 {
00526   register unsigned long int __d0;
00527   register unsigned char *__res;
00528   __asm__ __volatile__
00529     ("cld\n\t"
00530      "repne; scasb\n\t"
00531      : "=D" (__res), "=&c" (__d0)
00532      : "a" (__c), "0" (__s), "1" (0xffffffff),
00533        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
00534      : "cc");
00535   return __res - 1;
00536 }
00537 # ifdef __USE_GNU
00538 __STRING_INLINE void *
00539 rawmemchr (const void *__s, int __c)
00540 {
00541   return __rawmemchr (__s, __c);
00542 }
00543 # endif       /* use GNU */
00544 #endif
00545 
00546 
00547 /* Return the length of S.  */
00548 #define _HAVE_STRING_ARCH_strlen 1
00549 #define strlen(str) \
00550   (__extension__ (__builtin_constant_p (str)                                \
00551                 ? __builtin_strlen (str)                             \
00552                 : __strlen_g (str)))
00553 __STRING_INLINE size_t __strlen_g (__const char *__str);
00554 
00555 __STRING_INLINE size_t
00556 __strlen_g (__const char *__str)
00557 {
00558   register char __dummy;
00559   register __const char *__tmp = __str;
00560   __asm__ __volatile__
00561     ("1:\n\t"
00562      "movb    (%0),%b1\n\t"
00563      "leal    1(%0),%0\n\t"
00564      "testb   %b1,%b1\n\t"
00565      "jne     1b"
00566      : "=r" (__tmp), "=&q" (__dummy)
00567      : "0" (__str),
00568        "m" ( *(struct { char __x[0xfffffff]; } *)__str)
00569      : "cc" );
00570   return __tmp - __str - 1;
00571 }
00572 
00573 
00574 /* Copy SRC to DEST.  */
00575 #define _HAVE_STRING_ARCH_strcpy 1
00576 #define strcpy(dest, src) \
00577   (__extension__ (__builtin_constant_p (src)                                \
00578                 ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8          \
00579                    ? __strcpy_a_small ((dest), (src), strlen (src) + 1)     \
00580                    : (char *) memcpy ((char *) (dest),               \
00581                                    (__const char *) (src),                  \
00582                                    strlen (src) + 1))                \
00583                 : __strcpy_g ((dest), (src))))
00584 
00585 #define __strcpy_a_small(dest, src, srclen) \
00586   (__extension__ ({ char *__dest = (dest);                                  \
00587                   union {                                            \
00588                     unsigned int __ui;                               \
00589                     unsigned short int __usi;                               \
00590                     unsigned char __uc;                              \
00591                     char __c;                                               \
00592                   } *__u = (void *) __dest;                                 \
00593                   switch (srclen)                                    \
00594                     {                                                       \
00595                     case 1:                                          \
00596                      __u->__uc = '\0';                               \
00597                      break;                                          \
00598                     case 2:                                          \
00599                      __u->__usi = __STRING_SMALL_GET16 (src, 0);            \
00600                      break;                                          \
00601                     case 3:                                          \
00602                      __u->__usi = __STRING_SMALL_GET16 (src, 0);            \
00603                      __u = __extension__ ((void *) __u + 2);                \
00604                      __u->__uc = '\0';                               \
00605                      break;                                          \
00606                     case 4:                                          \
00607                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00608                      break;                                          \
00609                     case 5:                                          \
00610                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00611                      __u = __extension__ ((void *) __u + 4);                \
00612                      __u->__uc = '\0';                               \
00613                      break;                                          \
00614                     case 6:                                          \
00615                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00616                      __u = __extension__ ((void *) __u + 4);                \
00617                      __u->__usi = __STRING_SMALL_GET16 (src, 4);            \
00618                      break;                                          \
00619                     case 7:                                          \
00620                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00621                      __u = __extension__ ((void *) __u + 4);                \
00622                      __u->__usi = __STRING_SMALL_GET16 (src, 4);            \
00623                      __u = __extension__ ((void *) __u + 2);                \
00624                      __u->__uc = '\0';                               \
00625                      break;                                          \
00626                     case 8:                                          \
00627                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00628                      __u = __extension__ ((void *) __u + 4);                \
00629                      __u->__ui = __STRING_SMALL_GET32 (src, 4);             \
00630                      break;                                          \
00631                     }                                                       \
00632                   (char *) __dest; }))
00633 
00634 __STRING_INLINE char *__strcpy_g (char *__dest, __const char *__src);
00635 
00636 __STRING_INLINE char *
00637 __strcpy_g (char *__dest, __const char *__src)
00638 {
00639   register char *__tmp = __dest;
00640   register char __dummy;
00641   __asm__ __volatile__
00642     (
00643      "1:\n\t"
00644      "movb    (%0),%b2\n\t"
00645      "leal    1(%0),%0\n\t"
00646      "movb    %b2,(%1)\n\t"
00647      "leal    1(%1),%1\n\t"
00648      "testb   %b2,%b2\n\t"
00649      "jne     1b"
00650      : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy),
00651        "=m" ( *(struct { char __x[0xfffffff]; } *)__dest)
00652      : "0" (__src), "1" (__tmp),
00653        "m" ( *(struct { char __x[0xfffffff]; } *)__src)
00654      : "cc");
00655   return __dest;
00656 }
00657 
00658 
00659 #ifdef __USE_GNU
00660 # define _HAVE_STRING_ARCH_stpcpy 1
00661 /* Copy SRC to DEST.  */
00662 # define __stpcpy(dest, src) \
00663   (__extension__ (__builtin_constant_p (src)                                \
00664                 ? (strlen (src) + 1 <= 8                             \
00665                    ? __stpcpy_a_small ((dest), (src), strlen (src) + 1)     \
00666                    : __stpcpy_c ((dest), (src), strlen (src) + 1))          \
00667                 : __stpcpy_g ((dest), (src))))
00668 # define __stpcpy_c(dest, src, srclen) \
00669   ((srclen) % 4 == 0                                                 \
00670    ? __mempcpy_by4 (dest, src, srclen) - 1                                  \
00671    : ((srclen) % 2 == 0                                                     \
00672       ? __mempcpy_by2 (dest, src, srclen) - 1                               \
00673       : __mempcpy_byn (dest, src, srclen) - 1))
00674 
00675 /* In glibc itself we use this symbol for namespace reasons.  */
00676 # define stpcpy(dest, src) __stpcpy ((dest), (src))
00677 
00678 # define __stpcpy_a_small(dest, src, srclen) \
00679   (__extension__ ({ union {                                          \
00680                     unsigned int __ui;                               \
00681                     unsigned short int __usi;                               \
00682                     unsigned char __uc;                              \
00683                     char __c;                                               \
00684                   } *__u = (void *) (dest);                                 \
00685                   switch (srclen)                                    \
00686                     {                                                       \
00687                     case 1:                                          \
00688                      __u->__uc = '\0';                               \
00689                      break;                                          \
00690                     case 2:                                          \
00691                      __u->__usi = __STRING_SMALL_GET16 (src, 0);            \
00692                      __u = __extension__ ((void *) __u + 1);                \
00693                      break;                                          \
00694                     case 3:                                          \
00695                      __u->__usi = __STRING_SMALL_GET16 (src, 0);            \
00696                      __u = __extension__ ((void *) __u + 2);                \
00697                      __u->__uc = '\0';                               \
00698                      break;                                          \
00699                     case 4:                                          \
00700                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00701                      __u = __extension__ ((void *) __u + 3);                \
00702                      break;                                          \
00703                     case 5:                                          \
00704                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00705                      __u = __extension__ ((void *) __u + 4);                \
00706                      __u->__uc = '\0';                               \
00707                      break;                                          \
00708                     case 6:                                          \
00709                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00710                      __u = __extension__ ((void *) __u + 4);                \
00711                      __u->__usi = __STRING_SMALL_GET16 (src, 4);            \
00712                      __u = __extension__ ((void *) __u + 1);                \
00713                      break;                                          \
00714                     case 7:                                          \
00715                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00716                      __u = __extension__ ((void *) __u + 4);                \
00717                      __u->__usi = __STRING_SMALL_GET16 (src, 4);            \
00718                      __u = __extension__ ((void *) __u + 2);                \
00719                      __u->__uc = '\0';                               \
00720                      break;                                          \
00721                     case 8:                                          \
00722                      __u->__ui = __STRING_SMALL_GET32 (src, 0);             \
00723                      __u = __extension__ ((void *) __u + 4);                \
00724                      __u->__ui = __STRING_SMALL_GET32 (src, 4);             \
00725                      __u = __extension__ ((void *) __u + 3);                \
00726                      break;                                          \
00727                     }                                                       \
00728                   (char *) __u; }))
00729 
00730 __STRING_INLINE char *__mempcpy_by4 (char *__dest, __const char *__src,
00731                                  size_t __srclen);
00732 
00733 __STRING_INLINE char *
00734 __mempcpy_by4 (char *__dest, __const char *__src, size_t __srclen)
00735 {
00736   register char *__tmp = __dest;
00737   register unsigned long int __d0, __d1;
00738   __asm__ __volatile__
00739     ("1:\n\t"
00740      "movl    (%2),%0\n\t"
00741      "leal    4(%2),%2\n\t"
00742      "movl    %0,(%1)\n\t"
00743      "leal    4(%1),%1\n\t"
00744      "decl    %3\n\t"
00745      "jnz     1b"
00746      : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1)
00747      : "1" (__tmp), "2" (__src), "3" (__srclen / 4)
00748      : "memory", "cc");
00749   return __tmp;
00750 }
00751 
00752 __STRING_INLINE char *__mempcpy_by2 (char *__dest, __const char *__src,
00753                                  size_t __srclen);
00754 
00755 __STRING_INLINE char *
00756 __mempcpy_by2 (char *__dest, __const char *__src, size_t __srclen)
00757 {
00758   register char *__tmp = __dest;
00759   register unsigned long int __d0, __d1;
00760   __asm__ __volatile__
00761     ("shrl    $1,%3\n\t"
00762      "jz      2f\n"                 /* only a word */
00763      "1:\n\t"
00764      "movl    (%2),%0\n\t"
00765      "leal    4(%2),%2\n\t"
00766      "movl    %0,(%1)\n\t"
00767      "leal    4(%1),%1\n\t"
00768      "decl    %3\n\t"
00769      "jnz     1b\n"
00770      "2:\n\t"
00771      "movw    (%2),%w0\n\t"
00772      "movw    %w0,(%1)"
00773      : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1),
00774        "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest)
00775      : "1" (__tmp), "2" (__src), "3" (__srclen / 2),
00776        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
00777      : "cc");
00778   return __tmp + 2;
00779 }
00780 
00781 __STRING_INLINE char *__mempcpy_byn (char *__dest, __const char *__src,
00782                                  size_t __srclen);
00783 
00784 __STRING_INLINE char *
00785 __mempcpy_byn (char *__dest, __const char *__src, size_t __srclen)
00786 {
00787   register unsigned long __d0, __d1;
00788   register char *__tmp = __dest;
00789   __asm__ __volatile__
00790     ("cld\n\t"
00791      "shrl    $1,%%ecx\n\t"
00792      "jnc     1f\n\t"
00793      "movsb\n"
00794      "1:\n\t"
00795      "shrl    $1,%%ecx\n\t"
00796      "jnc     2f\n\t"
00797      "movsw\n"
00798      "2:\n\t"
00799      "rep; movsl"
00800      : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1),
00801        "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest)
00802      : "0" (__tmp), "1" (__srclen), "2" (__src),
00803        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
00804      : "cc");
00805   return __tmp;
00806 }
00807 
00808 __STRING_INLINE char *__stpcpy_g (char *__dest, __const char *__src);
00809 
00810 __STRING_INLINE char *
00811 __stpcpy_g (char *__dest, __const char *__src)
00812 {
00813   register char *__tmp = __dest;
00814   register char __dummy;
00815   __asm__ __volatile__
00816     (
00817      "1:\n\t"
00818      "movb    (%0),%b2\n\t"
00819      "leal    1(%0),%0\n\t"
00820      "movb    %b2,(%1)\n\t"
00821      "leal    1(%1),%1\n\t"
00822      "testb   %b2,%b2\n\t"
00823      "jne     1b"
00824      : "=&r" (__src), "=r" (__tmp), "=&q" (__dummy),
00825        "=m" ( *(struct { char __x[0xfffffff]; } *)__dest)
00826      : "0" (__src), "1" (__tmp),
00827        "m" ( *(struct { char __x[0xfffffff]; } *)__src)
00828      : "cc");
00829   return __tmp - 1;
00830 }
00831 #endif
00832 
00833 
00834 /* Copy no more than N characters of SRC to DEST.  */
00835 #define _HAVE_STRING_ARCH_strncpy 1
00836 #define strncpy(dest, src, n) \
00837   (__extension__ (__builtin_constant_p (src)                                \
00838                 ? ((strlen (src) + 1 >= ((size_t) (n))               \
00839                     ? (char *) memcpy ((char *) (dest),              \
00840                                     (__const char *) (src), n)       \
00841                     : __strncpy_cg ((dest), (src), strlen (src) + 1, n)))   \
00842                 : __strncpy_gg ((dest), (src), n)))
00843 #define __strncpy_cg(dest, src, srclen, n) \
00844   (((srclen) % 4 == 0)                                                      \
00845    ? __strncpy_by4 (dest, src, srclen, n)                            \
00846    : (((srclen) % 2 == 0)                                            \
00847       ? __strncpy_by2 (dest, src, srclen, n)                                \
00848       : __strncpy_byn (dest, src, srclen, n)))
00849 
00850 __STRING_INLINE char *__strncpy_by4 (char *__dest, __const char __src[],
00851                                  size_t __srclen, size_t __n);
00852 
00853 __STRING_INLINE char *
00854 __strncpy_by4 (char *__dest, __const char __src[], size_t __srclen, size_t __n)
00855 {
00856   register char *__tmp = __dest;
00857   register int __dummy1, __dummy2;
00858   __asm__ __volatile__
00859     ("1:\n\t"
00860      "movl    (%2),%0\n\t"
00861      "leal    4(%2),%2\n\t"
00862      "movl    %0,(%1)\n\t"
00863      "leal    4(%1),%1\n\t"
00864      "decl    %3\n\t"
00865      "jnz     1b"
00866      : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2),
00867        "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest)
00868      : "1" (__tmp), "2" (__src), "3" (__srclen / 4),
00869        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
00870      : "cc");
00871   (void) memset (__tmp, '\0', __n - __srclen);
00872   return __dest;
00873 }
00874 
00875 __STRING_INLINE char *__strncpy_by2 (char *__dest, __const char __src[],
00876                                  size_t __srclen, size_t __n);
00877 
00878 __STRING_INLINE char *
00879 __strncpy_by2 (char *__dest, __const char __src[], size_t __srclen, size_t __n)
00880 {
00881   register char *__tmp = __dest;
00882   register int __dummy1, __dummy2;
00883   __asm__ __volatile__
00884     ("shrl    $1,%3\n\t"
00885      "jz      2f\n"                 /* only a word */
00886      "1:\n\t"
00887      "movl    (%2),%0\n\t"
00888      "leal    4(%2),%2\n\t"
00889      "movl    %0,(%1)\n\t"
00890      "leal    4(%1),%1\n\t"
00891      "decl    %3\n\t"
00892      "jnz     1b\n"
00893      "2:\n\t"
00894      "movw    (%2),%w0\n\t"
00895      "movw    %w0,(%1)\n\t"
00896      : "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2),
00897        "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest)
00898      : "1" (__tmp), "2" (__src), "3" (__srclen / 2),
00899        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
00900      : "cc");
00901   (void) memset (__tmp + 2, '\0', __n - __srclen);
00902   return __dest;
00903 }
00904 
00905 __STRING_INLINE char *__strncpy_byn (char *__dest, __const char __src[],
00906                                  size_t __srclen, size_t __n);
00907 
00908 __STRING_INLINE char *
00909 __strncpy_byn (char *__dest, __const char __src[], size_t __srclen, size_t __n)
00910 {
00911   register unsigned long int __d0, __d1;
00912   register char *__tmp = __dest;
00913   __asm__ __volatile__
00914     ("cld\n\t"
00915      "shrl    $1,%1\n\t"
00916      "jnc     1f\n\t"
00917      "movsb\n"
00918      "1:\n\t"
00919      "shrl    $1,%1\n\t"
00920      "jnc     2f\n\t"
00921      "movsw\n"
00922      "2:\n\t"
00923      "rep; movsl"
00924      : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1),
00925        "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest)
00926      : "1" (__srclen), "0" (__tmp),"2" (__src),
00927        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
00928      : "cc");
00929   (void) memset (__tmp, '\0', __n - __srclen);
00930   return __dest;
00931 }
00932 
00933 __STRING_INLINE char *__strncpy_gg (char *__dest, __const char *__src,
00934                                 size_t __n);
00935 
00936 __STRING_INLINE char *
00937 __strncpy_gg (char *__dest, __const char *__src, size_t __n)
00938 {
00939   register char *__tmp = __dest;
00940   register char __dummy;
00941   if (__n > 0)
00942     __asm__ __volatile__
00943       ("1:\n\t"
00944        "movb  (%0),%2\n\t"
00945        "incl  %0\n\t"
00946        "movb  %2,(%1)\n\t"
00947        "incl  %1\n\t"
00948        "decl  %3\n\t"
00949        "je    3f\n\t"
00950        "testb %2,%2\n\t"
00951        "jne   1b\n\t"
00952        "2:\n\t"
00953        "movb  %2,(%1)\n\t"
00954        "incl  %1\n\t"
00955        "decl  %3\n\t"
00956        "jne   2b\n\t"
00957        "3:"
00958        : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy), "=&r" (__n)
00959        : "0" (__src), "1" (__tmp), "3" (__n)
00960        : "memory", "cc");
00961 
00962   return __dest;
00963 }
00964 
00965 
00966 /* Append SRC onto DEST.  */
00967 #define _HAVE_STRING_ARCH_strcat 1
00968 #define strcat(dest, src) \
00969   (__extension__ (__builtin_constant_p (src)                                \
00970                 ? __strcat_c ((dest), (src), strlen (src) + 1)       \
00971                 : __strcat_g ((dest), (src))))
00972 
00973 __STRING_INLINE char *__strcat_c (char *__dest, __const char __src[],
00974                               size_t __srclen);
00975 
00976 __STRING_INLINE char *
00977 __strcat_c (char *__dest, __const char __src[], size_t __srclen)
00978 {
00979 #ifdef __i686__
00980   register unsigned long int __d0;
00981   register char *__tmp;
00982   __asm__ __volatile__
00983     ("repne; scasb"
00984      : "=D" (__tmp), "=&c" (__d0),
00985        "=m" ( *(struct { char __x[0xfffffff]; } *)__dest)
00986      : "0" (__dest), "1" (0xffffffff), "a" (0),
00987        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
00988      : "cc");
00989   --__tmp;
00990 #else
00991   register char *__tmp = __dest - 1;
00992   __asm__ __volatile__
00993     ("1:\n\t"
00994      "incl    %0\n\t"
00995      "cmpb    $0,(%0)\n\t"
00996      "jne     1b\n"
00997      : "=r" (__tmp),
00998        "=m" ( *(struct { char __x[0xfffffff]; } *)__dest)
00999      : "0" (__tmp),
01000        "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
01001      : "cc");
01002 #endif
01003   (void) memcpy (__tmp, __src, __srclen);
01004   return __dest;
01005 }
01006 
01007 __STRING_INLINE char *__strcat_g (char *__dest, __const char *__src);
01008 
01009 __STRING_INLINE char *
01010 __strcat_g (char *__dest, __const char *__src)
01011 {
01012   register char *__tmp = __dest - 1;
01013   register char __dummy;
01014   __asm__ __volatile__
01015     ("1:\n\t"
01016      "incl    %1\n\t"
01017      "cmpb    $0,(%1)\n\t"
01018      "jne     1b\n"
01019      "2:\n\t"
01020      "movb    (%2),%b0\n\t"
01021      "incl    %2\n\t"
01022      "movb    %b0,(%1)\n\t"
01023      "incl    %1\n\t"
01024      "testb   %b0,%b0\n\t"
01025      "jne     2b\n"
01026      : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src),
01027        "=m" ( *(struct { char __x[0xfffffff]; } *)__dest)
01028      : "1"  (__tmp), "2"  (__src),
01029        "m" ( *(struct { char __x[0xfffffff]; } *)__src)
01030      : "memory", "cc");
01031   return __dest;
01032 }
01033 
01034 
01035 /* Append no more than N characters from SRC onto DEST.  */
01036 #define _HAVE_STRING_ARCH_strncat 1
01037 #define strncat(dest, src, n) \
01038   (__extension__ ({ char *__dest = (dest);                                  \
01039                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
01040                   ? (strlen (src) < ((size_t) (n))                          \
01041                      ? strcat (__dest, (src))                               \
01042                      : (*(char *)__mempcpy (strchr (__dest, '\0'),          \
01043                                           (__const char *) (src),           \
01044                                          (n)) = 0, __dest))          \
01045                   : __strncat_g (__dest, (src), (n)); }))
01046 
01047 __STRING_INLINE char *__strncat_g (char *__dest, __const char __src[],
01048                                size_t __n);
01049 
01050 __STRING_INLINE char *
01051 __strncat_g (char *__dest, __const char __src[], size_t __n)
01052 {
01053   register char *__tmp = __dest;
01054   register char __dummy;
01055 #ifdef __i686__
01056   __asm__ __volatile__
01057     ("repne; scasb\n"
01058      "movl %4, %3\n\t"
01059      "decl %1\n\t"
01060      "1:\n\t"
01061      "decl    %3\n\t"
01062      "js      2f\n\t"
01063      "movb    (%2),%b0\n\t"
01064      "movsb\n\t"
01065      "testb   %b0,%b0\n\t"
01066      "jne     1b\n\t"
01067      "decl    %1\n"
01068      "2:\n\t"
01069      "movb    $0,(%1)"
01070      : "=&a" (__dummy), "=&D" (__tmp), "=&S" (__src), "=&c" (__n)
01071      :  "g" (__n), "0" (0), "1" (__tmp), "2" (__src), "3" (0xffffffff)
01072      : "memory", "cc");
01073 #else
01074   --__tmp;
01075   __asm__ __volatile__
01076     ("1:\n\t"
01077      "cmpb    $0,1(%1)\n\t"
01078      "leal    1(%1),%1\n\t"
01079      "jne     1b\n"
01080      "2:\n\t"
01081      "decl    %3\n\t"
01082      "js      3f\n\t"
01083      "movb    (%2),%b0\n\t"
01084      "leal    1(%2),%2\n\t"
01085      "movb    %b0,(%1)\n\t"
01086      "leal    1(%1),%1\n\t"
01087      "testb   %b0,%b0\n\t"
01088      "jne     2b\n\t"
01089      "decl    %1\n"
01090      "3:\n\t"
01091      "movb    $0,(%1)"
01092      : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n)
01093      : "1" (__tmp), "2" (__src), "3" (__n)
01094      : "memory", "cc");
01095 #endif
01096   return __dest;
01097 }
01098 
01099 
01100 /* Compare S1 and S2.  */
01101 #define _HAVE_STRING_ARCH_strcmp 1
01102 #define strcmp(s1, s2) \
01103   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
01104                 && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
01105                 && (sizeof ((s2)[0]) != 1 || strlen (s2) >= 4)       \
01106                 ? memcmp ((__const char *) (s1), (__const char *) (s2),     \
01107                          (strlen (s1) < strlen (s2)                         \
01108                           ? strlen (s1) : strlen (s2)) + 1)                 \
01109                 : (__builtin_constant_p (s1) && sizeof ((s1)[0]) == 1       \
01110                    && sizeof ((s2)[0]) == 1 && strlen (s1) < 4       \
01111                    ? (__builtin_constant_p (s2) && sizeof ((s2)[0]) == 1    \
01112                      ? __strcmp_cc ((__const unsigned char *) (s1),         \
01113                                    (__const unsigned char *) (s2),          \
01114                                    strlen (s1))                      \
01115                      : __strcmp_cg ((__const unsigned char *) (s1),         \
01116                                    (__const unsigned char *) (s2),          \
01117                                    strlen (s1)))                     \
01118                    : (__builtin_constant_p (s2) && sizeof ((s1)[0]) == 1    \
01119                      && sizeof ((s2)[0]) == 1 && strlen (s2) < 4            \
01120                      ? (__builtin_constant_p (s1)                           \
01121                         ? __strcmp_cc ((__const unsigned char *) (s1),     \
01122                                      (__const unsigned char *) (s2),     \
01123                                      strlen (s2))                           \
01124                         : __strcmp_gc ((__const unsigned char *) (s1),     \
01125                                      (__const unsigned char *) (s2),     \
01126                                      strlen (s2)))                          \
01127                      : __strcmp_gg ((s1), (s2))))))
01128 
01129 #define __strcmp_cc(s1, s2, l) \
01130   (__extension__ ({ register int __result = (s1)[0] - (s2)[0];              \
01131                   if (l > 0 && __result == 0)                               \
01132                     {                                                       \
01133                      __result = (s1)[1] - (s2)[1];                          \
01134                      if (l > 1 && __result == 0)                     \
01135                        {                                             \
01136                          __result = (s1)[2] - (s2)[2];               \
01137                          if (l > 2 && __result == 0)                        \
01138                            __result = (s1)[3] - (s2)[3];                    \
01139                        }                                             \
01140                     }                                                       \
01141                   __result; }))
01142 
01143 #define __strcmp_cg(s1, s2, l1) \
01144   (__extension__ ({ __const unsigned char *__s2 = (s2);                     \
01145                   register int __result = (s1)[0] - __s2[0];                \
01146                   if (l1 > 0 && __result == 0)                       \
01147                     {                                                       \
01148                      __result = (s1)[1] - __s2[1];                          \
01149                      if (l1 > 1 && __result == 0)                           \
01150                        {                                             \
01151                          __result = (s1)[2] - __s2[2];               \
01152                          if (l1 > 2 && __result == 0)                \
01153                            __result = (s1)[3] - __s2[3];                    \
01154                        }                                             \
01155                     }                                                       \
01156                   __result; }))
01157 
01158 #define __strcmp_gc(s1, s2, l2) \
01159   (__extension__ ({ __const unsigned char *__s1 = (s1);                     \
01160                   register int __result = __s1[0] - (s2)[0];                \
01161                   if (l2 > 0 && __result == 0)                       \
01162                     {                                                       \
01163                      __result = __s1[1] - (s2)[1];                          \
01164                      if (l2 > 1 && __result == 0)                           \
01165                        {                                             \
01166                          __result = __s1[2] - (s2)[2];               \
01167                          if (l2 > 2 && __result == 0)                \
01168                            __result = __s1[3] - (s2)[3];                    \
01169                        }                                             \
01170                     }                                                       \
01171                   __result; }))
01172 
01173 __STRING_INLINE int __strcmp_gg (__const char *__s1, __const char *__s2);
01174 
01175 __STRING_INLINE int
01176 __strcmp_gg (__const char *__s1, __const char *__s2)
01177 {
01178   register int __res;
01179   __asm__ __volatile__
01180     ("1:\n\t"
01181      "movb    (%1),%b0\n\t"
01182      "leal    1(%1),%1\n\t"
01183      "cmpb    %b0,(%2)\n\t"
01184      "jne     2f\n\t"
01185      "leal    1(%2),%2\n\t"
01186      "testb   %b0,%b0\n\t"
01187      "jne     1b\n\t"
01188      "xorl    %0,%0\n\t"
01189      "jmp     3f\n"
01190      "2:\n\t"
01191      "movl    $1,%0\n\t"
01192      "jb      3f\n\t"
01193      "negl    %0\n"
01194      "3:"
01195      : "=q" (__res), "=&r" (__s1), "=&r" (__s2)
01196      : "1" (__s1), "2" (__s2),
01197        "m" ( *(struct { char __x[0xfffffff]; } *)__s1),
01198        "m" ( *(struct { char __x[0xfffffff]; } *)__s2)
01199      : "cc");
01200   return __res;
01201 }
01202 
01203 
01204 /* Compare N characters of S1 and S2.  */
01205 #define _HAVE_STRING_ARCH_strncmp 1
01206 #define strncmp(s1, s2, n) \
01207   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
01208                 ? strcmp ((s1), (s2))                                       \
01209                 : (__builtin_constant_p (s2) && strlen (s2) < ((size_t) (n))\
01210                    ? strcmp ((s1), (s2))                             \
01211                    : __strncmp_g ((s1), (s2), (n)))))
01212 
01213 __STRING_INLINE int __strncmp_g (__const char *__s1, __const char *__s2,
01214                              size_t __n);
01215 
01216 __STRING_INLINE int
01217 __strncmp_g (__const char *__s1, __const char *__s2, size_t __n)
01218 {
01219   register int __res;
01220   __asm__ __volatile__
01221     ("1:\n\t"
01222      "decl    %3\n\t"
01223      "js      2f\n\t"
01224      "movb    (%1),%b0\n\t"
01225      "incl    %1\n\t"
01226      "cmpb    %b0,(%2)\n\t"
01227      "jne     3f\n\t"
01228      "incl    %2\n\t"
01229      "testb   %b0,%b0\n\t"
01230      "jne     1b\n"
01231      "2:\n\t"
01232      "xorl    %0,%0\n\t"
01233      "jmp     4f\n"
01234      "3:\n\t"
01235      "movl    $1,%0\n\t"
01236      "jb      4f\n\t"
01237      "negl    %0\n"
01238      "4:"
01239      : "=q" (__res), "=&r" (__s1), "=&r" (__s2), "=&r" (__n)
01240      : "1"  (__s1), "2"  (__s2),  "3" (__n),
01241        "m" ( *(struct { __extension__ char __x[__n]; } *)__s1),
01242        "m" ( *(struct { __extension__ char __x[__n]; } *)__s2)
01243      : "cc");
01244   return __res;
01245 }
01246 
01247 
01248 /* Find the first occurrence of C in S.  */
01249 #define _HAVE_STRING_ARCH_strchr 1
01250 #define _USE_STRING_ARCH_strchr 1
01251 #define strchr(s, c) \
01252   (__extension__ (__builtin_constant_p (c)                                  \
01253                 ? ((c) == '\0'                                       \
01254                    ? (char *) __rawmemchr ((s), (c))                        \
01255                    : __strchr_c ((s), ((c) & 0xff) << 8))                   \
01256                 : __strchr_g ((s), (c))))
01257 
01258 __STRING_INLINE char *__strchr_c (__const char *__s, int __c);
01259 
01260 __STRING_INLINE char *
01261 __strchr_c (__const char *__s, int __c)
01262 {
01263   register unsigned long int __d0;
01264   register char *__res;
01265   __asm__ __volatile__
01266     ("1:\n\t"
01267      "movb    (%0),%%al\n\t"
01268      "cmpb    %%ah,%%al\n\t"
01269      "je      2f\n\t"
01270      "leal    1(%0),%0\n\t"
01271      "testb   %%al,%%al\n\t"
01272      "jne     1b\n\t"
01273      "xorl    %0,%0\n"
01274      "2:"
01275      : "=r" (__res), "=&a" (__d0)
01276      : "0" (__s), "1" (__c),
01277        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01278      : "cc");
01279   return __res;
01280 }
01281 
01282 __STRING_INLINE char *__strchr_g (__const char *__s, int __c);
01283 
01284 __STRING_INLINE char *
01285 __strchr_g (__const char *__s, int __c)
01286 {
01287   register unsigned long int __d0;
01288   register char *__res;
01289   __asm__ __volatile__
01290     ("movb    %%al,%%ah\n"
01291      "1:\n\t"
01292      "movb    (%0),%%al\n\t"
01293      "cmpb    %%ah,%%al\n\t"
01294      "je      2f\n\t"
01295      "leal    1(%0),%0\n\t"
01296      "testb   %%al,%%al\n\t"
01297      "jne     1b\n\t"
01298      "xorl    %0,%0\n"
01299      "2:"
01300      : "=r" (__res), "=&a" (__d0)
01301      : "0" (__s), "1" (__c),
01302        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01303      : "cc");
01304   return __res;
01305 }
01306 
01307 
01308 /* Find the first occurrence of C in S or the final NUL byte.  */
01309 #define _HAVE_STRING_ARCH_strchrnul 1
01310 #define __strchrnul(s, c) \
01311   (__extension__ (__builtin_constant_p (c)                                  \
01312                 ? ((c) == '\0'                                       \
01313                    ? (char *) __rawmemchr ((s), c)                          \
01314                    : __strchrnul_c ((s), ((c) & 0xff) << 8))                \
01315                 : __strchrnul_g ((s), c)))
01316 
01317 __STRING_INLINE char *__strchrnul_c (__const char *__s, int __c);
01318 
01319 __STRING_INLINE char *
01320 __strchrnul_c (__const char *__s, int __c)
01321 {
01322   register unsigned long int __d0;
01323   register char *__res;
01324   __asm__ __volatile__
01325     ("1:\n\t"
01326      "movb    (%0),%%al\n\t"
01327      "cmpb    %%ah,%%al\n\t"
01328      "je      2f\n\t"
01329      "leal    1(%0),%0\n\t"
01330      "testb   %%al,%%al\n\t"
01331      "jne     1b\n\t"
01332      "decl    %0\n"
01333      "2:"
01334      : "=r" (__res), "=&a" (__d0)
01335      : "0" (__s), "1" (__c),
01336        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01337      : "cc");
01338   return __res;
01339 }
01340 
01341 __STRING_INLINE char *__strchrnul_g (__const char *__s, int __c);
01342 
01343 __STRING_INLINE char *
01344 __strchrnul_g (__const char *__s, int __c)
01345 {
01346   register unsigned long int __d0;
01347   register char *__res;
01348   __asm__ __volatile__
01349     ("movb    %%al,%%ah\n"
01350      "1:\n\t"
01351      "movb    (%0),%%al\n\t"
01352      "cmpb    %%ah,%%al\n\t"
01353      "je      2f\n\t"
01354      "leal    1(%0),%0\n\t"
01355      "testb   %%al,%%al\n\t"
01356      "jne     1b\n\t"
01357      "decl    %0\n"
01358      "2:"
01359      : "=r" (__res), "=&a" (__d0)
01360      : "0" (__s), "1" (__c),
01361        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01362      : "cc");
01363   return __res;
01364 }
01365 #ifdef __USE_GNU
01366 # define strchrnul(s, c) __strchrnul ((s), (c))
01367 #endif
01368 
01369 
01370 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
01371 /* Find the first occurrence of C in S.  This is the BSD name.  */
01372 # define _HAVE_STRING_ARCH_index 1
01373 # define index(s, c) \
01374   (__extension__ (__builtin_constant_p (c)                                  \
01375                 ? __strchr_c ((s), ((c) & 0xff) << 8)                       \
01376                 : __strchr_g ((s), (c))))
01377 #endif
01378 
01379 
01380 /* Find the last occurrence of C in S.  */
01381 #define _HAVE_STRING_ARCH_strrchr 1
01382 #define strrchr(s, c) \
01383   (__extension__ (__builtin_constant_p (c)                                  \
01384                 ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
01385                 : __strrchr_g ((s), (c))))
01386 
01387 #ifdef __i686__
01388 __STRING_INLINE char *__strrchr_c (__const char *__s, int __c);
01389 
01390 __STRING_INLINE char *
01391 __strrchr_c (__const char *__s, int __c)
01392 {
01393   register unsigned long int __d0, __d1;
01394   register char *__res;
01395   __asm__ __volatile__
01396     ("cld\n"
01397      "1:\n\t"
01398      "lodsb\n\t"
01399      "cmpb    %h2,%b2\n\t"
01400      "cmove   %1,%0\n\t"
01401      "testb   %b2,%b2\n\t"
01402      "jne 1b"
01403      : "=d" (__res), "=&S" (__d0), "=&a" (__d1)
01404      : "0" (1), "1" (__s), "2" (__c),
01405        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01406      : "cc");
01407   return __res - 1;
01408 }
01409 
01410 __STRING_INLINE char *__strrchr_g (__const char *__s, int __c);
01411 
01412 __STRING_INLINE char *
01413 __strrchr_g (__const char *__s, int __c)
01414 {
01415   register unsigned long int __d0, __d1;
01416   register char *__res;
01417   __asm__ __volatile__
01418     ("movb    %b2,%h2\n"
01419      "cld\n\t"
01420      "1:\n\t"
01421      "lodsb\n\t"
01422      "cmpb    %h2,%b2\n\t"
01423      "cmove   %1,%0\n\t"
01424      "testb   %b2,%b2\n\t"
01425      "jne 1b"
01426      : "=d" (__res), "=&S" (__d0), "=&a" (__d1)
01427      : "0" (1), "1" (__s), "2" (__c),
01428        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01429      : "cc");
01430   return __res - 1;
01431 }
01432 #else
01433 __STRING_INLINE char *__strrchr_c (__const char *__s, int __c);
01434 
01435 __STRING_INLINE char *
01436 __strrchr_c (__const char *__s, int __c)
01437 {
01438   register unsigned long int __d0, __d1;
01439   register char *__res;
01440   __asm__ __volatile__
01441     ("cld\n"
01442      "1:\n\t"
01443      "lodsb\n\t"
01444      "cmpb    %%ah,%%al\n\t"
01445      "jne     2f\n\t"
01446      "leal    -1(%%esi),%0\n"
01447      "2:\n\t"
01448      "testb   %%al,%%al\n\t"
01449      "jne 1b"
01450      : "=d" (__res), "=&S" (__d0), "=&a" (__d1)
01451      : "0" (0), "1" (__s), "2" (__c),
01452        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01453      : "cc");
01454   return __res;
01455 }
01456 
01457 __STRING_INLINE char *__strrchr_g (__const char *__s, int __c);
01458 
01459 __STRING_INLINE char *
01460 __strrchr_g (__const char *__s, int __c)
01461 {
01462   register unsigned long int __d0, __d1;
01463   register char *__res;
01464   __asm__ __volatile__
01465     ("movb    %%al,%%ah\n"
01466      "cld\n\t"
01467      "1:\n\t"
01468      "lodsb\n\t"
01469      "cmpb    %%ah,%%al\n\t"
01470      "jne     2f\n\t"
01471      "leal    -1(%%esi),%0\n"
01472      "2:\n\t"
01473      "testb   %%al,%%al\n\t"
01474      "jne 1b"
01475      : "=r" (__res), "=&S" (__d0), "=&a" (__d1)
01476      : "0" (0), "1" (__s), "2" (__c),
01477        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01478      : "cc");
01479   return __res;
01480 }
01481 #endif
01482 
01483 
01484 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
01485 /* Find the last occurrence of C in S.  This is the BSD name.  */
01486 # define _HAVE_STRING_ARCH_rindex 1
01487 # define rindex(s, c) \
01488   (__extension__ (__builtin_constant_p (c)                                  \
01489                 ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
01490                 : __strrchr_g ((s), (c))))
01491 #endif
01492 
01493 
01494 /* Return the length of the initial segment of S which
01495    consists entirely of characters not in REJECT.  */
01496 #define _HAVE_STRING_ARCH_strcspn 1
01497 #define strcspn(s, reject) \
01498   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
01499                 ? ((reject)[0] == '\0'                               \
01500                    ? strlen (s)                                      \
01501                    : ((reject)[1] == '\0'                            \
01502                      ? __strcspn_c1 ((s), (((reject)[0] << 8) & 0xff00))   \
01503                      : __strcspn_cg ((s), (reject), strlen (reject))))     \
01504                 : __strcspn_g ((s), (reject))))
01505 
01506 __STRING_INLINE size_t __strcspn_c1 (__const char *__s, int __reject);
01507 
01508 #ifndef _FORCE_INLINES
01509 __STRING_INLINE size_t
01510 __strcspn_c1 (__const char *__s, int __reject)
01511 {
01512   register unsigned long int __d0;
01513   register char *__res;
01514   __asm__ __volatile__
01515     ("1:\n\t"
01516      "movb    (%0),%%al\n\t"
01517      "leal    1(%0),%0\n\t"
01518      "cmpb    %%ah,%%al\n\t"
01519      "je      2f\n\t"
01520      "testb   %%al,%%al\n\t"
01521      "jne     1b\n"
01522      "2:"
01523      : "=r" (__res), "=&a" (__d0)
01524      : "0" (__s), "1" (__reject),
01525        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01526      : "cc");
01527   return (__res - 1) - __s;
01528 }
01529 #endif
01530 
01531 __STRING_INLINE size_t __strcspn_cg (__const char *__s, __const char __reject[],
01532                                 size_t __reject_len);
01533 
01534 __STRING_INLINE size_t
01535 __strcspn_cg (__const char *__s, __const char __reject[], size_t __reject_len)
01536 {
01537   register unsigned long int __d0, __d1, __d2;
01538   register __const char *__res;
01539   __asm__ __volatile__
01540     ("cld\n"
01541      "1:\n\t"
01542      "lodsb\n\t"
01543      "testb   %%al,%%al\n\t"
01544      "je      2f\n\t"
01545      "movl    %5,%%edi\n\t"
01546      "movl    %6,%%ecx\n\t"
01547      "repne; scasb\n\t"
01548      "jne     1b\n"
01549      "2:"
01550      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
01551      : "0" (__s), "d" (__reject), "g" (__reject_len)
01552      : "memory", "cc");
01553   return (__res - 1) - __s;
01554 }
01555 
01556 __STRING_INLINE size_t __strcspn_g (__const char *__s, __const char *__reject);
01557 #ifdef __PIC__
01558 
01559 __STRING_INLINE size_t
01560 __strcspn_g (__const char *__s, __const char *__reject)
01561 {
01562   register unsigned long int __d0, __d1, __d2;
01563   register __const char *__res;
01564   __asm__ __volatile__
01565     ("pushl   %%ebx\n\t"
01566      "movl    %4,%%edi\n\t"
01567      "cld\n\t"
01568      "repne; scasb\n\t"
01569      "notl    %%ecx\n\t"
01570      "leal    -1(%%ecx),%%ebx\n"
01571      "1:\n\t"
01572      "lodsb\n\t"
01573      "testb   %%al,%%al\n\t"
01574      "je      2f\n\t"
01575      "movl    %4,%%edi\n\t"
01576      "movl    %%ebx,%%ecx\n\t"
01577      "repne; scasb\n\t"
01578      "jne     1b\n"
01579      "2:\n\t"
01580      "popl    %%ebx"
01581      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
01582      : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
01583      : "memory", "cc");
01584   return (__res - 1) - __s;
01585 }
01586 #else
01587 __STRING_INLINE size_t
01588 __strcspn_g (__const char *__s, __const char *__reject)
01589 {
01590   register unsigned long int __d0, __d1, __d2, __d3;
01591   register __const char *__res;
01592   __asm__ __volatile__
01593     ("cld\n\t"
01594      "repne; scasb\n\t"
01595      "notl    %%ecx\n\t"
01596      "leal    -1(%%ecx),%%edx\n"
01597      "1:\n\t"
01598      "lodsb\n\t"
01599      "testb   %%al,%%al\n\t"
01600      "je      2f\n\t"
01601      "movl    %%ebx,%%edi\n\t"
01602      "movl    %%edx,%%ecx\n\t"
01603      "repne; scasb\n\t"
01604      "jne     1b\n"
01605      "2:"
01606      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3)
01607      : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject)
01608      /* Clobber memory, otherwise GCC cannot handle this.  */
01609      : "memory", "cc");
01610   return (__res - 1) - __s;
01611 }
01612 #endif
01613 
01614 
01615 /* Return the length of the initial segment of S which
01616    consists entirely of characters in ACCEPT.  */
01617 #define _HAVE_STRING_ARCH_strspn 1
01618 #define strspn(s, accept) \
01619   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
01620                 ? ((accept)[0] == '\0'                               \
01621                    ? ((void) (s), 0)                                        \
01622                    : ((accept)[1] == '\0'                            \
01623                      ? __strspn_c1 ((s), (((accept)[0] << 8 ) & 0xff00))   \
01624                      : __strspn_cg ((s), (accept), strlen (accept))))      \
01625                 : __strspn_g ((s), (accept))))
01626 
01627 #ifndef _FORCE_INLINES
01628 __STRING_INLINE size_t __strspn_c1 (__const char *__s, int __accept);
01629 
01630 __STRING_INLINE size_t
01631 __strspn_c1 (__const char *__s, int __accept)
01632 {
01633   register unsigned long int __d0;
01634   register char *__res;
01635   /* Please note that __accept never can be '\0'.  */
01636   __asm__ __volatile__
01637     ("1:\n\t"
01638      "movb    (%0),%b1\n\t"
01639      "leal    1(%0),%0\n\t"
01640      "cmpb    %h1,%b1\n\t"
01641      "je      1b"
01642      : "=r" (__res), "=&q" (__d0)
01643      : "0" (__s), "1" (__accept),
01644        "m" ( *(struct { char __x[0xfffffff]; } *)__s)
01645      : "cc");
01646   return (__res - 1) - __s;
01647 }
01648 #endif
01649 
01650 __STRING_INLINE size_t __strspn_cg (__const char *__s, __const char __accept[],
01651                                 size_t __accept_len);
01652 
01653 __STRING_INLINE size_t
01654 __strspn_cg (__const char *__s, __const char __accept[], size_t __accept_len)
01655 {
01656   register unsigned long int __d0, __d1, __d2;
01657   register __const char *__res;
01658   __asm__ __volatile__
01659     ("cld\n"
01660      "1:\n\t"
01661      "lodsb\n\t"
01662      "testb   %%al,%%al\n\t"
01663      "je      2f\n\t"
01664      "movl    %5,%%edi\n\t"
01665      "movl    %6,%%ecx\n\t"
01666      "repne; scasb\n\t"
01667      "je      1b\n"
01668      "2:"
01669      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
01670      : "0" (__s), "g" (__accept), "g" (__accept_len),
01671        /* Since we do not know how large the memory we access it, use a
01672          really large amount.  */
01673        "m" ( *(struct { char __x[0xfffffff]; } *)__s),
01674        "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept)
01675      : "cc");
01676   return (__res - 1) - __s;
01677 }
01678 
01679 __STRING_INLINE size_t __strspn_g (__const char *__s, __const char *__accept);
01680 #ifdef __PIC__
01681 
01682 __STRING_INLINE size_t
01683 __strspn_g (__const char *__s, __const char *__accept)
01684 {
01685   register unsigned long int __d0, __d1, __d2;
01686   register __const char *__res;
01687   __asm__ __volatile__
01688     ("pushl   %%ebx\n\t"
01689      "cld\n\t"
01690      "repne; scasb\n\t"
01691      "notl    %%ecx\n\t"
01692      "leal    -1(%%ecx),%%ebx\n"
01693      "1:\n\t"
01694      "lodsb\n\t"
01695      "testb   %%al,%%al\n\t"
01696      "je      2f\n\t"
01697      "movl    %%edx,%%edi\n\t"
01698      "movl    %%ebx,%%ecx\n\t"
01699      "repne; scasb\n\t"
01700      "je      1b\n"
01701      "2:\n\t"
01702      "popl    %%ebx"
01703      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
01704      : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept)
01705      : "memory", "cc");
01706   return (__res - 1) - __s;
01707 }
01708 #else
01709 __STRING_INLINE size_t
01710 __strspn_g (__const char *__s, __const char *__accept)
01711 {
01712   register unsigned long int __d0, __d1, __d2, __d3;
01713   register __const char *__res;
01714   __asm__ __volatile__
01715     ("cld\n\t"
01716      "repne; scasb\n\t"
01717      "notl    %%ecx\n\t"
01718      "leal    -1(%%ecx),%%edx\n"
01719      "1:\n\t"
01720      "lodsb\n\t"
01721      "testb   %%al,%%al\n\t"
01722      "je      2f\n\t"
01723      "movl    %%ebx,%%edi\n\t"
01724      "movl    %%edx,%%ecx\n\t"
01725      "repne; scasb\n\t"
01726      "je      1b\n"
01727      "2:"
01728      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3)
01729      : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept)
01730      : "memory", "cc");
01731   return (__res - 1) - __s;
01732 }
01733 #endif
01734 
01735 
01736 /* Find the first occurrence in S of any character in ACCEPT.  */
01737 #define _HAVE_STRING_ARCH_strpbrk 1
01738 #define strpbrk(s, accept) \
01739   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
01740                 ? ((accept)[0] == '\0'                               \
01741                    ? ((void) (s), (char *) 0)                               \
01742                    : ((accept)[1] == '\0'                            \
01743                      ? strchr ((s), (accept)[0])                     \
01744                      : __strpbrk_cg ((s), (accept), strlen (accept))))     \
01745                 : __strpbrk_g ((s), (accept))))
01746 
01747 __STRING_INLINE char *__strpbrk_cg (__const char *__s, __const char __accept[],
01748                                 size_t __accept_len);
01749 
01750 __STRING_INLINE char *
01751 __strpbrk_cg (__const char *__s, __const char __accept[], size_t __accept_len)
01752 {
01753   register unsigned long int __d0, __d1, __d2;
01754   register char *__res;
01755   __asm__ __volatile__
01756     ("cld\n"
01757      "1:\n\t"
01758      "lodsb\n\t"
01759      "testb   %%al,%%al\n\t"
01760      "je      2f\n\t"
01761      "movl    %5,%%edi\n\t"
01762      "movl    %6,%%ecx\n\t"
01763      "repne; scasb\n\t"
01764      "jne     1b\n\t"
01765      "decl    %0\n\t"
01766      "jmp     3f\n"
01767      "2:\n\t"
01768      "xorl    %0,%0\n"
01769      "3:"
01770      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
01771      : "0" (__s), "d" (__accept), "g" (__accept_len)
01772      : "memory", "cc");
01773   return __res;
01774 }
01775 
01776 __STRING_INLINE char *__strpbrk_g (__const char *__s, __const char *__accept);
01777 #ifdef __PIC__
01778 
01779 __STRING_INLINE char *
01780 __strpbrk_g (__const char *__s, __const char *__accept)
01781 {
01782   register unsigned long int __d0, __d1, __d2;
01783   register char *__res;
01784   __asm__ __volatile__
01785     ("pushl   %%ebx\n\t"
01786      "movl    %%edx,%%edi\n\t"
01787      "cld\n\t"
01788      "repne; scasb\n\t"
01789      "notl    %%ecx\n\t"
01790      "leal    -1(%%ecx),%%ebx\n"
01791      "1:\n\t"
01792      "lodsb\n\t"
01793      "testb   %%al,%%al\n\t"
01794      "je      2f\n\t"
01795      "movl    %%edx,%%edi\n\t"
01796      "movl    %%ebx,%%ecx\n\t"
01797      "repne; scasb\n\t"
01798      "jne     1b\n\t"
01799      "decl    %0\n\t"
01800      "jmp     3f\n"
01801      "2:\n\t"
01802      "xorl    %0,%0\n"
01803      "3:\n\t"
01804      "popl    %%ebx"
01805      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
01806      : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
01807      : "memory", "cc");
01808   return __res;
01809 }
01810 #else
01811 __STRING_INLINE char *
01812 __strpbrk_g (__const char *__s, __const char *__accept)
01813 {
01814   register unsigned long int __d0, __d1, __d2, __d3;
01815   register char *__res;
01816   __asm__ __volatile__
01817     ("movl    %%ebx,%%edi\n\t"
01818      "cld\n\t"
01819      "repne; scasb\n\t"
01820      "notl    %%ecx\n\t"
01821      "leal    -1(%%ecx),%%edx\n"
01822      "1:\n\t"
01823      "lodsb\n\t"
01824      "testb   %%al,%%al\n\t"
01825      "je      2f\n\t"
01826      "movl    %%ebx,%%edi\n\t"
01827      "movl    %%edx,%%ecx\n\t"
01828      "repne; scasb\n\t"
01829      "jne     1b\n\t"
01830      "decl    %0\n\t"
01831      "jmp     3f\n"
01832      "2:\n\t"
01833      "xorl    %0,%0\n"
01834      "3:"
01835      : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
01836      : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept)
01837      : "memory", "cc");
01838   return __res;
01839 }
01840 #endif
01841 
01842 
01843 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
01844 #define _HAVE_STRING_ARCH_strstr 1
01845 #define strstr(haystack, needle) \
01846   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
01847                 ? ((needle)[0] == '\0'                               \
01848                    ? (haystack)                                      \
01849                    : ((needle)[1] == '\0'                            \
01850                      ? strchr ((haystack), (needle)[0])              \
01851                      : __strstr_cg ((haystack), (needle),                   \
01852                                    strlen (needle))))                \
01853                 : __strstr_g ((haystack), (needle))))
01854 
01855 /* Please note that this function need not handle NEEDLEs with a
01856    length shorter than two.  */
01857 __STRING_INLINE char *__strstr_cg (__const char *__haystack, __const char __needle[],
01858                                size_t __needle_len);
01859 
01860 __STRING_INLINE char *
01861 __strstr_cg (__const char *__haystack, __const char __needle[],
01862             size_t __needle_len)
01863 {
01864   register unsigned long int __d0, __d1, __d2;
01865   register char *__res;
01866   __asm__ __volatile__
01867     ("cld\n" \
01868      "1:\n\t"
01869      "movl    %6,%%edi\n\t"
01870      "movl    %5,%%eax\n\t"
01871      "movl    %4,%%ecx\n\t"
01872      "repe; cmpsb\n\t"
01873      "je      2f\n\t"
01874      "cmpb    $0,-1(%%esi)\n\t"
01875      "leal    1(%%eax),%5\n\t"
01876      "jne     1b\n\t"
01877      "xorl    %%eax,%%eax\n"
01878      "2:"
01879      : "=&a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2)
01880      : "g" (__needle_len), "1" (__haystack), "d" (__needle)
01881      : "memory", "cc");
01882   return __res;
01883 }
01884 
01885 __STRING_INLINE char *__strstr_g (__const char *__haystack, __const char *__needle);
01886 #ifdef __PIC__
01887 
01888 __STRING_INLINE char *
01889 __strstr_g (__const char *__haystack, __const char *__needle)
01890 {
01891   register unsigned long int __d0, __d1, __d2;
01892   register char *__res;
01893   __asm__ __volatile__
01894     ("cld\n\t"
01895      "repne; scasb\n\t"
01896      "notl    %%ecx\n\t"
01897      "pushl   %%ebx\n\t"
01898      "decl    %%ecx\n\t"    /* NOTE! This also sets Z if searchstring='' */
01899      "movl    %%ecx,%%ebx\n"
01900      "1:\n\t"
01901      "movl    %%edx,%%edi\n\t"
01902      "movl    %%esi,%%eax\n\t"
01903      "movl    %%ebx,%%ecx\n\t"
01904      "repe; cmpsb\n\t"
01905      "je      2f\n\t"              /* also works for empty string, see above */
01906      "cmpb    $0,-1(%%esi)\n\t"
01907      "leal    1(%%eax),%%esi\n\t"
01908      "jne     1b\n\t"
01909      "xorl    %%eax,%%eax\n"
01910      "2:\n\t"
01911      "popl    %%ebx"
01912      : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
01913      : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle),
01914        "d" (__needle)
01915      : "memory", "cc");
01916   return __res;
01917 }
01918 #else
01919 __STRING_INLINE char *
01920 __strstr_g (__const char *__haystack, __const char *__needle)
01921 {
01922   register unsigned long int __d0, __d1, __d2, __d3;
01923   register char *__res;
01924   __asm__ __volatile__
01925     ("cld\n\t"
01926      "repne; scasb\n\t"
01927      "notl    %%ecx\n\t"
01928      "decl    %%ecx\n\t"    /* NOTE! This also sets Z if searchstring='' */
01929      "movl    %%ecx,%%edx\n"
01930      "1:\n\t"
01931      "movl    %%ebx,%%edi\n\t"
01932      "movl    %%esi,%%eax\n\t"
01933      "movl    %%edx,%%ecx\n\t"
01934      "repe; cmpsb\n\t"
01935      "je      2f\n\t"              /* also works for empty string, see above */
01936      "cmpb    $0,-1(%%esi)\n\t"
01937      "leal    1(%%eax),%%esi\n\t"
01938      "jne     1b\n\t"
01939      "xorl    %%eax,%%eax\n"
01940      "2:"
01941      : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), "=&d" (__d3)
01942      : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle),
01943        "b" (__needle)
01944      : "memory", "cc");
01945   return __res;
01946 }
01947 #endif
01948 
01949 
01950 /* Bit find functions.  We define only the i686 version since for the other
01951    processors gcc generates good code.  */
01952 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
01953 # ifdef __i686__
01954 #  define _HAVE_STRING_ARCH_ffs 1
01955 #  define ffs(word) (__builtin_constant_p (word)                     \
01956                    ? __builtin_ffs (word)                            \
01957                    : ({ int __cnt, __tmp;                            \
01958                        __asm__ __volatile__                                 \
01959                          ("bsfl %2,%0\n\t"                                  \
01960                           "cmovel %1,%0"                             \
01961                           : "=&r" (__cnt), "=r" (__tmp)              \
01962                           : "rm" (word), "1" (-1));                         \
01963                        __cnt + 1; }))
01964 
01965 #  ifndef ffsl
01966 #   define ffsl(word) ffs(word)
01967 #  endif
01968 # endif       /* i686 */
01969 #endif /* BSD || X/Open */
01970 
01971 #ifndef _FORCE_INLINES
01972 # undef __STRING_INLINE
01973 #endif
01974 
01975 #endif /* use string inlines && GNU CC */