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 55
55
*/
56
56
#cmakedefine01 HAVE_DECL_FORK
57
57
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
65
60
66
61
/* Define to 1 if you have the declaration of `pipe2', and to 0 if you don't.
67
62
*/
Original file line number Diff line number Diff line change 4
4
5
5
include (CheckCXXSourceCompiles )
6
6
include (CheckCXXSymbolExists )
7
- include (CheckIncludeFileCXX )
8
7
9
8
check_cxx_symbol_exists (O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC )
10
9
check_cxx_symbol_exists (fdatasync "unistd.h" HAVE_FDATASYNC )
11
10
check_cxx_symbol_exists (fork "unistd.h" HAVE_DECL_FORK )
12
11
check_cxx_symbol_exists (pipe2 "unistd.h" HAVE_DECL_PIPE2 )
13
12
check_cxx_symbol_exists (setsid "unistd.h" HAVE_DECL_SETSID )
14
13
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 )
18
15
include (TestAppendRequiredLibraries )
19
16
test_append_socket_library (core_interface )
20
17
endif ()
Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ function(test_append_socket_library target)
38
38
message (FATAL_ERROR "Cannot figure out how to use getifaddrs/freeifaddrs." )
39
39
endif ()
40
40
endif ()
41
- set (HAVE_DECL_GETIFADDRS TRUE PARENT_SCOPE )
42
- set (HAVE_DECL_FREEIFADDRS TRUE PARENT_SCOPE )
41
+ set (HAVE_IFADDRS TRUE PARENT_SCOPE )
43
42
endfunction ()
44
43
45
44
# Clang, when building for 32-bit,
Original file line number Diff line number Diff line change 29
29
#include < sys/sysctl.h>
30
30
#endif
31
31
32
+ #ifdef HAVE_IFADDRS
33
+ #include < sys/types.h>
34
+ #include < ifaddrs.h>
35
+ #endif
36
+
32
37
namespace {
33
38
34
39
// ! Return CNetAddr for the specified OS-level network address.
@@ -325,7 +330,7 @@ std::vector<CNetAddr> GetLocalAddresses()
325
330
}
326
331
}
327
332
}
328
- #elif (HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS )
333
+ #elif defined(HAVE_IFADDRS )
329
334
struct ifaddrs * myaddrs;
330
335
if (getifaddrs (&myaddrs) == 0 ) {
331
336
for (struct ifaddrs * ifa = myaddrs; ifa != nullptr ; ifa = ifa->ifa_next )
Original file line number Diff line number Diff line change 20
20
#else
21
21
#include < arpa/inet.h> // IWYU pragma: export
22
22
#include < fcntl.h> // IWYU pragma: export
23
- #include < ifaddrs.h> // IWYU pragma: export
24
23
#include < net/if.h> // IWYU pragma: export
25
24
#include < netdb.h> // IWYU pragma: export
26
25
#include < netinet/in.h> // IWYU pragma: export
Original file line number Diff line number Diff line change 41
41
#include < string.h>
42
42
#endif
43
43
44
- #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
45
- #include < ifaddrs.h>
46
- #endif
47
-
48
44
#include < algorithm>
49
45
#include < array>
50
46
#include < cmath>
Original file line number Diff line number Diff line change 38
38
#include < sys/utsname.h>
39
39
#include < unistd.h>
40
40
#endif
41
- #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
41
+ #ifdef HAVE_IFADDRS
42
42
#include < ifaddrs.h>
43
43
#endif
44
44
#ifdef HAVE_SYSCTL
@@ -330,7 +330,7 @@ void RandAddStaticEnv(CSHA512& hasher)
330
330
}
331
331
#endif
332
332
333
- #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
333
+ #ifdef HAVE_IFADDRS
334
334
// Network interfaces
335
335
struct ifaddrs *ifad = nullptr ;
336
336
getifaddrs (&ifad);
You can’t perform that action at this time.
0 commit comments