From bb0116a433af6f2a1bb99b628a863be46446cea0 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 1 Sep 2010 18:56:45 +0000 Subject: Import vsnprintf from libiberty if not available. vasprintf and vsnprintf are not available on LynxOS, at least not on version 4.0.0. This patch updates the configury to import them from libiberty if not available out of the box. gdbserver/ * Makefile.in (vasprintf.o, vsnprintf.o): New rules. * configure.ac: Add check for vasprintf and vsnprintf. * configure, config.in: Regenerate. * server.h (vasprintf, vsnprintf): Add conditional declarations. --- gdb/gdbserver/ChangeLog | 7 +++++++ gdb/gdbserver/Makefile.in | 9 +++++++++ gdb/gdbserver/config.in | 14 ++++++++++++++ gdb/gdbserver/configure | 30 ++++++++++++++++++++++++++---- gdb/gdbserver/configure.ac | 4 ++-- gdb/gdbserver/server.h | 7 +++++++ 6 files changed, 65 insertions(+), 6 deletions(-) (limited to 'gdb') diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 71e878d..e6ab46f 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,12 @@ 2010-09-01 Joel Brobecker + * Makefile.in (vasprintf.o, vsnprintf.o): New rules. + * configure.ac: Add check for vasprintf and vsnprintf. + * configure, config.in: Regenerate. + * server.h (vasprintf, vsnprintf): Add conditional declarations. + +2010-09-01 Joel Brobecker + * gdbreplay.c: Move include of alloca.h up, next to include of malloc.h. * server.h: Add include of malloc.h. diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index 2f05c72..a12d895 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -357,6 +357,15 @@ signals.o: ../common/signals.c $(server_h) $(signals_def) memmem.o: ../gnulib/memmem.c $(CC) -o memmem.o -c $(CPPFLAGS) $(INTERNAL_WARN_CFLAGS) $< +# We build vasprintf with -DHAVE_CONFIG_H because we want that unit to +# include our config.h file. Otherwise, some system headers do not get +# included, and the compiler emits a warning about implicitly defined +# functions (missing declaration). +vasprintf.o: $(srcdir)/../../libiberty/vasprintf.c + $(CC) -o vasprintf.o -c $(CPPFLAGS) $(INTERNAL_CFLAGS) -DHAVE_CONFIG_H $< +vsnprintf.o: $(srcdir)/../../libiberty/vsnprintf.c + $(CC) -o vsnprintf.o -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< + i386_low_h = $(srcdir)/i386-low.h i386-low.o: i386-low.c $(i386_low_h) $(server_h) $(target_h) diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index a6a9704..909dcb9 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -30,6 +30,14 @@ don't. */ #undef HAVE_DECL_STRERROR +/* 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 `dladdr' function. */ #undef HAVE_DLADDR @@ -172,6 +180,12 @@ /* Define if UST is available */ #undef HAVE_UST +/* Define to 1 if you have the `vasprintf' function. */ +#undef HAVE_VASPRINTF + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + /* Checking if errno must be defined */ #undef MUST_DEFINE_ERRNO diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 05a4eba..957cbc8 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -4014,12 +4014,14 @@ _ACEOF fi done -for ac_func in memmem +for ac_func in memmem vasprintf vsnprintf do : - ac_fn_c_check_func "$LINENO" "memmem" "ac_cv_func_memmem" -if test "x$ac_cv_func_memmem" = x""yes; then : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_MEMMEM 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else @@ -4274,6 +4276,26 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MEMMEM $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" "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_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index bc3bb11..c61ab54 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -44,7 +44,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl netinet/tcp.h arpa/inet.h sys/wait.h) AC_CHECK_FUNCS(pread pwrite pread64) -AC_REPLACE_FUNCS(memmem) +AC_REPLACE_FUNCS(memmem vasprintf vsnprintf) # Check for UST ustlibs="" @@ -161,7 +161,7 @@ AC_TRY_LINK([ [AC_MSG_RESULT(no)]) fi -AC_CHECK_DECLS([strerror, perror, memmem]) +AC_CHECK_DECLS([strerror, perror, memmem, vasprintf, vsnprintf]) AC_CHECK_TYPES(socklen_t, [], [], [#include diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index d5f32e8..d007107 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -63,6 +63,13 @@ extern void perror (const char *); extern void *memmem (const void *, size_t , const void *, size_t); #endif +#if !HAVE_DECL_VASPRINTF +extern int vasprintf(char **strp, const char *fmt, va_list ap); +#endif +#if !HAVE_DECL_VSNPRINTF +int vsnprintf(char *str, size_t size, const char *format, va_list ap); +#endif + #ifndef ATTR_NORETURN #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) #define ATTR_NORETURN __attribute__ ((noreturn)) -- cgit v1.1