public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+
@ 2004-05-26 17:27 Jakub Jelinek
  2004-05-26 20:36 ` Ulrich Drepper
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2004-05-26 17:27 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers, gcc

Hi!

I went through <bits/string2.h> and GCC 3.2.3, 3.3.3, 3.4.0 and trunk.
This patch is removing memset macro for GCC 3.0+, since GCC really does
in most cases as good or better job as glibc and certainly has far more
information that glibc.
mempcpy in 3.4+ has all the optimizations glibc provided, similarly stpcpy.
The strchr macro is kept, as the optimization of strchr (p, '\0') to
__rawmemchr (p, '\0') is worthy, but was changed to optimize cases like
strchr ("foobar", '\0') with GCC 3.2+.
_USE_STRING_ARCH_mempcpy is not defined in any of the bits/string.h headers,
so I have removed that case from strncpy inline.
For strncpy and strncat GCC 3.2+ has the same optimizations as glibc did.
For strcmp, with GCC 3.2+ we can now optimize comparision of two constant
strings, yet the macro is kept for strcmp (p, "ab") cases (where one string
is literal with up to 4 characters).
For strcspn, strspn and strpbrk with GCC 3.2+ the macros have been changed
to handle both arguments string literals.

2004-05-26  Jakub Jelinek  <jakub@redhat.com>

	* include/string.h (mempcpy, stpcpy): Add libc_hidden_builtin_proto.
	* string/bits/string2.h (memset): Disable macro for GCC 3.0+.
	(__mempcpy): Use __builtin_mempcpy for GCC 3.4+.
	(strchr): For GCC 3.2+, only use __rawmemchr if second argument is
	constant '\0' and first argument is not constant.
	(__stpcpy): Use __builtin_stpcpy for GCC 3.4+.
	(strncpy): Remove #ifdef _USE_STRING_ARCH_mempcpy variant.
	For GCC 3.2+ use __builtin_strncpy.
	(strncat): For GCC 3.2+ use __builtin_strncat.
	(strcmp): For GCC 3.2+ use __builtin_strcmp if both arguments are
	constant.
	(strcspn, strspn, strpbrk): For GCC 3.2+, use builtin function
	if both arguments are constant.

--- libc/include/string.h.jj	2004-04-13 10:42:51.000000000 +0200
+++ libc/include/string.h	2004-05-26 16:08:50.082921658 +0200
@@ -83,6 +83,7 @@ libc_hidden_proto (__strxfrm_l)
 
 libc_hidden_builtin_proto (memchr)
 libc_hidden_builtin_proto (memcpy)
+libc_hidden_builtin_proto (mempcpy)
 libc_hidden_builtin_proto (memcmp)
 libc_hidden_builtin_proto (memmove)
 libc_hidden_builtin_proto (memset)
@@ -95,6 +96,7 @@ libc_hidden_builtin_proto (strlen)
 libc_hidden_builtin_proto (strncmp)
 libc_hidden_builtin_proto (strncpy)
 libc_hidden_builtin_proto (strpbrk)
+libc_hidden_builtin_proto (stpcpy)
 libc_hidden_builtin_proto (strrchr)
 libc_hidden_builtin_proto (strspn)
 libc_hidden_builtin_proto (strstr)
--- libc/string/bits/string2.h.jj	2004-05-07 14:32:32.000000000 +0200
+++ libc/string/bits/string2.h	2004-05-26 15:57:38.423291808 +0200
@@ -30,7 +30,7 @@
    means the code size increases a lot.  Instead the definitions here
    optimize some functions in a way which do not dramatically
    increase the code size and which do not use assembler.  The main
-   trick is to use GNU CC's `__builtin_constant_p' function.
+   trick is to use GCC's `__builtin_constant_p' function.
 
    Every function XXX which has a defined version in
    <bits/string.h> must be accompanied by a symbol _HAVE_STRING_ARCH_XXX
@@ -94,7 +94,7 @@ __STRING2_COPY_TYPE (8);
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to C.  */
-#ifndef _HAVE_STRING_ARCH_memset
+#if !defined _HAVE_STRING_ARCH_memset && ! __GNUC_PREREQ (3, 0)
 # if _STRING_ARCH_unaligned
 #  define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16			      \
@@ -178,12 +178,10 @@ __STRING2_COPY_TYPE (8);
 									      \
      __s; })
 # else
