1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

GLIBC uses strchr (s, '\0') as an idiom to find the end of a string.

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.
This commit is contained in:
Wilco Dijkstra
2017-02-10 17:26:16 +00:00
parent 3403a17fea
commit 40b7fbf273
2 changed files with 4 additions and 10 deletions

View File

@ -58,16 +58,6 @@
#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