From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 301 invoked by alias); 27 Jun 2013 08:44:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 32713 invoked by uid 89); 27 Jun 2013 08:44:44 -0000 X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,TW_RV,TW_TR,TW_XS autolearn=ham version=3.3.1 Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 27 Jun 2013 08:44:43 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 27 Jun 2013 01:44:43 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 27 Jun 2013 01:44:41 -0700 Received: from ulslx001.iul.intel.com (ulslx001.iul.intel.com [172.28.207.63]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id r5R8ie8F009509; Thu, 27 Jun 2013 09:44:40 +0100 Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id r5R8iekM003470; Thu, 27 Jun 2013 10:44:40 +0200 Received: (from mgherza1@localhost) by ulslx001.iul.intel.com with id r5R8ieXP003466; Thu, 27 Jun 2013 10:44:40 +0200 From: Mircea Gherzan To: tromey@redhat.com, palves@redhat.com, jan.kratochvil@redhat.com Cc: gdb-patches@sourceware.org, Mircea Gherzan Subject: [PATCH 6/7] common: add an alternative implementation for xstrvprintf Date: Thu, 27 Jun 2013 08:44:00 -0000 Message-Id: <1372322622-3216-7-git-send-email-mircea.gherzan@intel.com> In-Reply-To: <1372322622-3216-1-git-send-email-mircea.gherzan@intel.com> References: <1372322622-3216-1-git-send-email-mircea.gherzan@intel.com> X-SW-Source: 2013-06/txt/msg00811.txt.bz2 The vasprintf(), used by the current implementation, is a GNU extension. 2013-06-25 Mircea Gherzan * configure.ac (AC_CHECK_FUNCS): Add vasprintf. * config.in: Rebuild. * configure: Rebuild. * common/common-utils.c (xstrvprintf): Add an alternative implementation that uses vsnprintf. Signed-off-by: Mircea Gherzan --- gdb/common/common-utils.c | 30 ++++++++++++++++++++++++++++++ gdb/config.in | 3 +++ gdb/configure | 2 +- gdb/configure.ac | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c index 4204abf..e4f1fda 100644 --- a/gdb/common/common-utils.c +++ b/gdb/common/common-utils.c @@ -123,6 +123,8 @@ xstrprintf (const char *format, ...) return ret; } +#ifdef HAVE_VASPRINTF + char * xstrvprintf (const char *format, va_list ap) { @@ -138,6 +140,34 @@ xstrvprintf (const char *format, va_list ap) return ret; } +#else + +char * +xstrvprintf (const char *format, va_list ap) +{ + char *buf; + int size; + size_t format_len; + + format_len = strlen (format); + buf = xmalloc (format_len + 1); + size = vsnprintf (buf, format_len + 1, format, ap); + + if (size > (int)format_len) + { + /* The original size might not be enough. */ + buf = xrealloc (buf, size + 1); + size = vsnprintf (buf, size + 1, format, ap); + } + + if (size < 0) + internal_error (__FILE__, __LINE__, _("vsnprintf call failed")); + + return buf; +} + +#endif + int xsnprintf (char *str, size_t size, const char *format, ...) { diff --git a/gdb/config.in b/gdb/config.in index 7cd22e3..78e4534 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -554,6 +554,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `vasprintf' function. */ +#undef HAVE_VASPRINTF + /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK diff --git a/gdb/configure b/gdb/configure index 383d634..003e591 100755 --- a/gdb/configure +++ b/gdb/configure @@ -10178,7 +10178,7 @@ for ac_func in canonicalize_file_name realpath getrusage getuid getgid \ sigaction sigprocmask sigsetmask socketpair syscall \ ttrace wborder wresize setlocale iconvlist libiconvlist btowc \ setrlimit getrlimit posix_madvise waitpid lstat \ - fdwalk pipe2 + fdwalk pipe2 vasprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/gdb/configure.ac b/gdb/configure.ac index 46a97bd..ffd790f 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1180,7 +1180,7 @@ AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid getgid \ sigaction sigprocmask sigsetmask socketpair syscall \ ttrace wborder wresize setlocale iconvlist libiconvlist btowc \ setrlimit getrlimit posix_madvise waitpid lstat \ - fdwalk pipe2]) + fdwalk pipe2 vasprintf]) AM_LANGINFO_CODESET # Check the return and argument types of ptrace. No canned test for -- 1.7.12.4