public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Remove ancient GCC string inlines
@ 2016-02-19 17:17 Wilco Dijkstra
  2016-02-20  8:11 ` Mike Frysinger
  0 siblings, 1 reply; 8+ messages in thread
From: Wilco Dijkstra @ 2016-02-19 17:17 UTC (permalink / raw)
  To: 'GNU C Library'; +Cc: nd

Remove pre GCC3.2 optimizations from string/bits/string2.h. Passes AArch64, x86 and x64 regression.

OK for commit?

ChangeLog:
2016-02-19  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/bits/string2.h (__STRING2_SMALL_GET16): Remove.
	(__STRING2_SMALL_GET32): Remove.
	(memset): Remove.
	(__memset_1): Remove.
	(__memset_gc): Remove.
	(__mempcpy_args): Remove.
	(strcpy): Remove.
	(strcpy_args): Remove.
	(__stpcpy_args): Remove.
	(strstr): Remove.

--

diff --git a/string/bits/string2.h b/string/bits/string2.h
index 8200ef173da116589e2ff2e321984e80b1bb40e1..183b89c4308c5c5e431877866ebbb558a8182c4a 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -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_INLINE_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_INLINE_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_INLINE_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_INLINE_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) \

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Remove ancient GCC string inlines
  2016-02-19 17:17 [PATCH 1/2] Remove ancient GCC string inlines Wilco Dijkstra
@ 2016-02-20  8:11 ` Mike Frysinger
  2016-02-22 14:03   ` Wilco Dijkstra
  2016-02-25 13:04   ` Wilco Dijkstra
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Frysinger @ 2016-02-20  8:11 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: 'GNU C Library', nd

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

On 19 Feb 2016 17:17, Wilco Dijkstra wrote:
> --- a/string/bits/string2.h
> +++ b/string/bits/string2.h
> @@ -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

endian.h is no longer needed to be included, and the comment above it too.

