public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove defines to builtins in string2.h
@ 2016-11-18 15:38 Wilco Dijkstra
  2016-11-22 14:36 ` [PATCH v2] " Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-18 15:38 UTC (permalink / raw)
  To: libc-alpha; +Cc: nd

As discussed in https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
for C90 functions there is no need to use a define to the GCC builtin as
an optimization.  So remove the defines for strchr, strncpy, strcspn, strspn
and strpbrk from string/bits/string2.h.

ChangeLog:
2015-11-18  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/bits/string2.h (strchr) Remove define.
	(strncpy): Likewise.
	(strcspn): Likewise.
	(strspn): Likewise.
	(strpbrk): Likewise.
--
diff --git a/string/bits/string2.h b/string/bits/string2.h
index 8fa35d52e7c8e3ff592573fa64472da526e8616d..265e9b6eb88b2d4935d683ec733c56b09580a1fb 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -58,11 +58,6 @@
 #endif
 
 
-#ifndef _HAVE_STRING_ARCH_strchr
-# define strchr(s, c) __builtin_strchr (s, c)
-#endif
-
-
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
 #ifdef __USE_GNU
 # ifndef _HAVE_STRING_ARCH_stpcpy
@@ -74,12 +69,6 @@
 #endif
 
 
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
 /* Append no more than N characters from SRC onto DEST.  */
 #ifndef _HAVE_STRING_ARCH_strncat
 # ifdef _USE_STRING_ARCH_strchr
@@ -155,26 +144,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #if !defined _HAVE_STRING_ARCH_strsep
 # ifdef __USE_MISC
 #  define strsep(s, reject) __strsep (s, reject)

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

* [PATCH v2] Remove defines to builtins in string2.h
  2016-11-18 15:38 [PATCH] Remove defines to builtins in string2.h Wilco Dijkstra
@ 2016-11-22 14:36 ` Wilco Dijkstra
  2016-11-22 15:26   ` Florian Weimer
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-22 14:36 UTC (permalink / raw)
  To: libc-alpha; +Cc: nd

As discussed in https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
for C90 functions there is no need to use define to use the GCC builtin as
an optimization.  Also other headers already ensure (most) non-C90 symbols
are redirected to avoid name space clashes.

So remove the defines for strchr, __stpcpy, stpcpy, strncpy, strncat, strcspn,
strspn, strpbrk and strsep from string/bits/string2.h. The strncat define only
uses the #else as _USE_STRING_ARCH_strchr is never defined unless
_HAVE_STRING_ARCH_strncat is defined too.

elf/check-localplt and linknamespace test pass so the redirections weren't
required or useful.

ChangeLog:
2015-11-22  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/bits/string2.h (strchr) Remove define.
	(stpcpy): Likewise.
	(__stpcpy): Likewise.
	(strncpy): Likewise.
	(strncat): Likewise.
	(strcspn): Likewise.
	(strspn): Likewise.
	(strpbrk): Likewise.
	(strsep): Likewise.
 --
diff --git a/string/bits/string2.h b/string/bits/string2.h
index 8fa35d52e7c8e3ff592573fa64472da526e8616d..941e9bff015a89908dbf61044a1787bcb4026b89 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -58,45 +58,6 @@
 #endif
 
 
-#ifndef _HAVE_STRING_ARCH_strchr
-# define strchr(s, c) __builtin_strchr (s, c)
-#endif
-
-
-/* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);				      \
-		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
-		    ? (strlen (src) < ((size_t) (n))			      \
-		       ? strcat (__dest, src)				      \
-		       : (*((char *) __mempcpy (strchr (__dest, '\0'),	      \
-						src, n)) = '\0', __dest))     \
-		    : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
-#endif
-
-
 /* Compare characters of S1 and S2.  */
 #ifndef _HAVE_STRING_ARCH_strcmp
 # define strcmp(s1, s2) \
@@ -155,32 +116,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
-#if !defined _HAVE_STRING_ARCH_strsep
-# ifdef __USE_MISC
-#  define strsep(s, reject) __strsep (s, reject)
-# endif
-#endif
-
 /* We need the memory allocation functions for inline strdup().
    Referring to stdlib.h (even minimally) is not allowed
    in any of the tight standards compliant modes.  */
 

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

* Re: [PATCH v2] Remove defines to builtins in string2.h
  2016-11-22 14:36 ` [PATCH v2] " Wilco Dijkstra
@ 2016-11-22 15:26   ` Florian Weimer
  2016-11-22 16:34     ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2016-11-22 15:26 UTC (permalink / raw)
  To: Wilco Dijkstra, libc-alpha; +Cc: nd

On 11/22/2016 03:35 PM, Wilco Dijkstra wrote:
> As discussed in https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
> for C90 functions there is no need to use define to use the GCC builtin as
> an optimization.  Also other headers already ensure (most) non-C90 symbols
> are redirected to avoid name space clashes.

> -#ifndef _HAVE_STRING_ARCH_strchr
> -# define strchr(s, c) __builtin_strchr (s, c)
> -#endif

Please remove the definition of _HAVE_STRING_ARCH_strchr as well (from 
sysdeps/x86/bits/string.h).

> -/* Copy SRC to DEST, returning pointer to final NUL byte.  */
> -#ifdef __USE_GNU
> -# ifndef _HAVE_STRING_ARCH_stpcpy
> -#  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
> -#endif

I'm surprised to see stpcpy in this patch because the first paragraph 
says this change is exclusively about C90 functions, and stpcpy isn't one.

> -/* Copy no more than N characters of SRC to DEST.  */
> -#ifndef _HAVE_STRING_ARCH_strncpy
> -# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
> -#endif

_HAVE_STRING_ARCH_strncpy needs removal.

> -#ifndef _HAVE_STRING_ARCH_strncat
> -# ifdef _USE_STRING_ARCH_strchr

These two need to be removed as well.  I'm not listing the other feature 
macros which can be removed.

> -#if !defined _HAVE_STRING_ARCH_strsep
> -# ifdef __USE_MISC
> -#  define strsep(s, reject) __strsep (s, reject)
> -# endif
> -#endif

See above, not a C90 function.

Thanks,
Florian

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

* Re: [PATCH v2] Remove defines to builtins in string2.h
  2016-11-22 15:26   ` Florian Weimer
@ 2016-11-22 16:34     ` Wilco Dijkstra
  2016-11-22 16:36       ` Florian Weimer
                         ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-22 16:34 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha; +Cc: nd

Florian Weimer wrote:
> Please remove the definition of _HAVE_STRING_ARCH_strchr as well (from 
> sysdeps/x86/bits/string.h).

Sure I'll have a quick hunt for dead defines. There must be quite a few by now...

> I'm surprised to see stpcpy in this patch because the first paragraph 
> says this change is exclusively about C90 functions, and stpcpy isn't one.

Joseph's reply to my question made it clear the redirection is done elsewhere
in most cases, so that means we can remove the redirections of non-C90
symbols from string2.h as well:

> > Also other headers already ensure (most) non-C90 symbols
> > are redirected to avoid name space clashes.

I checked and there are no namespace issues introduced by my patch
(note strdup/strndup doesn't appear to redirect internally, so building with -Os
or removing the str(n)dup defines from string2.h causes a namespace bug).

Wilco
    

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

* Re: [PATCH v2] Remove defines to builtins in string2.h
  2016-11-22 16:34     ` Wilco Dijkstra
@ 2016-11-22 16:36       ` Florian Weimer
  2016-11-22 16:55       ` Zack Weinberg
  2016-11-22 17:35       ` Joseph Myers
  2 siblings, 0 replies; 22+ messages in thread
From: Florian Weimer @ 2016-11-22 16:36 UTC (permalink / raw)
  To: Wilco Dijkstra, libc-alpha; +Cc: nd

On 11/22/2016 05:34 PM, Wilco Dijkstra wrote:
> Florian Weimer wrote:
>> Please remove the definition of _HAVE_STRING_ARCH_strchr as well (from
>> sysdeps/x86/bits/string.h).
>
> Sure I'll have a quick hunt for dead defines. There must be quite a few by now...

Thanks.

>> I'm surprised to see stpcpy in this patch because the first paragraph
>> says this change is exclusively about C90 functions, and stpcpy isn't one.
>
> Joseph's reply to my question made it clear the redirection is done elsewhere
> in most cases, so that means we can remove the redirections of non-C90
> symbols from string2.h as well:
>
>>> Also other headers already ensure (most) non-C90 symbols
>>> are redirected to avoid name space clashes.

Ah, I found the reference to C90 symbols confusing.

Florian

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

* Re: [PATCH v2] Remove defines to builtins in string2.h
  2016-11-22 16:34     ` Wilco Dijkstra
  2016-11-22 16:36       ` Florian Weimer
@ 2016-11-22 16:55       ` Zack Weinberg
  2016-11-22 17:35       ` Joseph Myers
  2 siblings, 0 replies; 22+ messages in thread
From: Zack Weinberg @ 2016-11-22 16:55 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: Florian Weimer, libc-alpha, nd

On Tue, Nov 22, 2016 at 11:34 AM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> I checked and there are no namespace issues introduced by my patch
> (note strdup/strndup doesn't appear to redirect internally, so building with -Os
> or removing the str(n)dup defines from string2.h causes a namespace bug).

In the "no-string-opts" branch, I noticed a problem with
strsep/__strsep as well.  I sprinkled __ around where necessary to get
things compiling again, but internal redirections would probably be
better, so code can continue using the undecorated names.

zw

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

* Re: [PATCH v2] Remove defines to builtins in string2.h
  2016-11-22 16:34     ` Wilco Dijkstra
  2016-11-22 16:36       ` Florian Weimer
  2016-11-22 16:55       ` Zack Weinberg
@ 2016-11-22 17:35       ` Joseph Myers
  2016-11-22 19:10         ` Wilco Dijkstra
  2 siblings, 1 reply; 22+ messages in thread
From: Joseph Myers @ 2016-11-22 17:35 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: Florian Weimer, libc-alpha, nd

On Tue, 22 Nov 2016, Wilco Dijkstra wrote:

> > I'm surprised to see stpcpy in this patch because the first paragraph 
> > says this change is exclusively about C90 functions, and stpcpy isn't one.
> 
> Joseph's reply to my question made it clear the redirection is done elsewhere
> in most cases, so that means we can remove the redirections of non-C90
> symbols from string2.h as well:

My suggestion for stpcpy included:

  Thus, it should be possible just to call stpcpy directly everywhere in 
  glibc rather than __stpcpy, and rely on those redirections to ensure that 
  the calls actually end up being namespace-clean (but can be inlined if 
  appropriate as GCC knows about stpcpy as a built-in function in gnu11 
  mode).  Then the definition of __stpcpy in bits/string2.h should not be 
  needed for building glibc.

Unless you also change all calls to __stpcpy to call stpcpy directly, you 
are potentially losing built-in function optimizations by removing the 
__stpcpy macro.  glibc contains calls to __stpcpy as well as direct ones 
to stpcpy.  Because of the other redirections, it's safe to change 
__stpcpy calls to stpcpy calls in glibc as a preparatory patch.  Likewise 
__mempcpy.

I think you need to separate the case of

#define foo(x) __builtin_foo (x)

from all the other cases, where a more complicated macro expansion is 
involved (in which case we need to see if GCC has relevant optimizations 
or have a reason why they are appropriate to discard), or where the macro 
is __foo instead of foo.

Also, patches like this are the sort where it would be useful to make sure 
that installed stripped shared libraries and executables are unchanged by 
the patch, or to have a reason why it results in any changes to the 
generated code.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2] Remove defines to builtins in string2.h
  2016-11-22 17:35       ` Joseph Myers
