[PATCH v2] Support libiberty functions as macros; fix up AC_CHECK_DECL tree-wide

Nick Alcock nix@esperi.org.uk
Fri Nov 20 15:25:40 GMT 2026


On 19 Nov 2026, Tom Tromey outgrape:

>>>>>> "Nick" == Nick Alcock <nix@esperi.org.uk> writes:
>
> Nick> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
> Nick> a new AC_CHECK_FUNCS of memrchr in every project that transitively
> Nick> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
> Nick> on FreeBSD 15).
>
> Not really your issue but this would all be a lot simpler if libiberty
> made a config.h-style header with its own namespaced names, and then
> included this and checked these names from the include/ headers.

It would.

I might work on that after this.

> That way changes to libiberty wouldn't have to propagate through all the
> possible users.
>
> gdb kinds of works around this deficiency with libiberty.m4 but really
> that's a failure of encapsulation.

I'll say.

> Nick> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
> Nick> here, I'd be interested in anything better. (The need to use %top in
> Nick> binutils/arlex.l is slightly worrying.  It's not in POSIX, but
> Nick> we need something like it or we can't include config.h before the
> Nick> system headers it must precede.  (Including config.h in libiberty.h
> Nick> won't work for the same reason.)
>
> In gdb we switched to pre-including the "defs.h" file from the compiler
> command line, which I guess avoids stuff like this.  Though at the same
> time I don't think we had this precise problem so I wonder what's up
> with that.
>
>
> The gdb and sim bits here are fine but it sounds like this patch is
> going to be handled a different way in libiberty?

Yeah, I have a slightly different approach now, thuogh the gdb etc bits
are very similar:

(local test matrix finished OK: trybots running and so far seem happy.)

8<----------------------------------->8
>From aa01fab60111b4554c5db05b3faf442f7f15f845 Mon Sep 17 00:00:00 2001
From: Nick Alcock <nix@esperi.org.uk>
Date: Mon, 16 Nov 2026 18:25:03 +0000
Subject: [PATCH v2] Support libiberty functions as macros; fix up
 AC_CHECK_DECL tree-wide

libiberty.h includes redeclarations of a bunch of possibly-system-
provided functions (mkstemps, etc); but it doesn't properly handle the
case where the system defines these as macros, and has already defined
them when libiberty.h is #included.  This has a tendency to cause build
faulures on such systems (glibc is usually explicitly ruled out, which
is a bit of a code smell in itself).

Redeclare in parentheses, avoiding any macro definition.  This lets us
avoid AC_CHECK_DECLing for these functions unnecessarily in subprojects
that don't use them, since the redeclarations will no longer fail: audit
the tree for unnecessary and missing AC_CHECK_DECLs of the functions
that libiberty.h checks for, and missing ones that are nonetheless used.
(Alas, there are more missing ones than redundant ones.)

All relevant configury regenerated.

Also touches GDB machinery, so gdb-patches is Cc:ed.

include/
	* libiberty.h: Wrap POSIX-specified function redeclarations in
	parens to protect against prior declaration as macros.
bfd/
	* configure.ac: Add missing decls; remove unnecessary ones.
	* config.in: Regenerate.
	* configure: Likewise.
binutils/
	* configure.ac: Add missing decls.
	* config.in: Regenerate.
	* configure: Likewise.
gas/
	* configure.ac: Add missing decls.
	* config.in: Regenerate.
	* configure: Likewise.
gdbsupport/
	* libiberty.m4: Add missing decls.
	* config.in: Regenerate.
	* configure: Likewise.
sim/
	* config.h.in: Regenerate.
	* configure: Likewise.
gdb/
	* config.in: Regenerate.
	* configure: Likewise.
gdbserver/
	* config.in: Regenerate.
	* configure: Likewise.
gprof/
	* configure.ac: Add missing decls.
	* gconfig.in: Regenerate.
	* configure: Likewise.
gprofng/
	* configure.ac: Add missing decls.
	* common/config.h.in: Regenerate.
	* configure: Likewise.
gold/
	* configure.ac: Add missing decls; remove unnecessary ones.
	* config.in: Regenerate.
	* configure: Likewise.
ld/
	* configure.ac: Add missing decls.
	* config.in: Regenerate.
	* configure: Likewise.
libctf/
	* configure.ac: Add missing decls.
	* config.h.in: Regenerate.
	* configure: Likewise.
opcodes/
	* configure.ac: Add missing decls; remove unnecessary ones.
	* config.in: Regenerate.
	* configure: Likewise.
---
 bfd/config.in              |  24 +++++--
 bfd/configure              |  60 +++++++++++++++---
 bfd/configure.ac           |   2 +-
 binutils/config.in         |  16 +++++
 binutils/configure         |  40 ++++++++++++
 binutils/configure.ac      |   2 +-
 gas/config.in              |  23 +++++++
 gas/configure              |  60 ++++++++++++++++++
 gas/configure.ac           |   2 +-
 gdb/config.in              |   8 +++
 gdb/configure              |  22 +++++++
 gdbserver/config.in        |   8 +++
 gdbserver/configure        |  22 +++++++
 gdbsupport/config.in       |   8 +++
 gdbsupport/configure       |  22 +++++++
 gdbsupport/libiberty.m4    |   4 +-
 gold/config.in             |  19 +++---
 gold/configure             | 126 +++++++++++++++++++++----------------
 gold/configure.ac          |   4 +-
 gprof/configure            |  61 +++++++++++++++++-
 gprof/configure.ac         |   1 +
 gprof/gconfig.in           |   4 ++
 gprofng/common/config.h.in |  24 +++++++
 gprofng/configure          |  70 +++++++++++++++++++++
 gprofng/configure.ac       |   2 +-
 include/libiberty.h        |  54 ++++++++--------
 ld/config.in               |  16 +++++
 ld/configure               |  50 +++++++++++++++
 ld/configure.ac            |   2 +-
 libctf/config.h.in         |   4 ++
 libctf/configure           |  10 +++
 libctf/configure.ac        |   2 +-
 opcodes/config.in          |  20 ++++--
 opcodes/configure          |  36 ++++++++++-
 opcodes/configure.ac       |   2 +-
 sim/config.h.in            |   8 +++
 sim/configure              |  22 +++++++
 37 files changed, 737 insertions(+), 123 deletions(-)

diff --git a/bfd/config.in b/bfd/config.in
index 3efd3dc3ce1..302e0b2040c 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -40,10 +40,6 @@
    don't. */
 #undef HAVE_DECL_ASPRINTF
 
-/* Define to 1 if you have the declaration of `basename', and to 0 if you
-   don't. */
-#undef HAVE_DECL_BASENAME
-
 /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
 #undef HAVE_DECL_FFS
 
@@ -67,6 +63,10 @@
    don't. */
 #undef HAVE_DECL_FTELLO64
 
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_SNPRINTF
+
 /* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
    */
 #undef HAVE_DECL_STPCPY
@@ -75,6 +75,18 @@
    don't. */
 #undef HAVE_DECL_STRNLEN
 
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoll', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOLL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
 /* Define to 1 if you have the declaration of `strtoull', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRTOULL
@@ -83,6 +95,10 @@
    don't. */
 #undef HAVE_DECL_VASPRINTF
 
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_VSNPRINTF
+
 /* Define to 1 if you have the declaration of `___lc_codepage_func', and to 0
    if you don't. */
 #undef HAVE_DECL____LC_CODEPAGE_FUNC
diff --git a/bfd/configure b/bfd/configure
index d010a3f9aa6..e631ac2a892 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -15142,16 +15142,6 @@ fi
 done
 
 
-ac_fn_c_check_decl "$LINENO" "basename" "ac_cv_have_decl_basename" "$ac_includes_default"
-if test "x$ac_cv_have_decl_basename" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_BASENAME $ac_have_decl
-_ACEOF
 ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
 if test "x$ac_cv_have_decl_ffs" = xyes; then :
   ac_have_decl=1
@@ -15192,6 +15182,26 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_VASPRINTF $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
 ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strnlen" = xyes; then :
   ac_have_decl=1
@@ -15202,6 +15212,36 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRNLEN $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoll" "ac_cv_have_decl_strtoll" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoll" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOLL $ac_have_decl
+_ACEOF
 ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strtoull" = xyes; then :
   ac_have_decl=1
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 0630973a11d..d0f077f15ff 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -222,7 +222,7 @@ AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
 AC_CHECK_FUNCS(fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \
 	       sysconf)
 
-AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen, strtoull])
+AC_CHECK_DECLS([ffs, stpcpy, asprintf, vasprintf, snprintf, vsnprintf, strnlen, strtol, strtoul, strtoll, strtoull])
 AC_CHECK_DECLS([___lc_codepage_func], [], [], [[#include <locale.h>]])
 
 BFD_BINARY_FOPEN
diff --git a/binutils/config.in b/binutils/config.in
index 3c3b547e320..60d8d9bf025 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -61,6 +61,10 @@
 /* Is the prototype for getopt in <unistd.h> in the expected format? */
 #undef HAVE_DECL_GETOPT
 
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_SNPRINTF
+
 /* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
    */
 #undef HAVE_DECL_STPCPY
@@ -69,6 +73,18 @@
    don't. */
 #undef HAVE_DECL_STRNLEN
 
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_VSNPRINTF
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/binutils/configure b/binutils/configure
index c455cb4c0d9..5f54319c721 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -15852,6 +15852,46 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRNLEN $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
 
 
 # Link in zlib/zstd if we can.  This allows us to read compressed debug
diff --git a/binutils/configure.ac b/binutils/configure.ac
index e9fda4f42bb..abfaf7eb76e 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -278,7 +278,7 @@ if test $bu_cv_header_utime_h = yes; then
   AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
 fi
 
-AC_CHECK_DECLS([environ, getc_unlocked, stpcpy, strnlen])
+AC_CHECK_DECLS([environ, getc_unlocked, stpcpy, strnlen, snprintf, vsnprintf, strtol, strtoul])
 
 # Link in zlib/zstd if we can.  This allows us to read compressed debug
 # sections.  This is used only by readelf.c (objdump uses bfd for
diff --git a/gas/config.in b/gas/config.in
index 33482aa73dc..fd48752497b 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -93,6 +93,9 @@
    */
 #undef HAVE_DCGETTEXT
 
+/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
+#undef HAVE_DECL_FFS
+
 /* Is the prototype for getopt in <unistd.h> in the expected format? */
 #undef HAVE_DECL_GETOPT
 
@@ -100,10 +103,30 @@
    don't. */
 #undef HAVE_DECL_MEMPCPY
 
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_SNPRINTF
+
 /* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
    */
 #undef HAVE_DECL_STPCPY
 
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOULL
+
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_VSNPRINTF
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/gas/configure b/gas/configure
index bf3ccf3006d..2fe9eae96f7 100755
--- a/gas/configure
+++ b/gas/configure
@@ -16029,6 +16029,66 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STPCPY $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
+if test "x$ac_cv_have_decl_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFS $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
 
 
 
diff --git a/gas/configure.ac b/gas/configure.ac
index 09089b395c5..7e799d3d0c1 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -1021,7 +1021,7 @@ fi
 GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
 GAS_CHECK_DECL_NEEDED(ffs, f, int (*f)(int), $gas_test_headers)
 
-AC_CHECK_DECLS([mempcpy, stpcpy])
+AC_CHECK_DECLS([mempcpy, stpcpy, ffs, snprintf, vsnprintf, strtol, strtoul, strtoull])
 
 BFD_BINARY_FOPEN
 
diff --git a/gdb/config.in b/gdb/config.in
index 2e42440d4cc..f73b3b16eda 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -155,10 +155,18 @@
    don't. */
 #undef HAVE_DECL_GETTHRDS
 
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+   don't. */
+#undef HAVE_DECL_MKSTEMPS
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
 /* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
    */
 #undef HAVE_DECL_STRTOL
diff --git a/gdb/configure b/gdb/configure
index e747ffce49f..cb708f1983f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -29607,6 +29607,17 @@ cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRTOULL $ac_have_decl
 _ACEOF
 
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
 ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
   ac_have_decl=1
@@ -29616,6 +29627,17 @@ fi
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
 _ACEOF
 
     ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
diff --git a/gdbserver/config.in b/gdbserver/config.in
index cf6ebe0a4f2..a73b518fa46 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -58,10 +58,18 @@
 /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
 #undef HAVE_DECL_FFS
 
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+   don't. */
+#undef HAVE_DECL_MKSTEMPS
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
 /* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
    */
 #undef HAVE_DECL_STRTOL
diff --git a/gdbserver/configure b/gdbserver/configure
index e00e1e1c1c5..bc232efcaa4 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -13180,6 +13180,17 @@ cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRTOULL $ac_have_decl
 _ACEOF
 
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
 ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
   ac_have_decl=1
@@ -13189,6 +13200,17 @@ fi
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
 _ACEOF
 
     ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index ff84ab0d600..91d8e17ecbe 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -58,10 +58,18 @@
 /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
 #undef HAVE_DECL_FFS
 
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+   don't. */
+#undef HAVE_DECL_MKSTEMPS
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
 /* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
    */
 #undef HAVE_DECL_STRTOL
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 7ed4e259ffe..3849420d198 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -10518,6 +10518,17 @@ cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRTOULL $ac_have_decl
 _ACEOF
 
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
 ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
   ac_have_decl=1
@@ -10527,6 +10538,17 @@ fi
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
 _ACEOF
 
     ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
diff --git a/gdbsupport/libiberty.m4 b/gdbsupport/libiberty.m4
index 6c4a83c59a3..ae7a7c03705 100644
--- a/gdbsupport/libiberty.m4
+++ b/gdbsupport/libiberty.m4
@@ -26,6 +26,6 @@ AC_DEFUN([libiberty_INIT],
 
   AC_CHECK_DECLS([basename(char *)])
   AC_CHECK_DECLS_ONCE([ffs, asprintf, vasprintf, snprintf, vsnprintf])
-  AC_CHECK_DECLS_ONCE([strtol, strtoul, strtoll, strtoull])
-  AC_CHECK_DECLS_ONCE([strverscmp])
+  AC_CHECK_DECLS_ONCE([strtol, strtoul, strtoll, strtoull, strnlen])
+  AC_CHECK_DECLS_ONCE([strverscmp, mkstemps])
 ])
diff --git a/gold/config.in b/gold/config.in
index 3dcb30da9f4..5c866efb6f1 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -59,10 +59,6 @@
    */
 #undef HAVE_DCGETTEXT
 
-/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
-   don't. */
-#undef HAVE_DECL_ASPRINTF
-
 /* Define to 1 if you have the declaration of `basename', and to 0 if you
    don't. */
 #undef HAVE_DECL_BASENAME
@@ -79,9 +75,6 @@
    don't. */
 #undef HAVE_DECL_BSWAP_64
 
-/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
-#undef HAVE_DECL_FFS
-
 /* Define to 1 if you have the declaration of `memmem', and to 0 if you don't.
    */
 #undef HAVE_DECL_MEMMEM
@@ -94,9 +87,17 @@
    don't. */
 #undef HAVE_DECL_STRNDUP
 
-/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
    don't. */
-#undef HAVE_DECL_STRVERSCMP
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOULL
 
 /* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
    don't. */
diff --git a/gold/configure b/gold/configure
index 36fb3a0085c..6735f28b018 100755
--- a/gold/configure
+++ b/gold/configure
@@ -12000,26 +12000,6 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_BASENAME $ac_have_decl
 _ACEOF
-ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
-if test "x$ac_cv_have_decl_ffs" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FFS $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default"
-if test "x$ac_cv_have_decl_asprintf" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ASPRINTF $ac_have_decl
-_ACEOF
 ac_fn_c_check_decl "$LINENO" "vasprintf" "ac_cv_have_decl_vasprintf" "$ac_includes_default"
 if test "x$ac_cv_have_decl_vasprintf" = xyes; then :
   ac_have_decl=1
@@ -12050,15 +12030,55 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_VSNPRINTF $ac_have_decl
 _ACEOF
-ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
+ac_fn_c_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strndup" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
 fi
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRVERSCMP $ac_have_decl
+#define HAVE_DECL_STRNDUP $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "memmem" "ac_cv_have_decl_memmem" "$ac_includes_default"
+if test "x$ac_cv_have_decl_memmem" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MEMMEM $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
 _ACEOF
 
 
@@ -12443,26 +12463,6 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_BASENAME $ac_have_decl
 _ACEOF
-ac_fn_cxx_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
-if test "x$ac_cv_have_decl_ffs" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FFS $ac_have_decl
-_ACEOF
-ac_fn_cxx_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default"
-if test "x$ac_cv_have_decl_asprintf" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ASPRINTF $ac_have_decl
-_ACEOF
 ac_fn_cxx_check_decl "$LINENO" "vasprintf" "ac_cv_have_decl_vasprintf" "$ac_includes_default"
 if test "x$ac_cv_have_decl_vasprintf" = xyes; then :
   ac_have_decl=1
@@ -12493,16 +12493,6 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_VSNPRINTF $ac_have_decl
 _ACEOF
-ac_fn_cxx_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRVERSCMP $ac_have_decl
-_ACEOF
 ac_fn_cxx_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strndup" = xyes; then :
   ac_have_decl=1
@@ -12523,6 +12513,36 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_MEMMEM $ac_have_decl
 _ACEOF
+ac_fn_cxx_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_cxx_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_cxx_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
 
 
 # Use of ::std::tr1::unordered_map::rehash causes undefined symbols
diff --git a/gold/configure.ac b/gold/configure.ac
index 89348b660be..e181fa842aa 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -620,7 +620,7 @@ dnl We have to check these in C, not C++, because autoconf generates
 dnl tests which have no type information, and current glibc provides
 dnl multiple declarations of functions like basename when compiling
 dnl with C++.
-AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])
+AC_CHECK_DECLS([basename, vasprintf, snprintf, vsnprintf, strndup, memmem, strtol, strtoul, strtoull])
 
 dnl Check if gcc supports the -gpubnames option.
 dnl Use -Werror in case of compilers that make unknown -g options warnings.
