public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it
       [not found] <1423524046-20605-1-git-send-email-palves@redhat.com>
@ 2015-02-09 23:20 ` Pedro Alves
  2015-02-09 23:35   ` Pedro Alves
  2015-02-27 16:58   ` Pedro Alves
  2015-02-09 23:21 ` [PATCH 09/36] floatformat.h: Wrap in extern "C" Pedro Alves
  1 sibling, 2 replies; 11+ messages in thread
From: Pedro Alves @ 2015-02-09 23:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: GCC Patches

Converting GDB to be a C++ program, I stumbled on 'basename' issues,
like:

 src/gdb/../include/ansidecl.h:169:64: error: new declaration ‘char* basename(const char*)’
 /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’

which I believe led to this bit in gold's configure.ac:

 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])

These checks IIUC intend to generate all the HAVE_DECL_FOO symbols
that libiberty.h and ansidecl.h check.

GDB is missing these checks currently, which results in the conflict
shown above.

I could just copy gold's bits over to GDB.  But, since libiberty's
ansidecl.h and libiberty.h check HAVE_DECL_XXX symbols, ISTM that all
programs that use these headers should be doing the exact same
corresponding AC_CHECK_DECLS autoconf checks, and that there's good
potential for bit rot here.

So I thought of adding a m4 file that projects that use libiberty can
source to pull in the autoconf checks that libiberty needs done in
order to use its public headers.

Turns out that this has already happened.  Since I first wrote this a
few months back, libiberty gained more HAVE_DECL_FOO checks even, for
the strtol & friends replacements.

Are the libiberty changes OK?

libiberty/ChangeLog:
2015-02-09  Pedro Alves  <palves@redhat.com>

	* libiberty.m4: New file.

gdb/ChangeLog:
2015-02-09  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include libiberty.m4.
	* config.in, configure: Regenerate.
	* configure.ac: Call libiberty_INIT.

gdb/gdbserver/
2015-02-09  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include libiberty.m4.
	* config.in, configure: Regenerate.
	* configure.ac: Call libiberty_INIT.
---
 gdb/acinclude.m4           |   3 +
 gdb/config.in              |  45 ++++++
 gdb/configure              | 266 +++++++++++++++++++++++++++--------
 gdb/configure.ac           |   2 +
 gdb/gdbserver/acinclude.m4 |   3 +
 gdb/gdbserver/config.in    |  41 ++++++
 gdb/gdbserver/configure    | 338 +++++++++++++++++++++++++++++++++++++++++++++
 gdb/gdbserver/configure.ac |   2 +
 libiberty/libiberty.m4     |  33 +++++
 9 files changed, 679 insertions(+), 54 deletions(-)
 create mode 100644 libiberty/libiberty.m4

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 6f71486..ff4aff0 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -54,6 +54,9 @@ sinclude([../config/zlib.m4])
 
 m4_include([common/common.m4])
 
+dnl For libiberty_INIT.
+m4_include(../libiberty/libiberty.m4)
+
 ## ----------------------------------------- ##
 ## ANSIfy the C compiler whenever possible.  ##
 ## From Franc,ois Pinard                     ##
diff --git a/gdb/config.in b/gdb/config.in
index 806cbac..6a8df15 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -85,6 +85,17 @@
    you don't. */
 #undef HAVE_DECL_ADDR_NO_RANDOMIZE
 
+/* 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(char *)', 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
+
 /* Define to 1 if you have the declaration of `free', and to 0 if you don't.
    */
 #undef HAVE_DECL_FREE
@@ -117,6 +128,34 @@
    */
 #undef HAVE_DECL_STRSTR
 
+/* 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
+
+/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRVERSCMP
+
+/* 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
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
@@ -225,6 +264,9 @@
 /* Define to 1 if the compiler supports long double. */
 #undef HAVE_LONG_DOUBLE
 
+/* Define if you have the `long long' type. */
+#undef HAVE_LONG_LONG
+
 /* Define if <sys/procfs.h> has lwpid_t. */
 #undef HAVE_LWPID_T
 
@@ -635,6 +677,9 @@
 /* The size of `long', as computed by sizeof. */
 #undef SIZEOF_LONG
 
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
 /* The size of `unsigned long', as computed by sizeof. */
 #undef SIZEOF_UNSIGNED_LONG
 
diff --git a/gdb/configure b/gdb/configure
index 9632f9a..05e355c 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -2184,6 +2184,60 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+	 return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+	    return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+
 # ac_fn_c_check_decl LINENO SYMBOL VAR
 # ------------------------------------
 # Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
@@ -2285,60 +2339,6 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 
 } # ac_fn_c_check_member
-
-# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
-# -------------------------------------------
-# Tests whether TYPE exists after having included INCLUDES, setting cache
-# variable VAR accordingly.
-ac_fn_c_check_type ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=no"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-if (sizeof ($2))
-	 return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-if (sizeof (($2)))
-	    return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  eval "$3=yes"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_type
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -9584,6 +9584,164 @@ done
 # Checks for declarations.  #
 # ------------------------- #
 
+
+  # Check for presence of long long.
+  ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
+if test "x$ac_cv_type_long_long" = x""yes; then :
+
+$as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h
+ # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
+$as_echo_n "checking size of long long... " >&6; }
+if test "${ac_cv_sizeof_long_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
+$as_echo "$ac_cv_sizeof_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
+fi
+
+
+  ac_fn_c_check_decl "$LINENO" "basename(char *)" "ac_cv_have_decl_basename_char_p_" "$ac_includes_default"
+if test "x$ac_cv_have_decl_basename_char_p_" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $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" = x""yes; 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_c_check_decl "$LINENO" "free" "ac_cv_have_decl_free" "$ac_includes_default"
 if test "x$ac_cv_have_decl_free" = x""yes; then :
   ac_have_decl=1
