Merge #14127: build: avoid getifaddrs when unavailable

9256f7d13f5b68ebc2981e8f45777f4bdc43f1b3 build: avoid getifaddrs when unavailable (Cory Fields)

Pull request description:

  These changes from @theuni help building when targeting platforms that don't always have getifaddrs available like Android < 24

Tree-SHA512: dbfeb83297bd6f00b7991f53eef8a04948d2d739bf47c0524d9ae5335b843b8a5c06ff98c109fe5e6192665e6d0cf58700b8aa7e2a0b410281d3c052881973ff
This commit is contained in:
Wladimir J. van der Laan 2018-09-10 18:07:53 +02:00 committed by pasta
parent 1d37f75cd1
commit deab1b0397
2 changed files with 5 additions and 1 deletions

View File

@ -819,6 +819,10 @@ fi
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h]) AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
AC_CHECK_DECLS([getifaddrs, freeifaddrs],,,
[#include <sys/types.h>
#include <ifaddrs.h>]
)
AC_CHECK_DECLS([strnlen]) AC_CHECK_DECLS([strnlen])
# Check for daemon(3), unrelated to --with-daemon (although used by it) # Check for daemon(3), unrelated to --with-daemon (although used by it)

View File

@ -2987,7 +2987,7 @@ void Discover()
} }
} }
} }
#else #elif (HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS)
// Get local host ip // Get local host ip
struct ifaddrs* myaddrs; struct ifaddrs* myaddrs;
if (getifaddrs(&myaddrs) == 0) if (getifaddrs(&myaddrs) == 0)