Skip to content

Commit c491279

Browse files
authored
Merge pull request #803 from ikesyo/fix-osx-nshost-build
2 parents 5ba9b7c + 7bb68d0 commit c491279

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CoreFoundation/Base.subproj/SwiftRuntime/CoreFoundation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
#include <netdb.h> // for NSHost.swift
4444
#endif
4545

46+
#if __has_include(<ifaddrs.h>)
47+
#include <ifaddrs.h> // for NSHost.swift
48+
#endif
49+
4650
#if defined(__STDC_VERSION__) && (199901L <= __STDC_VERSION__)
4751

4852
#include <inttypes.h>

Foundation/NSHost.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ open class Host: NSObject {
7979
while let ifaValue = ifa?.pointee {
8080
if let ifa_addr = ifaValue.ifa_addr, ifaValue.ifa_flags & UInt32(IFF_LOOPBACK) == 0 {
8181
let family = ifa_addr.pointee.sa_family
82-
if family == UInt16(AF_INET) || family == UInt16(AF_INET6) {
83-
let sa_len: socklen_t = socklen_t((family == UInt16(AF_INET6)) ? MemoryLayout<sockaddr_in6>.size : MemoryLayout<sockaddr_in>.size)
82+
if family == sa_family_t(AF_INET) || family == sa_family_t(AF_INET6) {
83+
let sa_len: socklen_t = socklen_t((family == sa_family_t(AF_INET6)) ? MemoryLayout<sockaddr_in6>.size : MemoryLayout<sockaddr_in>.size)
8484
if getnameinfo(ifa_addr, sa_len, address, socklen_t(NI_MAXHOST), nil, 0, NI_NUMERICHOST) == 0 {
8585
_addresses.append(String(cString: address))
8686
}

0 commit comments

Comments
 (0)