diff --git a/gdb/configure.ac b/gdb/configure.ac
index dfc6947..920e580 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1283,6 +1283,8 @@ AC_CHECK_HEADERS(term.h, [], [],
 # Checks for declarations.  #
 # ------------------------- #
 
+libiberty_INIT
+
 AC_CHECK_DECLS([free, malloc, realloc, snprintf])
 AM_LC_MESSAGES
 
diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4
index 744871a..ba4a21f 100644
--- a/gdb/gdbserver/acinclude.m4
+++ b/gdb/gdbserver/acinclude.m4
@@ -20,6 +20,9 @@ dnl anything else in gdbserver.
 m4_include(../../config/codeset.m4)
 m4_include(../common/common.m4)
 
+dnl For libiberty_INIT.
+m4_include(../../libiberty/libiberty.m4)
+
 dnl Check for existence of a type $1 in libthread_db.h
 dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4.
 
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 8f68ed2..cf8e59d 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -22,10 +22,25 @@
    you don't. */
 #undef HAVE_DECL_ADDR_NO_RANDOMIZE
 
+/* 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(char *)', 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
+
 /* Define to 1 if you have the declaration of `perror', and to 0 if you don't.
    */
 #undef HAVE_DECL_PERROR
 
+/* 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 `strerror', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRERROR
@@ -34,6 +49,26 @@
    */
 #undef HAVE_DECL_STRSTR
 
+/* 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
+
+/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRVERSCMP
+
 /* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_VASPRINTF
@@ -96,6 +131,9 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
+/* Define if you have the `long long' type. */
+#undef HAVE_LONG_LONG
+
 /* Define if <thread_db.h> has lwpid_t. */
 #undef HAVE_LWPID_T
 
@@ -253,6 +291,9 @@
 /* Bug reporting address */
 #undef REPORT_BUGS_TO
 
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at runtime.
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 2240b78..5623746 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -1882,6 +1882,184 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 
 } # ac_fn_c_check_type
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+			if test $ac_lo -le $ac_mid; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+			if test $ac_mid -le $ac_hi; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+	return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+	return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  return $ac_retval
+
+} # ac_fn_c_compute_int
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -5338,6 +5516,166 @@ done
 
 LIBS="$old_LIBS"
 
+
+
+  # Check for presense of long long
+  ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
+if test "x$ac_cv_type_long_long" = x""yes; then :
+
+$as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h
+ # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
+$as_echo_n "checking size of long long... " >&6; }
+if test "${ac_cv_sizeof_long_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
+$as_echo "$ac_cv_sizeof_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
+fi
+
+
+  ac_fn_c_check_decl "$LINENO" "basename(char *)" "ac_cv_have_decl_basename_char_p_" "$ac_includes_default"
+if test "x$ac_cv_have_decl_basename_char_p_" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $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" = x""yes; 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_c_check_decl "$LINENO" "strerror" "ac_cv_have_decl_strerror" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strerror" = x""yes; then :
   ac_have_decl=1
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index f883adc..60636f7 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -193,6 +193,8 @@ LIBS="$LIBS -ldl"
 AC_CHECK_FUNCS(dladdr)
 LIBS="$old_LIBS"
 
+libiberty_INIT
+
 AC_CHECK_DECLS([strerror, perror, vasprintf, vsnprintf])
 
 AC_CHECK_TYPES(socklen_t, [], [],
diff --git a/libiberty/libiberty.m4 b/libiberty/libiberty.m4
new file mode 100644
index 0000000..6d9fd05
--- /dev/null
+++ b/libiberty/libiberty.m4
@@ -0,0 +1,33 @@
+dnl Bits libiberty clients must do on their autoconf step.
+dnl
+dnl   Copyright (C) 2012-2015 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+dnl Checks for declarations ansidecl.h and libiberty.h themselves
+dnl check with HAVE_DECL_XXX, etc.
+
+AC_DEFUN([libiberty_INIT],
+[
+  # Check for presence of long long.
+  AC_CHECK_TYPE([long long],
+    [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])],
+    [])
+
+  AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
+  AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
+  AC_CHECK_DECLS([strverscmp])
+])
-- 
1.9.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 09/36] floatformat.h: Wrap in extern "C".
       [not found] <1423524046-20605-1-git-send-email-palves@redhat.com>
  2015-02-09 23:20 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
@ 2015-02-09 23:21 ` Pedro Alves
  2015-02-09 23:35   ` Andrew Pinski
  1 sibling, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2015-02-09 23:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: GCC Patches

Just like libiberty.h.  So that C++ programs, such as GDB when built
as a C++ program, can use it.

include/ChangeLog:
2015-02-09  Pedro Alves  <palves@redhat.com>

	* floatformat.h [__cplusplus]: Wrap in extern "C".
---
 include/floatformat.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/floatformat.h b/include/floatformat.h
index 6b559864..71d332b 100644
--- a/include/floatformat.h
+++ b/include/floatformat.h
@@ -20,6 +20,10 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 #if !defined (FLOATFORMAT_H)
 #define FLOATFORMAT_H 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "ansidecl.h"
 
 /* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
@@ -148,4 +152,8 @@ floatformat_from_double (const struct floatformat *, const double *, void *);
 extern int
 floatformat_is_valid (const struct floatformat *fmt, const void *from);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif	/* defined (FLOATFORMAT_H) */
-- 
1.9.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it
  2015-02-09 23:20 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
@ 2015-02-09 23:35   ` Pedro Alves
  2015-02-27 16:58   ` Pedro Alves
  1 sibling, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2015-02-09 23:35 UTC (permalink / raw)
  To: gdb-patches; +Cc: GCC Patches

Bah, looks like I dropped gdb-patches@ by accident, adding it back
(patch here: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00580.html).

For the gcc folks, this is part of this series:
 https://sourceware.org/ml/gdb-patches/2015-02/msg00202.html

Thanks,
Pedro Alves

