diff --git a/cmake/bitcoin-build-config.h.in b/cmake/bitcoin-build-config.h.in index ef846fd0b7f..4783209ef77 100644 --- a/cmake/bitcoin-build-config.h.in +++ b/cmake/bitcoin-build-config.h.in @@ -55,13 +55,8 @@ */ #cmakedefine01 HAVE_DECL_FORK -/* Define to 1 if you have the declaration of `freeifaddrs', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_FREEIFADDRS - -/* Define to 1 if you have the declaration of `getifaddrs', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_GETIFADDRS +/* Define to 1 if '*ifaddrs' are available. */ +#cmakedefine HAVE_IFADDRS 1 /* Define to 1 if you have the declaration of `pipe2', and to 0 if you don't. */ diff --git a/cmake/introspection.cmake b/cmake/introspection.cmake index 3c95c31bd0f..e8538ae73cd 100644 --- a/cmake/introspection.cmake +++ b/cmake/introspection.cmake @@ -4,7 +4,6 @@ include(CheckCXXSourceCompiles) include(CheckCXXSymbolExists) -include(CheckIncludeFileCXX) check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC) check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC) @@ -12,9 +11,7 @@ check_cxx_symbol_exists(fork "unistd.h" HAVE_DECL_FORK) check_cxx_symbol_exists(pipe2 "unistd.h" HAVE_DECL_PIPE2) check_cxx_symbol_exists(setsid "unistd.h" HAVE_DECL_SETSID) -check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H) -check_include_file_cxx(ifaddrs.h HAVE_IFADDRS_H) -if(HAVE_SYS_TYPES_H AND HAVE_IFADDRS_H) +if(NOT WIN32) include(TestAppendRequiredLibraries) test_append_socket_library(core_interface) endif() diff --git a/cmake/module/TestAppendRequiredLibraries.cmake b/cmake/module/TestAppendRequiredLibraries.cmake index e15c2b9934d..1fc339a9541 100644 --- a/cmake/module/TestAppendRequiredLibraries.cmake +++ b/cmake/module/TestAppendRequiredLibraries.cmake @@ -38,8 +38,7 @@ function(test_append_socket_library target) message(FATAL_ERROR "Cannot figure out how to use getifaddrs/freeifaddrs.") endif() endif() - set(HAVE_DECL_GETIFADDRS TRUE PARENT_SCOPE) - set(HAVE_DECL_FREEIFADDRS TRUE PARENT_SCOPE) + set(HAVE_IFADDRS TRUE PARENT_SCOPE) endfunction() # Clang, when building for 32-bit, diff --git a/src/common/netif.cpp b/src/common/netif.cpp index 7bfec08fdd0..51a7522dbf5 100644 --- a/src/common/netif.cpp +++ b/src/common/netif.cpp @@ -29,6 +29,11 @@ #include #endif +#ifdef HAVE_IFADDRS +#include +#include +#endif + namespace { //! Return CNetAddr for the specified OS-level network address. @@ -325,7 +330,7 @@ std::vector GetLocalAddresses() } } } -#elif (HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS) +#elif defined(HAVE_IFADDRS) struct ifaddrs* myaddrs; if (getifaddrs(&myaddrs) == 0) { for (struct ifaddrs* ifa = myaddrs; ifa != nullptr; ifa = ifa->ifa_next) diff --git a/src/compat/compat.h b/src/compat/compat.h index 366c648ae72..05210b74bad 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -20,7 +20,6 @@ #else #include // IWYU pragma: export #include // IWYU pragma: export -#include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/src/net.cpp b/src/net.cpp index 66ded1041cd..13febcde442 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -41,10 +41,6 @@ #include #endif -#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS -#include -#endif - #include #include #include diff --git a/src/randomenv.cpp b/src/randomenv.cpp index fbab23afe94..84486b38ea6 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -38,7 +38,7 @@ #include #include #endif -#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS +#ifdef HAVE_IFADDRS #include #endif #ifdef HAVE_SYSCTL @@ -330,7 +330,7 @@ void RandAddStaticEnv(CSHA512& hasher) } #endif -#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS +#ifdef HAVE_IFADDRS // Network interfaces struct ifaddrs *ifad = nullptr; getifaddrs(&ifad);