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

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.
This commit is contained in:
Wilco Dijkstra
2017-03-13 18:42:35 +00:00
parent 53a4608f8d
commit ae65d4f3c3
15 changed files with 41 additions and 98 deletions

View File

@ -25,16 +25,13 @@
#include <bits/libc-header-start.h>
/* Get size_t, wchar_t and NULL from <stddef.h>. */
#define __need_size_t
#ifndef __need_malloc_and_calloc
# define __need_wchar_t
# define __need_NULL
#endif
#define __need_size_t
#define __need_wchar_t
#define __need_NULL
#include <stddef.h>
__BEGIN_DECLS
#ifndef __need_malloc_and_calloc
#define _STDLIB_H 1
#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
@ -434,10 +431,6 @@ extern int lcong48_r (unsigned short int __param[7],
# endif /* Use misc. */
#endif /* Use misc or X/Open. */
#endif /* don't just need malloc and calloc */
#ifndef __malloc_and_calloc_defined
# define __malloc_and_calloc_defined
__BEGIN_NAMESPACE_STD
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
@ -445,9 +438,7 @@ extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
extern void *calloc (size_t __nmemb, size_t __size)
__THROW __attribute_malloc__ __wur;
__END_NAMESPACE_STD
#endif
#ifndef __need_malloc_and_calloc
__BEGIN_NAMESPACE_STD
/* Re-allocate the previously allocated block
in PTR, making the new block SIZE bytes long. */
@ -944,9 +935,6 @@ extern int ttyslot (void) __THROW;
# include <bits/stdlib-ldbl.h>
#endif
#endif /* don't just need malloc and calloc */
#undef __need_malloc_and_calloc
__END_DECLS
#endif /* stdlib.h */