<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17875">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">BuildSystem: Fix misdetection of gethostbyname_r() on NetBSD<br><br>Fix the configure script not to detect the presence of gethostbyname_r()<br>on NetBSD incorrectly. NetBSD includes it as an internal libc symbol<br>that is not exposed in system headers and that is incompatible with<br>other implementations. In order to avoid misdetecting it, perform<br>the symbol check only if the declaration is found in the public header<br>first.<br><br>ASTERISK-29817<br><br>Change-Id: Iafa359b09908251bcd299ff54be003ea129b9eda<br>---<br>M configure<br>M configure.ac<br>2 files changed, 107 insertions(+), 28 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/75/17875/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configure b/configure</span><br><span>index e7ec180..b5bee2e 100755</span><br><span>--- a/configure</span><br><span>+++ b/configure</span><br><span>@@ -2922,6 +2922,52 @@</span><br><span> </span><br><span> } # ac_fn_c_check_member</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES</span><br><span style="color: hsl(120, 100%, 40%);">+# ---------------------------------------------</span><br><span style="color: hsl(120, 100%, 40%);">+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR</span><br><span style="color: hsl(120, 100%, 40%);">+# accordingly.</span><br><span style="color: hsl(120, 100%, 40%);">+ac_fn_c_check_decl ()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack</span><br><span style="color: hsl(120, 100%, 40%);">+ as_decl_name=`echo $2|sed 's/ *(.*//'`</span><br><span style="color: hsl(120, 100%, 40%);">+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+if eval \${$3+:} false; then :</span><br><span style="color: hsl(120, 100%, 40%);">+ $as_echo_n "(cached) " >&6</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext</span><br><span style="color: hsl(120, 100%, 40%);">+/* end confdefs.h. */</span><br><span style="color: hsl(120, 100%, 40%);">+$4</span><br><span style="color: hsl(120, 100%, 40%);">+int</span><br><span style="color: hsl(120, 100%, 40%);">+main ()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef $as_decl_name</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+ (void) $as_decl_use;</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+ (void) $as_decl_name;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ;</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+_ACEOF</span><br><span style="color: hsl(120, 100%, 40%);">+if ac_fn_c_try_compile "$LINENO"; then :</span><br><span style="color: hsl(120, 100%, 40%);">+ eval "$3=yes"</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ eval "$3=no"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+eval ac_res=\$$3</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "$ac_res" >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+} # ac_fn_c_check_decl</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES</span><br><span> # --------------------------------------------</span><br><span> # Tries to find the compile-time value of EXPR in a program that includes</span><br><span>@@ -17654,8 +17700,30 @@</span><br><span> rm -f core conftest.err conftest.$ac_objext \</span><br><span> conftest$ac_exeext conftest.$ac_ext</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c</span><br><span style="color: hsl(0, 100%, 40%);">-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+# NetBSD libc ships with an internal-only incompatible symbol gethostbyname_r</span><br><span style="color: hsl(120, 100%, 40%);">+ac_fn_c_check_decl "$LINENO" "gethostbyname_r" "ac_cv_have_decl_gethostbyname_r" "#include <stdlib.h></span><br><span style="color: hsl(120, 100%, 40%);">+ #include <netdb.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+"</span><br><span style="color: hsl(120, 100%, 40%);">+if test "x$ac_cv_have_decl_gethostbyname_r" = xyes; then :</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_have_decl=1</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_have_decl=0</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+cat >>confdefs.h <<_ACEOF</span><br><span style="color: hsl(120, 100%, 40%);">+#define HAVE_DECL_GETHOSTBYNAME_R $ac_have_decl</span><br><span style="color: hsl(120, 100%, 40%);">+_ACEOF</span><br><span style="color: hsl(120, 100%, 40%);">+if test $ac_have_decl = 1; then :</span><br><span style="color: hsl(120, 100%, 40%);">+ have_gethostbyname_r_public_declaration=yes</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ have_gethostbyname_r_public_declaration=no</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if test "x$have_gethostbyname_r_public_declaration" = "xyes"; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5</span><br><span> $as_echo_n "checking for library containing gethostbyname_r... " >&6; }</span><br><span> if ${ac_cv_search_gethostbyname_r+:} false; then :</span><br><span> $as_echo_n "(cached) " >&6</span><br><span>@@ -17712,12 +17780,12 @@</span><br><span> fi</span><br><span> </span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 6 arguments" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 6 arguments" >&5</span><br><span> $as_echo_n "checking for gethostbyname_r with 6 arguments... " >&6; }</span><br><span style="color: hsl(0, 100%, 40%);">-cat confdefs.h - <<_ACEOF >conftest.$ac_ext</span><br><span style="color: hsl(120, 100%, 40%);">+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext</span><br><span> /* end confdefs.h. */</span><br><span> #include <stdlib.h></span><br><span style="color: hsl(0, 100%, 40%);">- #include <netdb.h></span><br><span style="color: hsl(120, 100%, 40%);">+ #include <netdb.h></span><br><span> int</span><br><span> main ()</span><br><span> {</span><br><span>@@ -17740,12 +17808,12 @@</span><br><span> rm -f core conftest.err conftest.$ac_objext \</span><br><span> conftest$ac_exeext conftest.$ac_ext</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 5 arguments" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 5 arguments" >&5</span><br><span> $as_echo_n "checking for gethostbyname_r with 5 arguments... " >&6; }</span><br><span style="color: hsl(0, 100%, 40%);">-cat confdefs.h - <<_ACEOF >conftest.$ac_ext</span><br><span style="color: hsl(120, 100%, 40%);">+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext</span><br><span> /* end confdefs.h. */</span><br><span> #include <stdlib.h></span><br><span style="color: hsl(0, 100%, 40%);">- #include <netdb.h></span><br><span style="color: hsl(120, 100%, 40%);">+ #include <netdb.h></span><br><span> int</span><br><span> main ()</span><br><span> {</span><br><span>@@ -17767,6 +17835,7 @@</span><br><span> fi</span><br><span> rm -f core conftest.err conftest.$ac_objext \</span><br><span> conftest$ac_exeext conftest.$ac_ext</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span> </span><br><span> ac_fn_c_check_header_mongrel "$LINENO" "byteswap.h" "ac_cv_header_byteswap_h" "$ac_includes_default"</span><br><span> if test "x$ac_cv_header_byteswap_h" = xyes; then :</span><br><span>diff --git a/configure.ac b/configure.ac</span><br><span>index 355e2e0..9eb62b8 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -952,28 +952,38 @@</span><br><span> AC_MSG_RESULT(no)</span><br><span> )</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c</span><br><span style="color: hsl(0, 100%, 40%);">-AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)</span><br><span style="color: hsl(0, 100%, 40%);">-AC_LINK_IFELSE(</span><br><span style="color: hsl(0, 100%, 40%);">- [AC_LANG_PROGRAM([#include <stdlib.h></span><br><span style="color: hsl(0, 100%, 40%);">- #include <netdb.h>],</span><br><span style="color: hsl(0, 100%, 40%);">- [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);])],</span><br><span style="color: hsl(0, 100%, 40%);">- AC_MSG_RESULT(yes)</span><br><span style="color: hsl(0, 100%, 40%);">- AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),</span><br><span style="color: hsl(0, 100%, 40%);">- AC_MSG_RESULT(no)</span><br><span style="color: hsl(120, 100%, 40%);">+# NetBSD libc ships with an internal-only incompatible symbol gethostbyname_r</span><br><span style="color: hsl(120, 100%, 40%);">+AC_CHECK_DECLS([gethostbyname_r],</span><br><span style="color: hsl(120, 100%, 40%);">+ [have_gethostbyname_r_public_declaration=yes],</span><br><span style="color: hsl(120, 100%, 40%);">+ [have_gethostbyname_r_public_declaration=no],</span><br><span style="color: hsl(120, 100%, 40%);">+ [#include <stdlib.h></span><br><span style="color: hsl(120, 100%, 40%);">+ #include <netdb.h>]</span><br><span> )</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)</span><br><span style="color: hsl(0, 100%, 40%);">-AC_LINK_IFELSE(</span><br><span style="color: hsl(0, 100%, 40%);">- [AC_LANG_PROGRAM([#include <stdlib.h></span><br><span style="color: hsl(0, 100%, 40%);">- #include <netdb.h>],</span><br><span style="color: hsl(0, 100%, 40%);">- [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);])],</span><br><span style="color: hsl(0, 100%, 40%);">- AC_MSG_RESULT(yes)</span><br><span style="color: hsl(0, 100%, 40%);">- AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),</span><br><span style="color: hsl(0, 100%, 40%);">- AC_MSG_RESULT(no)</span><br><span style="color: hsl(0, 100%, 40%);">-)</span><br><span style="color: hsl(120, 100%, 40%);">+if test "x$have_gethostbyname_r_public_declaration" = "xyes"; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_LINK_IFELSE(</span><br><span style="color: hsl(120, 100%, 40%);">+ [AC_LANG_PROGRAM([#include <stdlib.h></span><br><span style="color: hsl(120, 100%, 40%);">+ #include <netdb.h>],</span><br><span style="color: hsl(120, 100%, 40%);">+ [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);])],</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(yes)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(no)</span><br><span style="color: hsl(120, 100%, 40%);">+ )</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_LINK_IFELSE(</span><br><span style="color: hsl(120, 100%, 40%);">+ [AC_LANG_PROGRAM([#include <stdlib.h></span><br><span style="color: hsl(120, 100%, 40%);">+ #include <netdb.h>],</span><br><span style="color: hsl(120, 100%, 40%);">+ [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);])],</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(yes)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(no)</span><br><span style="color: hsl(120, 100%, 40%);">+ )</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span> </span><br><span> AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17875">change 17875</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/17875"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Iafa359b09908251bcd299ff54be003ea129b9eda </div>
<div style="display:none"> Gerrit-Change-Number: 17875 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-CC: Michał Górny <mgorny@NetBSD.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>