Skip to content

Commit 78aafdd

Browse files
committed
Get Android constants used by Channel from Bionic instead
Motivation: An upcoming pull, swiftlang/swift#35707, moves Android to the same single-header modulemap for Bionic as used on linux, but that doesn't work unless this is changed. This approach works both with the current release toolchain and with that new modulemap. Modifications: Change how these Bionic constants are imported. Result: This repo compiles for Android and the tests pass with both modulemap approaches.
1 parent c2cabf4 commit 78aafdd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/NIOCore/BSDSocketAPI.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ private let sysInet_ntop: @convention(c) (CInt, UnsafeRawPointer?, UnsafeMutable
6767
private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMutableRawPointer?) -> CInt = inet_pton
6868
#endif
6969

70-
// Work around SO_TIMESTAMP/SO_RCVTIMEO being awkwardly defined in glibc.
7170
#if os(Android)
72-
let IFF_BROADCAST: CUnsignedInt = numericCast(CNIOLinux.IFF_BROADCAST.rawValue)
73-
let IFF_POINTOPOINT: CUnsignedInt = numericCast(CNIOLinux.IFF_POINTOPOINT.rawValue)
74-
let IFF_MULTICAST: CUnsignedInt = numericCast(CNIOLinux.IFF_MULTICAST.rawValue)
71+
let IFF_BROADCAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_BROADCAST.rawValue)
72+
let IFF_POINTOPOINT: CUnsignedInt = numericCast(SwiftGlibc.IFF_POINTOPOINT.rawValue)
73+
let IFF_MULTICAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_MULTICAST.rawValue)
7574
#if arch(arm)
7675
let SO_RCVTIMEO = SO_RCVTIMEO_OLD
7776
let SO_TIMESTAMP = SO_TIMESTAMP_OLD
7877
#endif
7978
#elseif os(Linux)
79+
// Work around SO_TIMESTAMP/SO_RCVTIMEO being awkwardly defined in glibc.
8080
let SO_TIMESTAMP = CNIOLinux_SO_TIMESTAMP
8181
let SO_RCVTIMEO = CNIOLinux_SO_RCVTIMEO
8282
#endif

Sources/NIOPosix/System.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ let badOS = { fatalError("unsupported OS") }()
3636

3737
#if os(Android)
3838
let INADDR_ANY = UInt32(0) // #define INADDR_ANY ((unsigned long int) 0x00000000)
39-
let IFF_BROADCAST: CUnsignedInt = numericCast(CNIOLinux.IFF_BROADCAST.rawValue)
40-
let IFF_POINTOPOINT: CUnsignedInt = numericCast(CNIOLinux.IFF_POINTOPOINT.rawValue)
41-
let IFF_MULTICAST: CUnsignedInt = numericCast(CNIOLinux.IFF_MULTICAST.rawValue)
39+
let IFF_BROADCAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_BROADCAST.rawValue)
40+
let IFF_POINTOPOINT: CUnsignedInt = numericCast(SwiftGlibc.IFF_POINTOPOINT.rawValue)
41+
let IFF_MULTICAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_MULTICAST.rawValue)
4242
internal typealias in_port_t = UInt16
4343
extension ipv6_mreq { // http://lkml.iu.edu/hypermail/linux/kernel/0106.1/0080.html
4444
init (ipv6mr_multiaddr: in6_addr, ipv6mr_interface: UInt32) {

0 commit comments

Comments
 (0)