-#  if ! __GNUC_PREREQ (3, 0)
-#   define memset(s, c, n) \
+#  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 optimizes memset(s, 0, n) but not bzero(s, n).
@@ -200,7 +198,9 @@ __STRING2_COPY_TYPE (8);
 #ifdef __USE_GNU
 # if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
 #  ifndef _HAVE_STRING_ARCH_mempcpy
-#   if __GNUC_PREREQ (3, 0)
+#   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			      \
@@ -387,10 +387,18 @@ __mempcpy_small (void *__dest, char __sr
 /* Return pointer to C in S.  */
 #ifndef _HAVE_STRING_ARCH_strchr
 extern void *__rawmemchr (const void *__s, int __c);
-# define strchr(s, c) \
+# if __GNUC_PREREQ (3, 2)
+#  define strchr(s, c) \
+  (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s)	      \
+		  && (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
 
 
@@ -560,7 +568,9 @@ __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, 0)
+#   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	      \
@@ -742,16 +752,8 @@ __stpcpy_small (char *__dest,
 
 /* Copy no more than N characters of SRC to DEST.  */
 #ifndef _HAVE_STRING_ARCH_strncpy
-# if defined _USE_STRING_ARCH_memset && defined _USE_STRING_ARCH_mempcpy
-#  define strncpy(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);				      \
-		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
-		    ? (strlen (src) + 1 >= ((size_t) (n))		      \
-		       ? (char *) memcpy (__dest, src, n)		      \
-		       : (memset (__mempcpy (__dest, src, strlen (src)),      \
-				  '\0', n - strlen (src)),		      \
-			  __dest))					      \
-		    : strncpy (__dest, src, n); }))
+# 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)      \
@@ -774,6 +776,8 @@ __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)      \
@@ -787,7 +791,28 @@ __stpcpy_small (char *__dest,
 
 /* Compare characters of S1 and S2.  */
 #ifndef _HAVE_STRING_ARCH_strcmp
-# define strcmp(s1, s2) \
+# if __GNUC_PREREQ (3, 2)
+#  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))		      \
+      ? __builtin_strcmp (s1, s2)					      \
+      : (__builtin_constant_p (s1) && __string2_1bptr_p (s1)		      \
+	 && (__s1_len = strlen (s1), __s1_len < 4)			      \
+	 ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2)		      \
+	    ? __builtin_strcmp (s1, s2)					      \
+	    : __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)	      \
+	       ? __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)		      \
@@ -807,6 +832,7 @@ __stpcpy_small (char *__dest,
 	       ? __strcmp_cc (s1, s2, __s2_len)				      \
 	       : __strcmp_gc (s1, s2, __s2_len))			      \
 	    : strcmp (s1, s2)))); })
+#endif
 
 # define __strcmp_cc(s1, s2, l) \
   (__extension__ ({ register int __result =				      \
@@ -900,7 +926,25 @@ __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
-#  define strcspn(s, reject) \
+#  if __GNUC_PREREQ (3, 2)
+#   define strcspn(s, reject) \
+  __extension__								      \
+  ({ char __r0, __r1, __r2;						      \
+     (__builtin_constant_p (reject) && __string2_1bptr_p (reject)	      \
+      ? ((__builtin_constant_p (s) && __string2_1bptr_p (s))		      \
+	 ? __builtin_strcspn (s, 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)		      \
+		     : __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)	      \
@@ -913,7 +957,8 @@ __stpcpy_small (char *__dest,
 	       : (((__const char *) (reject))[3] == '\0'		      \
 		  ? __strcspn_c3 (s, __r0, __r1, __r2)			      \
 		  : strcspn (s, reject)))))				      \
-		  : strcspn (s, reject)); })
+      : strcspn (s, reject)); })
+#  endif
 # endif
 
 __STRING_INLINE size_t __strcspn_c1 (__const char *__s, int __reject);
