From patchwork Sun Jan 5 06:15:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 37202 Received: (qmail 41098 invoked by alias); 5 Jan 2020 06:15:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40995 invoked by uid 89); 5 Jan 2020 06:15:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=2020-01-05 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Jan 2020 06:15:25 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2DEC4116FAE; Sun, 5 Jan 2020 01:15:24 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id lr8Ff0dsAFpV; Sun, 5 Jan 2020 01:15:24 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id B3591116F97; Sun, 5 Jan 2020 01:15:23 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 52D3B838C8; Sun, 5 Jan 2020 10:15:19 +0400 (+04) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Eli Zaretskii Subject: [pushed/gdb-9-branch] libctf: Add configure check for asprintf (for MinGW) Date: Sun, 5 Jan 2020 10:15:17 +0400 Message-Id: <20200105061517.21874-2-brobecker@adacore.com> In-Reply-To: <20200105061517.21874-1-brobecker@adacore.com> References: <20200105061517.21874-1-brobecker@adacore.com> From: Eli Zaretskii Hello, This commit fixes a compilation warning when compiling libctf on MinGW: libctf/ctf-dump.c:118:8: warning: implicit declaration of function 'asprintf'; did you mean 'vasprintf'? [-Wimplicit-function-declaration] if (asprintf (&bit, " %lx: [slice 0x%x:0x%x]", ^~~~~~~~ vasprintf MinGW doesn't provide that function, so we depend on the one provided by libiberty. However, the declaration is guarded by HAVE_DECL_ASPRINTF, which we do not have in libctf's config.h. libctf/ChangeLog: PR binutils/25155: * configure.ac: Add AC_CHECK_DECLS([asprintf]). * configure, config.h.in: Regenerate. Backported from master, and pushed to gdb-9-branch. Thank you, diff --git a/libctf/ChangeLog b/libctf/ChangeLog index fc36bf2bdc4..5843cd92e1e 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,9 @@ +2020-01-05 Joel Brobecker + + PR binutils/25155: + * configure.ac: Add AC_CHECK_DECLS([asprintf]). + * configure, config.h.in: Regenerate. + 2020-01-05 Joel Brobecker * Makefile.in, aclocal.m4: Regenerate. diff --git a/libctf/config.h.in b/libctf/config.h.in index 4c8be4ab78a..264cbc3e49d 100644 --- a/libctf/config.h.in +++ b/libctf/config.h.in @@ -9,6 +9,10 @@ /* Define to 1 if you have the header file. */ #undef HAVE_BYTESWAP_H +/* 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 header file. */ #undef HAVE_DLFCN_H diff --git a/libctf/configure b/libctf/configure index 66b583fbbe7..e5493b31691 100755 --- a/libctf/configure +++ b/libctf/configure @@ -1875,6 +1875,52 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func + +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -11385,7 +11431,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11388 "configure" +#line 11434 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11491,7 +11537,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11494 "configure" +#line 11540 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12971,6 +13017,18 @@ fi done +ac_fn_c_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default" +if test "x$ac_cv_have_decl_asprintf" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ASPRINTF $ac_have_decl +_ACEOF + + diff --git a/libctf/configure.ac b/libctf/configure.ac index aa40e4e234b..9c71a270ce0 100644 --- a/libctf/configure.ac +++ b/libctf/configure.ac @@ -99,6 +99,8 @@ AC_C_BIGENDIAN AC_CHECK_HEADERS(byteswap.h endian.h) AC_CHECK_FUNCS(pread) +AC_CHECK_DECLS([asprintf]) + dnl Check for qsort_r. (Taken from gnulib.) AC_CHECK_FUNCS_ONCE([qsort_r]) if test $ac_cv_func_qsort_r = yes; then