Skip to content

Commit 448b832

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 8631602 commit 448b832

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 @@ fileprivate 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

@@ -85,9 +87,15 @@ private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMut
8587
#endif
8688

8789
#if os(Android)
90+
#if canImport(Android)
91+
let IFF_BROADCAST: CUnsignedInt = numericCast(Android.IFF_BROADCAST.rawValue)
92+
let IFF_POINTOPOINT: CUnsignedInt = numericCast(Android.IFF_POINTOPOINT.rawValue)
93+
let IFF_MULTICAST: CUnsignedInt = numericCast(Android.IFF_MULTICAST.rawValue)
94+
#else
8895
let IFF_BROADCAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_BROADCAST.rawValue)
8996
let IFF_POINTOPOINT: CUnsignedInt = numericCast(SwiftGlibc.IFF_POINTOPOINT.rawValue)
9097
let IFF_MULTICAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_MULTICAST.rawValue)
98+
#endif
9199
#if arch(arm)
92100
let SO_RCVTIMEO = SO_RCVTIMEO_OLD
93101
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
@@ -22,6 +22,8 @@ import WinSDK
2222
import Glibc
2323
#elseif canImport(Musl)
2424
import Musl
25+
#elseif canImport(Bionic)
26+
import Bionic
2527
#else
2628
#error("Unsupported C library")
2729
#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)