@@ -663,7 +663,7 @@ esac
 AC_SUBST(DLOPEN_LIBS)
 
 AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp)
-AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
+AC_CHECK_DECLS([basename, vasprintf, snprintf, vsnprintf, strndup, memmem, strtol, strtoul, strtoull])
 
 # Use of ::std::tr1::unordered_map::rehash causes undefined symbols
 # at link time with some versions of GCC.
diff --git a/gprof/configure b/gprof/configure
index f2c7218ecbf..f279abbf15f 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -1903,6 +1903,52 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_func
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -11029,7 +11075,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11032 "configure"
+#line 11078 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11135,7 +11181,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11138 "configure"
+#line 11184 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11764,6 +11810,17 @@ _ACEOF
 fi
 done
 
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+
 
 ALL_LINGUAS="bg da de eo es fi fr ga hu id it ja ms nl pt_BR ro ru rw sr sv tr uk vi"
 
diff --git a/gprof/configure.ac b/gprof/configure.ac
index 91e7a9afb75..a72f3690cce 100644
--- a/gprof/configure.ac
+++ b/gprof/configure.ac
@@ -41,6 +41,7 @@ ACX_LARGEFILE
 # These are in addition to what is made available in bfd/.
 AC_CHECK_HEADERS(sys/time.h)
 AC_CHECK_FUNCS(setitimer)