although these inline macros don't have __GNUC_PREREQ around them.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Remove ancient GCC string inlines
  2016-02-20  8:11 ` Mike Frysinger
@ 2016-02-22 14:03   ` Wilco Dijkstra
  2016-02-25 13:04   ` Wilco Dijkstra
  1 sibling, 0 replies; 8+ messages in thread
From: Wilco Dijkstra @ 2016-02-22 14:03 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: 'GNU C Library', nd

Mike Frysinger <vapier@gentoo.org> wrote:
> On 19 Feb 2016 17:17, Wilco Dijkstra wrote:
> > --- a/string/bits/string2.h
> > +++ b/string/bits/string2.h
> > @@ -51,25 +51,6 @@
> >  # include <endian.h>
> >  # include <bits/types.h>
>
> endian.h is no longer needed to be included, and the comment above it too.
> 
> although these inline macros don't have __GNUC_PREREQ around them.

I've updated the patch to remove these lines too (the 2nd in the series removes them 
anyway). The only use of the macros was inside blocks that based on __GNUC_PREREQ,
so it is safe to remove them.

Wilco

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Remove ancient GCC string inlines
  2016-02-20  8:11 ` Mike Frysinger
  2016-02-22 14:03   ` Wilco Dijkstra
@ 2016-02-25 13:04   ` Wilco Dijkstra
  2016-04-10  4:10     ` Mike Frysinger
  1 sibling, 1 reply; 8+ messages in thread
From: Wilco Dijkstra @ 2016-02-25 13:04 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: 'GNU C Library', nd

Mike Frysinger wrote:
> endian.h is no longer needed to be included, and the comment above it too.

OK here is the improved version. Besides dropping the endian.h include, this
also removes all of the GNUC_PREREQ from string2.h and the mempcpy
defines (string.h redefines them so they are no longer needed).

2016-02-25  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/string.h: Use __GNUC_PREREQ(3,4).
	* string/bits/string2.h (__STRING2_SMALL_GET16): Remove.
	(__STRING2_SMALL_GET32): Remove.
	(memset): Remove.
	(__memset_1): Remove.
	(__memset_gc): Remove.
	(__mempcpy): Remove.
	(mempcpy): Remove.
	(__mempcpy_args): Remove.
	(strchr): Remove.
	(strcpy): Remove.
	(strcpy_args): Remove.
	(__stpcpy_args): Remove.
	(strstr): Remove.

---

diff --git a/string/bits/string2.h b/string/bits/string2.h
index 8200ef173da116589e2ff2e321984e80b1bb40e1..9bcb2e6120c1bd6065ef5bcd296c6dc6775f474b 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -47,29 +47,8 @@
 #endif
 
 #if _STRING_INLINE_unaligned
-/* If we can do unaligned memory accesses we must know the endianess.  */
-# 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,297 +73,7 @@ __STRING2_COPY_TYPE (8);
 
 /* Set N bytes of S to C.  */
 #if !defined _HAVE_STRING_ARCH_memset
-# if !__GNUC_PREREQ (3, 0)
-#  if _STRING_INLINE_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
-   if it decides to call the library function, it calls memset
-   and not bzero.  */
-# 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
-# if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
-#  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 _STRING_INLINE_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);
-__STRING_INLINE void *
-__mempcpy_small (void *__dest1,
-		 char __src0_1, char __src2_1, char __src4_1, char __src6_1,
-		 __uint16_t __src0_2, __uint16_t __src4_2,
-		 __uint32_t __src0_4, __uint32_t __src4_4,
-		 size_t __srclen)
-{
-  union {
-    __uint32_t __ui;
-    __uint16_t __usi;
-    unsigned char __uc;
-    unsigned char __c;
-  } *__u = __dest1;
-  switch ((unsigned int) __srclen)
-    {
-    case 1:
-      __u->__c = __src0_1;
-      __u = __extension__ ((void *) __u + 1);
-      break;
-    case 2:
-      __u->__usi = __src0_2;
-      __u = __extension__ ((void *) __u + 2);
-      break;
-    case 3:
-      __u->__usi = __src0_2;
-      __u = __extension__ ((void *) __u + 2);
-      __u->__c = __src2_1;
-      __u = __extension__ ((void *) __u + 1);
-      break;
-    case 4:
-      __u->__ui = __src0_4;
-      __u = __extension__ ((void *) __u + 4);
-      break;
-    case 5:
-      __u->__ui = __src0_4;
-      __u = __extension__ ((void *) __u + 4);
-      __u->__c = __src4_1;
-      __u = __extension__ ((void *) __u + 1);
-      break;
-    case 6:
-      __u->__ui = __src0_4;
-      __u = __extension__ ((void *) __u + 4);
-      __u->__usi = __src4_2;
-      __u = __extension__ ((void *) __u + 2);
-      break;
-    case 7:
-      __u->__ui = __src0_4;
-      __u = __extension__ ((void *) __u + 4);
-      __u->__usi = __src4_2;
-      __u = __extension__ ((void *) __u + 2);
-      __u->__c = __src6_1;
-      __u = __extension__ ((void *) __u + 1);
-      break;
-    case 8:
-      __u->__ui = __src0_4;
-      __u = __extension__ ((void *) __u + 4);
-      __u->__ui = __src4_4;
-      __u = __extension__ ((void *) __u + 4);
-      break;
-    }
-  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,
-				       __STRING2_COPY_ARR5,
-				       __STRING2_COPY_ARR6,
-				       __STRING2_COPY_ARR7,
-				       __STRING2_COPY_ARR8, size_t);
-__STRING_INLINE void *
-__mempcpy_small (void *__dest, char __src1,
-		 __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3,
-		 __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5,
-		 __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7,
-		 __STRING2_COPY_ARR8 __src8, size_t __srclen)
-{
-  union {
-    char __c;
-    __STRING2_COPY_ARR2 __sca2;
-    __STRING2_COPY_ARR3 __sca3;
-    __STRING2_COPY_ARR4 __sca4;
-    __STRING2_COPY_ARR5 __sca5;
-    __STRING2_COPY_ARR6 __sca6;
-    __STRING2_COPY_ARR7 __sca7;
-    __STRING2_COPY_ARR8 __sca8;
-  } *__u = __dest;
-  switch ((unsigned int) __srclen)
-    {
-    case 1:
-      __u->__c = __src1;
-      break;
-    case 2:
-      __extension__ __u->__sca2 = __src2;
-      break;
-    case 3:
-      __extension__ __u->__sca3 = __src3;
-      break;
-    case 4:
-      __extension__ __u->__sca4 = __src4;
-      break;
-    case 5:
-      __extension__ __u->__sca5 = __src5;
-      break;
-    case 6:
-      __extension__ __u->__sca6 = __src6;
-      break;
-    case 7:
-      __extension__ __u->__sca7 = __src7;
-      break;
-    case 8:
-      __extension__ __u->__sca8 = __src8;
-      break;
-    }
-  return __extension__ ((void *) __u + __srclen);
-}
-#   endif
-#  endif
-# endif
+# define __bzero(s, n) __builtin_memset (s, '\0', n)
 #endif
 
 
@@ -397,36 +86,13 @@ extern void *__rawmemchr (const void *__s, int __c);
 		  && (c) == '\0'					      \
 		  ? (char *) __rawmemchr (s, c)				      \
 		  : __builtin_strchr (s, c)))
-# else
-#  define strchr(s, c) \
-  (__extension__ (__builtin_constant_p (c) && (c) == '\0'		      \
-		  ? (char *) __rawmemchr (s, c)				      \
-		  : strchr (s, c)))
 # endif
 #endif
 
 
 /* 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_INLINE_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 +148,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,
@@ -572,40 +209,14 @@ __strcpy_small (char *__dest,
 #ifdef __USE_GNU
 # if !defined _HAVE_STRING_ARCH_stpcpy || defined _FORCE_INLINES
 #  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
+#   define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 /* 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_INLINE_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 +277,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,
@@ -756,16 +338,7 @@ __stpcpy_small (char *__dest,
 
 /* Copy no more than N characters of SRC to 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
+# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
 #endif
 
 
@@ -780,23 +353,15 @@ __stpcpy_small (char *__dest,
 		       : (*((char *) __mempcpy (strchr (__dest, '\0'),	      \
 						src, n)) = '\0', __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)))
+#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
 # endif
 #endif
 
 
 /* Compare characters of S1 and S2.  */
 #ifndef _HAVE_STRING_ARCH_strcmp
-# if __GNUC_PREREQ (3, 2)
-#  define strcmp(s1, s2) \
+# define strcmp(s1, s2) \
   __extension__								      \
   ({ size_t __s1_len, __s2_len;						      \
      (__builtin_constant_p (s1) && __builtin_constant_p (s2)		      \
@@ -815,28 +380,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) \
   (__extension__ ({ int __result =					      \
@@ -907,8 +450,7 @@ __stpcpy_small (char *__dest,
    consists entirely of characters not in REJECT.  */
 #if !defined _HAVE_STRING_ARCH_strcspn || defined _FORCE_INLINES
 # ifndef _HAVE_STRING_ARCH_strcspn
-#  if __GNUC_PREREQ (3, 2)
-#   define strcspn(s, reject) \
+#  define strcspn(s, reject) \
   __extension__								      \
   ({ char __r0, __r1, __r2;						      \
      (__builtin_constant_p (reject) && __string2_1bptr_p (reject)	      \
@@ -924,22 +466,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
 
 __STRING_INLINE size_t __strcspn_c1 (const char *__s, int __reject);
@@ -983,8 +509,7 @@ __strcspn_c3 (const char *__s, int __reject1, int __reject2,
    consists entirely of characters in ACCEPT.  */
 #if !defined _HAVE_STRING_ARCH_strspn || defined _FORCE_INLINES
 # ifndef _HAVE_STRING_ARCH_strspn
-#  if __GNUC_PREREQ (3, 2)
-#   define strspn(s, accept) \
+#  define strspn(s, accept) \
   __extension__								      \
   ({ char __a0, __a1, __a2;						      \
      (__builtin_constant_p (accept) && __string2_1bptr_p (accept)	      \
@@ -1000,22 +525,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
 
 __STRING_INLINE size_t __strspn_c1 (const char *__s, int __accept);
@@ -1059,8 +568,7 @@ __strspn_c3 (const char *__s, int __accept1, int __accept2, int __accept3)
 /* Find the first occurrence in S of any character in ACCEPT.  */
 #if !defined _HAVE_STRING_ARCH_strpbrk || defined _FORCE_INLINES
 # ifndef _HAVE_STRING_ARCH_strpbrk
-#  if __GNUC_PREREQ (3, 2)
-#   define strpbrk(s, accept) \
+#  define strpbrk(s, accept) \
   __extension__								      \
   ({ char __a0, __a1, __a2;						      \
      (__builtin_constant_p (accept) && __string2_1bptr_p (accept)	      \
@@ -1076,22 +584,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
 
 __STRING_INLINE char *__strpbrk_c2 (const char *__s, int __accept1,
@@ -1119,21 +611,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) \
diff --git a/string/string.h b/string/string.h
index 1f3e3488340f37ca35f4213dc30836b3f8308d91..c7f8fde7b89dab9a6178a34baf971df99a8215b1 100644
--- a/string/string.h
+++ b/string/string.h
@@ -602,7 +602,7 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
 #endif
 
 
-#if defined __GNUC__ && __GNUC__ >= 2
+#if __GNUC_PREREQ (3,4)
 # if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
      && !defined __NO_INLINE__ && !defined __cplusplus
 /* When using GNU CC we provide some optimized versions of selected
@@ -640,8 +640,6 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
     && defined __extern_always_inline && __GNUC_PREREQ (3,2)
 # if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy
 
-#undef mempcpy
-#undef __mempcpy
 #define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
 #define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Remove ancient GCC string inlines
  2016-02-25 13:04   ` Wilco Dijkstra