@ 2016-11-22 19:10         ` Wilco Dijkstra
  2016-11-22 20:26           ` [PATCH v3] " Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-22 19:10 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd

Joseph Myers wrote:

> Unless you also change all calls to __stpcpy to call stpcpy directly, you 
> are potentially losing built-in function optimizations by removing the 
> __stpcpy macro.  glibc contains calls to __stpcpy as well as direct ones 
> to stpcpy.  Because of the other redirections, it's safe to change 
> __stpcpy calls to stpcpy calls in glibc as a preparatory patch.  Likewise 
> __mempcpy.

Right, it does seem there are a few cases where __stpcpy may be optimized.
So for this patch I'll keep the #define __stpcpy until existing calls to __stpcpy
have been changed.

> I think you need to separate the case of
> 
> #define foo(x) __builtin_foo (x)
> 
> from all the other cases, where a more complicated macro expansion is 
> involved (in which case we need to see if GCC has relevant optimizations 
> or have a reason why they are appropriate to discard), or where the macro 
> is __foo instead of foo.

This patch doesn't remove any optimizations - as I mentioned in the description,
the strncat macro is unused as _USE_STRING_ARCH_strchr is always false
(and in the next version I'm removing that define as well).

> Also, patches like this are the sort where it would be useful to make sure 
> that installed stripped shared libraries and executables are unchanged by 
> the patch, or to have a reason why it results in any changes to the 
> generated code.

Yes my goal was no diff, and that's true for the new version that also removes
all unused string defines.

Wilco
    

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

* [PATCH v3] Remove defines to builtins in string2.h
  2016-11-22 19:10         ` Wilco Dijkstra
@ 2016-11-22 20:26           ` Wilco Dijkstra
  2016-11-22 20:53             ` Florian Weimer
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-22 20:26 UTC (permalink / raw)
  To: libc-alpha; +Cc: Florian Weimer, nd, Joseph Myers


As discussed in https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-22  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/string-inlines.c: Remove include of bits/string2.h.
	* string/bits/string2.h (__bzero): Always redirect to memset.
	(strchr) Remove define.
	(__stpcpy): Keep redirection for internal use.
	(stpcpy): Remove define.
	(strncpy): Likewise.
	(strncat): Likewise.
	(strcspn): Likewise.
	(strspn): Likewise.
	(strpbrk): Likewise.
	(_HAVE_STRING_ARCH_strdup): Likewise.
	* sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
	(_HAVE_STRING_ARCH_strcpy): Likewise.
	(_HAVE_STRING_ARCH_strncpy): Likewise.
	(_HAVE_STRING_ARCH_strcat): Likewise.
	(_HAVE_STRING_ARCH_strncat): Likewise.
	(_HAVE_STRING_ARCH_memchr): Likewise.
	* sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
	* sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
	(_HAVE_STRING_ARCH_memmove): Likewise.
	(_HAVE_STRING_ARCH_memcmp): Likewise.
	(_HAVE_STRING_ARCH_memset): Likewise.
	(_USE_STRING_ARCH_memset): Likewise.
	(_HAVE_STRING_ARCH_memchr): Likewise.
	(_HAVE_STRING_ARCH_memrchr): Likewise.
	(_HAVE_STRING_ARCH_rawmemchr): Likewise.
	(_HAVE_STRING_ARCH_strlen): Likewise.
	(_HAVE_STRING_ARCH_strcpy): Likewise.
	(_HAVE_STRING_ARCH_strpcpy): Likewise.
	(_HAVE_STRING_ARCH_strncpy): Likewise.
	(_HAVE_STRING_ARCH_strncat): Likewise.
	(_HAVE_STRING_ARCH_strchr): Likewise.
	(_USE_STRING_ARCH_strchr): Likewise.
	(_HAVE_STRING_ARCH_strnchr): Likewise.
	(_HAVE_STRING_ARCH_strchrnul): Likewise.
	(_HAVE_STRING_ARCH_strrchr): Likewise.
	(_HAVE_STRING_ARCH_index): Likewise.
	(_HAVE_STRING_ARCH_rindex): Likewise.
	(_HAVE_STRING_ARCH_strcspn): Likewise.
	(_HAVE_STRING_ARCH_strspn): Likewise.
	(_HAVE_STRING_ARCH_strpbrk): Likewise.
	(_HAVE_STRING_ARCH_strstr): Likewise.
	(_HAVE_STRING_ARCH_ffs): Likewise.

--

diff --git a/string/bits/string2.h b/string/bits/string2.h
index c8799c5aeccc070f2a975fafa660d7814fa304cc..c2edfdc2feebe04d7aad41b1b79c8cb32c3c19c6 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,50 +53,13 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
-
-#ifndef _HAVE_STRING_ARCH_strchr
-# define strchr(s, c) __builtin_strchr (s, c)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);				      \
-		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
-		    ? (strlen (src) < ((size_t) (n))			      \
-		       ? strcat (__dest, src)				      \
-		       : (*((char *) __mempcpy (strchr (__dest, '\0'),	      \
-						src, n)) = '\0', __dest))     \
-		    : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
 /* Compare characters of S1 and S2.  */
 #ifndef _HAVE_STRING_ARCH_strcmp
 # define strcmp(s1, s2) \
@@ -155,40 +118,16 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 /* We need the memory allocation functions for inline strdup().
    Referring to stdlib.h (even minimally) is not allowed
    in any of the tight standards compliant modes.  */
 #ifdef __USE_MISC
 
-# if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup
-#  define __need_malloc_and_calloc
-#  include <stdlib.h>
-# endif
-
-# ifndef _HAVE_STRING_ARCH_strdup
+# define __need_malloc_and_calloc
+# include <stdlib.h>
 
 extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
-#  define __strdup(s) \
+# define __strdup(s) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)	      \
 		  ? (((const char *) (s))[0] == '\0'			      \
 		     ? (char *) calloc ((size_t) 1, (size_t) 1)		      \
@@ -199,16 +138,14 @@ extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
 			  __retval; }))					      \
 		  : __strdup (s)))
 
-#  if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-#   define strdup(s) __strdup (s)
-#  endif
+# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+#  define strdup(s) __strdup (s)
 # endif
 
-# ifndef _HAVE_STRING_ARCH_strndup
 
 extern char *__strndup (const char *__string, size_t __n)
      __THROW __attribute_malloc__;
-#  define __strndup(s, n) \
+# define __strndup(s, n) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)	      \
 		  ? (((const char *) (s))[0] == '\0'			      \
 		     ? (char *) calloc ((size_t) 1, (size_t) 1)		      \
@@ -227,9 +164,8 @@ extern char *__strndup (const char *__string, size_t __n)
 			  __retval; }))					      \
 		  : __strndup (s, n)))
 
-#  ifdef __USE_XOPEN2K8
-#   define strndup(s, n) __strndup (s, n)
-#  endif
+# ifdef __USE_XOPEN2K8
+#  define strndup(s, n) __strndup (s, n)
 # endif
 
 #endif /* Use misc. or use GNU.  */
diff --git a/string/string-inlines.c b/string/string-inlines.c
index 7b1de7180f8be3dca1515e23553a9ecbdc76f5e2..6d0c0c51b3027f99d26aace85523d7f337df8308 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 39e0b7fe7c7a100c7f4e2a3c13f815951815e854..a707ce8ce18d047d649b78dac4b8a360c4436199 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 10beca6a5a98cc126e39227cae5ff25a1ac09857..75a3eb31f3edc7109c360550c95d3d00402204a7 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 805d33f0a2d13743e763e18c5c474c9507186a15..849ba9377498eb6f8d2218226dbfad6214e0fb35 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)				      \
 		  ? __memcpy_c ((dest), (src), (n))			      \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16			      \
 		  ? ((n) == 1						      \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)				      \
 		  ? __builtin_strlen (str)				      \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8	      \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? ((strlen (src) + 1 >= ((size_t) (n))		      \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? __strcat_c ((dest), (src), strlen (src) + 1)	      \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);				      \
 		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1263,8 +1249,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? ((c) == '\0'					      \
@@ -1323,7 +1307,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? ((c) == '\0'					      \
@@ -1386,7 +1369,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strchr_c ((s), ((c) & 0xff) << 8)			      \
@@ -1395,7 +1377,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strrchr_c ((s), ((c) & 0xff) << 8)		      \
@@ -1500,7 +1481,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strrchr_c ((s), ((c) & 0xff) << 8)		      \
@@ -1510,7 +1490,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
 		  ? ((reject)[0] == '\0'				      \
@@ -1631,7 +1610,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
 		  ? ((accept)[0] == '\0'				      \
@@ -1751,7 +1729,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
 		  ? ((accept)[0] == '\0'				      \
@@ -1858,7 +1835,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
 		  ? ((needle)[0] == '\0'				      \
@@ -1970,7 +1946,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)			      \
 		      ? __builtin_ffs (word)				      \
 		      : ({ int __cnt, __tmp;				      \
        

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

* Re: [PATCH v3] Remove defines to builtins in string2.h
  2016-11-22 20:26           ` [PATCH v3] " Wilco Dijkstra
@ 2016-11-22 20:53             ` Florian Weimer
  2016-11-22 21:16               ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2016-11-22 20:53 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: libc-alpha, nd, Joseph Myers

* Wilco Dijkstra:

> -#ifndef _HAVE_STRING_ARCH_strchr
> -# define strchr(s, c) __builtin_strchr (s, c)
> -#endif

Current master has this:

#ifndef _HAVE_STRING_ARCH_strchr
extern void *__rawmemchr (const void *__s, int __c);
#  define strchr(s, c) \
  (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s)	      \
		  && (c) == '\0'					      \
		  ? (char *) __rawmemchr (s, c)				      \
		  : __builtin_strchr (s, c)))
#endif

So I'm afraid the patch doesn't apply.

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

* Re: [PATCH v3] Remove defines to builtins in string2.h
  2016-11-22 20:53             ` Florian Weimer
@ 2016-11-22 21:16               ` Wilco Dijkstra
  2016-11-23  8:40                 ` Florian Weimer
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-22 21:16 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, nd, Joseph Myers

Florian Weimer wrote:

> -#ifndef _HAVE_STRING_ARCH_strchr
> -# define strchr(s, c) __builtin_strchr (s, c)
> -#endif

> Current master has this:
...
> So I'm afraid the patch doesn't apply.

Yes there is overlap with this patch: https://sourceware.org/ml/libc-alpha/2016-11/msg00586.html
(a previous version of that was posted back in February...). This particular
change could be rolled back into the original strchr patch to avoid this conflict.

You may also need my recent strtok and strsep patches although I think there should
be no direct conflicts like the above.

Wilco

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

* Re: [PATCH v3] Remove defines to builtins in string2.h
  2016-11-22 21:16               ` Wilco Dijkstra
@ 2016-11-23  8:40                 ` Florian Weimer
  2016-11-23 12:23                   ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2016-11-23  8:40 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: libc-alpha, nd, Joseph Myers

On 11/22/2016 10:15 PM, Wilco Dijkstra wrote:
> Florian Weimer wrote:
>
>> -#ifndef _HAVE_STRING_ARCH_strchr
>> -# define strchr(s, c) __builtin_strchr (s, c)
>> -#endif
>
>> Current master has this:
> ...
>> So I'm afraid the patch doesn't apply.
>
> Yes there is overlap with this patch: https://sourceware.org/ml/libc-alpha/2016-11/msg00586.html
> (a previous version of that was posted back in February...). This particular
> change could be rolled back into the original strchr patch to avoid this conflict.

Please consolidate the two into a single patch, and make sure it applies 
before resubmitting it.

We really should test this patch on x86 and s390.

Thanks,
Florian

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

* Re: [PATCH v3] Remove defines to builtins in string2.h
  2016-11-23  8:40                 ` Florian Weimer
@ 2016-11-23 12:23                   ` Wilco Dijkstra
  2016-11-23 13:40                     ` Joseph Myers
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-23 12:23 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, nd, Joseph Myers

Florian Weimer wrote:    
> On 11/22/2016 10:15 PM, Wilco Dijkstra wrote:
> > Yes there is overlap with this patch:  https://sourceware.org/ml/libc-alpha/2016-11/msg00586.html
> > (a previous version of that was posted back in February...). This particular
> > change could be rolled back into the original strchr patch to avoid this conflict.
>
> Please consolidate the two into a single patch, and make sure it applies 
> before resubmitting it.
>
> We really should test this patch on x86 and s390.

Unfortunately it looks like it'll need my strsep and strtok patches too, ie. it'll become a
huge patch with many diffs in GLIBC, so testing it causes no unexpected changes on
several targets would become a huge amount of work.

So I think it's better to remove all these defines in one go in a way that causes no diffs.
We could either do that after finishing dealing with all the string2.h optimizations (ie. after
committing my various oustanding patches) or as a separate patch that we commit
before making any changes to the current optimizations in string2.h (I don't believe
any of the _HAVE_STRING_ARCH_xxx are ever defined while building GLIBC).

Wilco

    

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

* Re: [PATCH v3] Remove defines to builtins in string2.h
  2016-11-23 12:23                   ` Wilco Dijkstra
@ 2016-11-23 13:40                     ` Joseph Myers
  2016-11-23 19:00                       ` [PATCH v4] " Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Joseph Myers @ 2016-11-23 13:40 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: Florian Weimer, libc-alpha, nd

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

On Wed, 23 Nov 2016, Wilco Dijkstra wrote:

> Florian Weimer wrote:    
> > On 11/22/2016 10:15 PM, Wilco Dijkstra wrote:
> > > Yes there is overlap with this patch:  https://sourceware.org/ml/libc-alpha/2016-11/msg00586.html
> > > (a previous version of that was posted back in February...). This particular
> > > change could be rolled back into the original strchr patch to avoid this conflict.
> >
> > Please consolidate the two into a single patch, and make sure it applies 
> > before resubmitting it.
> >
> > We really should test this patch on x86 and s390.
> 
> Unfortunately it looks like it'll need my strsep and strtok patches too, 
> ie. it'll become a huge patch with many diffs in GLIBC, so testing it 
> causes no unexpected changes on several targets would become a huge 
> amount of work.

Well, you can always repost / ping those patches as an alternative to 
combining them.  But in any case, if posting a patch that depends on a 
previous one but isn't posted as part of the same series as it, *make sure 
the posting lists all the dependencies explicitly* (this includes if the 
dependency is only textual rather than logical and you could in fact apply 
the patches out of order with some fixups if approved out of order).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* [PATCH v4] Remove defines to builtins in string2.h
  2016-11-23 13:40                     ` Joseph Myers
@ 2016-11-23 19:00                       ` Wilco Dijkstra
  2017-02-09 15:31                         ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2016-11-23 19:00 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd

Here is v4 of the patch rebased so it applies cleanly after the strchr patch.
It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

This patch depends on https://sourceware.org/ml/libc-alpha/2016-11/msg00843.html
being applied first.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/string-inlines.c: Remove include of bits/string2.h.
	* string/bits/string2.h (__bzero): Always redirect to memset.
	(strchr) Remove define.
	(__stpcpy): Keep redirection for internal use.
	(stpcpy): Remove define.
	(strncpy): Likewise.
	(strncat): Likewise.
	(_HAVE_STRING_ARCH_strcmp): Likewise.
	(_HAVE_STRING_ARCH_strncmp): Likewise.
	(strcspn): Likewise.
	(strspn): Likewise.
	(strpbrk): Likewise.
	(_HAVE_STRING_ARCH_strdup): Likewise.
	(_HAVE_STRING_ARCH_strndup): Likewise.
	* sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
	(_HAVE_STRING_ARCH_strcpy): Likewise.
	(_HAVE_STRING_ARCH_strncpy): Likewise.
	(_HAVE_STRING_ARCH_strcat): Likewise.
	(_HAVE_STRING_ARCH_strncat): Likewise.
	(_HAVE_STRING_ARCH_memchr): Likewise.
	(_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
	* sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
	* sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
	(_HAVE_STRING_ARCH_memmove): Likewise.
	(_HAVE_STRING_ARCH_memcmp): Likewise.
	(_HAVE_STRING_ARCH_memset): Likewise.
	(_USE_STRING_ARCH_memset): Likewise.
	(_HAVE_STRING_ARCH_memchr): Likewise.
	(_HAVE_STRING_ARCH_memrchr): Likewise.
	(_HAVE_STRING_ARCH_rawmemchr): Likewise.
	(_HAVE_STRING_ARCH_strlen): Likewise.
	(_HAVE_STRING_ARCH_strcpy): Likewise.
	(_HAVE_STRING_ARCH_strpcpy): Likewise.
	(_HAVE_STRING_ARCH_strncpy): Likewise.
	(_HAVE_STRING_ARCH_strncat): Likewise.
	(_HAVE_STRING_ARCH_strcmp): Likewise.
	(_HAVE_STRING_ARCH_strncmp): Likewise.
	(_HAVE_STRING_ARCH_strchr): Likewise.
	(_USE_STRING_ARCH_strchr): Likewise.
	(_HAVE_STRING_ARCH_strnchr): Likewise.
	(_HAVE_STRING_ARCH_strchrnul): Likewise.
	(_HAVE_STRING_ARCH_strrchr): Likewise.
	(_HAVE_STRING_ARCH_index): Likewise.
	(_HAVE_STRING_ARCH_rindex): Likewise.
	(_HAVE_STRING_ARCH_strcspn): Likewise.
	(_HAVE_STRING_ARCH_strspn): Likewise.
	(_HAVE_STRING_ARCH_strpbrk): Likewise.
	(_HAVE_STRING_ARCH_strstr): Likewise.
	(_HAVE_STRING_ARCH_ffs): Likewise.

--

diff --git a/string/bits/string2.h b/string/bits/string2.h
index de426b47cae09933b2dc53e0956d63b4c93aebc0..5acdb7866e4e70a6c3aa050b0427b31aed8943ec 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);				      \
-		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
-		    ? (strlen (src) < ((size_t) (n))			      \
-		       ? strcat (__dest, src)				      \
-		       : (*((char *) __mempcpy (strchr (__dest, '\0'),	      \
-						src, n)) = '\0', __dest))     \
-		    : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
-#endif
-
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__								      \
   ({ size_t __s1_len, __s2_len;						      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)						      \
   (__extension__ (__builtin_constant_p (n)				      \
 		  && ((__builtin_constant_p (s1)			      \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #if !defined _HAVE_STRING_ARCH_strsep || defined _FORCE_INLINES
 # ifndef _HAVE_STRING_ARCH_strsep
 
@@ -265,15 +213,11 @@ __strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
    in any of the tight standards compliant modes.  */
 #ifdef __USE_MISC
 
-# if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup
-#  define __need_malloc_and_calloc
-#  include <stdlib.h>
-# endif
-
-# ifndef _HAVE_STRING_ARCH_strdup
+# define __need_malloc_and_calloc
+# include <stdlib.h>
 
 extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
-#  define __strdup(s) \
+# define __strdup(s) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)	      \
 		  ? (((const char *) (s))[0] == '\0'			      \
 		     ? (char *) calloc ((size_t) 1, (size_t) 1)		      \
@@ -284,16 +228,14 @@ extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
 			  __retval; }))					      \
 		  : __strdup (s)))
 
-#  if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-#   define strdup(s) __strdup (s)
-#  endif
+# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+#  define strdup(s) __strdup (s)
 # endif
 
-# ifndef _HAVE_STRING_ARCH_strndup
 
 extern char *__strndup (const char *__string, size_t __n)
      __THROW __attribute_malloc__;
-#  define __strndup(s, n) \
+# define __strndup(s, n) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)	      \
 		  ? (((const char *) (s))[0] == '\0'			      \
 		     ? (char *) calloc ((size_t) 1, (size_t) 1)		      \
@@ -312,9 +254,8 @@ extern char *__strndup (const char *__string, size_t __n)
 			  __retval; }))					      \
 		  : __strndup (s, n)))
 
