Back to index

glibc  2.9
string2.h
Go to the documentation of this file.
00001 /* Machine-independant string function optimizations.
00002    Copyright (C) 1997-2003, 2004, 2007, 2008 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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/string2.h> directly; include <string.h> instead."
00023 #endif
00024 
00025 #if !defined __NO_STRING_INLINES && !defined __BOUNDED_POINTERS__
00026 
00027 /* Unlike the definitions in the header <bits/string.h> the
00028    definitions contained here are not optimized down to assembler
00029    level.  Those optimizations are not always a good idea since this
00030    means the code size increases a lot.  Instead the definitions here
00031    optimize some functions in a way which do not dramatically
00032    increase the code size and which do not use assembler.  The main
00033    trick is to use GCC's `__builtin_constant_p' function.
00034 
00035    Every function XXX which has a defined version in
00036    <bits/string.h> must be accompanied by a symbol _HAVE_STRING_ARCH_XXX
00037    to make sure we don't get redefinitions.
00038 
00039    We must use here macros instead of inline functions since the
00040    trick won't work with the latter.  */
00041 
00042 #ifndef __STRING_INLINE
00043 # ifdef __cplusplus
00044 #  define __STRING_INLINE inline
00045 # else
00046 #  define __STRING_INLINE __extern_inline
00047 # endif
00048 #endif
00049 
00050 #if _STRING_ARCH_unaligned
00051 /* If we can do unaligned memory accesses we must know the endianess.  */
00052 # include <endian.h>
00053 # include <bits/types.h>
00054 
00055 # if __BYTE_ORDER == __LITTLE_ENDIAN
00056 #  define __STRING2_SMALL_GET16(src, idx) \
00057      (((__const unsigned char *) (__const char *) (src))[idx + 1] << 8             \
00058       | ((__const unsigned char *) (__const char *) (src))[idx])
00059 #  define __STRING2_SMALL_GET32(src, idx) \
00060      (((((__const unsigned char *) (__const char *) (src))[idx + 3] << 8      \
00061        | ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8   \
00062        | ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8    \
00063       | ((__const unsigned char *) (__const char *) (src))[idx])
00064 # else
00065 #  define __STRING2_SMALL_GET16(src, idx) \
00066      (((__const unsigned char *) (__const char *) (src))[idx] << 8          \
00067       | ((__const unsigned char *) (__const char *) (src))[idx + 1])
00068 #  define __STRING2_SMALL_GET32(src, idx) \
00069      (((((__const unsigned char *) (__const char *) (src))[idx] << 8        \
00070        | ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8   \
00071        | ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8    \
00072       | ((__const unsigned char *) (__const char *) (src))[idx + 3])
00073 # endif
00074 #else
00075 /* These are a few types we need for the optimizations if we cannot
00076    use unaligned memory accesses.  */
00077 # define __STRING2_COPY_TYPE(N) \
00078   typedef struct { unsigned char __arr[N]; }                                \
00079     __attribute__ ((__packed__)) __STRING2_COPY_ARR##N
00080 __STRING2_COPY_TYPE (2);
00081 __STRING2_COPY_TYPE (3);
00082 __STRING2_COPY_TYPE (4);
00083 __STRING2_COPY_TYPE (5);
00084 __STRING2_COPY_TYPE (6);
00085 __STRING2_COPY_TYPE (7);
00086 __STRING2_COPY_TYPE (8);
00087 # undef __STRING2_COPY_TYPE
00088 #endif
00089 
00090 /* Dereferencing a pointer arg to run sizeof on it fails for the void
00091    pointer case, so we use this instead.
00092    Note that __x is evaluated twice. */
00093 #define __string2_1bptr_p(__x) \
00094   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
00095 
00096 /* Set N bytes of S to C.  */
00097 #if !defined _HAVE_STRING_ARCH_memset
00098 # if !__GNUC_PREREQ (3, 0)
00099 #  if _STRING_ARCH_unaligned
00100 #   define memset(s, c, n) \
00101   (__extension__ (__builtin_constant_p (n) && (n) <= 16                     \
00102                 ? ((n) == 1                                          \
00103                    ? __memset_1 (s, c)                               \
00104                    : __memset_gc (s, c, n))                                 \
00105                 : (__builtin_constant_p (c) && (c) == '\0'                  \
00106                    ? ({ void *__s = (s); __bzero (__s, n); __s; })          \
00107                    : memset (s, c, n))))
00108 
00109 #   define __memset_1(s, c) ({ void *__s = (s);                             \
00110                          *((__uint8_t *) __s) = (__uint8_t) c; __s; })
00111 
00112 #   define __memset_gc(s, c, n) \
00113   ({ void *__s = (s);                                                       \
00114      union {                                                         \
00115        unsigned int __ui;                                            \
00116        unsigned short int __usi;                                     \
00117        unsigned char __uc;                                           \
00118      } *__u = __s;                                                   \
00119      __uint8_t __c = (__uint8_t) (c);                                       \
00120                                                                      \
00121      /* This `switch' statement will be removed at compile-time.  */        \
00122      switch ((unsigned int) (n))                                     \
00123        {                                                             \
00124        case 15:                                                             \
00125         __u->__ui = __c * 0x01010101;                                       \
00126         __u = __extension__ ((void *) __u + 4);                      \
00127        case 11:                                                             \
00128         __u->__ui = __c * 0x01010101;                                       \
00129         __u = __extension__ ((void *) __u + 4);                      \
00130        case 7:                                                              \
00131         __u->__ui = __c * 0x01010101;                                       \
00132         __u = __extension__ ((void *) __u + 4);                      \
00133        case 3:                                                              \
00134         __u->__usi = (unsigned short int) __c * 0x0101;              \
00135         __u = __extension__ ((void *) __u + 2);                      \
00136         __u->__uc = (unsigned char) __c;                             \
00137         break;                                                              \
00138                                                                      \
00139        case 14:                                                             \
00140         __u->__ui = __c * 0x01010101;                                       \
00141         __u = __extension__ ((void *) __u + 4);                      \
00142        case 10:                                                             \
00143         __u->__ui = __c * 0x01010101;                                       \
00144         __u = __extension__ ((void *) __u + 4);                      \
00145        case 6:                                                              \
00146         __u->__ui = __c * 0x01010101;                                       \
00147         __u = __extension__ ((void *) __u + 4);                      \
00148        case 2:                                                              \
00149         __u->__usi = (unsigned short int) __c * 0x0101;              \
00150         break;                                                              \
00151                                                                      \
00152        case 13:                                                             \
00153         __u->__ui = __c * 0x01010101;                                       \
00154         __u = __extension__ ((void *) __u + 4);                      \
00155        case 9:                                                              \
00156         __u->__ui = __c * 0x01010101;                                       \
00157         __u = __extension__ ((void *) __u + 4);                      \
00158        case 5:                                                              \
00159         __u->__ui = __c * 0x01010101;                                       \
00160         __u = __extension__ ((void *) __u + 4);                      \
00161        case 1:                                                              \
00162         __u->__uc = (unsigned char) __c;                             \
00163         break;                                                              \
00164                                                                      \
00165        case 16:                                                             \
00166         __u->__ui = __c * 0x01010101;                                       \
00167         __u = __extension__ ((void *) __u + 4);                      \
00168        case 12:                                                             \
00169         __u->__ui = __c * 0x01010101;                                       \
00170         __u = __extension__ ((void *) __u + 4);                      \
00171        case 8:                                                              \
00172         __u->__ui = __c * 0x01010101;                                       \
00173         __u = __extension__ ((void *) __u + 4);                      \
00174        case 4:                                                              \
00175         __u->__ui = __c * 0x01010101;                                       \
00176        case 0:                                                              \
00177         break;                                                              \
00178        }                                                             \
00179                                                                      \
00180      __s; })
00181 #  else
00182 #   define memset(s, c, n) \
00183   (__extension__ (__builtin_constant_p (c) && (c) == '\0'                   \
00184                 ? ({ void *__s = (s); __bzero (__s, n); __s; })             \
00185                 : memset (s, c, n)))
00186 #  endif
00187 # endif
00188 
00189 /* GCC < 3.0 optimizes memset(s, 0, n) but not bzero(s, n).
00190    The optimization is broken before EGCS 1.1.
00191    GCC 3.0+ has __builtin_bzero as well, but at least till GCC 3.4
00192    if it decides to call the library function, it calls memset
00193    and not bzero.  */
00194 # if __GNUC_PREREQ (2, 91)
00195 #  define __bzero(s, n) __builtin_memset (s, '\0', n)
00196 # endif
00197 
00198 #endif
00199 
00200 
00201 /* Copy N bytes from SRC to DEST, returning pointer to byte following the
00202    last copied.  */
00203 #ifdef __USE_GNU
00204 # if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
00205 #  ifndef _HAVE_STRING_ARCH_mempcpy
00206 #   if __GNUC_PREREQ (3, 4)
00207 #    define __mempcpy(dest, src, n) __builtin_mempcpy (dest, src, n)
00208 #   elif __GNUC_PREREQ (3, 0)
00209 #    define __mempcpy(dest, src, n) \
00210   (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
00211                 && __string2_1bptr_p (src) && n <= 8                        \
00212                 ? __builtin_memcpy (dest, src, n) + (n)              \
00213                 : __mempcpy (dest, src, n)))
00214 #   else
00215 #    define __mempcpy(dest, src, n) \
00216   (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
00217                 && __string2_1bptr_p (src) && n <= 8                        \
00218                 ? __mempcpy_small (dest, __mempcpy_args (src), n)           \
00219                 : __mempcpy (dest, src, n)))
00220 #   endif
00221 /* In glibc we use this function frequently but for namespace reasons
00222    we have to use the name `__mempcpy'.  */
00223 #   define mempcpy(dest, src, n) __mempcpy (dest, src, n)
00224 #  endif
00225 
00226 #  if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
00227 #   if _STRING_ARCH_unaligned
00228 #    ifndef _FORCE_INLINES
00229 #     define __mempcpy_args(src) \
00230      ((__const char *) (src))[0], ((__const char *) (src))[2],              \
00231      ((__const char *) (src))[4], ((__const char *) (src))[6],              \
00232      __extension__ __STRING2_SMALL_GET16 (src, 0),                          \
00233      __extension__ __STRING2_SMALL_GET16 (src, 4),                          \
00234      __extension__ __STRING2_SMALL_GET32 (src, 0),                          \
00235      __extension__ __STRING2_SMALL_GET32 (src, 4)
00236 #    endif
00237 __STRING_INLINE void *__mempcpy_small (void *, char, char, char, char,
00238                                    __uint16_t, __uint16_t, __uint32_t,
00239                                    __uint32_t, size_t);
00240 __STRING_INLINE void *
00241 __mempcpy_small (void *__dest1,
00242                char __src0_1, char __src2_1, char __src4_1, char __src6_1,
00243                __uint16_t __src0_2, __uint16_t __src4_2,
00244                __uint32_t __src0_4, __uint32_t __src4_4,
00245                size_t __srclen)
00246 {
00247   union {
00248     __uint32_t __ui;
00249     __uint16_t __usi;
00250     unsigned char __uc;
00251     unsigned char __c;
00252   } *__u = __dest1;
00253   switch ((unsigned int) __srclen)
00254     {
00255     case 1:
00256       __u->__c = __src0_1;
00257       __u = __extension__ ((void *) __u + 1);
00258       break;
00259     case 2:
00260       __u->__usi = __src0_2;
00261       __u = __extension__ ((void *) __u + 2);
00262       break;
00263     case 3:
00264       __u->__usi = __src0_2;
00265       __u = __extension__ ((void *) __u + 2);
00266       __u->__c = __src2_1;
00267       __u = __extension__ ((void *) __u + 1);
00268       break;
00269     case 4:
00270       __u->__ui = __src0_4;
00271       __u = __extension__ ((void *) __u + 4);
00272       break;
00273     case 5:
00274       __u->__ui = __src0_4;
00275       __u = __extension__ ((void *) __u + 4);
00276       __u->__c = __src4_1;
00277       __u = __extension__ ((void *) __u + 1);
00278       break;
00279     case 6:
00280       __u->__ui = __src0_4;
00281       __u = __extension__ ((void *) __u + 4);
00282       __u->__usi = __src4_2;
00283       __u = __extension__ ((void *) __u + 2);
00284       break;
00285     case 7:
00286       __u->__ui = __src0_4;
00287       __u = __extension__ ((void *) __u + 4);
00288       __u->__usi = __src4_2;
00289       __u = __extension__ ((void *) __u + 2);
00290       __u->__c = __src6_1;
00291       __u = __extension__ ((void *) __u + 1);
00292       break;
00293     case 8:
00294       __u->__ui = __src0_4;
00295       __u = __extension__ ((void *) __u + 4);
00296       __u->__ui = __src4_4;
00297       __u = __extension__ ((void *) __u + 4);
00298       break;
00299     }
00300   return (void *) __u;
00301 }
00302 #   else
00303 #    ifndef _FORCE_INLINES
00304 #     define __mempcpy_args(src) \
00305      ((__const char *) (src))[0],                                    \
00306      __extension__ ((__STRING2_COPY_ARR2)                            \
00307       { { ((__const char *) (src))[0], ((__const char *) (src))[1] } }),      \
00308      __extension__ ((__STRING2_COPY_ARR3)                            \
00309       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00310          ((__const char *) (src))[2] } }),                                  \
00311      __extension__ ((__STRING2_COPY_ARR4)                            \
00312       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00313          ((__const char *) (src))[2], ((__const char *) (src))[3] } }),      \
00314      __extension__ ((__STRING2_COPY_ARR5)                            \
00315       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00316          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00317          ((__const char *) (src))[4] } }),                                  \
00318      __extension__ ((__STRING2_COPY_ARR6)                            \
00319       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00320          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00321          ((__const char *) (src))[4], ((__const char *) (src))[5] } }),      \
00322      __extension__ ((__STRING2_COPY_ARR7)                            \
00323       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00324          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00325          ((__const char *) (src))[4], ((__const char *) (src))[5],          \
00326          ((__const char *) (src))[6] } }),                                  \
00327      __extension__ ((__STRING2_COPY_ARR8)                            \
00328       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00329          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00330          ((__const char *) (src))[4], ((__const char *) (src))[5],          \
00331          ((__const char *) (src))[6], ((__const char *) (src))[7] } })
00332 #    endif
00333 __STRING_INLINE void *__mempcpy_small (void *, char, __STRING2_COPY_ARR2,
00334                                    __STRING2_COPY_ARR3,
00335                                    __STRING2_COPY_ARR4,
00336                                    __STRING2_COPY_ARR5,
00337                                    __STRING2_COPY_ARR6,
00338                                    __STRING2_COPY_ARR7,
00339                                    __STRING2_COPY_ARR8, size_t);
00340 __STRING_INLINE void *
00341 __mempcpy_small (void *__dest, char __src1,
00342                __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3,
00343                __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5,
00344                __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7,
00345                __STRING2_COPY_ARR8 __src8, size_t __srclen)
00346 {
00347   union {
00348     char __c;
00349     __STRING2_COPY_ARR2 __sca2;
00350     __STRING2_COPY_ARR3 __sca3;
00351     __STRING2_COPY_ARR4 __sca4;
00352     __STRING2_COPY_ARR5 __sca5;
00353     __STRING2_COPY_ARR6 __sca6;
00354     __STRING2_COPY_ARR7 __sca7;
00355     __STRING2_COPY_ARR8 __sca8;
00356   } *__u = __dest;
00357   switch ((unsigned int) __srclen)
00358     {
00359     case 1:
00360       __u->__c = __src1;
00361       break;
00362     case 2:
00363       __extension__ __u->__sca2 = __src2;
00364       break;
00365     case 3:
00366       __extension__ __u->__sca3 = __src3;
00367       break;
00368     case 4:
00369       __extension__ __u->__sca4 = __src4;
00370       break;
00371     case 5:
00372       __extension__ __u->__sca5 = __src5;
00373       break;
00374     case 6:
00375       __extension__ __u->__sca6 = __src6;
00376       break;
00377     case 7:
00378       __extension__ __u->__sca7 = __src7;
00379       break;
00380     case 8:
00381       __extension__ __u->__sca8 = __src8;
00382       break;
00383     }
00384   return __extension__ ((void *) __u + __srclen);
00385 }
00386 #   endif
00387 #  endif
00388 # endif
00389 #endif
00390 
00391 
00392 /* Return pointer to C in S.  */
00393 #ifndef _HAVE_STRING_ARCH_strchr
00394 extern void *__rawmemchr (const void *__s, int __c);
00395 # if __GNUC_PREREQ (3, 2)
00396 #  define strchr(s, c) \
00397   (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s)            \
00398                 && (c) == '\0'                                       \
00399                 ? (char *) __rawmemchr (s, c)                               \
00400                 : __builtin_strchr (s, c)))
00401 # else
00402 #  define strchr(s, c) \
00403   (__extension__ (__builtin_constant_p (c) && (c) == '\0'                   \
00404                 ? (char *) __rawmemchr (s, c)                               \
00405                 : strchr (s, c)))
00406 # endif
00407 #endif
00408 
00409 
00410 /* Copy SRC to DEST.  */
00411 #if (!defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)) \
00412     || defined _FORCE_INLINES
00413 # if !defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)
00414 #  define strcpy(dest, src) \
00415   (__extension__ (__builtin_constant_p (src)                                \
00416                 ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8         \
00417                    ? __strcpy_small (dest, __strcpy_args (src),             \
00418                                    strlen (src) + 1)                 \
00419                    : (char *) memcpy (dest, src, strlen (src) + 1))         \
00420                 : strcpy (dest, src)))
00421 # endif
00422 
00423 # if _STRING_ARCH_unaligned
00424 #  ifndef _FORCE_INLINES
00425 #   define __strcpy_args(src) \
00426      __extension__ __STRING2_SMALL_GET16 (src, 0),                          \
00427      __extension__ __STRING2_SMALL_GET16 (src, 4),                          \
00428      __extension__ __STRING2_SMALL_GET32 (src, 0),                          \
00429      __extension__ __STRING2_SMALL_GET32 (src, 4)
00430 #  endif
00431 __STRING_INLINE char *__strcpy_small (char *, __uint16_t, __uint16_t,
00432                                   __uint32_t, __uint32_t, size_t);
00433 __STRING_INLINE char *
00434 __strcpy_small (char *__dest,
00435               __uint16_t __src0_2, __uint16_t __src4_2,
00436               __uint32_t __src0_4, __uint32_t __src4_4,
00437               size_t __srclen)
00438 {
00439   union {
00440     __uint32_t __ui;
00441     __uint16_t __usi;
00442     unsigned char __uc;
00443   } *__u = (void *) __dest;
00444   switch ((unsigned int) __srclen)
00445     {
00446     case 1:
00447       __u->__uc = '\0';
00448       break;
00449     case 2:
00450       __u->__usi = __src0_2;
00451       break;
00452     case 3:
00453       __u->__usi = __src0_2;
00454       __u = __extension__ ((void *) __u + 2);
00455       __u->__uc = '\0';
00456       break;
00457     case 4:
00458       __u->__ui = __src0_4;
00459       break;
00460     case 5:
00461       __u->__ui = __src0_4;
00462       __u = __extension__ ((void *) __u + 4);
00463       __u->__uc = '\0';
00464       break;
00465     case 6:
00466       __u->__ui = __src0_4;
00467       __u = __extension__ ((void *) __u + 4);
00468       __u->__usi = __src4_2;
00469       break;
00470     case 7:
00471       __u->__ui = __src0_4;
00472       __u = __extension__ ((void *) __u + 4);
00473       __u->__usi = __src4_2;
00474       __u = __extension__ ((void *) __u + 2);
00475       __u->__uc = '\0';
00476       break;
00477     case 8:
00478       __u->__ui = __src0_4;
00479       __u = __extension__ ((void *) __u + 4);
00480       __u->__ui = __src4_4;
00481       break;
00482     }
00483   return __dest;
00484 }
00485 # else
00486 #  ifndef _FORCE_INLINES
00487 #   define __strcpy_args(src) \
00488      __extension__ ((__STRING2_COPY_ARR2)                            \
00489       { { ((__const char *) (src))[0], '\0' } }),                           \
00490      __extension__ ((__STRING2_COPY_ARR3)                            \
00491       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00492          '\0' } }),                                                  \
00493      __extension__ ((__STRING2_COPY_ARR4)                            \
00494       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00495          ((__const char *) (src))[2], '\0' } }),                     \
00496      __extension__ ((__STRING2_COPY_ARR5)                            \
00497       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00498          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00499          '\0' } }),                                                  \
00500      __extension__ ((__STRING2_COPY_ARR6)                            \
00501       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00502          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00503          ((__const char *) (src))[4], '\0' } }),                     \
00504      __extension__ ((__STRING2_COPY_ARR7)                            \
00505       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00506          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00507          ((__const char *) (src))[4], ((__const char *) (src))[5],          \
00508          '\0' } }),                                                  \
00509      __extension__ ((__STRING2_COPY_ARR8)                            \
00510       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00511          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00512          ((__const char *) (src))[4], ((__const char *) (src))[5],          \
00513          ((__const char *) (src))[6], '\0' } })
00514 #  endif
00515 __STRING_INLINE char *__strcpy_small (char *, __STRING2_COPY_ARR2,
00516                                   __STRING2_COPY_ARR3,
00517                                   __STRING2_COPY_ARR4,
00518                                   __STRING2_COPY_ARR5,
00519                                   __STRING2_COPY_ARR6,
00520                                   __STRING2_COPY_ARR7,
00521                                   __STRING2_COPY_ARR8, size_t);
00522 __STRING_INLINE char *
00523 __strcpy_small (char *__dest,
00524               __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3,
00525               __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5,
00526               __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7,
00527               __STRING2_COPY_ARR8 __src8, size_t __srclen)
00528 {
00529   union {
00530     char __c;
00531     __STRING2_COPY_ARR2 __sca2;
00532     __STRING2_COPY_ARR3 __sca3;
00533     __STRING2_COPY_ARR4 __sca4;
00534     __STRING2_COPY_ARR5 __sca5;
00535     __STRING2_COPY_ARR6 __sca6;
00536     __STRING2_COPY_ARR7 __sca7;
00537     __STRING2_COPY_ARR8 __sca8;
00538   } *__u = (void *) __dest;
00539   switch ((unsigned int) __srclen)
00540     {
00541     case 1:
00542       __u->__c = '\0';
00543       break;
00544     case 2:
00545       __extension__ __u->__sca2 = __src2;
00546       break;
00547     case 3:
00548       __extension__ __u->__sca3 = __src3;
00549       break;
00550     case 4:
00551       __extension__ __u->__sca4 = __src4;
00552       break;
00553     case 5:
00554       __extension__ __u->__sca5 = __src5;
00555       break;
00556     case 6:
00557       __extension__ __u->__sca6 = __src6;
00558       break;
00559     case 7:
00560       __extension__ __u->__sca7 = __src7;
00561       break;
00562     case 8:
00563       __extension__ __u->__sca8 = __src8;
00564       break;
00565   }
00566   return __dest;
00567 }
00568 # endif
00569 #endif
00570 
00571 
00572 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
00573 #ifdef __USE_GNU
00574 # if !defined _HAVE_STRING_ARCH_stpcpy || defined _FORCE_INLINES
00575 #  ifndef _HAVE_STRING_ARCH_stpcpy
00576 #   if __GNUC_PREREQ (3, 4)
00577 #    define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
00578 #   elif __GNUC_PREREQ (3, 0)
00579 #    define __stpcpy(dest, src) \
00580   (__extension__ (__builtin_constant_p (src)                                \
00581                 ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8         \
00582                    ? __builtin_strcpy (dest, src) + strlen (src)            \
00583                    : ((char *) (__mempcpy) (dest, src, strlen (src) + 1)    \
00584                      - 1))                                           \
00585                 : __stpcpy (dest, src)))
00586 #   else
00587 #    define __stpcpy(dest, src) \
00588   (__extension__ (__builtin_constant_p (src)                                \
00589                 ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8         \
00590                    ? __stpcpy_small (dest, __stpcpy_args (src),             \
00591                                    strlen (src) + 1)                 \
00592                    : ((char *) (__mempcpy) (dest, src, strlen (src) + 1)    \
00593                      - 1))                                           \
00594                 : __stpcpy (dest, src)))
00595 #   endif
00596 /* In glibc we use this function frequently but for namespace reasons
00597    we have to use the name `__stpcpy'.  */
00598 #   define stpcpy(dest, src) __stpcpy (dest, src)
00599 #  endif
00600 
00601 #  if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
00602 #   if _STRING_ARCH_unaligned
00603 #    ifndef _FORCE_INLINES
00604 #     define __stpcpy_args(src) \
00605      __extension__ __STRING2_SMALL_GET16 (src, 0),                          \
00606      __extension__ __STRING2_SMALL_GET16 (src, 4),                          \
00607      __extension__ __STRING2_SMALL_GET32 (src, 0),                          \
00608      __extension__ __STRING2_SMALL_GET32 (src, 4)
00609 #    endif
00610 __STRING_INLINE char *__stpcpy_small (char *, __uint16_t, __uint16_t,
00611                                   __uint32_t, __uint32_t, size_t);
00612 __STRING_INLINE char *
00613 __stpcpy_small (char *__dest,
00614               __uint16_t __src0_2, __uint16_t __src4_2,
00615               __uint32_t __src0_4, __uint32_t __src4_4,
00616               size_t __srclen)
00617 {
00618   union {
00619     unsigned int __ui;
00620     unsigned short int __usi;
00621     unsigned char __uc;
00622     char __c;
00623   } *__u = (void *) __dest;
00624   switch ((unsigned int) __srclen)
00625     {
00626     case 1:
00627       __u->__uc = '\0';
00628       break;
00629     case 2:
00630       __u->__usi = __src0_2;
00631       __u = __extension__ ((void *) __u + 1);
00632       break;
00633     case 3:
00634       __u->__usi = __src0_2;
00635       __u = __extension__ ((void *) __u + 2);
00636       __u->__uc = '\0';
00637       break;
00638     case 4:
00639       __u->__ui = __src0_4;
00640       __u = __extension__ ((void *) __u + 3);
00641       break;
00642     case 5:
00643       __u->__ui = __src0_4;
00644       __u = __extension__ ((void *) __u + 4);
00645       __u->__uc = '\0';
00646       break;
00647     case 6:
00648       __u->__ui = __src0_4;
00649       __u = __extension__ ((void *) __u + 4);
00650       __u->__usi = __src4_2;
00651       __u = __extension__ ((void *) __u + 1);
00652       break;
00653     case 7:
00654       __u->__ui = __src0_4;
00655       __u = __extension__ ((void *) __u + 4);
00656       __u->__usi = __src4_2;
00657       __u = __extension__ ((void *) __u + 2);
00658       __u->__uc = '\0';
00659       break;
00660     case 8:
00661       __u->__ui = __src0_4;
00662       __u = __extension__ ((void *) __u + 4);
00663       __u->__ui = __src4_4;
00664       __u = __extension__ ((void *) __u + 3);
00665       break;
00666     }
00667   return &__u->__c;
00668 }
00669 #   else
00670 #    ifndef _FORCE_INLINES
00671 #     define __stpcpy_args(src) \
00672      __extension__ ((__STRING2_COPY_ARR2)                            \
00673       { { ((__const char *) (src))[0], '\0' } }),                           \
00674      __extension__ ((__STRING2_COPY_ARR3)                            \
00675       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00676          '\0' } }),                                                  \
00677      __extension__ ((__STRING2_COPY_ARR4)                            \
00678       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00679          ((__const char *) (src))[2], '\0' } }),                     \
00680      __extension__ ((__STRING2_COPY_ARR5)                            \
00681       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00682          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00683          '\0' } }),                                                  \
00684      __extension__ ((__STRING2_COPY_ARR6)                            \
00685       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00686          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00687          ((__const char *) (src))[4], '\0' } }),                     \
00688      __extension__ ((__STRING2_COPY_ARR7)                            \
00689       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00690          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00691          ((__const char *) (src))[4], ((__const char *) (src))[5],          \
00692          '\0' } }),                                                  \
00693      __extension__ ((__STRING2_COPY_ARR8)                            \
00694       { { ((__const char *) (src))[0], ((__const char *) (src))[1],         \
00695          ((__const char *) (src))[2], ((__const char *) (src))[3],          \
00696          ((__const char *) (src))[4], ((__const char *) (src))[5],          \
00697          ((__const char *) (src))[6], '\0' } })
00698 #    endif
00699 __STRING_INLINE char *__stpcpy_small (char *, __STRING2_COPY_ARR2,
00700                                   __STRING2_COPY_ARR3,
00701                                   __STRING2_COPY_ARR4,
00702                                   __STRING2_COPY_ARR5,
00703                                   __STRING2_COPY_ARR6,
00704                                   __STRING2_COPY_ARR7,
00705                                   __STRING2_COPY_ARR8, size_t);
00706 __STRING_INLINE char *
00707 __stpcpy_small (char *__dest,
00708               __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3,
00709               __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5,
00710               __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7,
00711               __STRING2_COPY_ARR8 __src8, size_t __srclen)
00712 {
00713   union {
00714     char __c;
00715     __STRING2_COPY_ARR2 __sca2;
00716     __STRING2_COPY_ARR3 __sca3;
00717     __STRING2_COPY_ARR4 __sca4;
00718     __STRING2_COPY_ARR5 __sca5;
00719     __STRING2_COPY_ARR6 __sca6;
00720     __STRING2_COPY_ARR7 __sca7;
00721     __STRING2_COPY_ARR8 __sca8;
00722   } *__u = (void *) __dest;
00723   switch ((unsigned int) __srclen)
00724     {
00725     case 1:
00726       __u->__c = '\0';
00727       break;
00728     case 2:
00729       __extension__ __u->__sca2 = __src2;
00730       break;
00731     case 3:
00732       __extension__ __u->__sca3 = __src3;
00733       break;
00734     case 4:
00735       __extension__ __u->__sca4 = __src4;
00736       break;
00737     case 5:
00738       __extension__ __u->__sca5 = __src5;
00739       break;
00740     case 6:
00741       __extension__ __u->__sca6 = __src6;
00742       break;
00743     case 7:
00744       __extension__ __u->__sca7 = __src7;
00745       break;
00746     case 8:
00747       __extension__ __u->__sca8 = __src8;
00748       break;
00749   }
00750   return __dest + __srclen - 1;
00751 }
00752 #   endif
00753 #  endif
00754 # endif
00755 #endif
00756 
00757 
00758 /* Copy no more than N characters of SRC to DEST.  */
00759 #ifndef _HAVE_STRING_ARCH_strncpy
00760 # if __GNUC_PREREQ (3, 2)
00761 #  define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
00762 # else
00763 #  define strncpy(dest, src, n) \
00764   (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
00765                 ? (strlen (src) + 1 >= ((size_t) (n))                       \
00766                    ? (char *) memcpy (dest, src, n)                         \
00767                    : strncpy (dest, src, n))                                \
00768                 : strncpy (dest, src, n)))
00769 # endif
00770 #endif
00771 
00772 
00773 /* Append no more than N characters from SRC onto DEST.  */
00774 #ifndef _HAVE_STRING_ARCH_strncat
00775 # ifdef _USE_STRING_ARCH_strchr
00776 #  define strncat(dest, src, n) \
00777   (__extension__ ({ char *__dest = (dest);                                  \
00778                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
00779                   ? (strlen (src) < ((size_t) (n))                          \
00780                      ? strcat (__dest, src)                                 \
00781                      : (*((char *) __mempcpy (strchr (__dest, '\0'),        \
00782                                           src, n)) = '\0', __dest))     \
00783                   : strncat (dest, src, n); }))
00784 # elif __GNUC_PREREQ (3, 2)
00785 #  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
00786 # else
00787 #  define strncat(dest, src, n) \
00788   (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
00789                 ? (strlen (src) < ((size_t) (n))                     \
00790                    ? strcat (dest, src)                              \
00791                    : strncat (dest, src, n))                                \
00792                 : strncat (dest, src, n)))
00793 # endif
00794 #endif
00795 
00796 
00797 /* Compare characters of S1 and S2.  */
00798 #ifndef _HAVE_STRING_ARCH_strcmp
00799 # if __GNUC_PREREQ (3, 2)
00800 #  define strcmp(s1, s2) \
00801   __extension__                                                             \
00802   ({ size_t __s1_len, __s2_len;                                             \
00803      (__builtin_constant_p (s1) && __builtin_constant_p (s2)                \
00804       && (__s1_len = strlen (s1), __s2_len = strlen (s2),                   \
00805          (!__string2_1bptr_p (s1) || __s1_len >= 4)                         \
00806          && (!__string2_1bptr_p (s2) || __s2_len >= 4))              \
00807       ? __builtin_strcmp (s1, s2)                                    \
00808       : (__builtin_constant_p (s1) && __string2_1bptr_p (s1)                \
00809         && (__s1_len = strlen (s1), __s1_len < 4)                           \
00810         ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2)              \
00811            ? __builtin_strcmp (s1, s2)                                      \
00812            : __strcmp_cg (s1, s2, __s1_len))                                \
00813         : (__builtin_constant_p (s2) && __string2_1bptr_p (s2)              \
00814            && (__s2_len = strlen (s2), __s2_len < 4)                        \
00815            ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1)           \
00816               ? __builtin_strcmp (s1, s2)                            \
00817               : __strcmp_gc (s1, s2, __s2_len))                      \
00818            : __builtin_strcmp (s1, s2)))); })
00819 # else
00820 #  define strcmp(s1, s2) \
00821   __extension__                                                             \
00822   ({ size_t __s1_len, __s2_len;                                             \
00823      (__builtin_constant_p (s1) && __builtin_constant_p (s2)                \
00824       && (__s1_len = strlen (s1), __s2_len = strlen (s2),                   \
00825          (!__string2_1bptr_p (s1) || __s1_len >= 4)                         \
00826          && (!__string2_1bptr_p (s2) || __s2_len >= 4))              \
00827       ? memcmp ((__const char *) (s1), (__const char *) (s2),               \
00828               (__s1_len < __s2_len ? __s1_len : __s2_len) + 1)       \
00829       : (__builtin_constant_p (s1) && __string2_1bptr_p (s1)                \
00830         && (__s1_len = strlen (s1), __s1_len < 4)                           \
00831         ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2)              \
00832            ? __strcmp_cc (s1, s2, __s1_len)                                 \
00833            : __strcmp_cg (s1, s2, __s1_len))                                \
00834         : (__builtin_constant_p (s2) && __string2_1bptr_p (s2)              \
00835            && (__s2_len = strlen (s2), __s2_len < 4)                        \
00836            ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1)           \
00837               ? __strcmp_cc (s1, s2, __s2_len)                              \
00838               : __strcmp_gc (s1, s2, __s2_len))                      \
00839            : strcmp (s1, s2)))); })
00840 # endif
00841 
00842 # define __strcmp_cc(s1, s2, l) \
00843   (__extension__ ({ register int __result =                                 \
00844                     (((__const unsigned char *) (__const char *) (s1))[0]   \
00845                      - ((__const unsigned char *) (__const char *)(s2))[0]);\
00846                   if (l > 0 && __result == 0)                               \
00847                     {                                                       \
00848                      __result = (((__const unsigned char *)                 \
00849                                  (__const char *) (s1))[1]                  \
00850                                 - ((__const unsigned char *)         \
00851                                    (__const char *) (s2))[1]);       \
00852                      if (l > 1 && __result == 0)                     \
00853                        {                                             \
00854                          __result =                                         \
00855                            (((__const unsigned char *)               \
00856                             (__const char *) (s1))[2]                \
00857                             - ((__const unsigned char *)                    \
00858                               (__const char *) (s2))[2]);                   \
00859                          if (l > 2 && __result == 0)                        \
00860                            __result =                                \
00861                             (((__const unsigned char *)              \
00862                               (__const char *) (s1))[3]              \
00863                              - ((__const unsigned char *)                   \
00864                                 (__const char *) (s2))[3]);                 \
00865                        }                                             \
00866                     }                                                       \
00867                   __result; }))
00868 
00869 # define __strcmp_cg(s1, s2, l1) \
00870   (__extension__ ({ __const unsigned char *__s2 =                           \
00871                     (__const unsigned char *) (__const char *) (s2);        \
00872                   register int __result =                            \
00873                     (((__const unsigned char *) (__const char *) (s1))[0]   \
00874                      - __s2[0]);                                     \
00875                   if (l1 > 0 && __result == 0)                       \
00876                     {                                                       \
00877                      __result = (((__const unsigned char *)                 \
00878                                  (__const char *) (s1))[1] - __s2[1]);    \
00879                      if (l1 > 1 && __result == 0)                           \
00880                        {                                             \
00881                          __result = (((__const unsigned char *)             \
00882                                     (__const char *) (s1))[2] - __s2[2]);\
00883                          if (l1 > 2 && __result == 0)                \
00884                            __result = (((__const unsigned char *)           \
00885                                      (__const char *)  (s1))[3]             \
00886                                      - __s2[3]);                     \
00887                        }                                             \
00888                     }                                                       \
00889                   __result; }))
00890 
00891 # define __strcmp_gc(s1, s2, l2) \
00892   (__extension__ ({ __const unsigned char *__s1 =                           \
00893                     (__const unsigned char *) (__const char *) (s1);        \
00894                   register int __result =                            \
00895                     __s1[0] - ((__const unsigned char *)                    \
00896                              (__const char *) (s2))[0];              \
00897                   if (l2 > 0 && __result == 0)                       \
00898                     {                                                       \
00899                      __result = (__s1[1]                             \
00900                                 - ((__const unsigned char *)         \
00901                                    (__const char *) (s2))[1]);       \
00902                      if (l2 > 1 && __result == 0)                           \
00903                        {                                             \
00904                          __result =                                         \
00905                            (__s1[2] - ((__const unsigned char *)            \
00906                                      (__const char *) (s2))[2]);            \
00907                          if (l2 > 2 && __result == 0)                \
00908                            __result =                                \
00909                             (__s1[3]                                 \
00910                              - ((__const unsigned char *)                   \
00911                                 (__const char *) (s2))[3]);                 \
00912                        }                                             \
00913                     }                                                       \
00914                   __result; }))
00915 #endif
00916 
00917 
00918 /* Compare N characters of S1 and S2.  */
00919 #ifndef _HAVE_STRING_ARCH_strncmp
00920 # define strncmp(s1, s2, n)                                          \
00921   (__extension__ (__builtin_constant_p (n)                                  \
00922                 && ((__builtin_constant_p (s1)                       \
00923                      && strlen (s1) < ((size_t) (n)))                       \
00924                     || (__builtin_constant_p (s2)                           \
00925                        && strlen (s2) < ((size_t) (n))))                    \
00926                 ? strcmp (s1, s2) : strncmp (s1, s2, n)))
00927 #endif
00928 
00929 
00930 /* Return the length of the initial segment of S which
00931    consists entirely of characters not in REJECT.  */
00932 #if !defined _HAVE_STRING_ARCH_strcspn || defined _FORCE_INLINES
00933 # ifndef _HAVE_STRING_ARCH_strcspn
00934 #  if __GNUC_PREREQ (3, 2)
00935 #   define strcspn(s, reject) \
00936   __extension__                                                             \
00937   ({ char __r0, __r1, __r2;                                          \
00938      (__builtin_constant_p (reject) && __string2_1bptr_p (reject)           \
00939       ? ((__builtin_constant_p (s) && __string2_1bptr_p (s))                \
00940         ? __builtin_strcspn (s, reject)                              \
00941         : ((__r0 = ((__const char *) (reject))[0], __r0 == '\0')            \
00942            ? strlen (s)                                              \
00943            : ((__r1 = ((__const char *) (reject))[1], __r1 == '\0')         \
00944               ? __strcspn_c1 (s, __r0)                                      \
00945               : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0')             \
00946                 ? __strcspn_c2 (s, __r0, __r1)                       \
00947                 : (((__const char *) (reject))[3] == '\0'                   \
00948                    ? __strcspn_c3 (s, __r0, __r1, __r2)              \
00949                    : __builtin_strcspn (s, reject))))))              \
00950       : __builtin_strcspn (s, reject)); })
00951 #  else
00952 #   define strcspn(s, reject) \
00953   __extension__                                                             \
00954   ({ char __r0, __r1, __r2;                                          \
00955      (__builtin_constant_p (reject) && __string2_1bptr_p (reject)           \
00956       ? ((__r0 = ((__const char *) (reject))[0], __r0 == '\0')              \
00957         ? strlen (s)                                                 \
00958         : ((__r1 = ((__const char *) (reject))[1], __r1 == '\0')            \
00959            ? __strcspn_c1 (s, __r0)                                         \
00960            : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0')         \
00961               ? __strcspn_c2 (s, __r0, __r1)                                \
00962               : (((__const char *) (reject))[3] == '\0'              \
00963                 ? __strcspn_c3 (s, __r0, __r1, __r2)                        \
00964                 : strcspn (s, reject)))))                            \
00965       : strcspn (s, reject)); })
00966 #  endif
00967 # endif
00968 
00969 __STRING_INLINE size_t __strcspn_c1 (__const char *__s, int __reject);
00970 __STRING_INLINE size_t
00971 __strcspn_c1 (__const char *__s, int __reject)
00972 {
00973   register size_t __result = 0;
00974   while (__s[__result] != '\0' && __s[__result] != __reject)
00975     ++__result;
00976   return __result;
00977 }
00978 
00979 __STRING_INLINE size_t __strcspn_c2 (__const char *__s, int __reject1,
00980                                  int __reject2);
00981 __STRING_INLINE size_t
00982 __strcspn_c2 (__const char *__s, int __reject1, int __reject2)
00983 {
00984   register size_t __result = 0;
00985   while (__s[__result] != '\0' && __s[__result] != __reject1
00986         && __s[__result] != __reject2)
00987     ++__result;
00988   return __result;
00989 }
00990 
00991 __STRING_INLINE size_t __strcspn_c3 (__const char *__s, int __reject1,
00992                                  int __reject2, int __reject3);
00993 __STRING_INLINE size_t
00994 __strcspn_c3 (__const char *__s, int __reject1, int __reject2,
00995              int __reject3)
00996 {
00997   register size_t __result = 0;
00998   while (__s[__result] != '\0' && __s[__result] != __reject1
00999         && __s[__result] != __reject2 && __s[__result] != __reject3)
01000     ++__result;
01001   return __result;
01002 }
01003 #endif
01004 
01005 
01006 /* Return the length of the initial segment of S which
01007    consists entirely of characters in ACCEPT.  */
01008 #if !defined _HAVE_STRING_ARCH_strspn || defined _FORCE_INLINES
01009 # ifndef _HAVE_STRING_ARCH_strspn
01010 #  if __GNUC_PREREQ (3, 2)
01011 #   define strspn(s, accept) \
01012   __extension__                                                             \
01013   ({ char __a0, __a1, __a2;                                          \
01014      (__builtin_constant_p (accept) && __string2_1bptr_p (accept)           \
01015       ? ((__builtin_constant_p (s) && __string2_1bptr_p (s))                \
01016         ? __builtin_strspn (s, accept)                                      \
01017         : ((__a0 = ((__const char *) (accept))[0], __a0 == '\0')            \
01018            ? ((void) (s), 0)                                                \
01019            : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0')         \
01020               ? __strspn_c1 (s, __a0)                                       \
01021               : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0')             \
01022                 ? __strspn_c2 (s, __a0, __a1)                               \
01023                 : (((__const char *) (accept))[3] == '\0'                   \
01024                    ? __strspn_c3 (s, __a0, __a1, __a2)               \
01025                    : __builtin_strspn (s, accept))))))               \
01026       : __builtin_strspn (s, accept)); })
01027 #  else
01028 #   define strspn(s, accept) \
01029   __extension__                                                             \
01030   ({ char __a0, __a1, __a2;                                          \
01031      (__builtin_constant_p (accept) && __string2_1bptr_p (accept)           \
01032       ? ((__a0 = ((__const char *) (accept))[0], __a0 == '\0')              \
01033         ? ((void) (s), 0)                                            \
01034         : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0')            \
01035            ? __strspn_c1 (s, __a0)                                   \
01036            : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0')         \
01037               ? __strspn_c2 (s, __a0, __a1)                                 \
01038               : (((__const char *) (accept))[3] == '\0'              \
01039                 ? __strspn_c3 (s, __a0, __a1, __a2)                         \
01040                 : strspn (s, accept)))))                             \
01041       : strspn (s, accept)); })
01042 #  endif
01043 # endif
01044 
01045 __STRING_INLINE size_t __strspn_c1 (__const char *__s, int __accept);
01046 __STRING_INLINE size_t
01047 __strspn_c1 (__const char *__s, int __accept)
01048 {
01049   register size_t __result = 0;
01050   /* Please note that __accept never can be '\0'.  */
01051   while (__s[__result] == __accept)
01052     ++__result;
01053   return __result;
01054 }
01055 
01056 __STRING_INLINE size_t __strspn_c2 (__const char *__s, int __accept1,
01057                                 int __accept2);
01058 __STRING_INLINE size_t
01059 __strspn_c2 (__const char *__s, int __accept1, int __accept2)
01060 {
01061   register size_t __result = 0;
01062   /* Please note that __accept1 and __accept2 never can be '\0'.  */
01063   while (__s[__result] == __accept1 || __s[__result] == __accept2)
01064     ++__result;
01065   return __result;
01066 }
01067 
01068 __STRING_INLINE size_t __strspn_c3 (__const char *__s, int __accept1,
01069                                 int __accept2, int __accept3);
01070 __STRING_INLINE size_t
01071 __strspn_c3 (__const char *__s, int __accept1, int __accept2, int __accept3)
01072 {
01073   register size_t __result = 0;
01074   /* Please note that __accept1 to __accept3 never can be '\0'.  */
01075   while (__s[__result] == __accept1 || __s[__result] == __accept2
01076         || __s[__result] == __accept3)
01077     ++__result;
01078   return __result;
01079 }
01080 #endif
01081 
01082 
01083 /* Find the first occurrence in S of any character in ACCEPT.  */
01084 #if !defined _HAVE_STRING_ARCH_strpbrk || defined _FORCE_INLINES
01085 # ifndef _HAVE_STRING_ARCH_strpbrk
01086 #  if __GNUC_PREREQ (3, 2)
01087 #   define strpbrk(s, accept) \
01088   __extension__                                                             \
01089   ({ char __a0, __a1, __a2;                                          \
01090      (__builtin_constant_p (accept) && __string2_1bptr_p (accept)           \
01091       ? ((__builtin_constant_p (s) && __string2_1bptr_p (s))                \
01092         ? __builtin_strpbrk (s, accept)                              \
01093         : ((__a0 = ((__const char  *) (accept))[0], __a0 == '\0')           \
01094            ? ((void) (s), (char *) NULL)                             \
01095            : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0')         \
01096               ? __builtin_strchr (s, __a0)                                  \
01097               : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0')             \
01098                 ? __strpbrk_c2 (s, __a0, __a1)                       \
01099                 : (((__const char *) (accept))[3] == '\0'                   \
01100                    ? __strpbrk_c3 (s, __a0, __a1, __a2)              \
01101                    : __builtin_strpbrk (s, accept))))))              \
01102       : __builtin_strpbrk (s, accept)); })
01103 #  else
01104 #   define strpbrk(s, accept) \
01105   __extension__                                                             \
01106   ({ char __a0, __a1, __a2;                                          \
01107      (__builtin_constant_p (accept) && __string2_1bptr_p (accept)           \
01108       ? ((__a0 = ((__const char  *) (accept))[0], __a0 == '\0')                    \
01109         ? ((void) (s), (char *) NULL)                                       \
01110         : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0')            \
01111            ? strchr (s, __a0)                                               \
01112            : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0')         \
01113               ? __strpbrk_c2 (s, __a0, __a1)                                \
01114               : (((__const char *) (accept))[3] == '\0'              \
01115                 ? __strpbrk_c3 (s, __a0, __a1, __a2)                        \
01116                 : strpbrk (s, accept)))))                            \
01117       : strpbrk (s, accept)); })
01118 #  endif
01119 # endif
01120 
01121 __STRING_INLINE char *__strpbrk_c2 (__const char *__s, int __accept1,
01122                                  int __accept2);
01123 __STRING_INLINE char *
01124 __strpbrk_c2 (__const char *__s, int __accept1, int __accept2)
01125 {
01126   /* Please note that __accept1 and __accept2 never can be '\0'.  */
01127   while (*__s != '\0' && *__s != __accept1 && *__s != __accept2)
01128     ++__s;
01129   return *__s == '\0' ? NULL : (char *) (size_t) __s;
01130 }
01131 
01132 __STRING_INLINE char *__strpbrk_c3 (__const char *__s, int __accept1,
01133                                  int __accept2, int __accept3);
01134 __STRING_INLINE char *
01135 __strpbrk_c3 (__const char *__s, int __accept1, int __accept2,
01136              int __accept3)
01137 {
01138   /* Please note that __accept1 to __accept3 never can be '\0'.  */
01139   while (*__s != '\0' && *__s != __accept1 && *__s != __accept2
01140         && *__s != __accept3)
01141     ++__s;
01142   return *__s == '\0' ? NULL : (char *) (size_t) __s;
01143 }
01144 #endif
01145 
01146 
01147 /* Find the first occurrence of NEEDLE in HAYSTACK.  Newer gcc versions
01148    do this itself.  */
01149 #if !defined _HAVE_STRING_ARCH_strstr && !__GNUC_PREREQ (2, 97)
01150 # define strstr(haystack, needle) \
01151   (__extension__ (__builtin_constant_p (needle) && __string2_1bptr_p (needle) \
01152                 ? (((__const char *) (needle))[0] == '\0'                   \
01153                    ? (char *) (size_t) (haystack)                           \
01154                    : (((__const char *) (needle))[1] == '\0'                \
01155                      ? strchr (haystack,                             \
01156                               ((__const char *) (needle))[0])        \
01157                      : strstr (haystack, needle)))                          \
01158                 : strstr (haystack, needle)))
01159 #endif
01160 
01161 
01162 #if !defined _HAVE_STRING_ARCH_strtok_r || defined _FORCE_INLINES
01163 # ifndef _HAVE_STRING_ARCH_strtok_r
01164 #  define __strtok_r(s, sep, nextp) \
01165   (__extension__ (__builtin_constant_p (sep) && __string2_1bptr_p (sep)            \
01166                 && ((__const char *) (sep))[0] != '\0'               \
01167                 && ((__const char *) (sep))[1] == '\0'               \
01168                 ? __strtok_r_1c (s, ((__const char *) (sep))[0], nextp)     \
01169                 : __strtok_r (s, sep, nextp)))
01170 # endif
01171 
01172 __STRING_INLINE char *__strtok_r_1c (char *__s, char __sep, char **__nextp);
01173 __STRING_INLINE char *
01174 __strtok_r_1c (char *__s, char __sep, char **__nextp)
01175 {
01176   char *__result;
01177   if (__s == NULL)
01178     __s = *__nextp;
01179   while (*__s == __sep)
01180     ++__s;
01181   __result = NULL;
01182   if (*__s != '\0')
01183     {
01184       __result = __s++;
01185       while (*__s != '\0')
01186        if (*__s++ == __sep)
01187          {
01188            __s[-1] = '\0';
01189            break;
01190          }
01191     }
01192   *__nextp = __s;
01193   return __result;
01194 }
01195 # if defined __USE_POSIX || defined __USE_MISC
01196 #  define strtok_r(s, sep, nextp) __strtok_r (s, sep, nextp)
01197 # endif
01198 #endif
01199 
01200 
01201 #if !defined _HAVE_STRING_ARCH_strsep || defined _FORCE_INLINES
01202 # ifndef _HAVE_STRING_ARCH_strsep
01203 
01204 extern char *__strsep_g (char **__stringp, __const char *__delim);
01205 #  define __strsep(s, reject) \
01206   __extension__                                                             \
01207   ({ char __r0, __r1, __r2;                                          \
01208      (__builtin_constant_p (reject) && __string2_1bptr_p (reject)           \
01209       && (__r0 = ((__const char *) (reject))[0],                     \
01210          ((__const char *) (reject))[0] != '\0')                     \
01211       ? ((__r1 = ((__const char *) (reject))[1],                     \
01212         ((__const char *) (reject))[1] == '\0')                      \
01213         ? __strsep_1c (s, __r0)                                      \
01214         : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0')            \
01215            ? __strsep_2c (s, __r0, __r1)                             \
01216            : (((__const char *) (reject))[3] == '\0'                        \
01217               ? __strsep_3c (s, __r0, __r1, __r2)                           \
01218               : __strsep_g (s, reject))))                            \
01219       : __strsep_g (s, reject)); })
01220 # endif
01221 
01222 __STRING_INLINE char *__strsep_1c (char **__s, char __reject);
01223 __STRING_INLINE char *
01224 __strsep_1c (char **__s, char __reject)
01225 {
01226   register char *__retval = *__s;
01227   if (__retval != NULL && (*__s = strchr (__retval, __reject)) != NULL)
01228     *(*__s)++ = '\0';
01229   return __retval;
01230 }
01231 
01232 __STRING_INLINE char *__strsep_2c (char **__s, char __reject1, char __reject2);
01233 __STRING_INLINE char *
01234 __strsep_2c (char **__s, char __reject1, char __reject2)
01235 {
01236   register char *__retval = *__s;
01237   if (__retval != NULL)
01238     {
01239       register char *__cp = __retval;
01240       while (1)
01241        {
01242          if (*__cp == '\0')
01243            {
01244              __cp = NULL;
01245          break;
01246            }
01247          if (*__cp == __reject1 || *__cp == __reject2)
01248            {
01249              *__cp++ = '\0';
01250              break;
01251            }
01252          ++__cp;
01253        }
01254       *__s = __cp;
01255     }
01256   return __retval;
01257 }
01258 
01259 __STRING_INLINE char *__strsep_3c (char **__s, char __reject1, char __reject2,
01260                                char __reject3);
01261 __STRING_INLINE char *
01262 __strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
01263 {
01264   register char *__retval = *__s;
01265   if (__retval != NULL)
01266     {
01267       register char *__cp = __retval;
01268       while (1)
01269        {
01270          if (*__cp == '\0')
01271            {
01272              __cp = NULL;
01273          break;
01274            }
01275          if (*__cp == __reject1 || *__cp == __reject2 || *__cp == __reject3)
01276            {
01277              *__cp++ = '\0';
01278              break;
01279            }
01280          ++__cp;
01281        }
01282       *__s = __cp;
01283     }
01284   return __retval;
01285 }
01286 # ifdef __USE_BSD
01287 #  define strsep(s, reject) __strsep (s, reject)
01288 # endif
01289 #endif
01290 
01291 /* We need the memory allocation functions for inline strdup().
01292    Referring to stdlib.h (even minimally) is not allowed
01293    in any of the tight standards compliant modes.  */
01294 #ifdef __USE_MISC
01295 
01296 # if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup
01297 #  define __need_malloc_and_calloc
01298 #  include <stdlib.h>
01299 # endif
01300 
01301 # ifndef _HAVE_STRING_ARCH_strdup
01302 
01303 extern char *__strdup (__const char *__string) __THROW __attribute_malloc__;
01304 #  define __strdup(s) \
01305   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)         \
01306                 ? (((__const char *) (s))[0] == '\0'                        \
01307                    ? (char *) calloc ((size_t) 1, (size_t) 1)               \
01308                    : ({ size_t __len = strlen (s) + 1;               \
01309                        char *__retval = (char *) malloc (__len);            \
01310                        if (__retval != NULL)                                \
01311                          __retval = (char *) memcpy (__retval, s, __len);  \
01312                        __retval; }))                                        \
01313                 : __strdup (s)))
01314 
01315 #  if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
01316 #   define strdup(s) __strdup (s)
01317 #  endif
01318 # endif
01319 
01320 # ifndef _HAVE_STRING_ARCH_strndup
01321 
01322 extern char *__strndup (__const char *__string, size_t __n)
01323      __THROW __attribute_malloc__;
01324 #  define __strndup(s, n) \
01325   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)         \
01326                 ? (((__const char *) (s))[0] == '\0'                        \
01327                    ? (char *) calloc ((size_t) 1, (size_t) 1)               \
01328                    : ({ size_t __len = strlen (s) + 1;               \
01329                        size_t __n = (n);                             \
01330                        char *__retval;                               \
01331                        if (__n < __len)                              \
01332                          __len = __n + 1;                            \
01333                        __retval = (char *) malloc (__len);                  \
01334                        if (__retval != NULL)                                \
01335                          {                                           \
01336                            __retval[__len - 1] = '\0';               \
01337                            __retval = (char *) memcpy (__retval, s,         \
01338                                                    __len - 1);       \
01339                          }                                           \
01340                        __retval; }))                                        \
01341                 : __strndup (s, n)))
01342 
01343 #  ifdef __USE_GNU
01344 #   define strndup(s, n) __strndup (s, n)
01345 #  endif
01346 # endif
01347 
01348 #endif /* Use misc. or use GNU.  */
01349 
01350 #ifndef _FORCE_INLINES
01351 # undef __STRING_INLINE
01352 #endif
01353 
01354 #endif /* No string inlines.  */