On 02/09/2015 11:20 PM, Pedro Alves wrote:
> Converting GDB to be a C++ program, I stumbled on 'basename' issues,
> like:
> 
>  src/gdb/../include/ansidecl.h:169:64: error: new declaration ‘char* basename(const char*)’
>  /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’
> 
> which I believe led to this bit in gold's configure.ac:
> 
>  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])
> 
> These checks IIUC intend to generate all the HAVE_DECL_FOO symbols
> that libiberty.h and ansidecl.h check.
> 
> GDB is missing these checks currently, which results in the conflict
> shown above.
> 
> I could just copy gold's bits over to GDB.  But, since libiberty's
> ansidecl.h and libiberty.h check HAVE_DECL_XXX symbols, ISTM that all
> programs that use these headers should be doing the exact same
> corresponding AC_CHECK_DECLS autoconf checks, and that there's good
> potential for bit rot here.
> 
> So I thought of adding a m4 file that projects that use libiberty can
> source to pull in the autoconf checks that libiberty needs done in
> order to use its public headers.
> 
> Turns out that this has already happened.  Since I first wrote this a
> few months back, libiberty gained more HAVE_DECL_FOO checks even, for
> the strtol & friends replacements.
> 
> Are the libiberty changes OK?
> 
> libiberty/ChangeLog:
> 2015-02-09  Pedro Alves  <palves@redhat.com>
> 
> 	* libiberty.m4: New file.
> 
> gdb/ChangeLog:
> 2015-02-09  Pedro Alves  <palves@redhat.com>
> 
> 	* acinclude.m4: Include libiberty.m4.
> 	* config.in, configure: Regenerate.
> 	* configure.ac: Call libiberty_INIT.
> 
> gdb/gdbserver/
> 2015-02-09  Pedro Alves  <palves@redhat.com>
> 
> 	* acinclude.m4: Include libiberty.m4.
> 	* config.in, configure: Regenerate.
> 	* configure.ac: Call libiberty_INIT.
> ---
>  gdb/acinclude.m4           |   3 +
>  gdb/config.in              |  45 ++++++
>  gdb/configure              | 266 +++++++++++++++++++++++++++--------
>  gdb/configure.ac           |   2 +
>  gdb/gdbserver/acinclude.m4 |   3 +
>  gdb/gdbserver/config.in    |  41 ++++++
>  gdb/gdbserver/configure    | 338 +++++++++++++++++++++++++++++++++++++++++++++
>  gdb/gdbserver/configure.ac |   2 +
>  libiberty/libiberty.m4     |  33 +++++
>  9 files changed, 679 insertions(+), 54 deletions(-)
>  create mode 100644 libiberty/libiberty.m4
> 
> diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
> index 6f71486..ff4aff0 100644
> --- a/gdb/acinclude.m4
> +++ b/gdb/acinclude.m4
> @@ -54,6 +54,9 @@ sinclude([../config/zlib.m4])
>  
>  m4_include([common/common.m4])
>  
> +dnl For libiberty_INIT.
> +m4_include(../libiberty/libiberty.m4)
> +
>  ## ----------------------------------------- ##
>  ## ANSIfy the C compiler whenever possible.  ##
>  ## From Franc,ois Pinard                     ##
> diff --git a/gdb/config.in b/gdb/config.in
> index 806cbac..6a8df15 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -85,6 +85,17 @@
>     you don't. */
>  #undef HAVE_DECL_ADDR_NO_RANDOMIZE
>  
> +/* 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(char *)', 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
> +
>  /* Define to 1 if you have the declaration of `free', and to 0 if you don't.
>     */
>  #undef HAVE_DECL_FREE
> @@ -117,6 +128,34 @@
>     */
>  #undef HAVE_DECL_STRSTR
>  
> +/* 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
> +
> +/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
> +   don't. */
> +#undef HAVE_DECL_STRVERSCMP
> +
> +/* 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
> +
>  /* Define to 1 if you have the <dlfcn.h> header file. */
>  #undef HAVE_DLFCN_H
>  
> @@ -225,6 +264,9 @@
>  /* Define to 1 if the compiler supports long double. */
>  #undef HAVE_LONG_DOUBLE
>  
> +/* Define if you have the `long long' type. */
> +#undef HAVE_LONG_LONG
> +
>  /* Define if <sys/procfs.h> has lwpid_t. */
>  #undef HAVE_LWPID_T
>  
> @@ -635,6 +677,9 @@
>  /* The size of `long', as computed by sizeof. */
>  #undef SIZEOF_LONG
>  
> +/* The size of `long long', as computed by sizeof. */
> +#undef SIZEOF_LONG_LONG
> +
>  /* The size of `unsigned long', as computed by sizeof. */
>  #undef SIZEOF_UNSIGNED_LONG
>  
> diff --git a/gdb/configure b/gdb/configure
> index 9632f9a..05e355c 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -2184,6 +2184,60 @@ $as_echo "$ac_res" >&6; }
>  
>  } # ac_fn_c_check_func
>  
> +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
> +# -------------------------------------------
> +# Tests whether TYPE exists after having included INCLUDES, setting cache
> +# variable VAR accordingly.
> +ac_fn_c_check_type ()
> +{
> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
> +$as_echo_n "checking for $2... " >&6; }
> +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  eval "$3=no"
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +if (sizeof ($2))
> +	 return 0;
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +if (sizeof (($2)))
> +	    return 0;
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +
> +else
> +  eval "$3=yes"
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
> +
> +} # ac_fn_c_check_type
> +
>  # ac_fn_c_check_decl LINENO SYMBOL VAR
>  # ------------------------------------
>  # Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
> @@ -2285,60 +2339,6 @@ $as_echo "$ac_res" >&6; }
>    eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
>  
>  } # ac_fn_c_check_member
> -
> -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
> -# -------------------------------------------
> -# Tests whether TYPE exists after having included INCLUDES, setting cache
> -# variable VAR accordingly.
> -ac_fn_c_check_type ()
> -{
> -  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
> -$as_echo_n "checking for $2... " >&6; }
> -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  eval "$3=no"
> -  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
> -$4
> -int
> -main ()
> -{
> -if (sizeof ($2))
> -	 return 0;
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -if ac_fn_c_try_compile "$LINENO"; then :
> -  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
> -$4
> -int
> -main ()
> -{
> -if (sizeof (($2)))
> -	    return 0;
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -if ac_fn_c_try_compile "$LINENO"; then :
> -
> -else
> -  eval "$3=yes"
> -fi
> -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> -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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
> -
> -} # ac_fn_c_check_type
>  cat >config.log <<_ACEOF
>  This file contains any messages produced by compilers while
>  running configure, to aid debugging if configure makes a mistake.
> @@ -9584,6 +9584,164 @@ done
>  # Checks for declarations.  #
>  # ------------------------- #
>  
> +
> +  # Check for presence of long long.
> +  ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
> +if test "x$ac_cv_type_long_long" = x""yes; then :
> +
> +$as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h
> + # The cast to long int works around a bug in the HP C Compiler
> +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
> +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
> +# This bug is HP SR number 8606223364.
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
> +$as_echo_n "checking size of long long... " >&6; }
> +if test "${ac_cv_sizeof_long_long+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long"        "$ac_includes_default"; then :
> +
> +else
> +  if test "$ac_cv_type_long_long" = yes; then
> +     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
> +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
> +{ as_fn_set_status 77
> +as_fn_error "cannot compute sizeof (long long)
> +See \`config.log' for more details." "$LINENO" 5; }; }
> +   else
> +     ac_cv_sizeof_long_long=0
> +   fi
> +fi
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
> +$as_echo "$ac_cv_sizeof_long_long" >&6; }
> +
> +
> +
> +cat >>confdefs.h <<_ACEOF
> +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
> +_ACEOF
> +
> +
> +fi
> +
> +
> +  ac_fn_c_check_decl "$LINENO" "basename(char *)" "ac_cv_have_decl_basename_char_p_" "$ac_includes_default"
> +if test "x$ac_cv_have_decl_basename_char_p_" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
> +  ac_have_decl=1
> +else
> +  ac_have_decl=0
> +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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
> +  ac_have_decl=1
> +else
> +  ac_have_decl=0
> +fi
> +
> +cat >>confdefs.h <<_ACEOF
> +#define HAVE_DECL_STRTOULL $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" = x""yes; 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_c_check_decl "$LINENO" "free" "ac_cv_have_decl_free" "$ac_includes_default"
>  if test "x$ac_cv_have_decl_free" = x""yes; then :
>    ac_have_decl=1
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index dfc6947..920e580 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1283,6 +1283,8 @@ AC_CHECK_HEADERS(term.h, [], [],
>  # Checks for declarations.  #
>  # ------------------------- #
>  
> +libiberty_INIT
> +
>  AC_CHECK_DECLS([free, malloc, realloc, snprintf])
>  AM_LC_MESSAGES
>  
> diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4
> index 744871a..ba4a21f 100644
> --- a/gdb/gdbserver/acinclude.m4
> +++ b/gdb/gdbserver/acinclude.m4
> @@ -20,6 +20,9 @@ dnl anything else in gdbserver.
>  m4_include(../../config/codeset.m4)
>  m4_include(../common/common.m4)
>  
> +dnl For libiberty_INIT.
> +m4_include(../../libiberty/libiberty.m4)
> +
>  dnl Check for existence of a type $1 in libthread_db.h
>  dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4.
>  
> diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
> index 8f68ed2..cf8e59d 100644
> --- a/gdb/gdbserver/config.in
> +++ b/gdb/gdbserver/config.in
> @@ -22,10 +22,25 @@
>     you don't. */
>  #undef HAVE_DECL_ADDR_NO_RANDOMIZE
>  
> +/* 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(char *)', 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
> +
>  /* Define to 1 if you have the declaration of `perror', and to 0 if you don't.
>     */
>  #undef HAVE_DECL_PERROR
>  
> +/* 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 `strerror', and to 0 if you
>     don't. */
>  #undef HAVE_DECL_STRERROR
> @@ -34,6 +49,26 @@
>     */
>  #undef HAVE_DECL_STRSTR
>  
> +/* 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
> +
> +/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
> +   don't. */
> +#undef HAVE_DECL_STRVERSCMP
> +
>  /* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
>     don't. */
>  #undef HAVE_DECL_VASPRINTF
> @@ -96,6 +131,9 @@
>  /* Define to 1 if you have the <locale.h> header file. */
>  #undef HAVE_LOCALE_H
>  
> +/* Define if you have the `long long' type. */
> +#undef HAVE_LONG_LONG
> +
>  /* Define if <thread_db.h> has lwpid_t. */
>  #undef HAVE_LWPID_T
>  
> @@ -253,6 +291,9 @@
>  /* Bug reporting address */
>  #undef REPORT_BUGS_TO
>  
> +/* The size of `long long', as computed by sizeof. */
> +#undef SIZEOF_LONG_LONG
> +
>  /* If using the C implementation of alloca, define if you know the
>     direction of stack growth for your system; otherwise it will be
>     automatically deduced at runtime.
> diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
> index 2240b78..5623746 100755
> --- a/gdb/gdbserver/configure
> +++ b/gdb/gdbserver/configure
> @@ -1882,6 +1882,184 @@ $as_echo "$ac_res" >&6; }
>    eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
>  
>  } # ac_fn_c_check_type
> +
> +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
> +# --------------------------------------------
> +# Tries to find the compile-time value of EXPR in a program that includes
> +# INCLUDES, setting VAR accordingly. Returns whether the value could be
> +# computed
> +ac_fn_c_compute_int ()
> +{
> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> +  if test "$cross_compiling" = yes; then
> +    # Depending upon the size, compute the lo and hi bounds.
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +static int test_array [1 - 2 * !(($2) >= 0)];
> +test_array [0] = 0
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  ac_lo=0 ac_mid=0
> +  while :; do
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +static int test_array [1 - 2 * !(($2) <= $ac_mid)];
> +test_array [0] = 0
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  ac_hi=$ac_mid; break
> +else
> +  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
> +			if test $ac_lo -le $ac_mid; then
> +			  ac_lo= ac_hi=
> +			  break
> +			fi
> +			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +  done
> +else
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +static int test_array [1 - 2 * !(($2) < 0)];
> +test_array [0] = 0
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  ac_hi=-1 ac_mid=-1
> +  while :; do
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +static int test_array [1 - 2 * !(($2) >= $ac_mid)];
> +test_array [0] = 0
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  ac_lo=$ac_mid; break
> +else
> +  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
> +			if test $ac_mid -le $ac_hi; then
> +			  ac_lo= ac_hi=
> +			  break
> +			fi
> +			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +  done
> +else
> +  ac_lo= ac_hi=
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +# Binary search between lo and hi bounds.
> +while test "x$ac_lo" != "x$ac_hi"; do
> +  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +int
> +main ()
> +{
> +static int test_array [1 - 2 * !(($2) <= $ac_mid)];
> +test_array [0] = 0
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  ac_hi=$ac_mid
> +else
> +  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +done
> +case $ac_lo in #((
> +?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
> +'') ac_retval=1 ;;
> +esac
> +  else
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +$4
> +static long int longval () { return $2; }
> +static unsigned long int ulongval () { return $2; }
> +#include <stdio.h>
> +#include <stdlib.h>
> +int
> +main ()
> +{
> +
> +  FILE *f = fopen ("conftest.val", "w");
> +  if (! f)
> +    return 1;
> +  if (($2) < 0)
> +    {
> +      long int i = longval ();
> +      if (i != ($2))
> +	return 1;
> +      fprintf (f, "%ld", i);
> +    }
> +  else
> +    {
> +      unsigned long int i = ulongval ();
> +      if (i != ($2))
> +	return 1;
> +      fprintf (f, "%lu", i);
> +    }
> +  /* Do not output a trailing newline, as this causes \r\n confusion
> +     on some platforms.  */
> +  return ferror (f) || fclose (f) != 0;
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_run "$LINENO"; then :
> +  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
> +else
> +  ac_retval=1
> +fi
> +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
> +  conftest.$ac_objext conftest.beam conftest.$ac_ext
> +rm -f conftest.val
> +
> +  fi
> +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
> +  return $ac_retval
> +
> +} # ac_fn_c_compute_int
>  cat >config.log <<_ACEOF
>  This file contains any messages produced by compilers while
>  running configure, to aid debugging if configure makes a mistake.
> @@ -5338,6 +5516,166 @@ done
>  
>  LIBS="$old_LIBS"
>  
> +
> +
> +  # Check for presense of long long
> +  ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
> +if test "x$ac_cv_type_long_long" = x""yes; then :
> +
> +$as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h
> + # The cast to long int works around a bug in the HP C Compiler
> +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
> +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
> +# This bug is HP SR number 8606223364.
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
> +$as_echo_n "checking size of long long... " >&6; }
> +if test "${ac_cv_sizeof_long_long+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long"        "$ac_includes_default"; then :
> +
> +else
> +  if test "$ac_cv_type_long_long" = yes; then
> +     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
> +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
> +{ as_fn_set_status 77
> +as_fn_error "cannot compute sizeof (long long)
> +See \`config.log' for more details." "$LINENO" 5; }; }
> +   else
> +     ac_cv_sizeof_long_long=0
> +   fi
> +fi
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
> +$as_echo "$ac_cv_sizeof_long_long" >&6; }
> +
> +
> +
> +cat >>confdefs.h <<_ACEOF
> +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
> +_ACEOF
> +
> +
> +fi
> +
> +
> +  ac_fn_c_check_decl "$LINENO" "basename(char *)" "ac_cv_have_decl_basename_char_p_" "$ac_includes_default"
> +if test "x$ac_cv_have_decl_basename_char_p_" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
> +  ac_have_decl=1
> +else
> +  ac_have_decl=0
> +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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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" = x""yes; then :
> +  ac_have_decl=1
> +else
> +  ac_have_decl=0
> +fi
> +
> +cat >>confdefs.h <<_ACEOF
> +#define HAVE_DECL_STRTOULL $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" = x""yes; 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_c_check_decl "$LINENO" "strerror" "ac_cv_have_decl_strerror" "$ac_includes_default"
>  if test "x$ac_cv_have_decl_strerror" = x""yes; then :
>    ac_have_decl=1
> diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
> index f883adc..60636f7 100644
> --- a/gdb/gdbserver/configure.ac
> +++ b/gdb/gdbserver/configure.ac
> @@ -193,6 +193,8 @@ LIBS="$LIBS -ldl"
>  AC_CHECK_FUNCS(dladdr)
>  LIBS="$old_LIBS"
>  
> +libiberty_INIT
> +
>  AC_CHECK_DECLS([strerror, perror, vasprintf, vsnprintf])
>  
>  AC_CHECK_TYPES(socklen_t, [], [],
> diff --git a/libiberty/libiberty.m4 b/libiberty/libiberty.m4
> new file mode 100644
> index 0000000..6d9fd05
> --- /dev/null
> +++ b/libiberty/libiberty.m4
> @@ -0,0 +1,33 @@
> +dnl Bits libiberty clients must do on their autoconf step.
> +dnl
> +dnl   Copyright (C) 2012-2015 Free Software Foundation, Inc.
> +dnl
> +dnl This file is free software; you can redistribute it and/or modify
> +dnl it under the terms of the GNU General Public License as published by
> +dnl the Free Software Foundation; either version 3 of the License, or
> +dnl (at your option) any later version.
> +dnl
> +dnl This program is distributed in the hope that it will be useful,
> +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
> +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +dnl GNU General Public License for more details.
> +dnl
> +dnl You should have received a copy of the GNU General Public License
> +dnl along with this program; see the file COPYING3.  If not see
> +dnl <http://www.gnu.org/licenses/>.
> +dnl
> +
> +dnl Checks for declarations ansidecl.h and libiberty.h themselves
> +dnl check with HAVE_DECL_XXX, etc.
> +
> +AC_DEFUN([libiberty_INIT],
> +[
> +  # Check for presence of long long.
> +  AC_CHECK_TYPE([long long],
> +    [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])],
> +    [])
> +
> +  AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
> +  AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
> +  AC_CHECK_DECLS([strverscmp])
> +])
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-09 23:21 ` [PATCH 09/36] floatformat.h: Wrap in extern "C" Pedro Alves
@ 2015-02-09 23:35   ` Andrew Pinski
  2015-02-09 23:49     ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Pinski @ 2015-02-09 23:35 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, GCC Patches

On Mon, Feb 9, 2015 at 3:20 PM, Pedro Alves <palves@redhat.com> wrote:
> Just like libiberty.h.  So that C++ programs, such as GDB when built
> as a C++ program, can use it.

Why is not needed for GCC building with C++ compiler?

Thanks,
Andrew

>
> include/ChangeLog:
> 2015-02-09  Pedro Alves  <palves@redhat.com>
>
>         * floatformat.h [__cplusplus]: Wrap in extern "C".
> ---
>  include/floatformat.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/include/floatformat.h b/include/floatformat.h
> index 6b559864..71d332b 100644
> --- a/include/floatformat.h
> +++ b/include/floatformat.h
> @@ -20,6 +20,10 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
>  #if !defined (FLOATFORMAT_H)
>  #define FLOATFORMAT_H 1
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
>  #include "ansidecl.h"
>
>  /* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
> @@ -148,4 +152,8 @@ floatformat_from_double (const struct floatformat *, const double *, void *);
>  extern int
>  floatformat_is_valid (const struct floatformat *fmt, const void *from);
>
> +#ifdef __cplusplus
> +}
> +#endif
> +
>  #endif /* defined (FLOATFORMAT_H) */
> --
> 1.9.3
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-09 23:35   ` Andrew Pinski
@ 2015-02-09 23:49     ` Pedro Alves
  2015-02-12 11:49       ` Pedro Alves
  2015-02-14 17:29       ` Doug Evans
  0 siblings, 2 replies; 11+ messages in thread
From: Pedro Alves @ 2015-02-09 23:49 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gdb-patches, GCC Patches

On 02/09/2015 11:35 PM, Andrew Pinski wrote:
> On Mon, Feb 9, 2015 at 3:20 PM, Pedro Alves <palves@redhat.com> wrote:
>> Just like libiberty.h.  So that C++ programs, such as GDB when built
>> as a C++ program, can use it.
> 
> Why is not needed for GCC building with C++ compiler?

Because it doesn't include it.

The header of the file claims it is part of GDB, though MAINTAINERS
nowadays says that everything under include/ is owned by GCC.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-09 23:49     ` Pedro Alves
@ 2015-02-12 11:49       ` Pedro Alves
  2015-02-18 19:55         ` Jakub Jelinek
  2015-02-14 17:29       ` Doug Evans
  1 sibling, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2015-02-12 11:49 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gdb-patches, GCC Patches

On 02/09/2015 11:49 PM, Pedro Alves wrote:
> On 02/09/2015 11:35 PM, Andrew Pinski wrote:
>> On Mon, Feb 9, 2015 at 3:20 PM, Pedro Alves <palves@redhat.com> wrote:
>>> Just like libiberty.h.  So that C++ programs, such as GDB when built
>>> as a C++ program, can use it.
>>
>> Why is not needed for GCC building with C++ compiler?
> 
> Because it doesn't include it.
> 
> The header of the file claims it is part of GDB, though MAINTAINERS
> nowadays says that everything under include/ is owned by GCC.

Here's an update that moves the extern "C" below the #include.

OK to push to the GCC repo?

From: Pedro Alves <palves@redhat.com>
Subject: [PATCH] floatformat.h: Wrap in extern "C".

Just like libiberty.h.  So that C++ programs, such as GDB when built
as a C++ program, can use it.

include/ChangeLog:
2015-02-12  Pedro Alves  <palves@redhat.com>

	* floatformat.h [__cplusplus]: Wrap in extern "C".
---
 include/floatformat.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/floatformat.h b/include/floatformat.h
index 6b559864..af4d09c 100644
--- a/include/floatformat.h
+++ b/include/floatformat.h
@@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.

 #include "ansidecl.h"

+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
    bytes are concatenated according to the byteorder flag, then each of those
    fields is contiguous.  We number the bits with 0 being the most significant
@@ -148,4 +152,8 @@ floatformat_from_double (const struct floatformat *, const double *, void *);
 extern int
 floatformat_is_valid (const struct floatformat *fmt, const void *from);

+#ifdef __cplusplus
+}
+#endif
+
 #endif	/* defined (FLOATFORMAT_H) */
-- 
1.9.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-09 23:49     ` Pedro Alves
  2015-02-12 11:49       ` Pedro Alves
@ 2015-02-14 17:29       ` Doug Evans
  2015-02-14 18:36         ` Pedro Alves
  1 sibling, 1 reply; 11+ messages in thread
From: Doug Evans @ 2015-02-14 17:29 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Andrew Pinski, gdb-patches, GCC Patches

On Mon, Feb 9, 2015 at 3:49 PM, Pedro Alves <palves@redhat.com> wrote:
> On 02/09/2015 11:35 PM, Andrew Pinski wrote:
>> On Mon, Feb 9, 2015 at 3:20 PM, Pedro Alves <palves@redhat.com> wrote:
>>> Just like libiberty.h.  So that C++ programs, such as GDB when built
>>> as a C++ program, can use it.
>>
>> Why is not needed for GCC building with C++ compiler?
>
> Because it doesn't include it.
>
> The header of the file claims it is part of GDB, though MAINTAINERS
> nowadays says that everything under include/ is owned by GCC.

Wait, what?

The actual wording is:
"The rule is that if the file exists in the gcc tree then gcc owns it."
It originated from this thread,
https://sourceware.org/ml/gdb/2013-11/msg00025.html
That's not the first message in the thread, but that's where
I remember wanting to see something written down.

Perhaps kinda unfortunate for things like include/gdb/gdb-index.h.
But at least it's a rule that can be expressed in one sentence,
and I don't think it's been a problem.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-14 17:29       ` Doug Evans
@ 2015-02-14 18:36         ` Pedro Alves
  2015-02-14 22:46           ` Doug Evans
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2015-02-14 18:36 UTC (permalink / raw)
  To: Doug Evans; +Cc: Andrew Pinski, gdb-patches, GCC Patches

On 02/14/2015 05:29 PM, Doug Evans wrote:
> On Mon, Feb 9, 2015 at 3:49 PM, Pedro Alves <palves@redhat.com> wrote:
>> On 02/09/2015 11:35 PM, Andrew Pinski wrote:
>>> Why is not needed for GCC building with C++ compiler?
>>
>> Because it doesn't include it.
>>
>> The header of the file claims it is part of GDB, though MAINTAINERS
>> nowadays says that everything under include/ is owned by GCC.
>
> Wait, what?
>
> The actual wording is:
> "The rule is that if the file exists in the gcc tree then gcc owns it."

I was paraphrasing, and simplified it.  That distinction seems
irrelevant to me here because the file does exist in the gcc tree.
It's necessary to build libiberty (for libiberty/floatformat.o).

It's a fact that the header claims it is part of GDB:

~~~~~~
/* IEEE floating point support declarations, for GDB, the GNU Debugger.
   Copyright (C) 1991-2015 Free Software Foundation, Inc.

This file is part of GDB.
(...)
~~~~~~

I guess it should say that it is part of libiberty instead.

> It originated from this thread,
> https://sourceware.org/ml/gdb/2013-11/msg00025.html
> That's not the first message in the thread, but that's where
> I remember wanting to see something written down.
>
> Perhaps kinda unfortunate for things like include/gdb/gdb-index.h.
> But at least it's a rule that can be expressed in one sentence,
> and I don't think it's been a problem.

I'm confused -- I didn't say it was a problem, nor expressed any
concern with the rule.  I just was pointing out facts.

ISTM that the procedure here is to push this change first through
the gcc repo first, and then merge it to binutils-gdb git.  Is that
wrong?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-14 18:36         ` Pedro Alves
@ 2015-02-14 22:46           ` Doug Evans
  0 siblings, 0 replies; 11+ messages in thread
From: Doug Evans @ 2015-02-14 22:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Andrew Pinski, gdb-patches, GCC Patches

On Sat, Feb 14, 2015 at 10:36 AM, Pedro Alves <palves@redhat.com> wrote:
> On 02/14/2015 05:29 PM, Doug Evans wrote:
>> On Mon, Feb 9, 2015 at 3:49 PM, Pedro Alves <palves@redhat.com> wrote:
>>> On 02/09/2015 11:35 PM, Andrew Pinski wrote:
>>>> Why is not needed for GCC building with C++ compiler?
>>>
>>> Because it doesn't include it.
>>>
>>> The header of the file claims it is part of GDB, though MAINTAINERS
>>> nowadays says that everything under include/ is owned by GCC.
>>
>> Wait, what?
>>
>> The actual wording is:
>> "The rule is that if the file exists in the gcc tree then gcc owns it."
>
> I was paraphrasing, and simplified it.  That distinction seems
> irrelevant to me here because the file does exist in the gcc tree.
> It's necessary to build libiberty (for libiberty/floatformat.o).

No worries, I just wanted to make sure it didn't say something
it shouldn't.

> It's a fact that the header claims it is part of GDB:
>
> ~~~~~~
> /* IEEE floating point support declarations, for GDB, the GNU Debugger.
>    Copyright (C) 1991-2015 Free Software Foundation, Inc.
>
> This file is part of GDB.
> (...)
> ~~~~~~
>
> I guess it should say that it is part of libiberty instead.

At the least the current wording is confusing.

>> It originated from this thread,
>> https://sourceware.org/ml/gdb/2013-11/msg00025.html
>> That's not the first message in the thread, but that's where
>> I remember wanting to see something written down.
>>
>> Perhaps kinda unfortunate for things like include/gdb/gdb-index.h.
>> But at least it's a rule that can be expressed in one sentence,
>> and I don't think it's been a problem.
>
> I'm confused -- I didn't say it was a problem, nor expressed any
> concern with the rule.  I just was pointing out facts.

I didn't say you said it was a problem.
It was just an offhand comment about the rule itself,
not anything you said.

> ISTM that the procedure here is to push this change first through
> the gcc repo first, and then merge it to binutils-gdb git.  Is that
> wrong?

That's the procedure as I understand it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 09/36] floatformat.h: Wrap in extern "C".
  2015-02-12 11:49       ` Pedro Alves
@ 2015-02-18 19:55         ` Jakub Jelinek
  0 siblings, 0 replies; 11+ messages in thread
From: Jakub Jelinek @ 2015-02-18 19:55 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Andrew Pinski, gdb-patches, GCC Patches

On Thu, Feb 12, 2015 at 11:49:01AM +0000, Pedro Alves wrote:
> On 02/09/2015 11:49 PM, Pedro Alves wrote:
> > On 02/09/2015 11:35 PM, Andrew Pinski wrote:
> >> On Mon, Feb 9, 2015 at 3:20 PM, Pedro Alves <palves@redhat.com> wrote:
> >>> Just like libiberty.h.  So that C++ programs, such as GDB when built
> >>> as a C++ program, can use it.
> >>
> >> Why is not needed for GCC building with C++ compiler?
> > 
> > Because it doesn't include it.
> > 
> > The header of the file claims it is part of GDB, though MAINTAINERS
> > nowadays says that everything under include/ is owned by GCC.
> 
> Here's an update that moves the extern "C" below the #include.
> 
> OK to push to the GCC repo?
> 
> From: Pedro Alves <palves@redhat.com>
> Subject: [PATCH] floatformat.h: Wrap in extern "C".
> 
> Just like libiberty.h.  So that C++ programs, such as GDB when built
> as a C++ program, can use it.
> 
> include/ChangeLog:
> 2015-02-12  Pedro Alves  <palves@redhat.com>
> 
> 	* floatformat.h [__cplusplus]: Wrap in extern "C".

Ok, thanks.

	Jakub

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it
  2015-02-09 23:20 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
  2015-02-09 23:35   ` Pedro Alves
@ 2015-02-27 16:58   ` Pedro Alves
  1 sibling, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2015-02-27 16:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: GCC Patches

On 02/09/2015 11:20 PM, Pedro Alves wrote:
> Converting GDB to be a C++ program, I stumbled on 'basename' issues,
> like:
> 

...
 
> So I thought of adding a m4 file that projects that use libiberty can
> source to pull in the autoconf checks that libiberty needs done in
> order to use its public headers.
> 
> Turns out that this has already happened.  Since I first wrote this a
> few months back, libiberty gained more HAVE_DECL_FOO checks even, for
> the strtol & friends replacements.
> 
> Are the libiberty changes OK?

I moved the libiberty.m4 patch to the gdb/ directory instead,
and pushed it, as below, in order to unblock the GDB C++ conversion
series, and make it easier for others to help with the
conversion as well.

I put a libiberty.m4 patch series here:

 https://github.com/palves/gdb/tree/palves/libiberty_m4

that converts gas, gold, ld, gdb and libiberty/ itself to
use libiberty/libiberty.m4.  If people think that's a good
idea, I can post it at some point.

----
From 07697489f4587e41f4f63aa526c1bd7d2fcd5494 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Fri, 27 Feb 2015 15:52:02 +0000
Subject: [PATCH] Create libiberty.m4, have GDB and GDBserver use it
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Converting GDB to be a C++ program, I stumbled on 'basename' issues,
like:

 src/gdb/../include/ansidecl.h:169:64: error: new declaration ‘char* basename(const char*)’
 /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’

which I believe led to this bit in gold's configure.ac:

 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])

These checks IIUC intend to generate all the HAVE_DECL_FOO symbols
that libiberty.h and ansidecl.h check.

GDB is missing these checks currently, which results in the conflict
shown above.

This adds an m4 file that both GDB and GDBserver's configury use to
pull in the autoconf checks that libiberty clients needs done in order
to use these libiberty.h/ansidecl.h.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* libiberty.m4: New file.
	* acinclude.m4: Include libiberty.m4.
	* configure.ac: Call libiberty_INIT.
	* config.in, configure: Regenerate.

gdb/gdbserver/
2015-02-27  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include libiberty.m4.
	* configure.ac: Call libiberty_INIT.
	* config.in, configure: Regenerate.
---
 gdb/ChangeLog              |   7 +
 gdb/gdbserver/ChangeLog    |   6 +
 gdb/acinclude.m4           |   3 +
 gdb/config.in              |  45 ++++++
 gdb/configure              | 269 +++++++++++++++++++++++++++--------
 gdb/configure.ac           |   2 +
 gdb/gdbserver/acinclude.m4 |   3 +
 gdb/gdbserver/config.in    |  41 ++++++
 gdb/gdbserver/configure    | 339 +++++++++++++++++++++++++++++++++++++++++++++
 gdb/gdbserver/configure.ac |   2 +
 gdb/libiberty.m4           |  31 +++++
 11 files changed, 694 insertions(+), 54 deletions(-)
 create mode 100644 gdb/libiberty.m4

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7d3b1ce..dfaad27 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-27  Pedro Alves  <palves@redhat.com>
+
+	* libiberty.m4: New file.
+	* acinclude.m4: Include libiberty.m4.
+	* configure.ac: Call libiberty_INIT.
+	* config.in, configure: Regenerate.
+
 2015-02-27  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
 	* s390-linux-tdep.c (s390_gcc_target_options): Not just handle
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 6bb8950..28b582f 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-27  Pedro Alves  <palves@redhat.com>
+
+	* acinclude.m4: Include libiberty.m4.
+	* configure.ac: Call libiberty_INIT.
+	* config.in, configure: Regenerate.
+
 2015-02-26  Pedro Alves  <palves@redhat.com>
 
 	* linux-low.c (linux_wait_1): When incrementing the PC past a
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 1f0b574..0ad90e7 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -57,6 +57,9 @@ sinclude([../config/zlib.m4])
 
 m4_include([common/common.m4])
 
+dnl For libiberty_INIT.
+m4_include(libiberty.m4)
+
 ## ----------------------------------------- ##
 ## ANSIfy the C compiler whenever possible.  ##
 ## From Franc,ois Pinard                     ##
diff --git a/gdb/config.in b/gdb/config.in
index 806cbac..4aaadb5 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -85,6 +85,17 @@
    you don't. */
 #undef HAVE_DECL_ADDR_NO_RANDOMIZE
 
+/* 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(char *)', 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
+
 /* Define to 1 if you have the declaration of `free', and to 0 if you don't.
    */
 #undef HAVE_DECL_FREE
@@ -117,6 +128,34 @@
    */
 #undef HAVE_DECL_STRSTR
 
+/* 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
+
+/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRVERSCMP
+
+/* 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
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
@@ -225,6 +264,9 @@
 /* Define to 1 if the compiler supports long double. */
 #undef HAVE_LONG_DOUBLE
 
+/* Define to 1 if the system has the type `long long'. */
+#undef HAVE_LONG_LONG
+
 /* Define if <sys/procfs.h> has lwpid_t. */
 #undef HAVE_LWPID_T
 
@@ -635,6 +677,9 @@
 /* The size of `long', as computed by sizeof. */
 #undef SIZEOF_LONG
 
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
 /* The size of `unsigned long', as computed by sizeof. */
 #undef SIZEOF_UNSIGNED_LONG
 

diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4
index 744871a..e5f4b76 100644
--- a/gdb/gdbserver/acinclude.m4
+++ b/gdb/gdbserver/acinclude.m4
@@ -20,6 +20,9 @@ dnl anything else in gdbserver.
 m4_include(../../config/codeset.m4)
 m4_include(../common/common.m4)
 
+dnl For libiberty_INIT.
+m4_include(../libiberty.m4)
+
 dnl Check for existence of a type $1 in libthread_db.h
 dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4.
 
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 8f68ed2..8114628 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -22,10 +22,25 @@
    you don't. */
 #undef HAVE_DECL_ADDR_NO_RANDOMIZE
 
+/* 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(char *)', 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
+
 /* Define to 1 if you have the declaration of `perror', and to 0 if you don't.
    */
 #undef HAVE_DECL_PERROR
 
+/* 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 `strerror', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRERROR
@@ -34,6 +49,26 @@
    */
 #undef HAVE_DECL_STRSTR
 
+/* 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
+
+/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRVERSCMP
+
 /* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_VASPRINTF
@@ -96,6 +131,9 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
+/* Define to 1 if the system has the type `long long'. */
+#undef HAVE_LONG_LONG
+
 /* Define if <thread_db.h> has lwpid_t. */
 #undef HAVE_LWPID_T
 
@@ -253,6 +291,9 @@
 /* Bug reporting address */
 #undef REPORT_BUGS_TO
 
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at runtime.

diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index f883adc..60636f7 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -193,6 +193,8 @@ LIBS="$LIBS -ldl"
 AC_CHECK_FUNCS(dladdr)
 LIBS="$old_LIBS"
 
+libiberty_INIT
+
 AC_CHECK_DECLS([strerror, perror, vasprintf, vsnprintf])
 
 AC_CHECK_TYPES(socklen_t, [], [],
diff --git a/gdb/libiberty.m4 b/gdb/libiberty.m4
new file mode 100644
index 0000000..5655e07
--- /dev/null
+++ b/gdb/libiberty.m4
@@ -0,0 +1,31 @@
+dnl Bits libiberty clients must do on their autoconf step.
+dnl
+dnl   Copyright (C) 2012-2015 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+dnl Checks for declarations ansidecl.h and libiberty.h themselves
+dnl check with HAVE_DECL_XXX, etc.
+
+AC_DEFUN([libiberty_INIT],
+[
+  # Check for presence and size of long long.
+  AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
+
+  AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
+  AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
+  AC_CHECK_DECLS([strverscmp])
+])
-- 
1.9.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-02-27 16:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1423524046-20605-1-git-send-email-palves@redhat.com>
2015-02-09 23:20 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
2015-02-09 23:35   ` Pedro Alves
2015-02-27 16:58   ` Pedro Alves
2015-02-09 23:21 ` [PATCH 09/36] floatformat.h: Wrap in extern "C" Pedro Alves
2015-02-09 23:35   ` Andrew Pinski
2015-02-09 23:49     ` Pedro Alves
2015-02-12 11:49       ` Pedro Alves
2015-02-18 19:55         ` Jakub Jelinek
2015-02-14 17:29       ` Doug Evans
2015-02-14 18:36         ` Pedro Alves
2015-02-14 22:46           ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).