-#  ifdef __USE_XOPEN2K8
-#   define strndup(s, n) __strndup (s, n)
-#  endif
+# ifdef __USE_XOPEN2K8
+#  define strndup(s, n) __strndup (s, n)
 # endif
 
 #endif /* Use misc. or use GNU.  */
diff --git a/string/string-inlines.c b/string/string-inlines.c
index d43e5897c37430e5f97940469d65e7ddbdcbd09c..f6f56c56f875a89fbc05dec61a7603c2a869607c 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 39e0b7fe7c7a100c7f4e2a3c13f815951815e854..4e80bd03835b38cadf1b3a60f632bc5c64720837 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 10beca6a5a98cc126e39227cae5ff25a1ac09857..75a3eb31f3edc7109c360550c95d3d00402204a7 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 805d33f0a2d13743e763e18c5c474c9507186a15..e3c9048971f249984e394a19444f6402d4521861 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)				      \
 		  ? __memcpy_c ((dest), (src), (n))			      \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16			      \
 		  ? ((n) == 1						      \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)				      \
 		  ? __builtin_strlen (str)				      \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8	      \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? ((strlen (src) + 1 >= ((size_t) (n))		      \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? __strcat_c ((dest), (src), strlen (src) + 1)	      \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);				      \
 		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
 		  && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)	      \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
 		  ? strcmp ((s1), (s2))					      \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? ((c) == '\0'					      \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? ((c) == '\0'					      \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strchr_c ((s), ((c) & 0xff) << 8)			      \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strrchr_c ((s), ((c) & 0xff) << 8)		      \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strrchr_c ((s), ((c) & 0xff) << 8)		      \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
 		  ? ((reject)[0] == '\0'				      \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
 		  ? ((accept)[0] == '\0'				      \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
 		  ? ((accept)[0] == '\0'				      \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
 		  ? ((needle)[0] == '\0'				      \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)			      \
 		      ? __builtin_ffs (word)				      \
 		      : ({ int __cnt, __tmp;				      \

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

* Re: [PATCH v4] Remove defines to builtins in string2.h
  2016-11-23 19:00                       ` [PATCH v4] " Wilco Dijkstra
@ 2017-02-09 15:31                         ` Wilco Dijkstra
  2017-02-10 19:09                           ` [PATCH v5] " Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2017-02-09 15:31 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd


ping



From: Wilco Dijkstra
Sent: 23 November 2016 18:59
To: Joseph Myers
Cc: Florian Weimer; libc-alpha@sourceware.org; nd
Subject: [PATCH v4] Remove defines to builtins in string2.h
    
Here is v4 of the patch rebased so it applies cleanly after the strchr patch.
It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in  https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

This patch depends on  https://sourceware.org/ml/libc-alpha/2016-11/msg00843.html
being applied first.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

        * string/string-inlines.c: Remove include of bits/string2.h.
        * string/bits/string2.h (__bzero): Always redirect to memset.
        (strchr) Remove define.
        (__stpcpy): Keep redirection for internal use.
        (stpcpy): Remove define.
        (strncpy): Likewise.
        (strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (strcspn): Likewise.
        (strspn): Likewise.
        (strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strdup): Likewise.
        (_HAVE_STRING_ARCH_strndup): Likewise.
        * sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strcat): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
        * sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
        * sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
        (_HAVE_STRING_ARCH_memmove): Likewise.
        (_HAVE_STRING_ARCH_memcmp): Likewise.
        (_HAVE_STRING_ARCH_memset): Likewise.
        (_USE_STRING_ARCH_memset): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_memrchr): Likewise.
        (_HAVE_STRING_ARCH_rawmemchr): Likewise.
        (_HAVE_STRING_ARCH_strlen): Likewise.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strpcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (_HAVE_STRING_ARCH_strchr): Likewise.
        (_USE_STRING_ARCH_strchr): Likewise.
        (_HAVE_STRING_ARCH_strnchr): Likewise.
        (_HAVE_STRING_ARCH_strchrnul): Likewise.
        (_HAVE_STRING_ARCH_strrchr): Likewise.
        (_HAVE_STRING_ARCH_index): Likewise.
        (_HAVE_STRING_ARCH_rindex): Likewise.
        (_HAVE_STRING_ARCH_strcspn): Likewise.
        (_HAVE_STRING_ARCH_strspn): Likewise.
        (_HAVE_STRING_ARCH_strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strstr): Likewise.
        (_HAVE_STRING_ARCH_ffs): Likewise.

--

diff --git a/string/bits/string2.h b/string/bits/string2.h
index de426b47cae09933b2dc53e0956d63b4c93aebc0..5acdb7866e4e70a6c3aa050b0427b31aed8943ec 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);                                   \
-                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
-                   ? (strlen (src) < ((size_t) (n))                           \
-                      ? strcat (__dest, src)                                  \
-                      : (*((char *) __mempcpy (strchr (__dest, '\0'),         \
-                                               src, n)) = '\0', __dest))     \
-                   : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
-#endif
-
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__                                                                      \
   ({ size_t __s1_len, __s2_len;                                                      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)                                                   \
   (__extension__ (__builtin_constant_p (n)                                   \
                   && ((__builtin_constant_p (s1)                       \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #if !defined _HAVE_STRING_ARCH_strsep || defined _FORCE_INLINES
 # ifndef _HAVE_STRING_ARCH_strsep
 
@@ -265,15 +213,11 @@ __strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
    in any of the tight standards compliant modes.  */
 #ifdef __USE_MISC
 
-# if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup
-#  define __need_malloc_and_calloc
-#  include <stdlib.h>
-# endif
-
-# ifndef _HAVE_STRING_ARCH_strdup
+# define __need_malloc_and_calloc
+# include <stdlib.h>
 
 extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
-#  define __strdup(s) \
+# define __strdup(s) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)          \
                   ? (((const char *) (s))[0] == '\0'                           \
                      ? (char *) calloc ((size_t) 1, (size_t) 1)                \
@@ -284,16 +228,14 @@ extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
                           __retval; }))                                        \
                   : __strdup (s)))
 
-#  if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-#   define strdup(s) __strdup (s)
-#  endif
+# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+#  define strdup(s) __strdup (s)
 # endif
 
-# ifndef _HAVE_STRING_ARCH_strndup
 
 extern char *__strndup (const char *__string, size_t __n)
      __THROW __attribute_malloc__;
-#  define __strndup(s, n) \
+# define __strndup(s, n) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)          \
                   ? (((const char *) (s))[0] == '\0'                           \
                      ? (char *) calloc ((size_t) 1, (size_t) 1)                \
@@ -312,9 +254,8 @@ extern char *__strndup (const char *__string, size_t __n)
                           __retval; }))                                        \
                   : __strndup (s, n)))
 
-#  ifdef __USE_XOPEN2K8
-#   define strndup(s, n) __strndup (s, n)
-#  endif
+# ifdef __USE_XOPEN2K8
+#  define strndup(s, n) __strndup (s, n)
 # endif
 
 #endif /* Use misc. or use GNU.  */
diff --git a/string/string-inlines.c b/string/string-inlines.c
index d43e5897c37430e5f97940469d65e7ddbdcbd09c..f6f56c56f875a89fbc05dec61a7603c2a869607c 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 39e0b7fe7c7a100c7f4e2a3c13f815951815e854..4e80bd03835b38cadf1b3a60f632bc5c64720837 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 10beca6a5a98cc126e39227cae5ff25a1ac09857..75a3eb31f3edc7109c360550c95d3d00402204a7 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 805d33f0a2d13743e763e18c5c474c9507186a15..e3c9048971f249984e394a19444f6402d4521861 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)                                   \
                   ? __memcpy_c ((dest), (src), (n))                            \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16                              \
                   ? ((n) == 1                                                  \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)                                 \
                   ? __builtin_strlen (str)                                     \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8           \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? ((strlen (src) + 1 >= ((size_t) (n))               \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? __strcat_c ((dest), (src), strlen (src) + 1)       \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);                                   \
                     __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
                   && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
                   ? strcmp ((s1), (s2))                                        \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strchr_c ((s), ((c) & 0xff) << 8)                        \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
                   ? ((reject)[0] == '\0'                               \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
                   ? ((needle)[0] == '\0'                               \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)                             \
                       ? __builtin_ffs (word)                                   \
                       : ({ int __cnt, __tmp;                                   \    

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

* Re: [PATCH v5] Remove defines to builtins in string2.h
  2017-02-09 15:31                         ` Wilco Dijkstra
@ 2017-02-10 19:09                           ` Wilco Dijkstra
  2017-02-17 13:09                             ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2017-02-10 19:09 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd

Here is v5 of the patch rebased so it applies cleanly again on latest trunk
with https://sourceware.org/ml/libc-alpha/2017-02/msg00220.html (they are
independent but it seems to confuse patch somehow).


It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in   https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

	* string/string-inlines.c: Remove include of bits/string2.h.
	* string/bits/string2.h (__bzero): Always redirect to memset.
	(strchr) Remove define.
	(__stpcpy): Keep redirection for internal use.
	(stpcpy): Remove define.
	(strncpy): Likewise.
	(strncat): Likewise.
	(_HAVE_STRING_ARCH_strcmp): Likewise.
	(_HAVE_STRING_ARCH_strncmp): Likewise.
	(strcspn): Likewise.
	(strspn): Likewise.
	(strpbrk): Likewise.
	(_HAVE_STRING_ARCH_strdup): Likewise.
	(_HAVE_STRING_ARCH_strndup): Likewise.
	* sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
	(_HAVE_STRING_ARCH_strcpy): Likewise.
	(_HAVE_STRING_ARCH_strncpy): Likewise.
	(_HAVE_STRING_ARCH_strcat): Likewise.
	(_HAVE_STRING_ARCH_strncat): Likewise.
	(_HAVE_STRING_ARCH_memchr): Likewise.
	(_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
	* sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
	* sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
	(_HAVE_STRING_ARCH_memmove): Likewise.
	(_HAVE_STRING_ARCH_memcmp): Likewise.
	(_HAVE_STRING_ARCH_memset): Likewise.
	(_USE_STRING_ARCH_memset): Likewise.
	(_HAVE_STRING_ARCH_memchr): Likewise.
	(_HAVE_STRING_ARCH_memrchr): Likewise.
	(_HAVE_STRING_ARCH_rawmemchr): Likewise.
	(_HAVE_STRING_ARCH_strlen): Likewise.
	(_HAVE_STRING_ARCH_strcpy): Likewise.
	(_HAVE_STRING_ARCH_strpcpy): Likewise.
	(_HAVE_STRING_ARCH_strncpy): Likewise.
	(_HAVE_STRING_ARCH_strncat): Likewise.
	(_HAVE_STRING_ARCH_strcmp): Likewise.
	(_HAVE_STRING_ARCH_strncmp): Likewise.
	(_HAVE_STRING_ARCH_strchr): Likewise.
	(_USE_STRING_ARCH_strchr): Likewise.
	(_HAVE_STRING_ARCH_strnchr): Likewise.
	(_HAVE_STRING_ARCH_strchrnul): Likewise.
	(_HAVE_STRING_ARCH_strrchr): Likewise.
	(_HAVE_STRING_ARCH_index): Likewise.
	(_HAVE_STRING_ARCH_rindex): Likewise.
	(_HAVE_STRING_ARCH_strcspn): Likewise.
	(_HAVE_STRING_ARCH_strspn): Likewise.
	(_HAVE_STRING_ARCH_strpbrk): Likewise.
	(_HAVE_STRING_ARCH_strstr): Likewise.
	(_HAVE_STRING_ARCH_ffs): Likewise.
 
---

diff --git a/string/bits/string2.h b/string/bits/string2.h
index d9acf8029d90b6eeb6db3b76bae4d419756a61e5..3987f616a241e814fe9636a54c321361c3ef78a4 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);				      \
-		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
-		    ? (strlen (src) < ((size_t) (n))			      \
-		       ? strcat (__dest, src)				      \
-		       : (*((char *) __mempcpy (strchr (__dest, '\0'),	      \
-						src, n)) = '\0', __dest))     \
-		    : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__								      \
   ({ size_t __s1_len, __s2_len;						      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)						      \
   (__extension__ (__builtin_constant_p (n)				      \
 		  && ((__builtin_constant_p (s1)			      \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #ifndef _FORCE_INLINES
 # undef __STRING_INLINE
 #endif
diff --git a/string/string-inlines.c b/string/string-inlines.c
index fa4a1594b2a1558f77a9c0de7263c94b6abee763..68aa7d072aca32367708e73a891772e332ddb18d 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 1e794f925d76182ddbf9e8d59f85aa4dbc3aee20..f99a72d4cf5a6985c58a913ac61dbe2451328354 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 4fd4e8d1de6afdf0a7e5a8b7fdb47a79894b5e71..63fa5a227f1959cb0ca04a4ce14882e1742c28d3 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 94cba8e76f2bcd4edafe17bde7243bbd0e965533..cdd45282e5e24b16e229047076d8692f96806841 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)				      \
 		  ? __memcpy_c ((dest), (src), (n))			      \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16			      \
 		  ? ((n) == 1						      \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)				      \
 		  ? __builtin_strlen (str)				      \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8	      \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? ((strlen (src) + 1 >= ((size_t) (n))		      \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? __strcat_c ((dest), (src), strlen (src) + 1)	      \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);				      \
 		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
 		  && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)	      \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
 		  ? strcmp ((s1), (s2))					      \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? ((c) == '\0'					      \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? ((c) == '\0'					      \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strchr_c ((s), ((c) & 0xff) << 8)			      \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strrchr_c ((s), ((c) & 0xff) << 8)		      \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)				      \
 		  ? __strrchr_c ((s), ((c) & 0xff) << 8)		      \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
 		  ? ((reject)[0] == '\0'				      \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
 		  ? ((accept)[0] == '\0'				      \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
 		  ? ((accept)[0] == '\0'				      \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
 		  ? ((needle)[0] == '\0'				      \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)			      \
 		      ? __builtin_ffs (word)				      \
 		      : ({ int __cnt, __tmp;				      \

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

* Re: [PATCH v5] Remove defines to builtins in string2.h
  2017-02-10 19:09                           ` [PATCH v5] " Wilco Dijkstra
@ 2017-02-17 13:09                             ` Wilco Dijkstra
  2017-03-07 15:30                               ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2017-02-17 13:09 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd

ping



From: Wilco Dijkstra
Sent: 10 February 2017 19:09
To: Joseph Myers
Cc: Florian Weimer; libc-alpha@sourceware.org; nd
Subject: Re: [PATCH v5] Remove defines to builtins in string2.h
    
Here is v5 of the patch rebased so it applies cleanly again on latest trunk
with https://sourceware.org/ml/libc-alpha/2017-02/msg00220.html (they are
independent but it seems to confuse patch somehow).


It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in    https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

        * string/string-inlines.c: Remove include of bits/string2.h.
        * string/bits/string2.h (__bzero): Always redirect to memset.
        (strchr) Remove define.
        (__stpcpy): Keep redirection for internal use.
        (stpcpy): Remove define.
        (strncpy): Likewise.
        (strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (strcspn): Likewise.
        (strspn): Likewise.
        (strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strdup): Likewise.
        (_HAVE_STRING_ARCH_strndup): Likewise.
        * sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strcat): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
        * sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
        * sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
        (_HAVE_STRING_ARCH_memmove): Likewise.
        (_HAVE_STRING_ARCH_memcmp): Likewise.
        (_HAVE_STRING_ARCH_memset): Likewise.
        (_USE_STRING_ARCH_memset): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_memrchr): Likewise.
        (_HAVE_STRING_ARCH_rawmemchr): Likewise.
        (_HAVE_STRING_ARCH_strlen): Likewise.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strpcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (_HAVE_STRING_ARCH_strchr): Likewise.
        (_USE_STRING_ARCH_strchr): Likewise.
        (_HAVE_STRING_ARCH_strnchr): Likewise.
        (_HAVE_STRING_ARCH_strchrnul): Likewise.
        (_HAVE_STRING_ARCH_strrchr): Likewise.
        (_HAVE_STRING_ARCH_index): Likewise.
        (_HAVE_STRING_ARCH_rindex): Likewise.
        (_HAVE_STRING_ARCH_strcspn): Likewise.
        (_HAVE_STRING_ARCH_strspn): Likewise.
        (_HAVE_STRING_ARCH_strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strstr): Likewise.
        (_HAVE_STRING_ARCH_ffs): Likewise.
 
---

diff --git a/string/bits/string2.h b/string/bits/string2.h
index d9acf8029d90b6eeb6db3b76bae4d419756a61e5..3987f616a241e814fe9636a54c321361c3ef78a4 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);                                   \
-                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
-                   ? (strlen (src) < ((size_t) (n))                           \
-                      ? strcat (__dest, src)                                  \
-                      : (*((char *) __mempcpy (strchr (__dest, '\0'),         \
-                                               src, n)) = '\0', __dest))     \
-                   : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__                                                                      \
   ({ size_t __s1_len, __s2_len;                                                      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)                                                   \
   (__extension__ (__builtin_constant_p (n)                                   \
                   && ((__builtin_constant_p (s1)                       \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #ifndef _FORCE_INLINES
 # undef __STRING_INLINE
 #endif
diff --git a/string/string-inlines.c b/string/string-inlines.c
index fa4a1594b2a1558f77a9c0de7263c94b6abee763..68aa7d072aca32367708e73a891772e332ddb18d 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 1e794f925d76182ddbf9e8d59f85aa4dbc3aee20..f99a72d4cf5a6985c58a913ac61dbe2451328354 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 4fd4e8d1de6afdf0a7e5a8b7fdb47a79894b5e71..63fa5a227f1959cb0ca04a4ce14882e1742c28d3 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 94cba8e76f2bcd4edafe17bde7243bbd0e965533..cdd45282e5e24b16e229047076d8692f96806841 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)                                   \
                   ? __memcpy_c ((dest), (src), (n))                            \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16                              \
                   ? ((n) == 1                                                  \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)                                 \
                   ? __builtin_strlen (str)                                     \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8           \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? ((strlen (src) + 1 >= ((size_t) (n))               \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? __strcat_c ((dest), (src), strlen (src) + 1)       \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);                                   \
                     __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
                   && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
                   ? strcmp ((s1), (s2))                                        \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strchr_c ((s), ((c) & 0xff) << 8)                        \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
                   ? ((reject)[0] == '\0'                               \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
                   ? ((needle)[0] == '\0'                               \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)                             \
                       ? __builtin_ffs (word)                                   \
                       : ({ int __cnt, __tmp;                                   \
    

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

* Re: [PATCH v5] Remove defines to builtins in string2.h
  2017-02-17 13:09                             ` Wilco Dijkstra
@ 2017-03-07 15:30                               ` Wilco Dijkstra
  2017-03-23 11:17                                 ` Wilco Dijkstra
  0 siblings, 1 reply; 22+ messages in thread
From: Wilco Dijkstra @ 2017-03-07 15:30 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd

    
ping


From: Wilco Dijkstra
Sent: 10 February 2017 19:09
To: Joseph Myers
Cc: Florian Weimer; libc-alpha@sourceware.org; nd
Subject: Re: [PATCH v5] Remove defines to builtins in string2.h
    
Here is v5 of the patch rebased so it applies cleanly again on latest trunk
with https://sourceware.org/ml/libc-alpha/2017-02/msg00220.html (they are
independent but it seems to confuse patch somehow).


It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in     https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

        * string/string-inlines.c: Remove include of bits/string2.h.
        * string/bits/string2.h (__bzero): Always redirect to memset.
        (strchr) Remove define.
        (__stpcpy): Keep redirection for internal use.
        (stpcpy): Remove define.
        (strncpy): Likewise.
        (strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (strcspn): Likewise.
        (strspn): Likewise.
        (strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strdup): Likewise.
        (_HAVE_STRING_ARCH_strndup): Likewise.
        * sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strcat): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
        * sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
        * sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
        (_HAVE_STRING_ARCH_memmove): Likewise.
        (_HAVE_STRING_ARCH_memcmp): Likewise.
        (_HAVE_STRING_ARCH_memset): Likewise.
        (_USE_STRING_ARCH_memset): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_memrchr): Likewise.
        (_HAVE_STRING_ARCH_rawmemchr): Likewise.
        (_HAVE_STRING_ARCH_strlen): Likewise.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strpcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (_HAVE_STRING_ARCH_strchr): Likewise.
        (_USE_STRING_ARCH_strchr): Likewise.
        (_HAVE_STRING_ARCH_strnchr): Likewise.
        (_HAVE_STRING_ARCH_strchrnul): Likewise.
        (_HAVE_STRING_ARCH_strrchr): Likewise.
        (_HAVE_STRING_ARCH_index): Likewise.
        (_HAVE_STRING_ARCH_rindex): Likewise.
        (_HAVE_STRING_ARCH_strcspn): Likewise.
        (_HAVE_STRING_ARCH_strspn): Likewise.
        (_HAVE_STRING_ARCH_strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strstr): Likewise.
        (_HAVE_STRING_ARCH_ffs): Likewise.
 
---

diff --git a/string/bits/string2.h b/string/bits/string2.h
index d9acf8029d90b6eeb6db3b76bae4d419756a61e5..3987f616a241e814fe9636a54c321361c3ef78a4 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);                                   \
-                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
-                   ? (strlen (src) < ((size_t) (n))                           \
-                      ? strcat (__dest, src)                                  \
-                      : (*((char *) __mempcpy (strchr (__dest, '\0'),         \
-                                               src, n)) = '\0', __dest))     \
-                   : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__                                                                      \
   ({ size_t __s1_len, __s2_len;                                                      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)                                                   \
   (__extension__ (__builtin_constant_p (n)                                   \
                   && ((__builtin_constant_p (s1)                       \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #ifndef _FORCE_INLINES
 # undef __STRING_INLINE
 #endif
diff --git a/string/string-inlines.c b/string/string-inlines.c
index fa4a1594b2a1558f77a9c0de7263c94b6abee763..68aa7d072aca32367708e73a891772e332ddb18d 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 1e794f925d76182ddbf9e8d59f85aa4dbc3aee20..f99a72d4cf5a6985c58a913ac61dbe2451328354 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 4fd4e8d1de6afdf0a7e5a8b7fdb47a79894b5e71..63fa5a227f1959cb0ca04a4ce14882e1742c28d3 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 94cba8e76f2bcd4edafe17bde7243bbd0e965533..cdd45282e5e24b16e229047076d8692f96806841 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)                                   \
                   ? __memcpy_c ((dest), (src), (n))                            \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16                              \
                   ? ((n) == 1                                                  \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)                                 \
                   ? __builtin_strlen (str)                                     \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8           \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? ((strlen (src) + 1 >= ((size_t) (n))               \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? __strcat_c ((dest), (src), strlen (src) + 1)       \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);                                   \
                     __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
                   && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
                   ? strcmp ((s1), (s2))                                        \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strchr_c ((s), ((c) & 0xff) << 8)                        \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
                   ? ((reject)[0] == '\0'                               \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
                   ? ((needle)[0] == '\0'                               \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)                             \
                       ? __builtin_ffs (word)                                   \
                       : ({ int __cnt, __tmp;                                   \
        

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

* Re: [PATCH v5] Remove defines to builtins in string2.h
  2017-03-07 15:30                               ` Wilco Dijkstra
@ 2017-03-23 11:17                                 ` Wilco Dijkstra
  2017-03-24 21:27                                   ` Adhemerval Zanella
  2017-06-01 14:09                                   ` Wilco Dijkstra
  0 siblings, 2 replies; 22+ messages in thread
From: Wilco Dijkstra @ 2017-03-23 11:17 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd

    
ping


From: Wilco Dijkstra
Sent: 10 February 2017 19:09
To: Joseph Myers
Cc: Florian Weimer; libc-alpha@sourceware.org; nd
Subject: Re: [PATCH v5] Remove defines to builtins in string2.h
    
Here is v5 of the patch rebased so it applies cleanly again on latest trunk
with https://sourceware.org/ml/libc-alpha/2017-02/msg00220.html (they are
independent but it seems to confuse patch somehow).


It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in      https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

        * string/string-inlines.c: Remove include of bits/string2.h.
        * string/bits/string2.h (__bzero): Always redirect to memset.
        (strchr) Remove define.
        (__stpcpy): Keep redirection for internal use.
        (stpcpy): Remove define.
        (strncpy): Likewise.
        (strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (strcspn): Likewise.
        (strspn): Likewise.
        (strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strdup): Likewise.
        (_HAVE_STRING_ARCH_strndup): Likewise.
        * sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strcat): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
        * sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
        * sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
        (_HAVE_STRING_ARCH_memmove): Likewise.
        (_HAVE_STRING_ARCH_memcmp): Likewise.
        (_HAVE_STRING_ARCH_memset): Likewise.
        (_USE_STRING_ARCH_memset): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_memrchr): Likewise.
        (_HAVE_STRING_ARCH_rawmemchr): Likewise.
        (_HAVE_STRING_ARCH_strlen): Likewise.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strpcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (_HAVE_STRING_ARCH_strchr): Likewise.
        (_USE_STRING_ARCH_strchr): Likewise.
        (_HAVE_STRING_ARCH_strnchr): Likewise.
        (_HAVE_STRING_ARCH_strchrnul): Likewise.
        (_HAVE_STRING_ARCH_strrchr): Likewise.
        (_HAVE_STRING_ARCH_index): Likewise.
        (_HAVE_STRING_ARCH_rindex): Likewise.
        (_HAVE_STRING_ARCH_strcspn): Likewise.
        (_HAVE_STRING_ARCH_strspn): Likewise.
        (_HAVE_STRING_ARCH_strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strstr): Likewise.
        (_HAVE_STRING_ARCH_ffs): Likewise.
 
---

diff --git a/string/bits/string2.h b/string/bits/string2.h
index d9acf8029d90b6eeb6db3b76bae4d419756a61e5..3987f616a241e814fe9636a54c321361c3ef78a4 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);                                   \
-                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
-                   ? (strlen (src) < ((size_t) (n))                           \
-                      ? strcat (__dest, src)                                  \
-                      : (*((char *) __mempcpy (strchr (__dest, '\0'),         \
-                                               src, n)) = '\0', __dest))     \
-                   : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__                                                                      \
   ({ size_t __s1_len, __s2_len;                                                      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)                                                   \
   (__extension__ (__builtin_constant_p (n)                                   \
                   && ((__builtin_constant_p (s1)                       \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #ifndef _FORCE_INLINES
 # undef __STRING_INLINE
 #endif
diff --git a/string/string-inlines.c b/string/string-inlines.c
index fa4a1594b2a1558f77a9c0de7263c94b6abee763..68aa7d072aca32367708e73a891772e332ddb18d 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 1e794f925d76182ddbf9e8d59f85aa4dbc3aee20..f99a72d4cf5a6985c58a913ac61dbe2451328354 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 4fd4e8d1de6afdf0a7e5a8b7fdb47a79894b5e71..63fa5a227f1959cb0ca04a4ce14882e1742c28d3 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 94cba8e76f2bcd4edafe17bde7243bbd0e965533..cdd45282e5e24b16e229047076d8692f96806841 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)                                   \
                   ? __memcpy_c ((dest), (src), (n))                            \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16                              \
                   ? ((n) == 1                                                  \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)                                 \
                   ? __builtin_strlen (str)                                     \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8           \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? ((strlen (src) + 1 >= ((size_t) (n))               \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? __strcat_c ((dest), (src), strlen (src) + 1)       \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);                                   \
                     __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
                   && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
                   ? strcmp ((s1), (s2))                                        \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strchr_c ((s), ((c) & 0xff) << 8)                        \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
                   ? ((reject)[0] == '\0'                               \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
                   ? ((needle)[0] == '\0'                               \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)                             \
                       ? __builtin_ffs (word)                                   \
                       : ({ int __cnt, __tmp;                                   \
            

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

* Re: [PATCH v5] Remove defines to builtins in string2.h
  2017-03-23 11:17                                 ` Wilco Dijkstra
@ 2017-03-24 21:27                                   ` Adhemerval Zanella
  2017-06-01 14:09                                   ` Wilco Dijkstra
  1 sibling, 0 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2017-03-24 21:27 UTC (permalink / raw)
  To: libc-alpha

Some comments below.

On 23/03/2017 08:17, Wilco Dijkstra wrote:
>     
> ping
> 
> 
> diff --git a/string/bits/string2.h b/string/bits/string2.h
> index d9acf8029d90b6eeb6db3b76bae4d419756a61e5..3987f616a241e814fe9636a54c321361c3ef78a4 100644
> --- a/string/bits/string2.h
> +++ b/string/bits/string2.h
> @@ -53,47 +53,15 @@
>    ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
>  
>  /* Set N bytes of S to 0.  */
> -#if !defined _HAVE_STRING_ARCH_memset
> -# define __bzero(s, n) __builtin_memset (s, '\0', n)
> -#endif
> -
> +#define __bzero(s, n) __builtin_memset (s, '\0', n)

Since you are touching it, I would prefer to just get rid of __bzero altogether
(there is no need to keep using an outdated api within glibc).

>  
>  /* Copy SRC to DEST, returning pointer to final NUL byte.  */
> -#ifdef __USE_GNU
> -# ifndef _HAVE_STRING_ARCH_stpcpy
> -#  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
> -#endif
> -
> -
> -/* Copy no more than N characters of SRC to DEST.  */
> -#ifndef _HAVE_STRING_ARCH_strncpy
> -# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
> -#endif
> -
> -
> -/* Append no more than N characters from SRC onto DEST.  */
> -#ifndef _HAVE_STRING_ARCH_strncat
> -# ifdef _USE_STRING_ARCH_strchr
> -#  define strncat(dest, src, n) \
> -  (__extension__ ({ char *__dest = (dest);                                   \
> -                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
> -                   ? (strlen (src) < ((size_t) (n))                           \
> -                      ? strcat (__dest, src)                                  \
> -                      : (*((char *) __mempcpy (strchr (__dest, '\0'),         \
> -                                               src, n)) = '\0', __dest))     \
> -                   : strncat (dest, src, n); }))
> -# else
> -#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
> -# endif
> +#ifndef __stpcpy
> +# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
>  #endif
>  
> -
>  /* Compare characters of S1 and S2.  */
> -#ifndef _HAVE_STRING_ARCH_strcmp
> +#ifndef strcmp
>  # define strcmp(s1, s2) \
>    __extension__                                                                      \
>    ({ size_t __s1_len, __s2_len;                                                      \
> @@ -139,7 +107,7 @@
>  
>  
>  /* Compare N characters of S1 and S2.  */
> -#ifndef _HAVE_STRING_ARCH_strncmp
> +#ifndef strncmp
>  # define strncmp(s1, s2, n)                                                   \
>    (__extension__ (__builtin_constant_p (n)                                   \
>                    && ((__builtin_constant_p (s1)                       \
> @@ -150,26 +118,6 @@
>  #endif
>  
>  
> -/* Return the length of the initial segment of S which
> -   consists entirely of characters not in REJECT.  */
> -#ifndef _HAVE_STRING_ARCH_strcspn
> -# define strcspn(s, reject) __builtin_strcspn (s, reject)
> -#endif
> -
> -
> -/* Return the length of the initial segment of S which
> -   consists entirely of characters in ACCEPT.  */
> -#ifndef _HAVE_STRING_ARCH_strspn
> -# define strspn(s, accept) __builtin_strspn (s, accept)
> -#endif
> -
> -
> -/* Find the first occurrence in S of any character in ACCEPT.  */
> -#ifndef _HAVE_STRING_ARCH_strpbrk
> -# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
> -#endif
> -
> -
>  #ifndef _FORCE_INLINES
>  # undef __STRING_INLINE
>  #endif
> diff --git a/string/string-inlines.c b/string/string-inlines.c
> index fa4a1594b2a1558f77a9c0de7263c94b6abee763..68aa7d072aca32367708e73a891772e332ddb18d 100644
> --- a/string/string-inlines.c
> +++ b/string/string-inlines.c
> @@ -31,7 +31,6 @@
>  
>  #undef __NO_INLINE__
>  #include <bits/string.h>
> -#include <bits/string2.h>
>  
>  #include "shlib-compat.h"
>  
> diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
> index 1e794f925d76182ddbf9e8d59f85aa4dbc3aee20..f99a72d4cf5a6985c58a913ac61dbe2451328354 100644
> --- a/sysdeps/s390/bits/string.h
> +++ b/sysdeps/s390/bits/string.h
> @@ -37,7 +37,6 @@
>  # endif
>  #endif
>  
> -#define _HAVE_STRING_ARCH_strlen 1
>  #ifndef _FORCE_INLINES
>  #define strlen(str) __strlen_g ((str))
>  
> @@ -60,7 +59,6 @@ __strlen_g (const char *__str)
>  #endif
>  
>  /* Copy SRC to DEST.  */
> -#define _HAVE_STRING_ARCH_strcpy 1
>  #ifndef _FORCE_INLINES
>  #define strcpy(dest, src) __strcpy_g ((dest), (src))
>  
> @@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
>  }
>  #endif
>  
> -#define _HAVE_STRING_ARCH_strncpy 1
>  #ifndef _FORCE_INLINES
>  #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
>  
> @@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
>  #endif
>  
>  /* Append SRC onto DEST.  */
> -#define _HAVE_STRING_ARCH_strcat 1
>  #ifndef _FORCE_INLINES
>  #define strcat(dest, src) __strcat_g ((dest), (src))
>  
> @@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
>  #endif
>  
>  /* Append no more than N characters from SRC onto DEST.  */
> -#define _HAVE_STRING_ARCH_strncat 1
>  #ifndef _FORCE_INLINES
>  #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
>  
> @@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
>  #endif
>  
>  /* Search N bytes of S for C.  */
> -#define _HAVE_STRING_ARCH_memchr 1
>  #ifndef _FORCE_INLINES
>  __STRING_INLINE void *
>  memchr (const void *__str, int __c, size_t __n)
> @@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
>  #endif
>  
>  /* Compare S1 and S2.  */
> -#define _HAVE_STRING_ARCH_strcmp 1
>  #ifndef _FORCE_INLINES
> +#define strcmp(s1, s2) strcmp ((s1), (s2))

I am almost sure this won't work, as indicated by the warnings:

In file included from ../string/string.h:513:0,
                 from ../include/string.h:54,
                 from tester.c:32,
                 from inl-tester.c:6:
../sysdeps/s390/bits/string.h:225:32: error: expected declaration specifiers or ‘...’ before ‘(’ token
 #define strcmp(s1, s2) strcmp ((s1), (s2))
                                ^
../sysdeps/s390/bits/string.h:227:1: note: in expansion of macro ‘strcmp’
 strcmp (const char *__s1, const char *__s2)
 ^~~~~~
../sysdeps/s390/bits/string.h:225:38: error: expected declaration specifiers or ‘...’ before ‘(’ token
 #define strcmp(s1, s2) strcmp ((s1), (s2))
                                      ^
../sysdeps/s390/bits/string.h:227:1: note: in expansion of macro ‘strcmp’
 strcmp (const char *__s1, const char *__s2)
 ^~~~~~

I think it better to just remove the define.

>  __STRING_INLINE int
>  strcmp (const char *__s1, const char *__s2)
>  {
> diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
> index 4fd4e8d1de6afdf0a7e5a8b7fdb47a79894b5e71..63fa5a227f1959cb0ca04a4ce14882e1742c28d3 100644
> --- a/sysdeps/sparc/bits/string.h
> +++ b/sysdeps/sparc/bits/string.h
> @@ -23,9 +23,5 @@
>  /* sparc uses the aligned string inline ABI.  */
>  #define _STRING_INLINE_unaligned 0
>  
> -/* sparc32 and sparc64 strchr(x, '\0') perform better than
> -   __rawmemchr(x, '\0').  */
> -#define _HAVE_STRING_ARCH_strchr 1
> -
>  /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
>  #define _HAVE_STRING_ARCH_mempcpy 1
> diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
> index 94cba8e76f2bcd4edafe17bde7243bbd0e965533..cdd45282e5e24b16e229047076d8692f96806841 100644
> --- a/sysdeps/x86/bits/string.h
> +++ b/sysdeps/x86/bits/string.h
> @@ -66,7 +66,6 @@
>  
>  
>  /* Copy N bytes of SRC to DEST.  */
> -# define _HAVE_STRING_ARCH_memcpy 1
>  # define memcpy(dest, src, n) \
>    (__extension__ (__builtin_constant_p (n)                                   \
>                    ? __memcpy_c ((dest), (src), (n))                            \
> @@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
>    return __dest;
>  }
>  
> -# define _HAVE_STRING_ARCH_memmove 1
>  # ifndef _FORCE_INLINES
>  /* Copy N bytes of SRC to DEST, guaranteeing
>     correct behavior for overlapping strings.  */
> @@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
>  # endif
>  
>  /* Compare N bytes of S1 and S2.  */
> -# define _HAVE_STRING_ARCH_memcmp 1
>  # ifndef _FORCE_INLINES
>  #  ifndef __PIC__
>  /* gcc has problems to spill registers when using PIC.  */
> @@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
>  # endif
>  
>  /* Set N bytes of S to C.  */
> -# define _HAVE_STRING_ARCH_memset 1
> -# define _USE_STRING_ARCH_memset 1
>  # define memset(s, c, n) \
>    (__extension__ (__builtin_constant_p (n) && (n) <= 16                              \
>                    ? ((n) == 1                                                  \
> @@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
>  
>  
>  /* Search N bytes of S for C.  */
> -# define _HAVE_STRING_ARCH_memchr 1
>  # ifndef _FORCE_INLINES
>  __STRING_INLINE void *
>  memchr (const void *__s, int __c, size_t __n)
> @@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
>  }
>  # endif
>  
> -# define _HAVE_STRING_ARCH_memrchr 1
>  # ifndef _FORCE_INLINES
>  __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
>  
> @@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
>  # endif
>  
>  /* Return pointer to C in S.  */
> -# define _HAVE_STRING_ARCH_rawmemchr 1
>  __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
>  
>  # ifndef _FORCE_INLINES
> @@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
>  
>  
>  /* Return the length of S.  */
> -# define _HAVE_STRING_ARCH_strlen 1
>  # define strlen(str) \
>    (__extension__ (__builtin_constant_p (str)                                 \
>                    ? __builtin_strlen (str)                                     \
> @@ -588,7 +579,6 @@ __strlen_g (const char *__str)
>  
>  
>  /* Copy SRC to DEST.  */
> -# define _HAVE_STRING_ARCH_strcpy 1
>  # define strcpy(dest, src) \
>    (__extension__ (__builtin_constant_p (src)                                 \
>                    ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8           \
> @@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
>  
>  
>  # ifdef __USE_GNU
> -#  define _HAVE_STRING_ARCH_stpcpy 1
>  /* Copy SRC to DEST.  */
>  #  define __stpcpy(dest, src) \
>    (__extension__ (__builtin_constant_p (src)                                 \
> @@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
>  
>  
>  /* Copy no more than N characters of SRC to DEST.  */
> -# define _HAVE_STRING_ARCH_strncpy 1
>  # define strncpy(dest, src, n) \
>    (__extension__ (__builtin_constant_p (src)                                 \
>                    ? ((strlen (src) + 1 >= ((size_t) (n))               \
> @@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
>  
>  
>  /* Append SRC onto DEST.  */
> -# define _HAVE_STRING_ARCH_strcat 1
>  # define strcat(dest, src) \
>    (__extension__ (__builtin_constant_p (src)                                 \
>                    ? __strcat_c ((dest), (src), strlen (src) + 1)       \
> @@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
>  
>  
>  /* Append no more than N characters from SRC onto DEST.  */
> -# define _HAVE_STRING_ARCH_strncat 1
>  # define strncat(dest, src, n) \
>    (__extension__ ({ char *__dest = (dest);                                   \
>                      __builtin_constant_p (src) && __builtin_constant_p (n)    \
> @@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
>  
>  
>  /* Compare S1 and S2.  */
> -# define _HAVE_STRING_ARCH_strcmp 1
>  # define strcmp(s1, s2) \
>    (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
>                    && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
> @@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
>  
>  
>  /* Compare N characters of S1 and S2.  */
> -# define _HAVE_STRING_ARCH_strncmp 1
>  # define strncmp(s1, s2, n) \
>    (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
>                    ? strcmp ((s1), (s2))                                        \
> @@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
>  
>  
>  /* Find the first occurrence of C in S.  */
> -# define _HAVE_STRING_ARCH_strchr 1
> -# define _USE_STRING_ARCH_strchr 1
>  # define strchr(s, c) \
>    (__extension__ (__builtin_constant_p (c)                                   \
>                    ? ((c) == '\0'                                       \
> @@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
>  
>  
>  /* Find the first occurrence of C in S or the final NUL byte.  */
> -# define _HAVE_STRING_ARCH_strchrnul 1
>  # define __strchrnul(s, c) \
>    (__extension__ (__builtin_constant_p (c)                                   \
>                    ? ((c) == '\0'                                       \
> @@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
>  
>  # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
>  /* Find the first occurrence of C in S.  This is the BSD name.  */
> -#  define _HAVE_STRING_ARCH_index 1
>  #  define index(s, c) \
>    (__extension__ (__builtin_constant_p (c)                                   \
>                    ? __strchr_c ((s), ((c) & 0xff) << 8)                        \
> @@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
>  
>  
>  /* Find the last occurrence of C in S.  */
> -# define _HAVE_STRING_ARCH_strrchr 1
>  # define strrchr(s, c) \
>    (__extension__ (__builtin_constant_p (c)                                   \
>                    ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
> @@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
>  
>  # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
>  /* Find the last occurrence of C in S.  This is the BSD name.  */
> -#  define _HAVE_STRING_ARCH_rindex 1
>  #  define rindex(s, c) \
>    (__extension__ (__builtin_constant_p (c)                                   \
>                    ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
> @@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
>  
>  /* Return the length of the initial segment of S which
>     consists entirely of characters not in REJECT.  */
> -# define _HAVE_STRING_ARCH_strcspn 1
>  # define strcspn(s, reject) \
>    (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
>                    ? ((reject)[0] == '\0'                               \
> @@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
>  
>  /* Return the length of the initial segment of S which
>     consists entirely of characters in ACCEPT.  */
> -# define _HAVE_STRING_ARCH_strspn 1
>  # define strspn(s, accept) \
>    (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
>                    ? ((accept)[0] == '\0'                               \
> @@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
>  
>  
>  /* Find the first occurrence in S of any character in ACCEPT.  */
> -# define _HAVE_STRING_ARCH_strpbrk 1
>  # define strpbrk(s, accept) \
>    (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
>                    ? ((accept)[0] == '\0'                               \
> @@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
>  
>  
>  /* Find the first occurrence of NEEDLE in HAYSTACK.  */
> -# define _HAVE_STRING_ARCH_strstr 1
>  # define strstr(haystack, needle) \
>    (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
>                    ? ((needle)[0] == '\0'                               \
> @@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
>     processors gcc generates good code.  */
>  # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
>  #  ifdef __i686__
> -#   define _HAVE_STRING_ARCH_ffs 1
>  #   define ffs(word) (__builtin_constant_p (word)                             \
>                        ? __builtin_ffs (word)                                   \
>                        : ({ int __cnt, __tmp;                                   \
>             
> 

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

* Re: [PATCH v5] Remove defines to builtins in string2.h
  2017-03-23 11:17                                 ` Wilco Dijkstra
  2017-03-24 21:27                                   ` Adhemerval Zanella
@ 2017-06-01 14:09                                   ` Wilco Dijkstra
  1 sibling, 0 replies; 22+ messages in thread
From: Wilco Dijkstra @ 2017-06-01 14:09 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, nd


ping


From: Wilco Dijkstra
Sent: 10 February 2017 19:09
To: Joseph Myers
Cc: Florian Weimer; libc-alpha@sourceware.org; nd
Subject: Re: [PATCH v5] Remove defines to builtins in string2.h
    
Here is v5 of the patch rebased so it applies cleanly again on latest trunk
with https://sourceware.org/ml/libc-alpha/2017-02/msg00220.html (they are
independent but it seems to confuse patch somehow).


It now removes the _HAVE_STRING_ARCH_str(n)cmp defines too.

As discussed in       https://sourceware.org/ml/libc-alpha/2016-11/msg00625.html,
there is no need to use a define to redirect to the GCC builtin as an 
optimization (other headers already ensure symbols are redirected if
necessary to avoid name space clashes, for example when using non-C90 symbols).

Remove all redundant redirects from string/bits/string2.h. The strncat define
is redundant since _USE_STRING_ARCH_strchr is not defined for any target,
except for x86 where it may be defined, but if it is, this redirect is then
unused.

Redirects are kept for __bzero and __stpcpy as these are used in a few places
in GLIBC (and so using GCC builtins is a useful optimization) - when those
uses have been changed, the redirects can be removed too.

All unused _HAVE_STRING_ARCH_* defines are removed - this has no effect as they
are defined but not used or used in a #ifndef but not defined.

Verified no differences on AArch64 in all .so files in the install.

ChangeLog:
2015-11-23  Wilco Dijkstra  <wdijkstr@arm.com>

        * string/string-inlines.c: Remove include of bits/string2.h.
        * string/bits/string2.h (__bzero): Always redirect to memset.
        (strchr) Remove define.
        (__stpcpy): Keep redirection for internal use.
        (stpcpy): Remove define.
        (strncpy): Likewise.
        (strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (strcspn): Likewise.
        (strspn): Likewise.
        (strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strdup): Likewise.
        (_HAVE_STRING_ARCH_strndup): Likewise.
        * sysdeps/s390/bits/string.h (_HAVE_STRING_ARCH_strlen): Remove.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strcat): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Remove, define strcmp.
        * sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_strchr): Remove.
        * sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_memcpy): Remove.
        (_HAVE_STRING_ARCH_memmove): Likewise.
        (_HAVE_STRING_ARCH_memcmp): Likewise.
        (_HAVE_STRING_ARCH_memset): Likewise.
        (_USE_STRING_ARCH_memset): Likewise.
        (_HAVE_STRING_ARCH_memchr): Likewise.
        (_HAVE_STRING_ARCH_memrchr): Likewise.
        (_HAVE_STRING_ARCH_rawmemchr): Likewise.
        (_HAVE_STRING_ARCH_strlen): Likewise.
        (_HAVE_STRING_ARCH_strcpy): Likewise.
        (_HAVE_STRING_ARCH_strpcpy): Likewise.
        (_HAVE_STRING_ARCH_strncpy): Likewise.
        (_HAVE_STRING_ARCH_strncat): Likewise.
        (_HAVE_STRING_ARCH_strcmp): Likewise.
        (_HAVE_STRING_ARCH_strncmp): Likewise.
        (_HAVE_STRING_ARCH_strchr): Likewise.
        (_USE_STRING_ARCH_strchr): Likewise.
        (_HAVE_STRING_ARCH_strnchr): Likewise.
        (_HAVE_STRING_ARCH_strchrnul): Likewise.
        (_HAVE_STRING_ARCH_strrchr): Likewise.
        (_HAVE_STRING_ARCH_index): Likewise.
        (_HAVE_STRING_ARCH_rindex): Likewise.
        (_HAVE_STRING_ARCH_strcspn): Likewise.
        (_HAVE_STRING_ARCH_strspn): Likewise.
        (_HAVE_STRING_ARCH_strpbrk): Likewise.
        (_HAVE_STRING_ARCH_strstr): Likewise.
        (_HAVE_STRING_ARCH_ffs): Likewise.
 
---

diff --git a/string/bits/string2.h b/string/bits/string2.h
index d9acf8029d90b6eeb6db3b76bae4d419756a61e5..3987f616a241e814fe9636a54c321361c3ef78a4 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -53,47 +53,15 @@
   ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
 
 /* Set N bytes of S to 0.  */
-#if !defined _HAVE_STRING_ARCH_memset
-# define __bzero(s, n) __builtin_memset (s, '\0', n)
-#endif
-
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
 
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
-#ifdef __USE_GNU
-# ifndef _HAVE_STRING_ARCH_stpcpy
-#  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
-#endif
-
-
-/* Copy no more than N characters of SRC to DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncpy
-# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
-#endif
-
-
-/* Append no more than N characters from SRC onto DEST.  */
-#ifndef _HAVE_STRING_ARCH_strncat
-# ifdef _USE_STRING_ARCH_strchr
-#  define strncat(dest, src, n) \
-  (__extension__ ({ char *__dest = (dest);                                   \
-                   __builtin_constant_p (src) && __builtin_constant_p (n)    \
-                   ? (strlen (src) < ((size_t) (n))                           \
-                      ? strcat (__dest, src)                                  \
-                      : (*((char *) __mempcpy (strchr (__dest, '\0'),         \
-                                               src, n)) = '\0', __dest))     \
-                   : strncat (dest, src, n); }))
-# else
-#  define strncat(dest, src, n) __builtin_strncat (dest, src, n)
-# endif
+#ifndef __stpcpy
+# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
 #endif
 
-
 /* Compare characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strcmp
+#ifndef strcmp
 # define strcmp(s1, s2) \
   __extension__                                                                      \
   ({ size_t __s1_len, __s2_len;                                                      \
@@ -139,7 +107,7 @@
 
 
 /* Compare N characters of S1 and S2.  */
-#ifndef _HAVE_STRING_ARCH_strncmp
+#ifndef strncmp
 # define strncmp(s1, s2, n)                                                   \
   (__extension__ (__builtin_constant_p (n)                                   \
                   && ((__builtin_constant_p (s1)                       \
@@ -150,26 +118,6 @@
 #endif
 
 
-/* Return the length of the initial segment of S which
-   consists entirely of characters not in REJECT.  */
-#ifndef _HAVE_STRING_ARCH_strcspn
-# define strcspn(s, reject) __builtin_strcspn (s, reject)
-#endif
-
-
-/* Return the length of the initial segment of S which
-   consists entirely of characters in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strspn
-# define strspn(s, accept) __builtin_strspn (s, accept)
-#endif
-
-
-/* Find the first occurrence in S of any character in ACCEPT.  */
-#ifndef _HAVE_STRING_ARCH_strpbrk
-# define strpbrk(s, accept) __builtin_strpbrk (s, accept)
-#endif
-
-
 #ifndef _FORCE_INLINES
 # undef __STRING_INLINE
 #endif
diff --git a/string/string-inlines.c b/string/string-inlines.c
index fa4a1594b2a1558f77a9c0de7263c94b6abee763..68aa7d072aca32367708e73a891772e332ddb18d 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -31,7 +31,6 @@
 
 #undef __NO_INLINE__
 #include <bits/string.h>
-#include <bits/string2.h>
 
 #include "shlib-compat.h"
 
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 1e794f925d76182ddbf9e8d59f85aa4dbc3aee20..f99a72d4cf5a6985c58a913ac61dbe2451328354 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -37,7 +37,6 @@
 # endif
 #endif
 
-#define _HAVE_STRING_ARCH_strlen 1
 #ifndef _FORCE_INLINES
 #define strlen(str) __strlen_g ((str))
 
@@ -60,7 +59,6 @@ __strlen_g (const char *__str)
 #endif
 
 /* Copy SRC to DEST.  */
-#define _HAVE_STRING_ARCH_strcpy 1
 #ifndef _FORCE_INLINES
 #define strcpy(dest, src) __strcpy_g ((dest), (src))
 
@@ -80,7 +78,6 @@ __strcpy_g (char *__dest, const char *__src)
 }
 #endif
 
-#define _HAVE_STRING_ARCH_strncpy 1
 #ifndef _FORCE_INLINES
 #define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
 
@@ -124,7 +121,6 @@ __strncpy_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Append SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strcat 1
 #ifndef _FORCE_INLINES
 #define strcat(dest, src) __strcat_g ((dest), (src))
 
@@ -156,7 +152,6 @@ __strcat_g (char *__dest, const char *__src)
 #endif
 
 /* Append no more than N characters from SRC onto DEST.  */
-#define _HAVE_STRING_ARCH_strncat 1
 #ifndef _FORCE_INLINES
 #define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
 
@@ -204,7 +199,6 @@ __strncat_g (char *__dest, const char *__src, size_t __n)
 #endif
 
 /* Search N bytes of S for C.  */
-#define _HAVE_STRING_ARCH_memchr 1
 #ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__str, int __c, size_t __n)
@@ -227,8 +221,8 @@ memchr (const void *__str, int __c, size_t __n)
 #endif
 
 /* Compare S1 and S2.  */
-#define _HAVE_STRING_ARCH_strcmp 1
 #ifndef _FORCE_INLINES
+#define strcmp(s1, s2) strcmp ((s1), (s2))
 __STRING_INLINE int
 strcmp (const char *__s1, const char *__s2)
 {
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 4fd4e8d1de6afdf0a7e5a8b7fdb47a79894b5e71..63fa5a227f1959cb0ca04a4ce14882e1742c28d3 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -23,9 +23,5 @@
 /* sparc uses the aligned string inline ABI.  */
 #define _STRING_INLINE_unaligned 0
 
-/* sparc32 and sparc64 strchr(x, '\0') perform better than
-   __rawmemchr(x, '\0').  */
-#define _HAVE_STRING_ARCH_strchr 1
-
 /* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy.  */
 #define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 94cba8e76f2bcd4edafe17bde7243bbd0e965533..cdd45282e5e24b16e229047076d8692f96806841 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -66,7 +66,6 @@
 
 
 /* Copy N bytes of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_memcpy 1
 # define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)                                   \
                   ? __memcpy_c ((dest), (src), (n))                            \
@@ -155,7 +154,6 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
   return __dest;
 }
 
-# define _HAVE_STRING_ARCH_memmove 1
 # ifndef _FORCE_INLINES
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
@@ -194,7 +192,6 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
 # endif
 
 /* Compare N bytes of S1 and S2.  */
-# define _HAVE_STRING_ARCH_memcmp 1
 # ifndef _FORCE_INLINES
 #  ifndef __PIC__
 /* gcc has problems to spill registers when using PIC.  */
@@ -222,8 +219,6 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
 # endif
 
 /* Set N bytes of S to C.  */
-# define _HAVE_STRING_ARCH_memset 1
-# define _USE_STRING_ARCH_memset 1
 # define memset(s, c, n) \
   (__extension__ (__builtin_constant_p (n) && (n) <= 16                              \
                   ? ((n) == 1                                                  \
@@ -449,7 +444,6 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
 
 
 /* Search N bytes of S for C.  */
-# define _HAVE_STRING_ARCH_memchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *
 memchr (const void *__s, int __c, size_t __n)
@@ -486,7 +480,6 @@ memchr (const void *__s, int __c, size_t __n)
 }
 # endif
 
-# define _HAVE_STRING_ARCH_memrchr 1
 # ifndef _FORCE_INLINES
 __STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
 
@@ -532,7 +525,6 @@ __memrchr (const void *__s, int __c, size_t __n)
 # endif
 
 /* Return pointer to C in S.  */
-# define _HAVE_STRING_ARCH_rawmemchr 1
 __STRING_INLINE void *__rawmemchr (const void *__s, int __c);
 
 # ifndef _FORCE_INLINES
@@ -561,7 +553,6 @@ rawmemchr (const void *__s, int __c)
 
 
 /* Return the length of S.  */
-# define _HAVE_STRING_ARCH_strlen 1
 # define strlen(str) \
   (__extension__ (__builtin_constant_p (str)                                 \
                   ? __builtin_strlen (str)                                     \
@@ -588,7 +579,6 @@ __strlen_g (const char *__str)
 
 
 /* Copy SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strcpy 1
 # define strcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8           \
@@ -673,7 +663,6 @@ __strcpy_g (char *__dest, const char *__src)
 
 
 # ifdef __USE_GNU
-#  define _HAVE_STRING_ARCH_stpcpy 1
 /* Copy SRC to DEST.  */
 #  define __stpcpy(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
@@ -848,7 +837,6 @@ __stpcpy_g (char *__dest, const char *__src)
 
 
 /* Copy no more than N characters of SRC to DEST.  */
-# define _HAVE_STRING_ARCH_strncpy 1
 # define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? ((strlen (src) + 1 >= ((size_t) (n))               \
@@ -980,7 +968,6 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
 
 
 /* Append SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strcat 1
 # define strcat(dest, src) \
   (__extension__ (__builtin_constant_p (src)                                 \
                   ? __strcat_c ((dest), (src), strlen (src) + 1)       \
@@ -1051,7 +1038,6 @@ __strcat_g (char *__dest, const char *__src)
 
 
 /* Append no more than N characters from SRC onto DEST.  */
-# define _HAVE_STRING_ARCH_strncat 1
 # define strncat(dest, src, n) \
   (__extension__ ({ char *__dest = (dest);                                   \
                     __builtin_constant_p (src) && __builtin_constant_p (n)    \
@@ -1115,7 +1101,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
 
 
 /* Compare S1 and S2.  */
-# define _HAVE_STRING_ARCH_strcmp 1
 # define strcmp(s1, s2) \
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
                   && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)       \
@@ -1219,7 +1204,6 @@ __strcmp_gg (const char *__s1, const char *__s2)
 
 
 /* Compare N characters of S1 and S2.  */
-# define _HAVE_STRING_ARCH_strncmp 1
 # define strncmp(s1, s2, n) \
   (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
                   ? strcmp ((s1), (s2))                                        \
@@ -1263,8 +1247,6 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
 
 
 /* Find the first occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strchr 1
-# define _USE_STRING_ARCH_strchr 1
 # define strchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1323,7 +1305,6 @@ __strchr_g (const char *__s, int __c)
 
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-# define _HAVE_STRING_ARCH_strchrnul 1
 # define __strchrnul(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? ((c) == '\0'                                       \
@@ -1386,7 +1367,6 @@ __strchrnul_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the first occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_index 1
 #  define index(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strchr_c ((s), ((c) & 0xff) << 8)                        \
@@ -1395,7 +1375,6 @@ __strchrnul_g (const char *__s, int __c)
 
 
 /* Find the last occurrence of C in S.  */
-# define _HAVE_STRING_ARCH_strrchr 1
 # define strrchr(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1500,7 +1479,6 @@ __strrchr_g (const char *__s, int __c)
 
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Find the last occurrence of C in S.  This is the BSD name.  */
-#  define _HAVE_STRING_ARCH_rindex 1
 #  define rindex(s, c) \
   (__extension__ (__builtin_constant_p (c)                                   \
                   ? __strrchr_c ((s), ((c) & 0xff) << 8)               \
@@ -1510,7 +1488,6 @@ __strrchr_g (const char *__s, int __c)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
-# define _HAVE_STRING_ARCH_strcspn 1
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1  \
                   ? ((reject)[0] == '\0'                               \
@@ -1631,7 +1608,6 @@ __strcspn_g (const char *__s, const char *__reject)
 
 /* Return the length of the initial segment of S which
    consists entirely of characters in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strspn 1
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1751,7 +1727,6 @@ __strspn_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-# define _HAVE_STRING_ARCH_strpbrk 1
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1  \
                   ? ((accept)[0] == '\0'                               \
@@ -1858,7 +1833,6 @@ __strpbrk_g (const char *__s, const char *__accept)
 
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
-# define _HAVE_STRING_ARCH_strstr 1
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1  \
                   ? ((needle)[0] == '\0'                               \
@@ -1970,7 +1944,6 @@ __strstr_g (const char *__haystack, const char *__needle)
    processors gcc generates good code.  */
 # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 #  ifdef __i686__
-#   define _HAVE_STRING_ARCH_ffs 1
 #   define ffs(word) (__builtin_constant_p (word)                             \
                       ? __builtin_ffs (word)                                   \
                       : ({ int __cnt, __tmp;                                   \
                

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

end of thread, other threads:[~2017-06-01 14:09 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-18 15:38 [PATCH] Remove defines to builtins in string2.h Wilco Dijkstra
2016-11-22 14:36 ` [PATCH v2] " Wilco Dijkstra
2016-11-22 15:26   ` Florian Weimer
2016-11-22 16:34     ` Wilco Dijkstra
2016-11-22 16:36       ` Florian Weimer
2016-11-22 16:55       ` Zack Weinberg
2016-11-22 17:35       ` Joseph Myers
2016-11-22 19:10         ` Wilco Dijkstra
2016-11-22 20:26           ` [PATCH v3] " Wilco Dijkstra
2016-11-22 20:53             ` Florian Weimer
2016-11-22 21:16               ` Wilco Dijkstra
2016-11-23  8:40                 ` Florian Weimer
2016-11-23 12:23                   ` Wilco Dijkstra
2016-11-23 13:40                     ` Joseph Myers
2016-11-23 19:00                       ` [PATCH v4] " Wilco Dijkstra
2017-02-09 15:31                         ` Wilco Dijkstra
2017-02-10 19:09                           ` [PATCH v5] " Wilco Dijkstra
2017-02-17 13:09                             ` Wilco Dijkstra
2017-03-07 15:30                               ` Wilco Dijkstra
2017-03-23 11:17                                 ` Wilco Dijkstra
2017-03-24 21:27                                   ` Adhemerval Zanella
2017-06-01 14:09                                   ` 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).