This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 09/10] Remove bits/string2.h.
- From: Zack Weinberg <zackw at panix dot com>
- To: libc-alpha at sourceware dot org
- Cc: joseph at codesourcery dot com, adhemerval dot zanella at linaro dot org, Wilco dot Dijkstra at arm dot com, fweimer at redhat dot com, carlos at redhat dot com, schwab at suse dot de
- Date: Tue, 9 May 2017 11:41:02 -0400
- Subject: [PATCH 09/10] Remove bits/string2.h.
- Authentication-results: sourceware.org; auth=none
- References: <20170509154103.11973-1-zackw@panix.com>
There's very little left in bits/string2.h at this point and it's
likely that the current generation of compilers can do all of it
without our help.
* string/bits/string2.h: Delete file.
* include/bits/string2.h: Delete file.
* string/string.h: Don't include bits/string2.h.
Remove inline optimization for mempcpy.
* string/string-inlines.c: Don't include bits/string2.h.
* string/Makefile (headers): Remove bits/string2.h.
* include/string.h: Forward __bzero and __stpcpy to __builtin
versions here.
* elf/dl-cache.c, inet/rcmd.c, inet/rexec.c, intl/dcigettext.c
* locale/loadarchive.c, locale/setlocale.c
* posix/spawn_faction_addopen.c, stdlib/putenv.c
* sunrpc/svc_simple.c, sysdeps/posix/getaddrinfo.c:
Use __strdup instead of strdup.
* sysdeps/unix/sysv/linux/internal_statvfs.c:
Use __strsep instead of strsep.
---
include/bits/string2.h | 1 -
include/string.h | 2 +
intl/dcigettext.c | 2 +-
string/Makefile | 8 ++--
string/Versions | 2 +-
string/bits/string2.h | 119 ------------------------------------------------
string/string-inlines.c | 1 -
string/string.h | 20 --------
8 files changed, 8 insertions(+), 147 deletions(-)
delete mode 100644 include/bits/string2.h
delete mode 100644 string/bits/string2.h
diff --git a/include/bits/string2.h b/include/bits/string2.h
deleted file mode 100644
index e4c4c709b5..0000000000
--- a/include/bits/string2.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <string/bits/string2.h>
diff --git a/include/string.h b/include/string.h
index ce71674086..f777d617c4 100644
--- a/include/string.h
+++ b/include/string.h
@@ -44,6 +44,7 @@ extern void *__memchr (const void *__s, int __c, size_t __n)
__attribute_pure__;
extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
+#define __bzero(s, n) __builtin_memset (s, '\0', n)
extern int __ffs (int __i) __attribute__ ((const));
@@ -77,6 +78,7 @@ extern __typeof (strncasecmp_l) __strncasecmp_l;
libc_hidden_proto (__mempcpy)
libc_hidden_proto (__stpcpy)
+#define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
libc_hidden_proto (__stpncpy)
libc_hidden_proto (__rawmemchr)
libc_hidden_proto (__strcasecmp)
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index 3843b7cbdf..7ee0337284 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1073,7 +1073,7 @@ _nl_find_msg (struct loaded_l10nfile *domain_file,
domain->conversions = new_conversions;
/* Copy the 'encoding' string to permanent storage. */
- encoding = strdup (encoding);
+ encoding = __strdup (encoding);
if (__builtin_expect (encoding == NULL, 0))
/* Nothing we can do, no more memory. We cannot use the
translation because it might be encoded incorrectly. */
diff --git a/string/Makefile b/string/Makefile
index f317d02a8c..8a6322babb 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -22,10 +22,10 @@ subdir := string
include ../Makeconfig
-headers := string.h strings.h memory.h endian.h bits/endian.h \
- argz.h envz.h byteswap.h bits/byteswap.h bits/byteswap-16.h \
- bits/string.h bits/string2.h bits/string3.h \
- bits/strings_fortified.h bits/uintn-identity.h
+headers := string.h strings.h memory.h argz.h envz.h byteswap.h \
+ endian.h bits/byteswap.h bits/byteswap-16.h bits/endian.h \
+ bits/string.h bits/string3.h bits/strings_fortified.h \
+ bits/uintn-identity.h
routines := strcat strchr strcmp strcoll strcpy strcspn \
strverscmp strdup strndup \
diff --git a/string/Versions b/string/Versions
index 9b709d12a9..25afed063a 100644
--- a/string/Versions
+++ b/string/Versions
@@ -57,7 +57,7 @@ libc {
strcasestr; strverscmp;
}
GLIBC_2.1.1 {
- # extern inline functions used by <bits/string2.h>
+ # extern inline functions formerly used in string.h
__mempcpy_small; __stpcpy_small; __strcspn_c1; __strcspn_c2; __strcspn_c3;
__strcpy_small; __strspn_c1; __strspn_c2; __strspn_c3; __strpbrk_c2;
__strpbrk_c3; __strsep_1c; __strsep_2c; __strsep_3c; __strsep_g;
diff --git a/string/bits/string2.h b/string/bits/string2.h
deleted file mode 100644
index 6a26e2bc68..0000000000
--- a/string/bits/string2.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Machine-independant string function optimizations.
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#ifndef _STRING_H
-# error "Never use <bits/string2.h> directly; include <string.h> instead."
-#endif
-
-#ifndef __NO_STRING_INLINES
-
-/* Unlike the definitions in the header <bits/string.h> the
- definitions contained here are not optimized down to assembler
- level. Those optimizations are not always a good idea since this
- means the code size increases a lot. Instead the definitions here
- optimize some functions in a way which do not dramatically
- increase the code size and which do not use assembler. The main
- trick is to use GCC's `__builtin_constant_p' function.
-
- Every function XXX which has a defined version in
- <bits/string.h> must be accompanied by a symbol _HAVE_STRING_ARCH_XXX
- to make sure we don't get redefinitions.
-
- We must use here macros instead of inline functions since the
- trick won't work with the latter. */
-
-#ifndef __STRING_INLINE
-# ifdef __cplusplus
-# define __STRING_INLINE inline
-# else
-# define __STRING_INLINE __extern_inline
-# endif
-#endif
-
-/* Dereferencing a pointer arg to run sizeof on it fails for the void
- pointer case, so we use this instead.
- Note that __x is evaluated twice. */
-#define __string2_1bptr_p(__x) \
- ((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
-
-
-/* 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
-
-
-/* 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
-
-#endif /* No string inlines. */
diff --git a/string/string-inlines.c b/string/string-inlines.c
index fa4a1594b2..68aa7d072a 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/string/string.h b/string/string.h
index 8eed67d77d..ac872ff283 100644
--- a/string/string.h
+++ b/string/string.h
@@ -511,9 +511,6 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
/* Get the machine-dependent optimizations (if any). */
# include <bits/string.h>
-
-/* These are generic optimizations which do not add too much inline code. */
-# include <bits/string2.h>
# endif
# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
@@ -522,23 +519,6 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
# endif
#endif
-#if defined __USE_GNU && defined __OPTIMIZE__ \
- && defined __extern_always_inline && __GNUC_PREREQ (3,2)
-# if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy
-
-#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
-#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
-
-__extern_always_inline void *
-__mempcpy_inline (void *__restrict __dest,
- const void *__restrict __src, size_t __n)
-{
- return (char *) memcpy (__dest, __src, __n) + __n;
-}
-
-# endif
-#endif
-
__END_DECLS
#endif /* string.h */
--
2.11.0