]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
GLIBC uses strchr (s, '\0') as an idiom to find the end of a string.
authorWilco Dijkstra <wdijkstr@arm.com>
Fri, 10 Feb 2017 17:26:16 +0000 (17:26 +0000)
committerWilco Dijkstra <wdijkstr@arm.com>
Fri, 10 Feb 2017 17:28:11 +0000 (17:28 +0000)
This is transformed into rawmemchr by the bits/string2.h header.
However this is generally slower than strlen on most targets, even when
an optimized rawmemchr implementation exists.  Since GCC7 optimizes
strchr (s, '\0') to strlen (s) + s, the GLIBC headers should not
transform this to rawmemchr.  As GCC recognizes strchr as a builtin,
defining strchr as the builtin is not useful.

* string/bits/string2.h (strchr): Remove define.

ChangeLog
string/bits/string2.h

index 66dfc2b610fe1acfa52b14fa261cc9c6cb5cd498..fac0e11c40b4c9042187cbc34244a0d91b90621d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-10  Wilco Dijkstra  <wdijkstr@arm.com>
+
+       * string/bits/string2.h (strchr): Remove define.
+
 2017-02-09  H.J. Lu  <hongjiu.lu@intel.com>
 
        * sysdeps/x86_64/Makefile (tests): Add tst-sse, tst-avx and
index e5337becf6fd21a7f303f4e9e8152f8571ec96b1..8b138a2a3c10715a31a5ad717327f2f0a631a427 100644 (file)
 #endif
 
 
-#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
-
-
 /* Copy SRC to DEST, returning pointer to final NUL byte.  */
 #ifdef __USE_GNU
 # ifndef _HAVE_STRING_ARCH_stpcpy