@@ -957,7 +1002,25 @@ __strcspn_c3 (__const char *__s, int __r
    consists entirely of characters in ACCEPT.  */
 #if !defined _HAVE_STRING_ARCH_strspn || defined _FORCE_INLINES
 # ifndef _HAVE_STRING_ARCH_strspn
-#  define strspn(s, accept) \
+#  if __GNUC_PREREQ (3, 2)
+#   define strspn(s, accept) \
+  __extension__								      \
+  ({ char __a0, __a1, __a2;						      \
+     (__builtin_constant_p (accept) && __string2_1bptr_p (accept)	      \
+      ? ((__builtin_constant_p (s) && __string2_1bptr_p (s))		      \
+	 ? __builtin_strspn (s, accept)					      \
+	 : ((__a0 = ((__const char *) (accept))[0], __a0 == '\0')	      \
+	    ? ((void) (s), 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)		      \
+		     : __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)	      \
@@ -971,6 +1034,7 @@ __strcspn_c3 (__const char *__s, int __r
 		  ? __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);
@@ -1014,6 +1078,24 @@ __strspn_c3 (__const char *__s, int __ac
 /* 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) \
+  __extension__								      \
+  ({ char __a0, __a1, __a2;						      \
+     (__builtin_constant_p (accept) && __string2_1bptr_p (accept)	      \
+      ? ((__builtin_constant_p (s) && __string2_1bptr_p (s))		      \
+	 ? __builtin_strpbrk (s, accept)				      \
+	 : ((__a0 = ((__const char  *) (accept))[0], __a0 == '\0')	      \
+	    ? ((void) (s), (char *) NULL)				      \
+	    : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0')	      \
+	       ? __builtin_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)		      \
+		     : __builtin_strpbrk (s, accept))))))		      \
+      : __builtin_strpbrk (s, accept)); })
+#  else
 #  define strpbrk(s, accept) \
   __extension__								      \
   ({ char __a0, __a1, __a2;						      \
@@ -1028,6 +1110,7 @@ __strspn_c3 (__const char *__s, int __ac
 		  ? __strpbrk_c3 (s, __a0, __a1, __a2)			      \
 		  : strpbrk (s, accept)))))				      \
       : strpbrk (s, accept)); })
+#  endif
 # endif
 
 __STRING_INLINE char *__strpbrk_c2 (__const char *__s, int __accept1,

	Jakub

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

* Re: [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+
  2004-05-26 17:27 [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ Jakub Jelinek
@ 2004-05-26 20:36 ` Ulrich Drepper
  2004-05-27  1:01   ` H. J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Drepper @ 2004-05-26 20:36 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

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

* Re: [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+
  2004-05-26 20:36 ` Ulrich Drepper
@ 2004-05-27  1:01   ` H. J. Lu
  2004-05-27  9:26     ` H. J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: H. J. Lu @ 2004-05-27  1:01 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Jakub Jelinek, Glibc hackers

On Wed, May 26, 2004 at 10:26:26AM -0700, Ulrich Drepper wrote:
> Applied.
> 

FYI, this patch may have exposed a gcc regression:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15666


H.J.

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

* Re: [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+
  2004-05-27  1:01   ` H. J. Lu
@ 2004-05-27  9:26     ` H. J. Lu
  2004-05-27  9:47       ` [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup) Jakub Jelinek
  0 siblings, 1 reply; 7+ messages in thread
From: H. J. Lu @ 2004-05-27  9:26 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Jakub Jelinek, Glibc hackers

On Wed, May 26, 2004 at 01:36:23PM -0700, H. J. Lu wrote:
> On Wed, May 26, 2004 at 10:26:26AM -0700, Ulrich Drepper wrote:
> > Applied.
> > 

I think the patch is incomplete. 

2004-05-26  Jakub Jelinek  <jakub@redhat.com>
 
        * include/string.h (mempcpy, stpcpy): Add libc_hidden_builtin_proto.

Don't you need to add the corresponding libc_hidden_builtin_def for
mempcpy and stpcpy? ld.so failed to build with gcc 3.4 on ia64 and
i686 due to missing mempcpy and stpcpy.


H.J.

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

* [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup)
  2004-05-27  9:26     ` H. J. Lu
@ 2004-05-27  9:47       ` Jakub Jelinek
  2004-05-28  6:40         ` H. J. Lu
  2004-05-28  6:42         ` Ulrich Drepper
  0 siblings, 2 replies; 7+ messages in thread
From: Jakub Jelinek @ 2004-05-27  9:47 UTC (permalink / raw)
  To: Ulrich Drepper, H. J. Lu; +Cc: Glibc hackers

On Wed, May 26, 2004 at 06:01:02PM -0700, H. J. Lu wrote:
> I think the patch is incomplete. 

You are right, sorry.  I haven't built glibc with it after doing all changes,
only tested whether apps using that header are ok.
Further testing revealed that at least on x86_64 there was one new
.plt slot, __bzero.  This patch fixes that too.
Build/make check tested on x86_64 and i686.

2004-05-27  Jakub Jelinek  <jakub@redhat.com>

	* string/bits/string2.h (__bzero): Define even for GCC 3.0+.
	* sysdeps/alpha/stpcpy.S (stpcpy): Add libc_hidden_builtin_def.
	* sysdeps/alpha/alphaev67/stpcpy.S (stpcpy): Likewise.
	* sysdeps/powerpc/powerpc32/stpcpy.S (stpcpy): Likewise.
	* sysdeps/powerpc/powerpc64/stpcpy.S (stpcpy): Likewise.
	* sysdeps/sparc/sparc32/stpcpy.S (stpcpy): Likewise.
	* sysdeps/sparc/sparc64/stpcpy.S (stpcpy): Likewise.
	* sysdeps/i386/stpcpy.S (stpcpy): Likewise.
	* sysdeps/i386/i586/stpcpy.S (stpcpy): Likewise.
	* sysdeps/generic/stpcpy.c (stpcpy): Likewise.
	* sysdeps/x86_64/stpcpy.S (stpcpy): Likewise.
	* sysdeps/i386/i586/memcpy.S (memcpy): Remove
	libc_hidden_builtin_def if MEMPCPY_P.
	* sysdeps/x86_64/memcpy.S (memcpy): Likewise.
	* sysdeps/i386/i686/mempcpy.S (mempcpy): Add libc_hidden_builtin_def.
	* sysdeps/i386/i586/mempcpy.S (mempcpy): Likewise.
	* sysdeps/generic/mempcpy.c (mempcpy): Likewise.
	* sysdeps/x86_64/mempcpy.S (mempcpy): Likewise.

--- libc/sysdeps/alpha/alphaev67/stpcpy.S.jj	2002-08-04 03:22:10.000000000 +0200
+++ libc/sysdeps/alpha/alphaev67/stpcpy.S	2004-05-27 09:33:56.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson <rth@redhat.com>.
 
@@ -51,3 +51,4 @@ ENTRY(__stpcpy)
 
 weak_alias (__stpcpy, stpcpy)
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/alpha/stpcpy.S.jj	2002-08-04 03:22:10.000000000 +0200
+++ libc/sysdeps/alpha/stpcpy.S	2004-05-27 09:25:26.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson <rth@tamu.edu>, 1996.
 
@@ -53,3 +53,4 @@ ENTRY(__stpcpy)
 
 weak_alias (__stpcpy, stpcpy)
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/powerpc/powerpc64/stpcpy.S.jj	2002-09-18 01:50:02.000000000 +0200
+++ libc/sysdeps/powerpc/powerpc64/stpcpy.S	2004-05-27 09:34:42.000000000 +0200
@@ -1,5 +1,5 @@
 /* Optimized stpcpy implementation for PowerPC64.
-   Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -119,3 +119,4 @@ END (BP_SYM (__stpcpy))
 
 weak_alias (BP_SYM (__stpcpy), BP_SYM (stpcpy))
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/powerpc/powerpc32/stpcpy.S.jj	2002-09-05 10:26:37.000000000 +0200
+++ libc/sysdeps/powerpc/powerpc32/stpcpy.S	2004-05-27 09:34:21.000000000 +0200
@@ -1,5 +1,5 @@
 /* Optimized stpcpy implementation for PowerPC.
-   Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -119,3 +119,4 @@ END (BP_SYM (__stpcpy))
 
 weak_alias (BP_SYM (__stpcpy), BP_SYM (stpcpy))
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/sparc/sparc32/stpcpy.S.jj	2002-08-04 03:22:11.000000000 +0200
+++ libc/sysdeps/sparc/sparc32/stpcpy.S	2004-05-27 09:24:28.000000000 +0200
@@ -1,6 +1,6 @@
 /* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
    For SPARC v7.
-   Copyright (C) 1996, 1999, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1999, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
 
@@ -162,3 +162,4 @@ END(__stpcpy)
 
 weak_alias(__stpcpy, stpcpy)
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/sparc/sparc64/stpcpy.S.jj	2003-01-27 21:55:28.000000000 +0100
+++ libc/sysdeps/sparc/sparc64/stpcpy.S	2004-05-27 09:25:07.000000000 +0200
@@ -1,6 +1,6 @@
 /* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
    For SPARC v9.
-   Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
                   Jakub Jelinek <jj@ultra.linux.cz>.
@@ -272,3 +272,4 @@ END(__stpcpy)
 
 weak_alias (__stpcpy, stpcpy)
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/i386/i686/mempcpy.S.jj	2002-08-03 08:41:06.000000000 +0200
+++ libc/sysdeps/i386/i686/mempcpy.S	2004-05-27 09:44:36.649392190 +0200
@@ -1,7 +1,7 @@
 /* Copy memory block and return pointer to following byte.
    For Intel 80x86, x>=6.
    This file is part of the GNU C Library.
-   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -59,3 +59,4 @@ ENTRY (BP_SYM (__mempcpy))
 END (BP_SYM (__mempcpy))
 libc_hidden_def (BP_SYM (__mempcpy))
 weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))
+libc_hidden_builtin_def (mempcpy)
--- libc/sysdeps/i386/i586/memcpy.S.jj	2003-04-30 00:47:20.000000000 +0200
+++ libc/sysdeps/i386/i586/memcpy.S	2004-05-27 08:01:30.918955620 +0200
@@ -116,4 +116,6 @@ L(1):	rep; movsb
 	LEAVE
 	RET_PTR
 END (BP_SYM (memcpy))
+#if !MEMPCPY_P
 libc_hidden_builtin_def (memcpy)
+#endif
--- libc/sysdeps/i386/i586/mempcpy.S.jj	2002-08-03 08:41:05.000000000 +0200
+++ libc/sysdeps/i386/i586/mempcpy.S	2004-05-27 08:00:18.000000000 +0200
@@ -3,3 +3,4 @@
 
 libc_hidden_def (BP_SYM (__mempcpy))
 weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))
+libc_hidden_builtin_def (mempcpy)
--- libc/sysdeps/i386/i586/stpcpy.S.jj	2002-08-04 03:22:11.000000000 +0200
+++ libc/sysdeps/i386/i586/stpcpy.S	2004-05-27 09:23:46.000000000 +0200
@@ -5,3 +5,4 @@
 
 weak_alias (__stpcpy, stpcpy)
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/i386/stpcpy.S.jj	2002-08-04 03:22:10.000000000 +0200
+++ libc/sysdeps/i386/stpcpy.S	2004-05-27 09:23:21.000000000 +0200
@@ -1,6 +1,7 @@
 /* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
    For Intel 80x86, x>=3.
-   Copyright (C) 1994,1995,1996,1997,2000,2002 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2004
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper (drepper@gnu.ai.mit.edu).
 
@@ -94,3 +95,4 @@ END (BP_SYM (__stpcpy))
 
 weak_alias (BP_SYM (__stpcpy), BP_SYM (stpcpy))
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/sysdeps/generic/mempcpy.c.jj	2002-08-03 10:42:02.000000000 +0200
+++ libc/sysdeps/generic/mempcpy.c	2004-05-27 08:00:07.000000000 +0200
@@ -1,7 +1,7 @@
 /* Copy memory to memory until the specified number of bytes
    has been copied, return pointer to following byte.
    Overlap is NOT handled correctly.
-   Copyright (C) 1991, 1997, 1998, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1997, 1998, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Torbjorn Granlund (tege@sics.se).
 
@@ -66,3 +66,4 @@ __mempcpy (dstpp, srcpp, len)
 }
 libc_hidden_def (__mempcpy)
 weak_alias (__mempcpy, mempcpy)
+libc_hidden_builtin_def (mempcpy)
--- libc/sysdeps/generic/stpcpy.c.jj	2002-08-04 03:22:10.000000000 +0200
+++ libc/sysdeps/generic/stpcpy.c	2004-05-27 09:21:55.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995, 1997, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -50,3 +50,6 @@ libc_hidden_def (__stpcpy)
 #ifdef weak_alias
 weak_alias (__stpcpy, stpcpy)
 #endif
+#ifdef libc_hidden_builtin_def
+libc_hidden_builtin_def (stpcpy)
+#endif
--- libc/sysdeps/x86_64/memcpy.S.jj	2004-02-12 11:53:38.000000000 +0100
+++ libc/sysdeps/x86_64/memcpy.S	2004-05-27 08:03:31.249390840 +0200
@@ -1,5 +1,5 @@
 /* Highly optimized version for x86-64.
-   Copyright (C) 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Based on i586 version contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -90,4 +90,6 @@ ENTRY (BP_SYM (memcpy))
 	ret
 
 END (BP_SYM (memcpy))
+#if !MEMPCPY_P
 libc_hidden_builtin_def (memcpy)
+#endif
--- libc/sysdeps/x86_64/mempcpy.S.jj	2002-08-31 19:33:34.000000000 +0200
+++ libc/sysdeps/x86_64/mempcpy.S	2004-05-27 09:43:49.997752771 +0200
@@ -3,3 +3,4 @@
 
 libc_hidden_def (BP_SYM (__mempcpy))
 weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))
+libc_hidden_builtin_def (mempcpy)
--- libc/sysdeps/x86_64/stpcpy.S.jj	2002-08-31 19:41:24.000000000 +0200
+++ libc/sysdeps/x86_64/stpcpy.S	2004-05-27 09:22:26.614751714 +0200
@@ -5,3 +5,4 @@
 
 weak_alias (__stpcpy, stpcpy)
 libc_hidden_def (__stpcpy)
+libc_hidden_builtin_def (stpcpy)
--- libc/string/bits/string2.h.jj	2004-05-26 15:57:38.000000000 +0200
+++ libc/string/bits/string2.h	2004-05-27 10:08:28.008873934 +0200
@@ -94,9 +94,10 @@ __STRING2_COPY_TYPE (8);
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to C.  */
-#if !defined _HAVE_STRING_ARCH_memset && ! __GNUC_PREREQ (3, 0)
-# if _STRING_ARCH_unaligned
-#  define memset(s, c, n) \
+#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)				      \
@@ -105,10 +106,10 @@ __STRING2_COPY_TYPE (8);
 		     ? ({ void *__s = (s); __bzero (__s, n); __s; })	      \
 		     : memset (s, c, n))))
 
-#  define __memset_1(s, c) ({ void *__s = (s);				      \
+#   define __memset_1(s, c) ({ void *__s = (s);				      \
 			    *((__uint8_t *) __s) = (__uint8_t) c; __s; })
 
-#  define __memset_gc(s, c, n) \
+#   define __memset_gc(s, c, n) \
   ({ void *__s = (s);							      \
      union {								      \
        unsigned int __ui;						      \
@@ -177,15 +178,19 @@ __STRING2_COPY_TYPE (8);
        }								      \
 									      \
      __s; })
-# else
-#  define memset(s, c, n) \
+#  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 optimizes memset(s, 0, n) but not bzero(s, n).
-   The optimization is broken before EGCS 1.1.  */
+/* 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


	Jakub

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

* Re: [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup)
  2004-05-27  9:47       ` [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup) Jakub Jelinek
@ 2004-05-28  6:40         ` H. J. Lu
  2004-05-28  6:42         ` Ulrich Drepper
  1 sibling, 0 replies; 7+ messages in thread
From: H. J. Lu @ 2004-05-28  6:40 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers

On Thu, May 27, 2004 at 09:12:40AM +0200, Jakub Jelinek wrote:
> On Wed, May 26, 2004 at 06:01:02PM -0700, H. J. Lu wrote:
> > I think the patch is incomplete. 
> 
> You are right, sorry.  I haven't built glibc with it after doing all changes,
> only tested whether apps using that header are ok.
> Further testing revealed that at least on x86_64 there was one new
> .plt slot, __bzero.  This patch fixes that too.
> Build/make check tested on x86_64 and i686.
> 

You also need to add __bzero to sysdeps/ia64/bzero.S.


H.J.

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

* Re: [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup)
  2004-05-27  9:47       ` [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup) Jakub Jelinek
  2004-05-28  6:40         ` H. J. Lu
@ 2004-05-28  6:42         ` Ulrich Drepper
  1 sibling, 0 replies; 7+ messages in thread
From: Ulrich Drepper @ 2004-05-28  6:42 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

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

end of thread, other threads:[~2004-05-28  6:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-26 17:27 [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ Jakub Jelinek
2004-05-26 20:36 ` Ulrich Drepper
2004-05-27  1:01   ` H. J. Lu
2004-05-27  9:26     ` H. J. Lu
2004-05-27  9:47       ` [PATCH] <bits/string2.h> changes for GCC 3.2+ and 3.4+ (followup) Jakub Jelinek
2004-05-28  6:40         ` H. J. Lu
2004-05-28  6:42         ` Ulrich Drepper

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).