Skip to content

Commit 3a657c6

Browse files
Eli-Zaretskiibrobecke
authored andcommitted
libctf: Add configure check for asprintf (for MinGW)
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.
1 parent 7fddfec commit 3a657c6

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

libctf/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2020-02-05 Joel Brobecker <[email protected]>
2+
3+
PR binutils/25155:
4+
* configure.ac: Add AC_CHECK_DECLS([asprintf]).
5+
* configure, config.h.in: Regenerate.
6+
17
2020-01-01 Alan Modra <[email protected]>
28

39
Update year range in copyright notice of all files.

libctf/config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
/* Define to 1 if you have the <byteswap.h> header file. */
1010
#undef HAVE_BYTESWAP_H
1111

12+
/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
13+
don't. */
14+
#undef HAVE_DECL_ASPRINTF
15+
1216
/* Define to 1 if you have the <dlfcn.h> header file. */
1317
#undef HAVE_DLFCN_H
1418

libctf/configure

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,52 @@ $as_echo "$ac_res" >&6; }
18751875
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
18761876
18771877
} # ac_fn_c_check_func
1878+
1879+
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
1880+
# ---------------------------------------------
1881+
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
1882+
# accordingly.
1883+
ac_fn_c_check_decl ()
1884+
{
1885+
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1886+
as_decl_name=`echo $2|sed 's/ *(.*//'`
1887+
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
1888+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
1889+
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
1890+
if eval \${$3+:} false; then :
1891+
$as_echo_n "(cached) " >&6
1892+
else
1893+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1894+
/* end confdefs.h. */
1895+
$4
1896+
int
1897+
main ()
1898+
{
1899+
#ifndef $as_decl_name
1900+
#ifdef __cplusplus
1901+
(void) $as_decl_use;
1902+
#else
1903+
(void) $as_decl_name;
1904+
#endif
1905+
#endif
1906+
1907+
;
1908+
return 0;
1909+
}
1910+
_ACEOF
1911+
if ac_fn_c_try_compile "$LINENO"; then :
1912+
eval "$3=yes"
1913+
else
1914+
eval "$3=no"
1915+
fi
1916+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1917+
fi
1918+
eval ac_res=\$$3
1919+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1920+
$as_echo "$ac_res" >&6; }
1921+
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1922+
1923+
} # ac_fn_c_check_decl
18781924
cat >config.log <<_ACEOF
18791925
This file contains any messages produced by compilers while
18801926
running configure, to aid debugging if configure makes a mistake.
@@ -11385,7 +11431,7 @@ else
1138511431
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1138611432
lt_status=$lt_dlunknown
1138711433
cat > conftest.$ac_ext <<_LT_EOF
11388-
#line 11388 "configure"
11434+
#line 11434 "configure"
1138911435
#include "confdefs.h"
1139011436
1139111437
#if HAVE_DLFCN_H
@@ -11491,7 +11537,7 @@ else
1149111537
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1149211538
lt_status=$lt_dlunknown
1149311539
cat > conftest.$ac_ext <<_LT_EOF
11494-
#line 11494 "configure"
11540+
#line 11540 "configure"
1149511541
#include "confdefs.h"
1149611542
1149711543
#if HAVE_DLFCN_H
@@ -12971,6 +13017,18 @@ fi
1297113017
done
1297213018
1297313019
13020+
ac_fn_c_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default"
13021+
if test "x$ac_cv_have_decl_asprintf" = xyes; then :
13022+
ac_have_decl=1
13023+
else
13024+
ac_have_decl=0
13025+
fi
13026+
13027+
cat >>confdefs.h <<_ACEOF
13028+
#define HAVE_DECL_ASPRINTF $ac_have_decl
13029+
_ACEOF
13030+
13031+
1297413032
1297513033
1297613034

libctf/configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ AC_C_BIGENDIAN
9999
AC_CHECK_HEADERS(byteswap.h endian.h)
100100
AC_CHECK_FUNCS(pread)
101101

102+
AC_CHECK_DECLS([asprintf])
103+
102104
dnl Check for qsort_r. (Taken from gnulib.)
103105
AC_CHECK_FUNCS_ONCE([qsort_r])
104106
if test $ac_cv_func_qsort_r = yes; then

0 commit comments

Comments
 (0)