+AC_CHECK_DECLS([strtoul])
 
 ALL_LINGUAS="bg da de eo es fi fr ga hu id it ja ms nl pt_BR ro ru rw sr sv tr uk vi"
 ZW_GNU_GETTEXT_SISTER_DIR
diff --git a/gprof/gconfig.in b/gprof/gconfig.in
index f8cf42db7cc..a80b39fd8d9 100644
--- a/gprof/gconfig.in
+++ b/gprof/gconfig.in
@@ -19,6 +19,10 @@
 /* Is the prototype for getopt in <unistd.h> in the expected format? */
 #undef HAVE_DECL_GETOPT
 
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/gprofng/common/config.h.in b/gprofng/common/config.h.in
index 5f2c1278c95..dca17db2042 100644
--- a/gprofng/common/config.h.in
+++ b/gprofng/common/config.h.in
@@ -19,6 +19,30 @@
    don't. */
 #undef HAVE_DECL_BASENAME
 
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+   don't. */
+#undef HAVE_DECL_MKSTEMPS
+
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_SNPRINTF
+
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOULL
+
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_VSNPRINTF
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/gprofng/configure b/gprofng/configure
index 0888933579b..9f1a758f806 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -17613,6 +17613,76 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_BASENAME $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
 
 for ac_func in clock_gettime strsignal
 do :
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index 3a2eb0265dd..87fb223b583 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -245,7 +245,7 @@ AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
 AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
 AC_SUBST(NOLTO_CFLAGS, [${nolto_cflags}])
 
