Merge #21616: [0.21] build: link against -lsocket if required for *ifaddrs
1a9a2cb7dcc60781a3cbca3a7846ff153143260c net: add ifaddrs.h include (fanquake) f6896dfde73bb37f4f0f0f9bfe9855d4fe9e9fe5 build: check if -lsocket is required with *ifaddrs (fanquake) e99d6d0c7cbdbb23f966e50c045bbd525ba8daf0 rand: only try and use freeifaddrs if available (fanquake) Pull request description: Backports #21486 to the 0.21 branch. Related to #21485. ACKs for top commit: MarcoFalke: cherry-pick-only ACK 1a9a2cb7dcc60781a3cbca3a7846ff153143260c did not test or review 🚶 Tree-SHA512: 400dcf0f0bffa9b2c820403936b894969113a2bd82a32ae29d3fb73c4ef9ffafb55f5325fcc4929f6e685f8932be6f566f5dd2163ecf8a64b154b0c401109311
This commit is contained in:
commit
0b9a046c1a
36
build-aux/m4/l_socket.m4
Normal file
36
build-aux/m4/l_socket.m4
Normal file
@ -0,0 +1,36 @@
|
||||
# Illumos/SmartOS requires linking with -lsocket if
|
||||
# using getifaddrs & freeifaddrs
|
||||
|
||||
m4_define([_CHECK_SOCKET_testbody], [[
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
|
||||
int main() {
|
||||
struct ifaddrs *ifaddr;
|
||||
getifaddrs(&ifaddr);
|
||||
freeifaddrs(ifaddr);
|
||||
}
|
||||
]])
|
||||
|
||||
AC_DEFUN([CHECK_SOCKET], [
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
|
||||
AC_MSG_CHECKING([whether ifaddrs funcs can be used without link library])
|
||||
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_SOCKET_testbody])],[
|
||||
AC_MSG_RESULT([yes])
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
LIBS="$LIBS -lsocket"
|
||||
AC_MSG_CHECKING([whether getifaddrs needs -lsocket])
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_SOCKET_testbody])],[
|
||||
AC_MSG_RESULT([yes])
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_FAILURE([cannot figure out how to use getifaddrs])
|
||||
])
|
||||
])
|
||||
|
||||
AC_LANG_POP
|
||||
])
|
||||
@ -866,7 +866,7 @@ 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 sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h])
|
||||
|
||||
AC_CHECK_DECLS([getifaddrs, freeifaddrs],,,
|
||||
AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],,
|
||||
[#include <sys/types.h>
|
||||
#include <ifaddrs.h>]
|
||||
)
|
||||
|
||||
@ -28,6 +28,10 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_POLL
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_DECL_GETIFADDRS
|
||||
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
#if HAVE_SYSCTL
|
||||
@ -361,7 +361,7 @@ void RandAddStaticEnv(CSHA512& hasher)
|
||||
hasher.Write((const unsigned char*)hname, strnlen(hname, 256));
|
||||
}
|
||||
|
||||
#if HAVE_DECL_GETIFADDRS
|
||||
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
|
||||
// Network interfaces
|
||||
struct ifaddrs *ifad = NULL;
|
||||
getifaddrs(&ifad);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user