@@ -51,25 +51,6 @@
# include <endian.h>
# include <bits/types.h>
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# define __STRING2_SMALL_GET16(src, idx) \
- (((const unsigned char *) (const char *) (src))[idx + 1] << 8 \
- | ((const unsigned char *) (const char *) (src))[idx])
-# define __STRING2_SMALL_GET32(src, idx) \
- (((((const unsigned char *) (const char *) (src))[idx + 3] << 8 \
- | ((const unsigned char *) (const char *) (src))[idx + 2]) << 8 \
- | ((const unsigned char *) (const char *) (src))[idx + 1]) << 8 \
- | ((const unsigned char *) (const char *) (src))[idx])
-# else
-# define __STRING2_SMALL_GET16(src, idx) \
- (((const unsigned char *) (const char *) (src))[idx] << 8 \
- | ((const unsigned char *) (const char *) (src))[idx + 1])
-# define __STRING2_SMALL_GET32(src, idx) \
- (((((const unsigned char *) (const char *) (src))[idx] << 8 \
- | ((const unsigned char *) (const char *) (src))[idx + 1]) << 8 \
- | ((const unsigned char *) (const char *) (src))[idx + 2]) << 8 \
- | ((const unsigned char *) (const char *) (src))[idx + 3])
-# endif
#else
/* These are a few types we need for the optimizations if we cannot
use unaligned memory accesses. */
@@ -94,97 +75,6 @@ __STRING2_COPY_TYPE (8);
/* Set N bytes of S to C. */
#if !defined _HAVE_STRING_ARCH_memset
-# if !__GNUC_PREREQ (3, 0)
-# if _STRING_ARCH_unaligned
-# define memset(s, c, n) \
- (__extension__ (__builtin_constant_p (n) && (n) <= 16 \
- ? ((n) == 1 \
- ? __memset_1 (s, c) \
- : __memset_gc (s, c, n)) \
- : (__builtin_constant_p (c) && (c) == '\0' \
- ? ({ void *__s = (s); __bzero (__s, n); __s; }) \
- : memset (s, c, n))))
-
-# define __memset_1(s, c) ({ void *__s = (s); \
- *((__uint8_t *) __s) = (__uint8_t) c; __s; })
-
-# define __memset_gc(s, c, n) \
- ({ void *__s = (s); \
- union { \
- unsigned int __ui; \
- unsigned short int __usi; \
- unsigned char __uc; \
- } *__u = __s; \
- __uint8_t __c = (__uint8_t) (c); \
- \
- /* This `switch' statement will be removed at compile-time. */ \
- switch ((unsigned int) (n)) \
- { \
- case 15: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 11: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 7: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 3: \
- __u->__usi = (unsigned short int) __c * 0x0101; \
- __u = __extension__ ((void *) __u + 2); \
- __u->__uc = (unsigned char) __c; \
- break; \
- \
- case 14: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 10: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 6: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 2: \
- __u->__usi = (unsigned short int) __c * 0x0101; \
- break; \
- \
- case 13: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 9: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 5: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 1: \
- __u->__uc = (unsigned char) __c; \
- break; \
- \
- case 16: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 12: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 8: \
- __u->__ui = __c * 0x01010101; \
- __u = __extension__ ((void *) __u + 4); \
- case 4: \
- __u->__ui = __c * 0x01010101; \
- case 0: \
- break; \
- } \
- \
- __s; })
-# else
-# define memset(s, c, n) \
- (__extension__ (__builtin_constant_p (c) && (c) == '\0' \
- ? ({ void *__s = (s); __bzero (__s, n); __s; }) \
- : memset (s, c, n)))
-# endif
-# endif
-
/* GCC < 3.0 optimizes memset(s, 0, n) but not bzero(s, n).
The optimization is broken before EGCS 1.1.
GCC 3.0+ has __builtin_bzero as well, but at least till GCC 3.4
@@ -193,10 +83,8 @@ __STRING2_COPY_TYPE (8);
# if __GNUC_PREREQ (2, 91)
# define __bzero(s, n) __builtin_memset (s, '\0', n)
# endif
-
#endif
-
/* Copy N bytes from SRC to DEST, returning pointer to byte following the
last copied. */
#ifdef __USE_GNU
@@ -204,35 +92,14 @@ __STRING2_COPY_TYPE (8);
# ifndef _HAVE_STRING_ARCH_mempcpy
# if __GNUC_PREREQ (3, 4)
# define __mempcpy(dest, src, n) __builtin_mempcpy (dest, src, n)
-# elif __GNUC_PREREQ (3, 0)
-# define __mempcpy(dest, src, n) \
- (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
- && __string2_1bptr_p (src) && n <= 8 \
- ? __builtin_memcpy (dest, src, n) + (n) \
- : __mempcpy (dest, src, n)))
-# else
-# define __mempcpy(dest, src, n) \
- (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
- && __string2_1bptr_p (src) && n <= 8 \
- ? __mempcpy_small (dest, __mempcpy_args (src), n) \
- : __mempcpy (dest, src, n)))
# endif
/* In glibc we use this function frequently but for namespace reasons
we have to use the name `__mempcpy'. */
# define mempcpy(dest, src, n) __mempcpy (dest, src, n)
# endif
-# if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
+# if defined _FORCE_INLINES
# if _STRING_ARCH_unaligned
-# ifndef _FORCE_INLINES
-# define __mempcpy_args(src) \
- ((const char *) (src))[0], ((const char *) (src))[2], \
- ((const char *) (src))[4], ((const char *) (src))[6], \
- __extension__ __STRING2_SMALL_GET16 (src, 0), \
- __extension__ __STRING2_SMALL_GET16 (src, 4), \
- __extension__ __STRING2_SMALL_GET32 (src, 0), \
- __extension__ __STRING2_SMALL_GET32 (src, 4)
-# endif
__STRING_INLINE void *__mempcpy_small (void *, char, char, char, char,
__uint16_t, __uint16_t, __uint32_t,
__uint32_t, size_t);
@@ -299,36 +166,6 @@ __mempcpy_small (void *__dest1,
return (void *) __u;
}
# else
-# ifndef _FORCE_INLINES
-# define __mempcpy_args(src) \
- ((const char *) (src))[0], \
- __extension__ ((__STRING2_COPY_ARR2) \
- { { ((const char *) (src))[0], ((const char *) (src))[1] } }), \
- __extension__ ((__STRING2_COPY_ARR3) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2] } }), \
- __extension__ ((__STRING2_COPY_ARR4) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3] } }), \
- __extension__ ((__STRING2_COPY_ARR5) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4] } }), \
- __extension__ ((__STRING2_COPY_ARR6) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5] } }), \
- __extension__ ((__STRING2_COPY_ARR7) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5], \
- ((const char *) (src))[6] } }), \
- __extension__ ((__STRING2_COPY_ARR8) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5], \
- ((const char *) (src))[6], ((const char *) (src))[7] } })
-# endif
__STRING_INLINE void *__mempcpy_small (void *, char, __STRING2_COPY_ARR2,
__STRING2_COPY_ARR3,
__STRING2_COPY_ARR4,
@@ -407,26 +244,8 @@ extern void *__rawmemchr (const void *__s, int __c);
/* Copy SRC to DEST. */
-#if (!defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)) \
- || defined _FORCE_INLINES
-# if !defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)
-# define strcpy(dest, src) \
- (__extension__ (__builtin_constant_p (src) \
- ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
- ? __strcpy_small (dest, __strcpy_args (src), \
- strlen (src) + 1) \
- : (char *) memcpy (dest, src, strlen (src) + 1)) \
- : strcpy (dest, src)))
-# endif
-
+#if defined _FORCE_INLINES
# if _STRING_ARCH_unaligned
-# ifndef _FORCE_INLINES
-# define __strcpy_args(src) \
- __extension__ __STRING2_SMALL_GET16 (src, 0), \
- __extension__ __STRING2_SMALL_GET16 (src, 4), \
- __extension__ __STRING2_SMALL_GET32 (src, 0), \
- __extension__ __STRING2_SMALL_GET32 (src, 4)
-# endif
__STRING_INLINE char *__strcpy_small (char *, __uint16_t, __uint16_t,
__uint32_t, __uint32_t, size_t);
__STRING_INLINE char *
@@ -482,35 +301,6 @@ __strcpy_small (char *__dest,
return __dest;
}
# else
-# ifndef _FORCE_INLINES
-# define __strcpy_args(src) \
- __extension__ ((__STRING2_COPY_ARR2) \
- { { ((const char *) (src))[0], '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR3) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR4) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR5) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR6) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR7) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5], \
- '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR8) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5], \
- ((const char *) (src))[6], '\0' } })
-# endif
__STRING_INLINE char *__strcpy_small (char *, __STRING2_COPY_ARR2,
__STRING2_COPY_ARR3,
__STRING2_COPY_ARR4,
@@ -574,38 +364,14 @@ __strcpy_small (char *__dest,
# ifndef _HAVE_STRING_ARCH_stpcpy
# if __GNUC_PREREQ (3, 4)
# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
-# elif __GNUC_PREREQ (3, 0)
-# define __stpcpy(dest, src) \
- (__extension__ (__builtin_constant_p (src) \
- ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
- ? __builtin_strcpy (dest, src) + strlen (src) \
- : ((char *) (__mempcpy) (dest, src, strlen (src) + 1) \
- - 1)) \
- : __stpcpy (dest, src)))
-# else
-# define __stpcpy(dest, src) \
- (__extension__ (__builtin_constant_p (src) \
- ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
- ? __stpcpy_small (dest, __stpcpy_args (src), \
- strlen (src) + 1) \
- : ((char *) (__mempcpy) (dest, src, strlen (src) + 1) \
- - 1)) \
- : __stpcpy (dest, src)))
# endif
/* In glibc we use this function frequently but for namespace reasons
we have to use the name `__stpcpy'. */
# define stpcpy(dest, src) __stpcpy (dest, src)
# endif
-# if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
+# if defined _FORCE_INLINES
# if _STRING_ARCH_unaligned
-# ifndef _FORCE_INLINES
-# define __stpcpy_args(src) \
- __extension__ __STRING2_SMALL_GET16 (src, 0), \
- __extension__ __STRING2_SMALL_GET16 (src, 4), \
- __extension__ __STRING2_SMALL_GET32 (src, 0), \
- __extension__ __STRING2_SMALL_GET32 (src, 4)
-# endif
__STRING_INLINE char *__stpcpy_small (char *, __uint16_t, __uint16_t,
__uint32_t, __uint32_t, size_t);
__STRING_INLINE char *
@@ -666,35 +432,6 @@ __stpcpy_small (char *__dest,
return &__u->__c;
}
# else
-# ifndef _FORCE_INLINES
-# define __stpcpy_args(src) \
- __extension__ ((__STRING2_COPY_ARR2) \
- { { ((const char *) (src))[0], '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR3) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR4) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR5) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR6) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR7) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5], \
- '\0' } }), \
- __extension__ ((__STRING2_COPY_ARR8) \
- { { ((const char *) (src))[0], ((const char *) (src))[1], \
- ((const char *) (src))[2], ((const char *) (src))[3], \
- ((const char *) (src))[4], ((const char *) (src))[5], \
- ((const char *) (src))[6], '\0' } })
-# endif
__STRING_INLINE char *__stpcpy_small (char *, __STRING2_COPY_ARR2,
__STRING2_COPY_ARR3,
__STRING2_COPY_ARR4,
@@ -758,13 +495,6 @@ __stpcpy_small (char *__dest,
#ifndef _HAVE_STRING_ARCH_strncpy
# if __GNUC_PREREQ (3, 2)
# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-# else
-# define strncpy(dest, src, n) \
- (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
- ? (strlen (src) + 1 >= ((size_t) (n)) \
- ? (char *) memcpy (dest, src, n) \
- : strncpy (dest, src, n)) \
- : strncpy (dest, src, n)))
# endif
#endif
@@ -782,13 +512,6 @@ __stpcpy_small (char *__dest,
: strncat (dest, src, n); }))
# elif __GNUC_PREREQ (3, 2)
# define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# else
-# define strncat(dest, src, n) \
- (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
- ? (strlen (src) < ((size_t) (n)) \
- ? strcat (dest, src) \
- : strncat (dest, src, n)) \
- : strncat (dest, src, n)))
# endif
#endif
@@ -815,27 +538,6 @@ __stpcpy_small (char *__dest,
? __builtin_strcmp (s1, s2) \
: __strcmp_gc (s1, s2, __s2_len)) \
: __builtin_strcmp (s1, s2)))); })
-# else
-# define strcmp(s1, s2) \
- __extension__ \
- ({ size_t __s1_len, __s2_len; \
- (__builtin_constant_p (s1) && __builtin_constant_p (s2) \
- && (__s1_len = strlen (s1), __s2_len = strlen (s2), \
- (!__string2_1bptr_p (s1) || __s1_len >= 4) \
- && (!__string2_1bptr_p (s2) || __s2_len >= 4)) \
- ? memcmp ((const char *) (s1), (const char *) (s2), \
- (__s1_len < __s2_len ? __s1_len : __s2_len) + 1) \
- : (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \
- && (__s1_len = strlen (s1), __s1_len < 4) \
- ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \
- ? __strcmp_cc (s1, s2, __s1_len) \
- : __strcmp_cg (s1, s2, __s1_len)) \
- : (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \
- && (__s2_len = strlen (s2), __s2_len < 4) \
- ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \
- ? __strcmp_cc (s1, s2, __s2_len) \
- : __strcmp_gc (s1, s2, __s2_len)) \
- : strcmp (s1, s2)))); })
# endif
# define __strcmp_cc(s1, s2, l) \
@@ -924,21 +626,6 @@ __stpcpy_small (char *__dest,
? __strcspn_c3 (s, __r0, __r1, __r2) \
: __builtin_strcspn (s, reject)))))) \
: __builtin_strcspn (s, reject)); })
-# else
-# define strcspn(s, reject) \
- __extension__ \
- ({ char __r0, __r1, __r2; \
- (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
- ? ((__r0 = ((const char *) (reject))[0], __r0 == '\0') \
- ? strlen (s) \
- : ((__r1 = ((const char *) (reject))[1], __r1 == '\0') \
- ? __strcspn_c1 (s, __r0) \
- : ((__r2 = ((const char *) (reject))[2], __r2 == '\0') \
- ? __strcspn_c2 (s, __r0, __r1) \
- : (((const char *) (reject))[3] == '\0' \
- ? __strcspn_c3 (s, __r0, __r1, __r2) \
- : strcspn (s, reject))))) \
- : strcspn (s, reject)); })
# endif
# endif
@@ -1000,21 +687,6 @@ __strcspn_c3 (const char *__s, int __reject1, int __reject2,
? __strspn_c3 (s, __a0, __a1, __a2) \
: __builtin_strspn (s, accept)))))) \
: __builtin_strspn (s, accept)); })
-# else
-# define strspn(s, accept) \
- __extension__ \
- ({ char __a0, __a1, __a2; \
- (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
- ? ((__a0 = ((const char *) (accept))[0], __a0 == '\0') \
- ? ((void) (s), (size_t) 0) \
- : ((__a1 = ((const char *) (accept))[1], __a1 == '\0') \
- ? __strspn_c1 (s, __a0) \
- : ((__a2 = ((const char *) (accept))[2], __a2 == '\0') \
- ? __strspn_c2 (s, __a0, __a1) \
- : (((const char *) (accept))[3] == '\0' \
- ? __strspn_c3 (s, __a0, __a1, __a2) \
- : strspn (s, accept))))) \
- : strspn (s, accept)); })
# endif
# endif
@@ -1076,21 +748,6 @@ __strspn_c3 (const char *__s, int __accept1, int __accept2, int __accept3)
? __strpbrk_c3 (s, __a0, __a1, __a2) \
: __builtin_strpbrk (s, accept)))))) \
: __builtin_strpbrk (s, accept)); })
-# else
-# define strpbrk(s, accept) \
- __extension__ \
- ({ char __a0, __a1, __a2; \
- (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
- ? ((__a0 = ((const char *) (accept))[0], __a0 == '\0') \
- ? ((void) (s), (char *) NULL) \
- : ((__a1 = ((const char *) (accept))[1], __a1 == '\0') \
- ? strchr (s, __a0) \
- : ((__a2 = ((const char *) (accept))[2], __a2 == '\0') \
- ? __strpbrk_c2 (s, __a0, __a1) \
- : (((const char *) (accept))[3] == '\0' \
- ? __strpbrk_c3 (s, __a0, __a1, __a2) \
- : strpbrk (s, accept))))) \
- : strpbrk (s, accept)); })
# endif
# endif
@@ -1119,21 +776,6 @@ __strpbrk_c3 (const char *__s, int __accept1, int __accept2, int __accept3)
#endif
-/* Find the first occurrence of NEEDLE in HAYSTACK. Newer gcc versions
- do this itself. */
-#if !defined _HAVE_STRING_ARCH_strstr && !__GNUC_PREREQ (2, 97)
-# define strstr(haystack, needle) \
- (__extension__ (__builtin_constant_p (needle) && __string2_1bptr_p (needle) \
- ? (((const char *) (needle))[0] == '\0' \
- ? (char *) (size_t) (haystack) \
- : (((const char *) (needle))[1] == '\0' \
- ? strchr (haystack, \
- ((const char *) (needle))[0]) \
- : strstr (haystack, needle))) \
- : strstr (haystack, needle)))
-#endif
-
-
#if !defined _HAVE_STRING_ARCH_strtok_r || defined _FORCE_INLINES
# ifndef _HAVE_STRING_ARCH_strtok_r
# define __strtok_r(s, sep, nextp) \