-AC_CHECK_DECLS([basename])
+AC_CHECK_DECLS([basename, mkstemps, snprintf, vsnprintf, strtol, strtoul, strtoul, strtoull])
 AC_CHECK_FUNCS(clock_gettime strsignal)
 
 # For riscv builds inside incomplete environments such as during intermediate
diff --git a/include/libiberty.h b/include/libiberty.h
index bdb491b9b37..e18377ee8f5 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -114,7 +114,7 @@ extern char *expandargstr (const char *, const char *);
  || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \
  || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \
  || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME)
-extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
+extern char *(basename) (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
 #else
 /* Do not allow basename to be used if there is no prototype seen.  We
    either need to use the above prototype or have one from
@@ -213,17 +213,17 @@ extern int fdmatch (int fd1, int fd2);
 /* Prototypes vary from system to system, so we only provide a
    prototype on systems where we know that we need it.  */
 #if defined (HAVE_DECL_FFS) && !HAVE_DECL_FFS
-extern int ffs(int);
+extern int (ffs) (int);
 #endif
 
 #if defined (HAVE_DECL_MKSTEMPS) && !HAVE_DECL_MKSTEMPS
-extern int mkstemps(char *, int);
+extern int (mkstemps) (char *, int);
 #endif
 
 /* Make memrchr available on systems that do not have it.  */
 #if !defined (__GNU_LIBRARY__ ) && !defined (__linux__) && \
     !defined (HAVE_MEMRCHR)
-extern void *memrchr(const void *, int, size_t);
+extern void *(memrchr) (const void *, int, size_t);
 #endif
 
 /* Get the working directory.  The result is cached, so don't call
@@ -675,11 +675,11 @@ extern void *bsearch_r (const void *, const void *,
 			int (*)(const void *, const void *, void *),
 			void *);
 
-#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
+#if defined (HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
 /* Like sprintf but provides a pointer to malloc'd storage, which must
    be freed by the caller.  */
 
-extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+extern int (asprintf) (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
 #endif
 
 /* Like asprintf but allocates memory without fail. This works like
@@ -687,11 +687,11 @@ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
 
 extern char *xasprintf (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF_1;
 
-#if defined(HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
+#if defined (HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
 /* Like vsprintf but provides a pointer to malloc'd storage, which
    must be freed by the caller.  */
 
-extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
+extern int (vasprintf) (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
 #endif
 
 /* Like vasprintf but allocates memory without fail. This works like
@@ -699,45 +699,45 @@ extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
 
 extern char *xvasprintf (const char *, va_list) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF(1,0);
 
-#if defined(HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
+#if defined (HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
 /* Like sprintf but prints at most N characters.  */
-extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
+extern int (snprintf) (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
 #endif
 
-#if defined(HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
+#if defined (HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
 /* Like vsprintf but prints at most N characters.  */
-extern int vsnprintf (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
+extern int (vsnprintf) (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
 #endif
 
 #if defined (HAVE_DECL_STRNLEN) && !HAVE_DECL_STRNLEN
-extern size_t strnlen (const char *, size_t);
+extern size_t (strnlen) (const char *, size_t);
 #endif
 
-#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
+#if defined (HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
 /* Compare version strings.  */
-extern int strverscmp (const char *, const char *);
+extern int (strverscmp) (const char *, const char *);
 #endif
 
-#if defined(HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
-extern long int strtol (const char *nptr,
-                        char **endptr, int base);
+#if defined (HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
+extern long int (strtol) (const char *nptr,
+			  char **endptr, int base);
 #endif
 
-#if defined(HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
-extern unsigned long int strtoul (const char *nptr,
-                                  char **endptr, int base);
+#if defined (HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
+extern unsigned long int (strtoul) (const char *nptr,
+				    char **endptr, int base);
 #endif
 
-#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOLL
+#if defined (HAVE_LONG_LONG) && defined (HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOL
 __extension__
-extern long long int strtoll (const char *nptr,
-                              char **endptr, int base);
+extern long long int (strtoll) (const char *nptr,
+				char **endptr, int base);
 #endif
 
-#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOULL
+#if defined (HAVE_LONG_LONG) && defined (HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOUL
 __extension__
-extern unsigned long long int strtoull (const char *nptr,
-                                        char **endptr, int base);
+extern unsigned long long int (strtoull) (const char *nptr,
+					  char **endptr, int base);
 #endif
 
 /* Set the title of a process */
diff --git a/ld/config.in b/ld/config.in
index 1353370340d..cab652327ea 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -118,10 +118,26 @@
    */
 #undef HAVE_DECL_STPCPY
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
 /* Define to 1 if you have the declaration of `strtoull', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRTOULL
 
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_VSNPRINTF
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/ld/configure b/ld/configure
index cbf80648e1b..1f7c553c774 100755
--- a/ld/configure
+++ b/ld/configure
@@ -18731,6 +18731,56 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STPCPY $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
 ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strtoull" = xyes; then :
   ac_have_decl=1
diff --git a/ld/configure.ac b/ld/configure.ac
index 8c5e9606ac0..7e2b2540871 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -451,7 +451,7 @@ AC_CHECK_FUNCS(close getrusage glob lseek mkstemp open realpath waitpid mallinfo
 
 BFD_BINARY_FOPEN
 
-AC_CHECK_DECLS([environ, stpcpy, strtoull])
+AC_CHECK_DECLS([environ, stpcpy, vsnprintf, strtoul, strnlen, strtol, strtoul, strtoull])
 
 GCC_AC_FUNC_MMAP
 
diff --git a/libctf/config.h.in b/libctf/config.h.in
index 359f1f5ae1d..f670d155493 100644
--- a/libctf/config.h.in
+++ b/libctf/config.h.in
@@ -44,6 +44,10 @@
    don't. */
 #undef HAVE_DECL_BSWAP_64
 
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_SNPRINTF
+
 /* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
    */
 #undef HAVE_DECL_STPCPY
diff --git a/libctf/configure b/libctf/configure
index 8ccc9ac4ee1..00312c0f92c 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -17015,6 +17015,16 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_VASPRINTF $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
 ac_fn_c_check_decl "$LINENO" "stpcpy" "ac_cv_have_decl_stpcpy" "$ac_includes_default"
 if test "x$ac_cv_have_decl_stpcpy" = xyes; then :
   ac_have_decl=1
diff --git a/libctf/configure.ac b/libctf/configure.ac
index 1e1b429c98e..61db028f58f 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -122,7 +122,7 @@ AC_CHECK_FUNCS(pread)
 
 dnl Check for bswap_{16,32,64}
 AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
-AC_CHECK_DECLS([asprintf, vasprintf, stpcpy])
+AC_CHECK_DECLS([asprintf, vasprintf, snprintf, stpcpy])
 
 dnl Check for qsort_r.  (Taken from gnulib.)
 AC_CHECK_FUNCS_ONCE([qsort_r])
diff --git a/opcodes/config.in b/opcodes/config.in
index 36e654292b2..9b5d3268c2b 100644
--- a/opcodes/config.in
+++ b/opcodes/config.in
@@ -30,10 +30,6 @@
    don't. */
 #undef HAVE_DECL_ASPRINTF
 
-/* Define to 1 if you have the declaration of `basename', and to 0 if you
-   don't. */
-#undef HAVE_DECL_BASENAME
-
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
@@ -42,10 +38,26 @@
    */
 #undef HAVE_DECL_STPCPY
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRTOUL
+
 /* Define to 1 if you have the declaration of `strtoull', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRTOULL
 
+/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_VASPRINTF
+
 /* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_VSNPRINTF
diff --git a/opcodes/configure b/opcodes/configure
index 2ae65d00cbd..3c5314b10f1 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -13981,15 +13981,15 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_ASPRINTF $ac_have_decl
 _ACEOF
-ac_fn_c_check_decl "$LINENO" "basename" "ac_cv_have_decl_basename" "$ac_includes_default"
-if test "x$ac_cv_have_decl_basename" = xyes; then :
+ac_fn_c_check_decl "$LINENO" "vasprintf" "ac_cv_have_decl_vasprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vasprintf" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
 fi
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_BASENAME $ac_have_decl
+#define HAVE_DECL_VASPRINTF $ac_have_decl
 _ACEOF
 ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
 if test "x$ac_cv_have_decl_snprintf" = xyes; then :
@@ -14011,6 +14011,36 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STPCPY $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
 ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strtoull" = xyes; then :
   ac_have_decl=1
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index c6d8972aa0a..5dcc4a39d03 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -96,7 +96,7 @@ BFD_64_BIT
 AC_SUBST(HDEFINES)
 AC_PROG_INSTALL
 
-AC_CHECK_DECLS([asprintf, basename, snprintf, stpcpy, strtoull, vsnprintf])
+AC_CHECK_DECLS([asprintf, vasprintf, snprintf, stpcpy, strtol, strtoul, strnlen, strtoull, vsnprintf])
 
 # Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
 # since sigsetjmp might only be defined as a macro.
diff --git a/sim/config.h.in b/sim/config.h.in
index 44ff51580c7..0fcfbac19dd 100644
--- a/sim/config.h.in
+++ b/sim/config.h.in
@@ -51,10 +51,18 @@
 /* Is the prototype for getopt in <unistd.h> in the expected format? */
 #undef HAVE_DECL_GETOPT
 
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+   don't. */
+#undef HAVE_DECL_MKSTEMPS
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
 /* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
    */
 #undef HAVE_DECL_STRTOL
diff --git a/sim/configure b/sim/configure
index da4caa57aa1..da1778a5ef1 100755
--- a/sim/configure
+++ b/sim/configure
@@ -14375,6 +14375,17 @@ cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRTOULL $ac_have_decl
 _ACEOF
 
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
 ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
   ac_have_decl=1
@@ -14384,6 +14395,17 @@ fi
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
 _ACEOF
 
     ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"

base-commit: 5678a7bfceb3a6ea18bcde1ae68f7e96c43c998b
prerequisite-patch-id: 6bb7a1f3d29820aec4c1fe7c2b30a99b1c33b604
prerequisite-patch-id: 5e93f3723d2db6831a34d17656b17543529b0809
-- 
2.56.1.291.g6a80de6356



-- 
NULL && (void)


More information about the Binutils mailing list