File tree Expand file tree Collapse file tree 7 files changed +12
-21
lines changed
Expand file tree Collapse file tree 7 files changed +12
-21
lines changed Original file line number Diff line number Diff line change 5555 */
5656#cmakedefine01 HAVE_DECL_FORK
5757
58- /* Define to 1 if you have the declaration of `freeifaddrs', and to 0 if you
59- don't. */
60- #cmakedefine01 HAVE_DECL_FREEIFADDRS
61-
62- /* Define to 1 if you have the declaration of `getifaddrs', and to 0 if you
63- don't. */
64- #cmakedefine01 HAVE_DECL_GETIFADDRS
58+ /* Define to 1 if '*ifaddrs' are available. */
59+ #cmakedefine HAVE_IFADDRS 1
6560
6661/* Define to 1 if you have the declaration of `pipe2', and to 0 if you don't.
6762 */
Original file line number Diff line number Diff line change 44
55include (CheckCXXSourceCompiles)
66include (CheckCXXSymbolExists)
7- include (CheckIncludeFileCXX)
87
98check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
109check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
1110check_cxx_symbol_exists(fork "unistd.h" HAVE_DECL_FORK)
1211check_cxx_symbol_exists(pipe2 "unistd.h" HAVE_DECL_PIPE2)
1312check_cxx_symbol_exists(setsid "unistd.h" HAVE_DECL_SETSID)
1413
15- check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
16- check_include_file_cxx(ifaddrs.h HAVE_IFADDRS_H)
17- if (HAVE_SYS_TYPES_H AND HAVE_IFADDRS_H)
14+ if (NOT WIN32 )
1815 include (TestAppendRequiredLibraries)
1916 test_append_socket_library(core_interface)
2017endif ()
Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ function(test_append_socket_library target)
3838 message (FATAL_ERROR "Cannot figure out how to use getifaddrs/freeifaddrs." )
3939 endif ()
4040 endif ()
41- set (HAVE_DECL_GETIFADDRS TRUE PARENT_SCOPE)
42- set (HAVE_DECL_FREEIFADDRS TRUE PARENT_SCOPE)
41+ set (HAVE_IFADDRS TRUE PARENT_SCOPE)
4342endfunction ()
4443
4544# Clang, when building for 32-bit,
Original file line number Diff line number Diff line change 2929#include < sys/sysctl.h>
3030#endif
3131
32+ #ifdef HAVE_IFADDRS
33+ #include < sys/types.h>
34+ #include < ifaddrs.h>
35+ #endif
36+
3237namespace {
3338
3439// ! Return CNetAddr for the specified OS-level network address.
@@ -325,7 +330,7 @@ std::vector<CNetAddr> GetLocalAddresses()
325330 }
326331 }
327332 }
328- #elif (HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS )
333+ #elif defined(HAVE_IFADDRS )
329334 struct ifaddrs * myaddrs;
330335 if (getifaddrs (&myaddrs) == 0 ) {
331336 for (struct ifaddrs * ifa = myaddrs; ifa != nullptr ; ifa = ifa->ifa_next )
Original file line number Diff line number Diff line change 2020#else
2121#include < arpa/inet.h> // IWYU pragma: export
2222#include < fcntl.h> // IWYU pragma: export
23- #include < ifaddrs.h> // IWYU pragma: export
2423#include < net/if.h> // IWYU pragma: export
2524#include < netdb.h> // IWYU pragma: export
2625#include < netinet/in.h> // IWYU pragma: export
Original file line number Diff line number Diff line change 4141#include < string.h>
4242#endif
4343
44- #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
45- #include < ifaddrs.h>
46- #endif
47-
4844#include < algorithm>
4945#include < array>
5046#include < cmath>
Original file line number Diff line number Diff line change 3838#include < sys/utsname.h>
3939#include < unistd.h>
4040#endif
41- #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
41+ #ifdef HAVE_IFADDRS
4242#include < ifaddrs.h>
4343#endif
4444#ifdef HAVE_SYSCTL
@@ -330,7 +330,7 @@ void RandAddStaticEnv(CSHA512& hasher)
330330 }
331331#endif
332332
333- #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
333+ #ifdef HAVE_IFADDRS
334334 // Network interfaces
335335 struct ifaddrs *ifad = nullptr ;
336336 getifaddrs (&ifad);
You can’t perform that action at this time.
0 commit comments