Assume string.h, stdlib.h, and limits.h. We don't need to look for strings.h
as we don't use any functions that are only defined in it.
There are some changes to files (very) loosely based on glibc here
but I don't think we've synced them in a very long time, and I've tried
to keep such changes minimal.
Other autoconf macros mean we don't actually save header checks in configure
here other than limits.h for now, unfortunately.
libiberty/ChangeLog:
PR bootstrap/112422
* config.h-vms: Don't define obsolete HAVE_*.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Don't search for string.h, strings.h, stdlib.h, or
limits.h.
* _doprnt.c: Drop redundant ifdefs for headers.
* acinclude.m4: Ditto.
* alloca.c: Ditto.
* choose-temp.c: Ditto.
* concat.c: Ditto.
* cp-demangle.c: Ditto.
* cp-demint.c: Ditto.
* cplus-dem.c: Ditto.
* d-demangle.c: Ditto.
* dyn-string.c: Ditto.
* fibheap.c: Ditto.
* filename_cmp.c: Ditto.
* floatformat.c: Ditto.
* getcwd.c: Ditto.
* getopt.c: Ditto.
* getpwd.c: Ditto.
* hashtab.c: Ditto.
* ldirname.c: Ditto.
* lrealpath.c: Ditto.
* make-relative-prefix.c: Ditto.
* make-temp-file.c: Ditto.
* mkstemps.c: Ditto.
* objalloc.c: Ditto.
* partition.c: Ditto.
* pex-common.c: Ditto.
* pex-djgpp.c: Ditto.
* pex-msdos.c: Ditto.
* pex-unix.c: Ditto.
* pex-win32.c: Ditto.
* pexecute.c: Ditto.
* putenv.c: Ditto.
* regex.c: Ditto.
* rust-demangle.c: Ditto.
* setenv.c: Ditto.
* simple-object-coff.c: Ditto.
* simple-object-elf.c: Ditto.
* simple-object-mach-o.c: Ditto.
* simple-object-xcoff.c: Ditto.
* simple-object.c: Ditto.
* sort.c: Ditto.
* splay-tree.c: Ditto.
* strerror.c: Ditto.
* strsignal.c: Ditto.
* strtol.c: Ditto.
* strtoll.c: Ditto.
* strtoul.c: Ditto.
* strtoull.c: Ditto.
* testsuite/test-demangle.c: Ditto.
* testsuite/test-expandargv.c: Ditto.
* testsuite/test-pexecute.c: Ditto.
* testsuite/test-strtol.c: Ditto.
* vasprintf.c: Ditto.
* vprintf-support.c: Ditto.
* vsnprintf.c: Ditto.
* xatexit.c: Ditto.
* xexit.c: Ditto.
* xmalloc.c: Ditto.
* xmemdup.c: Ditto.
* xstrdup.c: Ditto.
* xstrndup.c: Ditto.
* xvasprintf.c: Ditto.
---
libiberty/_doprnt.c | 4 ----
libiberty/acinclude.m4 | 8 --------
libiberty/alloca.c | 4 ----
libiberty/choose-temp.c | 8 ++------
libiberty/concat.c | 12 +-----------
libiberty/config.h-vms | 2 --
libiberty/config.in | 3 ---
libiberty/configure | 14 +-------------
libiberty/configure.ac | 10 +++-------
libiberty/cp-demangle.c | 7 -------
libiberty/cp-demint.c | 4 ----
libiberty/cplus-dem.c | 6 ------
libiberty/d-demangle.c | 5 -----
libiberty/dyn-string.c | 6 ------
libiberty/fibheap.c | 6 ------
libiberty/filename_cmp.c | 5 -----
libiberty/floatformat.c | 2 --
libiberty/getcwd.c | 4 ----
libiberty/getopt.c | 14 +++-----------
libiberty/getpwd.c | 4 ----
libiberty/hashtab.c | 6 ------
libiberty/ldirname.c | 10 +---------
libiberty/lrealpath.c | 9 ++-------
libiberty/make-relative-prefix.c | 6 ++----
libiberty/make-temp-file.c | 8 ++------
libiberty/mkstemps.c | 4 ----
libiberty/objalloc.c | 14 ++------------
libiberty/partition.c | 5 -----
libiberty/pex-common.c | 8 ++------
libiberty/pex-djgpp.c | 2 --
libiberty/pex-msdos.c | 4 ----
libiberty/pex-unix.c | 4 ----
libiberty/pex-win32.c | 4 ----
libiberty/pexecute.c | 2 --
libiberty/putenv.c | 8 ++------
libiberty/regex.c | 2 +-
libiberty/rust-demangle.c | 7 -------
libiberty/setenv.c | 9 +++------
libiberty/simple-object-coff.c | 8 +-------
libiberty/simple-object-elf.c | 8 +-------
libiberty/simple-object-mach-o.c | 8 +-------
libiberty/simple-object-xcoff.c | 8 +-------
libiberty/simple-object.c | 7 +------
libiberty/sort.c | 6 ------
libiberty/splay-tree.c | 5 -----
libiberty/strerror.c | 9 ---------
libiberty/strsignal.c | 9 ---------
libiberty/strtol.c | 2 --
libiberty/strtoll.c | 2 --
libiberty/strtoul.c | 2 --
libiberty/strtoull.c | 2 --
libiberty/testsuite/test-demangle.c | 6 +-----
libiberty/testsuite/test-expandargv.c | 4 ----
libiberty/testsuite/test-pexecute.c | 4 ----
libiberty/testsuite/test-strtol.c | 4 ----
libiberty/vasprintf.c | 6 ------
libiberty/vprintf-support.c | 6 ------
libiberty/vsnprintf.c | 4 ----
libiberty/xatexit.c | 6 +-----
libiberty/xexit.c | 2 --
libiberty/xmalloc.c | 8 +++-----
libiberty/xmemdup.c | 6 ------
libiberty/xstrdup.c | 6 ------
libiberty/xstrndup.c | 6 ------
libiberty/xvasprintf.c | 2 --
65 files changed, 37 insertions(+), 349 deletions(-)
diff --git a/libiberty/_doprnt.c b/libiberty/_doprnt.c
index 271faf78dccf..d60b1276c79f 100644
--- a/libiberty/_doprnt.c
+++ b/libiberty/_doprnt.c
@@ -22,12 +22,8 @@ Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#include <stdio.h>
#include <stdarg.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#undef _doprnt
diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4
index ec2959e98468..b8635563f518 100644
--- a/libiberty/acinclude.m4
+++ b/libiberty/acinclude.m4
@@ -113,16 +113,8 @@ AC_CACHE_VAL(libiberty_cv_decl_needed_$1,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "confdefs.h"
#include <stdio.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif]],
diff --git a/libiberty/alloca.c b/libiberty/alloca.c
index b75f7560f945..18b5c4f36a08 100644
--- a/libiberty/alloca.c
+++ b/libiberty/alloca.c
@@ -48,12 +48,8 @@ the possibility of a GCC built-in function.
#include <libiberty.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
/* These variables are used by the ASTRDUP implementation that relies
on C_alloca. */
diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c
index db6c6b7cab35..3d2b0b4078e5 100644
--- a/libiberty/choose-temp.c
+++ b/libiberty/choose-temp.c
@@ -22,16 +22,12 @@ Boston, MA 02110-1301, USA. */
#endif
#include <stdio.h> /* May get P_tmpdir. */
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
#include "libiberty.h"
diff --git a/libiberty/concat.c b/libiberty/concat.c
index b3fe1b4a0263..a0574b2c3fea 100644
--- a/libiberty/concat.c
+++ b/libiberty/concat.c
@@ -41,18 +41,8 @@ Concatenate zero or more of strings and return the result in
freshly
#include <sys/types.h> /* size_t */
#include <stdarg.h>
-
-# if HAVE_STRING_H
-# include <string.h>
-# else
-# if HAVE_STRINGS_H
-# include <strings.h>
-# endif
-# endif
-
-#if HAVE_STDLIB_H
+#include <string.h>
#include <stdlib.h>
-#endif
static inline unsigned long vconcat_length (const char *, va_list);
static inline unsigned long
diff --git a/libiberty/config.h-vms b/libiberty/config.h-vms
index d923ecb3cf26..c5a9e573481f 100644
--- a/libiberty/config.h-vms
+++ b/libiberty/config.h-vms
@@ -1,7 +1,5 @@
/* This is -*- C -*- */
-#define HAVE_STDLIB_H 1
#define HAVE_UNISTD_H 1
-#define HAVE_STRING_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
diff --git a/libiberty/config.in b/libiberty/config.in
index 3b8716511f00..8a196ccd3be4 100644
--- a/libiberty/config.in
+++ b/libiberty/config.in
@@ -156,9 +156,6 @@
/* Define to 1 if you have the <libgen.h> header file. */
#undef HAVE_LIBGEN_H
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
/* Define if you have the `long long' type. */
#undef HAVE_LONG_LONG
diff --git a/libiberty/configure b/libiberty/configure
index e089a97392f8..d9aab36fea33 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -6012,7 +6012,7 @@ host_makefile_frag=${frag}
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h
unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h
fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h
sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h
sys/prctl.h spawn.h libgen.h
+for ac_header in sys/file.h sys/param.h malloc.h unistd.h sys/time.h time.h
sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h
sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h
stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
@@ -6299,9 +6299,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
@@ -6318,9 +6316,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
@@ -7862,16 +7858,8 @@ else
#include "confdefs.h"
#include <stdio.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 15e6994c0306..c54e92ba1e8f 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -310,7 +310,7 @@ AC_SUBST_FILE(host_makefile_frag)
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h
unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h
fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h
sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h
sys/prctl.h spawn.h libgen.h)
+AC_CHECK_HEADERS(sys/file.h sys/param.h malloc.h unistd.h sys/time.h time.h
sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h
sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h
stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h)
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
@@ -336,18 +336,14 @@ AC_CACHE_VAL(liberty_cv_uint64,
[[extern uint64_t foo;]])],
[liberty_cv_uint64=uint64_t],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
+[[#include <limits.h>
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif]],
[[extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];]])],
[liberty_cv_uint64="unsigned long"],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
+[[#include <limits.h>
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif]],
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index ab122fc388d2..012fa6c3513b 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -107,13 +107,8 @@
#endif
#include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
@@ -127,9 +122,7 @@ extern char *alloca ();
# endif /* alloca */
#endif /* HAVE_ALLOCA_H */
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifndef INT_MAX
# define INT_MAX (int)(((unsigned int) ~0) >> 1) /* 0x7FFFFFFF
*/
#endif
diff --git a/libiberty/cp-demint.c b/libiberty/cp-demint.c
index e6d8d3552deb..9dea22080ec3 100644
--- a/libiberty/cp-demint.c
+++ b/libiberty/cp-demint.c
@@ -41,12 +41,8 @@
#include "config.h"
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include "ansidecl.h"
#include "libiberty.h"
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index b882b6592369..020585627406 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -39,13 +39,7 @@ Boston, MA 02110-1301, USA. */
#include "safe-ctype.h"
#include <string.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#else
-void * malloc ();
-void * realloc ();
-#endif
#include <demangle.h>
#undef CURRENT_DEMANGLING_STYLE
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 9d55a1f2ccc2..cc1387a6e64a 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -31,19 +31,14 @@ If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#include "safe-ctype.h"
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include <demangle.h>
#include "libiberty.h"
diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c
index 6dfb36468472..7e2f81c22d7e 100644
--- a/libiberty/dyn-string.c
+++ b/libiberty/dyn-string.c
@@ -33,14 +33,8 @@ Boston, MA 02110-1301, USA. */
#endif
#include <stdio.h>
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include "libiberty.h"
#include "dyn-string.h"
diff --git a/libiberty/fibheap.c b/libiberty/fibheap.c
index ee1f674215f0..54f94eff9f45 100644
--- a/libiberty/fibheap.c
+++ b/libiberty/fibheap.c
@@ -22,15 +22,9 @@ Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include "libiberty.h"
#include "fibheap.h"
diff --git a/libiberty/filename_cmp.c b/libiberty/filename_cmp.c
index f85b89c5468c..c35681a7fb41 100644
--- a/libiberty/filename_cmp.c
+++ b/libiberty/filename_cmp.c
@@ -20,13 +20,8 @@
#include "config.h"
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include "filenames.h"
#include "safe-ctype.h"
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index 454b63544286..f1cdbe0c9688 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -28,9 +28,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA.
#include <math.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
/* On some platforms, <float.h> provides DBL_QNAN. */
#ifdef STDC_HEADERS
diff --git a/libiberty/getcwd.c b/libiberty/getcwd.c
index 28f26eb179ff..f76de7b08aeb 100644
--- a/libiberty/getcwd.c
+++ b/libiberty/getcwd.c
@@ -23,12 +23,8 @@ directory's path doesn't fit in @var{len} characters, the
result is
#include <sys/param.h>
#endif
#include <errno.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
extern char *getwd ();
extern int errno;
diff --git a/libiberty/getopt.c b/libiberty/getopt.c
index 3b6e35946e10..8e52d35dd452 100644
--- a/libiberty/getopt.c
+++ b/libiberty/getopt.c
@@ -68,9 +68,7 @@
#ifdef VMS
# include <unixlib.h>
-# if HAVE_STRING_H - 0
-# include <string.h>
-# endif
+# include <string.h>
#endif
#ifndef _
@@ -195,18 +193,12 @@ static char *posixly_correct;
# define my_index strchr
#else
-# if HAVE_STRING_H
-# include <string.h>
-# else
-# if HAVE_STRINGS_H
-# include <strings.h>
-# endif
-# endif
+#include <string.h>
/* Avoid depending on library functions or files
whose names are inconsistent. */
-#if HAVE_STDLIB_H && HAVE_DECL_GETENV
+#if HAVE_DECL_GETENV
# include <stdlib.h>
#elif !defined(getenv)
# ifdef __cplusplus
diff --git a/libiberty/getpwd.c b/libiberty/getpwd.c
index fa5c132fd6b6..35b8982b21fb 100644
--- a/libiberty/getpwd.c
+++ b/libiberty/getpwd.c
@@ -23,9 +23,7 @@ between calls to @code{getpwd}.
extern int errno;
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -35,9 +33,7 @@ extern int errno;
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#if HAVE_LIMITS_H
#include <limits.h>
-#endif
#include "libiberty.h"
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 71e4bae950a0..2d34814853ef 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -37,18 +37,12 @@ Boston, MA 02110-1301, USA. */
#include <sys/types.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
diff --git a/libiberty/ldirname.c b/libiberty/ldirname.c
index 2b9985c16cd1..ca3b7fd632cb 100644
--- a/libiberty/ldirname.c
+++ b/libiberty/ldirname.c
@@ -43,18 +43,10 @@ is returned on memory allocation error.
#include "filenames.h"
/* For malloc. */
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
/* For memcpy. */
-# if HAVE_STRING_H
-# include <string.h>
-# else
-# if HAVE_STRINGS_H
-# include <strings.h>
-# endif
-# endif
+#include <string.h>
#define LDIRNAME(FPREFIX,DIRSEP) \
char *FPREFIX##_ldirname (const char *name) \
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index ce228dbb366d..f0f85e2cbfb8 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -37,18 +37,13 @@ components will be simplified. The returned value will be
allocated using
#include "ansidecl.h"
#include "libiberty.h"
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
/* On GNU libc systems the declaration is only visible with _GNU_SOURCE. */
#if defined(HAVE_CANONICALIZE_FILE_NAME) \
diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c
index 05b52c2f2a18..ce895f512a77 100644
--- a/libiberty/make-relative-prefix.c
+++ b/libiberty/make-relative-prefix.c
@@ -51,9 +51,9 @@ relative prefix can be found, return @code{NULL}.
#include "config.h"
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -61,8 +61,6 @@ relative prefix can be found, return @code{NULL}.
#include <sys/stat.h>
#endif
-#include <string.h>
-
#include "ansidecl.h"
#include "libiberty.h"
diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c
index a19ded1b65a4..3f10c449fc7d 100644
--- a/libiberty/make-temp-file.c
+++ b/libiberty/make-temp-file.c
@@ -22,17 +22,13 @@ Boston, MA 02110-1301, USA. */
#endif
#include <stdio.h> /* May get P_tmpdir. */
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h> /* May get R_OK, etc. on some systems. */
#endif
diff --git a/libiberty/mkstemps.c b/libiberty/mkstemps.c
index e822a63d25d4..6ec81348052c 100644
--- a/libiberty/mkstemps.c
+++ b/libiberty/mkstemps.c
@@ -21,12 +21,8 @@
#endif
#include <sys/types.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c
index b3b255a1d65b..305e97d516d7 100644
--- a/libiberty/objalloc.c
+++ b/libiberty/objalloc.c
@@ -25,22 +25,12 @@ Boston, MA 02110-1301, USA. */
/* Get a definition for NULL. */
#include <stdio.h>
-#if VMS
#include <stdlib.h>
-#include <unixlib.h>
-#else
-
/* Get a definition for size_t. */
#include <stddef.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#else
-/* For systems with larger pointers than ints, this must be declared. */
-extern void *malloc (size_t);
-extern void free (void *);
-#endif
-
+#if VMS
+#include <unixlib.h>
#endif
/* These routines allocate space for an object. Freeing allocated
diff --git a/libiberty/partition.c b/libiberty/partition.c
index 73e3c707a104..559b333fce55 100644
--- a/libiberty/partition.c
+++ b/libiberty/partition.c
@@ -23,13 +23,8 @@
#include "config.h"
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include "libiberty.h"
#include "partition.h"
diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c
index 801a03d1795c..060dda22fc7e 100644
--- a/libiberty/pex-common.c
+++ b/libiberty/pex-common.c
@@ -23,16 +23,12 @@ Boston, MA 02110-1301, USA. */
#include "pex-common.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#ifdef NEED_DECLARATION_ERRNO
extern int errno;
#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/pex-djgpp.c b/libiberty/pex-djgpp.c
index fe5ae7178350..02f18e642fc6 100644
--- a/libiberty/pex-djgpp.c
+++ b/libiberty/pex-djgpp.c
@@ -25,9 +25,7 @@ Boston, MA 02110-1301, USA. */
#ifdef NEED_DECLARATION_ERRNO
extern int errno;
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/libiberty/pex-msdos.c b/libiberty/pex-msdos.c
index 3c3182ee3e6f..7532e544af69 100644
--- a/libiberty/pex-msdos.c
+++ b/libiberty/pex-msdos.c
@@ -25,12 +25,8 @@ Boston, MA 02110-1301, USA. */
#ifdef NEED_DECLARATION_ERRNO
extern int errno;
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include "safe-ctype.h"
#include <process.h>
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
index dab7cd96ddce..5b3af5284ac5 100644
--- a/libiberty/pex-unix.c
+++ b/libiberty/pex-unix.c
@@ -30,12 +30,8 @@ Boston, MA 02110-1301, USA. */
#ifdef NEED_DECLARATION_ERRNO
extern int errno;
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 8ea4e7f822af..de0d7860dd9b 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -23,12 +23,8 @@ Boston, MA 02110-1301, USA. */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c
index f3b08fd1e0a5..708c0f9bfaa2 100644
--- a/libiberty/pexecute.c
+++ b/libiberty/pexecute.c
@@ -25,9 +25,7 @@ Boston, MA 02110-1301, USA. */
#include "config.h"
#include "libiberty.h"
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
/* We only permit a single pexecute chain to execute at a time. This
was always true anyhow, though it wasn't documented. */
diff --git a/libiberty/putenv.c b/libiberty/putenv.c
index 5c05f44a1403..6552b8ad391d 100644
--- a/libiberty/putenv.c
+++ b/libiberty/putenv.c
@@ -41,12 +41,8 @@ name is unset/removed.
#define putenv libiberty_putenv
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-# include <string.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
diff --git a/libiberty/regex.c b/libiberty/regex.c
index 2379fe9eda77..85c958834db7 100644
--- a/libiberty/regex.c
+++ b/libiberty/regex.c
@@ -150,7 +150,7 @@ char *realloc ();
This is used in most programs--a few other programs avoid this
by defining INHIBIT_STRING_HEADER. */
# ifndef INHIBIT_STRING_HEADER
-# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
+# if defined STDC_HEADERS || defined _LIBC
# include <string.h>
# ifndef bzero
# ifndef _LIBC
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
index 013f14eebac3..a335d59f6f83 100644
--- a/libiberty/rust-demangle.c
+++ b/libiberty/rust-demangle.c
@@ -39,14 +39,7 @@ If not, see <http://www.gnu.org/licenses/>. */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-extern size_t strlen(const char *s);
-extern int strncmp(const char *s1, const char *s2, size_t n);
-extern void *memset(void *s, int c, size_t n);
-#endif
#include <demangle.h>
#include "libiberty.h"
diff --git a/libiberty/setenv.c b/libiberty/setenv.c
index 61112eb052f7..11721cc829c8 100644
--- a/libiberty/setenv.c
+++ b/libiberty/setenv.c
@@ -50,12 +50,9 @@ extern int errno;
#endif
#define __set_errno(ev) ((errno) = (ev))
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-# include <string.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
+
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
diff --git a/libiberty/simple-object-coff.c b/libiberty/simple-object-coff.c
index 648036921acf..87457e591d9b 100644
--- a/libiberty/simple-object-coff.c
+++ b/libiberty/simple-object-coff.c
@@ -23,19 +23,13 @@ Boston, MA 02110-1301, USA. */
#include <errno.h>
#include <stddef.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index bde623049541..af9ceba44cf6 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -27,19 +27,13 @@ Boston, MA 02110-1301, USA. */
# define ENOTSUP ENOSYS
#endif
#include <stddef.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c
index aaa9cbf3a066..88697c14f73f 100644
--- a/libiberty/simple-object-mach-o.c
+++ b/libiberty/simple-object-mach-o.c
@@ -22,19 +22,13 @@ Boston, MA 02110-1301, USA. */
#include "simple-object.h"
#include <stddef.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
diff --git a/libiberty/simple-object-xcoff.c b/libiberty/simple-object-xcoff.c
index 9c65ffa0cff7..de9d2820593a 100644
--- a/libiberty/simple-object-xcoff.c
+++ b/libiberty/simple-object-xcoff.c
@@ -23,19 +23,13 @@ Boston, MA 02110-1301, USA. */
#include <errno.h>
#include <stddef.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
index a4992a2b1811..b7d8ed7329ce 100644
--- a/libiberty/simple-object.c
+++ b/libiberty/simple-object.c
@@ -24,18 +24,13 @@ Boston, MA 02110-1301, USA. */
#include <errno.h>
#include <fcntl.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
+#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
diff --git a/libiberty/sort.c b/libiberty/sort.c
index 7bcbd2cef500..d9a6f06e114e 100644
--- a/libiberty/sort.c
+++ b/libiberty/sort.c
@@ -24,18 +24,12 @@ Boston, MA 02110-1301, USA. */
#endif
#include "libiberty.h"
#include "sort.h"
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifndef UCHAR_MAX
#define UCHAR_MAX ((unsigned char)(-1))
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index 199bb5ef968d..36661f00cbd8 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -28,13 +28,8 @@ Boston, MA 02110-1301, USA. */
#include "config.h"
#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-
#include <stdio.h>
#include "libiberty.h"
diff --git a/libiberty/strerror.c b/libiberty/strerror.c
index 07db71698d9e..55b2c14db04b 100644
--- a/libiberty/strerror.c
+++ b/libiberty/strerror.c
@@ -27,17 +27,8 @@
/* Routines imported from standard C runtime libraries. */
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#else
-extern void *malloc ();
-#endif
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-extern void *memset ();
-#endif
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c
index 33254ca8a233..6893e44b476b 100644
--- a/libiberty/strsignal.c
+++ b/libiberty/strsignal.c
@@ -23,17 +23,8 @@
/* Routines imported from standard C runtime libraries. */
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#else
-extern void *malloc ();
-#endif
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-extern void *memset ();
-#endif
/* Undefine the macro we used to hide the definition of sys_siglist
found in the system header files. */
diff --git a/libiberty/strtol.c b/libiberty/strtol.c
index bde5647c9a6b..c803ad059585 100644
--- a/libiberty/strtol.c
+++ b/libiberty/strtol.c
@@ -52,9 +52,7 @@ that the converted value is unsigned.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
diff --git a/libiberty/strtoll.c b/libiberty/strtoll.c
index 37ff8cd3d4c4..f6bab51053a7 100644
--- a/libiberty/strtoll.c
+++ b/libiberty/strtoll.c
@@ -52,9 +52,7 @@ that the converted value is unsigned.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
diff --git a/libiberty/strtoul.c b/libiberty/strtoul.c
index ba80063531e5..7accb997792b 100644
--- a/libiberty/strtoul.c
+++ b/libiberty/strtoul.c
@@ -31,9 +31,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
diff --git a/libiberty/strtoull.c b/libiberty/strtoull.c
index 2f580fb34544..3b77e5636db5 100644
--- a/libiberty/strtoull.c
+++ b/libiberty/strtoull.c
@@ -31,9 +31,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
diff --git a/libiberty/testsuite/test-demangle.c
b/libiberty/testsuite/test-demangle.c
index 3af7979982f4..67d1e7f6a37f 100644
--- a/libiberty/testsuite/test-demangle.c
+++ b/libiberty/testsuite/test-demangle.c
@@ -26,12 +26,8 @@
#include <stdio.h>
#include "libiberty.h"
#include "demangle.h"
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/testsuite/test-expandargv.c
b/libiberty/testsuite/test-expandargv.c
index e6efd39bbe78..00354879d0a8 100644
--- a/libiberty/testsuite/test-expandargv.c
+++ b/libiberty/testsuite/test-expandargv.c
@@ -34,12 +34,8 @@
#include "libiberty.h"
#include <stdio.h>
#include <errno.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/testsuite/test-pexecute.c
b/libiberty/testsuite/test-pexecute.c
index b0e2c9904bac..a532ec484cc7 100644
--- a/libiberty/testsuite/test-pexecute.c
+++ b/libiberty/testsuite/test-pexecute.c
@@ -27,13 +27,9 @@
#include <stdio.h>
#include <signal.h>
#include <errno.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include <sys/types.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/testsuite/test-strtol.c
b/libiberty/testsuite/test-strtol.c
index e16d81585558..035db03e0a2d 100644
--- a/libiberty/testsuite/test-strtol.c
+++ b/libiberty/testsuite/test-strtol.c
@@ -34,12 +34,8 @@
#include "libiberty.h"
#include <stdio.h>
#include <errno.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c
index 6b659738d04a..e453b6318858 100644
--- a/libiberty/vasprintf.c
+++ b/libiberty/vasprintf.c
@@ -27,14 +27,8 @@ Floor, Boston, MA 02110-1301, USA. */
# define va_copy(d,s) __va_copy((d),(s))
#endif
#include <stdio.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#else
-extern void *malloc ();
-#endif
#include "libiberty.h"
#include "vprintf-support.h"
diff --git a/libiberty/vprintf-support.c b/libiberty/vprintf-support.c
index 905e86b0437c..ecaf917a0d37 100644
--- a/libiberty/vprintf-support.c
+++ b/libiberty/vprintf-support.c
@@ -28,14 +28,8 @@ Floor, Boston, MA 02110-1301, USA. */
#endif
#include <stdio.h>
#include <errno.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#else
-extern unsigned long strtoul ();
-#endif
#include "libiberty.h"
static inline unsigned long
diff --git a/libiberty/vsnprintf.c b/libiberty/vsnprintf.c
index 5f36707f0c0f..a6db5a446c5d 100644
--- a/libiberty/vsnprintf.c
+++ b/libiberty/vsnprintf.c
@@ -46,12 +46,8 @@ used.
#include "ansidecl.h"
#include <stdarg.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include "libiberty.h"
diff --git a/libiberty/xatexit.c b/libiberty/xatexit.c
index 8a985cab4bc7..c8c35afec594 100644
--- a/libiberty/xatexit.c
+++ b/libiberty/xatexit.c
@@ -29,15 +29,11 @@ failure. If you use @code{xatexit} to register functions,
you must use
#include "libiberty.h"
#include <stdio.h>
-
#include <stddef.h>
+#include <stdlib.h>
#if VMS
-#include <stdlib.h>
#include <unixlib.h>
-#else
-/* For systems with larger pointers than ints, this must be declared. */
-void *malloc (size_t);
#endif
static void xatexit_cleanup (void);
diff --git a/libiberty/xexit.c b/libiberty/xexit.c
index 4fccd1be8b3a..13293b2b9585 100644
--- a/libiberty/xexit.c
+++ b/libiberty/xexit.c
@@ -33,9 +33,7 @@ Termination is handled via the system's normal @code{exit}
call.
#include "config.h"
#endif
#include <stdio.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#include "libiberty.h"
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index f38cc06c8148..a8e9e93452f1 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -68,17 +68,15 @@ function will be called to print an error message and
terminate execution.
#include "environ.h"
#include <stdio.h>
-
#include <stddef.h>
+#include <stdlib.h>
#if VMS
-#include <stdlib.h>
#include <unixlib.h>
#else
/* For systems with larger pointers than ints, these must be declared. */
-# if HAVE_STDLIB_H && HAVE_UNISTD_H && HAVE_DECL_MALLOC \
+# if HAVE_UNISTD_H && HAVE_DECL_MALLOC \
&& HAVE_DECL_REALLOC && HAVE_DECL_CALLOC && HAVE_DECL_SBRK
-# include <stdlib.h>
# include <unistd.h>
# else
# ifdef __cplusplus
@@ -93,7 +91,7 @@ void *sbrk (ptrdiff_t);
# ifdef __cplusplus
}
# endif /* __cplusplus */
-# endif /* HAVE_STDLIB_H ... */
+# endif /* HAVE_UNISTD_H ... */
#endif /* VMS */
/* The program name if set. */
diff --git a/libiberty/xmemdup.c b/libiberty/xmemdup.c
index f2ed41f9b4d9..19a65b764fae 100644
--- a/libiberty/xmemdup.c
+++ b/libiberty/xmemdup.c
@@ -23,13 +23,7 @@ allocated, the remaining memory is zeroed.
#include "libiberty.h"
#include <sys/types.h> /* For size_t. */
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-#endif
void *
xmemdup (const void *input, size_t copy_size, size_t alloc_size)
diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c
index fa12c96a3cd6..86fb7e875b67 100644
--- a/libiberty/xstrdup.c
+++ b/libiberty/xstrdup.c
@@ -17,13 +17,7 @@ obtain memory.
#include "config.h"
#endif
#include <sys/types.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-#endif
#include "ansidecl.h"
#include "libiberty.h"
diff --git a/libiberty/xstrndup.c b/libiberty/xstrndup.c
index f01e9ff7f88a..d1b83d743f61 100644
--- a/libiberty/xstrndup.c
+++ b/libiberty/xstrndup.c
@@ -34,13 +34,7 @@ always NUL terminated.
#include "config.h"
#endif
#include <sys/types.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-#endif
#include "ansidecl.h"
#include "libiberty.h"
diff --git a/libiberty/xvasprintf.c b/libiberty/xvasprintf.c
index 3f022d1814bf..85b9cfa151fd 100644
--- a/libiberty/xvasprintf.c
+++ b/libiberty/xvasprintf.c
@@ -27,9 +27,7 @@ Floor, Boston, MA 02110-1301, USA. */
# define va_copy(d,s) __va_copy((d),(s))
#endif
#include <stdio.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include "libiberty.h"
#include "vprintf-support.h"
--
2.56.0