summary refs log tree commit diff
path: root/string/bits
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2017-03-13 18:42:35 +0000
committerWilco Dijkstra <wdijkstr@arm.com>2017-03-13 18:45:42 +0000
commitae65d4f3c3995279ca458c460ebf8bab1885fa03 (patch)
treeafedd4aa53c009f9fe4b98d384a52db229d244a7 /string/bits
parent53a4608f8de7a89a41917ffeba9cd2098d6dec86 (diff)
downloadglibc-ae65d4f3c3995279ca458c460ebf8bab1885fa03.tar.gz
glibc-ae65d4f3c3995279ca458c460ebf8bab1885fa03.tar.xz
glibc-ae65d4f3c3995279ca458c460ebf8bab1885fa03.zip
Remove the str(n)dup inlines from string/bits/string2.h. Although inlining
calls with constant strings shows a small (~10%) performance gain, strdup is
typically used in error reporting code, so not performance critical.
Remove the now unused __need_malloc_and_calloc related defines from stdlib.h.

Rename existing uses of str(n)dup to __str(n)dup so it no longer needs to be
redirected to a builtin.  Also building GLIBC with -Os now no longer shows
localplt or linkname space failures (partial fix for BZ #15105 and BZ #19463).

        [BZ #15105]
        [BZ #19463]
        * elf/dl-cache.c (_dl_load_cache_lookup): Use __strdup.
        * inet/rcmd.c (rcmd_af): Likewise.
        * inet/rexec.c   (rexec_af): Likewise.
        * intl/dcigettext.c (_LIBC): Likewise.
        * intl/finddomain.c (_nl_find_domain): Use strdup expansion.
        * locale/loadarchive.c (_nl_load_locale_from_archive): Use __strdup.
        * locale/setlocale.c (setlocale): Likewise.
        * posix/spawn_faction_addopen.c
        (posix_spawn_file_actions_addopen): Likewise.
        * stdlib/putenv.c (putenv): Use __strndup.
        * sunrpc/svc_simple.c (__registerrpc): Use __strdup.
        * sysdeps/posix/getaddrinfo.c (gaih_inet): Use __strdup/__strndup.
        * include/stdlib.h (__need_malloc_and_calloc): Remove uses.
        (__Need_M_And_C) Remove define/undef.
        * stdlib/stdlib.h (__need_malloc_and_calloc): Remove uses.
        (__malloc_and_calloc_defined): Remove define.
        * string/bits/string2.h (__strdup): Remove define.
        (strdup): Likewise.
        (__strndup): Likewise.
        (strndup): Likewise.
Diffstat (limited to 'string/bits')
-rw-r--r--string/bits/string2.h59
1 files changed, 0 insertions, 59 deletions
diff --git a/string/bits/string2.h b/string/bits/string2.h
index 2d4eb41589..6a26e2bc68 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -112,65 +112,6 @@
 #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
-
-extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
-#  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)		      \
-		     : ({ size_t __len = strlen (s) + 1;		      \
-			  char *__retval = (char *) malloc (__len);	      \
-			  if (__retval != NULL)				      \
-			    __retval = (char *) memcpy (__retval, s, __len);  \
-			  __retval; }))					      \
-		  : __strdup (s)))
-
-#  if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-#   define strdup(s) __strdup (s)
-#  endif
-# endif
-
-# ifndef _HAVE_STRING_ARCH_strndup
-
-extern char *__strndup (const char *__string, size_t __n)
-     __THROW __attribute_malloc__;
-#  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)		      \
-		     : ({ size_t __len = strlen (s) + 1;		      \
-			  size_t __n = (n);				      \
-			  char *__retval;				      \
-			  if (__n < __len)				      \
-			    __len = __n + 1;				      \
-			  __retval = (char *) malloc (__len);		      \
-			  if (__retval != NULL)				      \
-			    {						      \
-			      __retval[__len - 1] = '\0';		      \
-			      __retval = (char *) memcpy (__retval, s,	      \
-							  __len - 1);	      \
-			    }						      \
-			  __retval; }))					      \
-		  : __strndup (s, n)))
-
-#  ifdef __USE_XOPEN2K8
-#   define strndup(s, n) __strndup (s, n)
-#  endif
-# endif
-
-#endif /* Use misc. or use GNU.  */
-
 #ifndef _FORCE_INLINES
 # undef __STRING_INLINE
 #endif