@ 2016-04-10  4:10     ` Mike Frysinger
  2016-04-15 12:16       ` Wilco Dijkstra
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2016-04-10  4:10 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: 'GNU C Library', nd

[-- Attachment #1: Type: text/plain, Size: 21 bytes --]

looks OK to me
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Remove ancient GCC string inlines
  2016-04-10  4:10     ` Mike Frysinger
@ 2016-04-15 12:16       ` Wilco Dijkstra
  0 siblings, 0 replies; 8+ messages in thread
From: Wilco Dijkstra @ 2016-04-15 12:16 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: 'GNU C Library', nd

Mike Frysinger wrote:
>
> looks OK to me

Thanks, rebased and retested on AArch64, x64 and x86. Committed as 155b...d8d1

Wilco

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] Remove ancient GCC string inlines
       [not found] <FF1B652685AE434E94C2981B001E196529AF7B0DBB@GEORGE.Emea.Arm.com>
@ 2015-12-16 13:06 ` Wilco Dijkstra
  0 siblings, 0 replies; 8+ messages in thread
From: Wilco Dijkstra @ 2015-12-16 13:06 UTC (permalink / raw)
  To: 'GNU C Library'; +Cc: nd

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

ping

> -----Original Message-----
> From: Wilco Dijkstra [mailto:wdijkstr@arm.com]
> Sent: 09 October 2015 16:53
> To: 'GNU C Library'
> Subject: [PATCH 1/2] Remove ancient GCC string inlines
> 
> Remove pre GCC3.2 optimizations from string/bits/string2.h. Passes AArch64, x86 and x64 regression.
> 
> OK for commit?
> 
> ChangeLog:
> 2015-10-09  Wilco Dijkstra  wdijkstr@arm.com
> 
> 	* string/bits/string2.h (__STRING2_SMALL_GET16): Remove.
> 	(__STRING2_SMALL_GET32): Remove.
> 	(memset): Remove.
> 	(__memset_1): Remove.
> 	(__memset_gc): Remove.
> 	(__mempcpy_args): Remove.
> 	(strcpy): Remove.
> 	(strcpy_args): Remove.
> 	(__stpcpy_args): Remove.
> 	(strstr): Remove.

[-- Attachment #2: 0001-Remove-optimizations-for-ancient-GCC-versions.txt --]
[-- Type: text/plain, Size: 21809 bytes --]

---
 string/bits/string2.h | 364 +-------------------------------------------------
 1 file changed, 3 insertions(+), 361 deletions(-)

diff --git a/string/bits/string2.h b/string/bits/string2.h
index 7645176..bd8c404 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -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) \
-- 
1.9.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] Remove ancient GCC string inlines
@ 2015-10-09 15:52 Wilco Dijkstra
  0 siblings, 0 replies; 8+ messages in thread
From: Wilco Dijkstra @ 2015-10-09 15:52 UTC (permalink / raw)
  To: 'GNU C Library'

[-- Attachment #1: Type: text/plain, Size: 464 bytes --]

Remove pre GCC3.2 optimizations from string/bits/string2.h. Passes AArch64, x86 and x64 regression.

OK for commit?

ChangeLog:
2015-10-09  Wilco Dijkstra  wdijkstr@arm.com

	* string/bits/string2.h (__STRING2_SMALL_GET16): Remove.
	(__STRING2_SMALL_GET32): Remove.
	(memset): Remove.
	(__memset_1): Remove.
	(__memset_gc): Remove.
	(__mempcpy_args): Remove.
	(strcpy): Remove.
	(strcpy_args): Remove.
	(__stpcpy_args): Remove.
	(strstr): Remove.

[-- Attachment #2: 0001-Remove-optimizations-for-ancient-GCC-versions.txt --]
[-- Type: text/plain, Size: 22313 bytes --]

---
 string/bits/string2.h | 364 +-------------------------------------------------
 1 file changed, 3 insertions(+), 361 deletions(-)

diff --git a/string/bits/string2.h b/string/bits/string2.h
index 7645176..bd8c404 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -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) \
-- 
1.9.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-15 12:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 17:17 [PATCH 1/2] Remove ancient GCC string inlines Wilco Dijkstra
2016-02-20  8:11 ` Mike Frysinger
2016-02-22 14:03   ` Wilco Dijkstra
2016-02-25 13:04   ` Wilco Dijkstra
2016-04-10  4:10     ` Mike Frysinger
2016-04-15 12:16       ` Wilco Dijkstra
     [not found] <FF1B652685AE434E94C2981B001E196529AF7B0DBB@GEORGE.Emea.Arm.com>
2015-12-16 13:06 ` Wilco Dijkstra
  -- strict thread matches above, loose matches on Subject: below --
2015-10-09 15:52 Wilco Dijkstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).