Skip to content

Commit 17d1def

Browse files
committed
Use the new Android overlay and Bionic module from Swift 6
Motivation: Get this repo building again for Android with the new overlay Modifications: - Import the new module or overlay wherever `Glibc` is used - Keep this repo building with Swift 5 by duplicating some declarations Result: All the same tests keep passing on my Android CI, finagolfin/swift-android-sdk#158
1 parent 2841257 commit 17d1def

33 files changed

+164
-43
lines changed

Sources/NIOConcurrencyHelpers/NIOLock.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import WinSDK
2121
import Glibc
2222
#elseif canImport(Musl)
2323
import Musl
24+
#elseif canImport(Bionic)
25+
import Bionic
2426
#else
2527
#error("The concurrency NIOLock module was unable to identify your C library.")
2628
#endif

Sources/NIOConcurrencyHelpers/atomics.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ private func sys_sched_yield() {
3030
import Glibc
3131
#elseif canImport(Musl)
3232
import Musl
33+
#elseif canImport(Bionic)
34+
import Bionic
3335
#else
3436
#error("The concurrency atomics module was unable to identify your C library.")
3537
#endif

Sources/NIOConcurrencyHelpers/lock.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import WinSDK
2121
import Glibc
2222
#elseif canImport(Musl)
2323
import Musl
24+
#elseif canImport(Bionic)
25+
import Bionic
2426
#else
2527
#error("The concurrency lock module was unable to identify your C library.")
2628
#endif

Sources/NIOCore/BSDSocketAPI.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ internal typealias socklen_t = ucrt.size_t
6565
import Glibc
6666
#elseif canImport(Musl)
6767
import Musl
68+
#elseif canImport(Android)
69+
import Android
6870
#endif
6971
import CNIOLinux
7072

@@ -90,9 +92,15 @@ private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMut
9092
#endif
9193

9294
#if os(Android)
95+
#if compiler(>=6.0)
96+
let IFF_BROADCAST: CUnsignedInt = numericCast(Android.IFF_BROADCAST.rawValue)
97+
let IFF_POINTOPOINT: CUnsignedInt = numericCast(Android.IFF_POINTOPOINT.rawValue)
98+
let IFF_MULTICAST: CUnsignedInt = numericCast(Android.IFF_MULTICAST.rawValue)
99+
#else
93100
let IFF_BROADCAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_BROADCAST.rawValue)
94101
let IFF_POINTOPOINT: CUnsignedInt = numericCast(SwiftGlibc.IFF_POINTOPOINT.rawValue)
95102
let IFF_MULTICAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_MULTICAST.rawValue)
103+
#endif
96104
#if arch(arm)
97105
let SO_RCVTIMEO = SO_RCVTIMEO_OLD
98106
let SO_TIMESTAMP = SO_TIMESTAMP_OLD

Sources/NIOCore/ByteBuffer-core.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import Darwin
2020
import Glibc
2121
#elseif canImport(Musl)
2222
import Musl
23+
#elseif canImport(Bionic)
24+
import Bionic
2325
#else
2426
#error("The Byte Buffer module was unable to identify your C library.")
2527
#endif

Sources/NIOCore/FileHandle.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import Darwin
1919
import Glibc
2020
#elseif canImport(Musl)
2121
import Musl
22+
#elseif canImport(Android)
23+
import Android
2224
#else
2325
#error("The File Handle module was unable to identify your C library.")
2426
#endif

Sources/NIOCore/FileRegion.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import Darwin
1919
import Glibc
2020
#elseif canImport(Musl)
2121
import Musl
22+
#elseif canImport(Bionic)
23+
import Bionic
2224
#else
2325
#error("The File Region module was unable to identify your C library.")
2426
#endif

Sources/NIOCore/GlobalSingletons.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import WinSDK
2323
import Glibc
2424
#elseif canImport(Musl)
2525
import Musl
26+
#elseif canImport(Bionic)
27+
import Bionic
2628
#else
2729
#error("Unsupported C library")
2830
#endif

Sources/NIOCore/IO.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ internal func MAKELANGID(_ p: WORD, _ s: WORD) -> DWORD {
3232
import Glibc
3333
#elseif canImport(Musl)
3434
import Musl
35+
#elseif canImport(Bionic)
36+
import Bionic
3537
#elseif canImport(Darwin)
3638
import Darwin
3739
#else

Sources/NIOCore/Interfaces.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import Glibc
1717
#elseif canImport(Musl)
1818
import Musl
19+
#elseif canImport(Bionic)
20+
import Bionic
1921
#endif
2022
import CNIOLinux
2123
#elseif canImport(Darwin)

0 commit comments

Comments
 (0)