Skip to content

Commit cd69948

Browse files
authored
Merge pull request #22 from PureSwift/feature/android-armv7
Add support for Android armv7
2 parents 85fdcac + 55c898c commit cd69948

11 files changed

Lines changed: 33 additions & 31 deletions

.github/workflows/swift.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
name: Linux
2424
strategy:
2525
matrix:
26-
container: ["swift:6.0.3", "swift:6.1.2"]
26+
container: ["swift:6.0.3", "swift:6.1.2", "swift:6.2.3"]
2727
config: ["debug", "release"]
2828
options: ["", "SWIFT_BUILD_DYNAMIC_LIBRARY=1"]
2929
runs-on: ubuntu-latest
@@ -41,8 +41,8 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
swift: ['6.1', 'nightly-6.2']
45-
arch: ["aarch64", "x86_64"]
44+
swift: ['6.2.3', 'nightly-6.3']
45+
arch: ['aarch64', 'x86_64', 'armv7']
4646
runs-on: macos-15
4747
timeout-minutes: 30
4848
steps:

Sources/Socket/System/CInternetAddress.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal extension String {
3838
T.family.rawValue,
3939
$0,
4040
cString,
41-
numericCast(T.stringLength)
41+
CInterop.SocketLength(T.stringLength)
4242
) != nil
4343
}
4444
guard success else {

Sources/Socket/System/CInterop.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public extension CInterop {
5454
typealias SocketType = CInt
5555
#endif
5656

57+
typealias SocketLength = socklen_t
58+
5759
/// The C `addrinfo` type
5860
typealias AddressInfo = addrinfo
5961

Sources/Socket/System/CSocketAddress.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ internal protocol CSocketAddress {
1010
internal extension CSocketAddress {
1111

1212
func withUnsafePointer<Result>(
13-
_ body: (UnsafePointer<CInterop.SocketAddress>, UInt32) throws -> Result
13+
_ body: (UnsafePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> Result
1414
) rethrows -> Result {
1515
return try Swift.withUnsafeBytes(of: self) {
16-
return try body($0.baseAddress!.assumingMemoryBound(to: CInterop.SocketAddress.self), UInt32(MemoryLayout<Self>.size))
16+
return try body($0.baseAddress!.assumingMemoryBound(to: CInterop.SocketAddress.self), CInterop.SocketLength(MemoryLayout<Self>.size))
1717
}
1818
}
1919

2020
mutating func withUnsafeMutablePointer<Result>(
21-
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, UInt32) throws -> Result
21+
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> Result
2222
) rethrows -> Result {
2323
return try Swift.withUnsafeMutableBytes(of: &self) {
24-
return try body($0.baseAddress!.assumingMemoryBound(to: CInterop.SocketAddress.self), UInt32(MemoryLayout<Self>.size))
24+
return try body($0.baseAddress!.assumingMemoryBound(to: CInterop.SocketAddress.self), CInterop.SocketLength(MemoryLayout<Self>.size))
2525
}
2626
}
2727
}

Sources/Socket/System/SocketAddress.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ public protocol SocketAddress: Sendable {
88

99
/// Unsafe pointer closure
1010
func withUnsafePointer<Result, Error>(
11-
_ body: (UnsafePointer<CInterop.SocketAddress>, UInt32) throws(Error) -> Result
11+
_ body: (UnsafePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws(Error) -> Result
1212
) rethrows -> Result where Error: Swift.Error
1313

1414
static func withUnsafePointer(
1515
_ pointer: UnsafeMutablePointer<CInterop.SocketAddress>
1616
) -> Self
1717

1818
static func withUnsafePointer(
19-
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, UInt32) throws -> ()
19+
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> ()
2020
) rethrows -> Self
2121
}
2222

Sources/Socket/System/SocketAddress/IPv4SocketAddress.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public struct IPv4SocketAddress: SocketAddress, Equatable, Hashable {
3232
}
3333

3434
public func withUnsafePointer<Result, Error>(
35-
_ body: (UnsafePointer<CInterop.SocketAddress>, UInt32) throws(Error) -> Result
35+
_ body: (UnsafePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws(Error) -> Result
3636
) rethrows -> Result where Error: Swift.Error {
3737

3838
var socketAddress = CInterop.IPv4SocketAddress()
@@ -51,7 +51,7 @@ public struct IPv4SocketAddress: SocketAddress, Equatable, Hashable {
5151
}
5252

5353
public static func withUnsafePointer(
54-
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, UInt32) throws -> ()
54+
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> ()
5555
) rethrows -> Self {
5656
var socketAddress = CInterop.IPv4SocketAddress()
5757
try socketAddress.withUnsafeMutablePointer(body)

Sources/Socket/System/SocketAddress/IPv6SocketAddress.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public struct IPv6SocketAddress: SocketAddress, Equatable, Hashable {
3232
}
3333

3434
public func withUnsafePointer<Result, Error>(
35-
_ body: (UnsafePointer<CInterop.SocketAddress>, UInt32) throws(Error) -> Result
35+
_ body: (UnsafePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws(Error) -> Result
3636
) rethrows -> Result where Error: Swift.Error {
3737

3838
var socketAddress = CInterop.IPv6SocketAddress()
@@ -51,7 +51,7 @@ public struct IPv6SocketAddress: SocketAddress, Equatable, Hashable {
5151
}
5252

5353
public static func withUnsafePointer(
54-
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, UInt32) throws -> ()
54+
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> ()
5555
) rethrows -> Self {
5656
var socketAddress = CInterop.IPv6SocketAddress()
5757
try socketAddress.withUnsafeMutablePointer(body)

Sources/Socket/System/SocketAddress/LinkLayerSocketAddress.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public struct LinkLayerSocketAddress: SocketAddress, Equatable, Hashable {
5151
}
5252

5353
public func withUnsafePointer<Result, Error>(
54-
_ body: (UnsafePointer<CInterop.SocketAddress>, UInt32) throws(Error) -> Result
54+
_ body: (UnsafePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws(Error) -> Result
5555
) rethrows -> Result where Error: Swift.Error {
5656

5757
var socketAddress = CSocketAddressType()
@@ -76,7 +76,7 @@ public struct LinkLayerSocketAddress: SocketAddress, Equatable, Hashable {
7676
}
7777

7878
public static func withUnsafePointer(
79-
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, UInt32) throws -> ()
79+
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> ()
8080
) rethrows -> Self {
8181
var socketAddress = CSocketAddressType()
8282
try socketAddress.withUnsafeMutablePointer(body)

Sources/Socket/System/SocketAddress/UnixSocketAddress.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct UnixSocketAddress: SocketAddress, Equatable, Hashable {
2727
}
2828

2929
public func withUnsafePointer<Result, Error>(
30-
_ body: (UnsafePointer<CInterop.SocketAddress>, UInt32) throws(Error) -> Result
30+
_ body: (UnsafePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws(Error) -> Result
3131
) rethrows -> Result where Error: Swift.Error {
3232
return try path.withPlatformString { platformString in
3333
var socketAddress = CInterop.UnixSocketAddress()
@@ -43,7 +43,7 @@ public struct UnixSocketAddress: SocketAddress, Equatable, Hashable {
4343
}
4444

4545
public static func withUnsafePointer(
46-
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, UInt32) throws -> ()
46+
_ body: (UnsafeMutablePointer<CInterop.SocketAddress>, CInterop.SocketLength) throws -> ()
4747
) rethrows -> Self {
4848
var socketAddress = CInterop.UnixSocketAddress()
4949
try socketAddress.withUnsafeMutablePointer(body)
@@ -64,4 +64,4 @@ extension CInterop.UnixSocketAddress: CSocketAddress {
6464
@_alwaysEmitIntoClient
6565
static var family: SocketAddressFamily { .unix }
6666
}
67-
#endif
67+
#endif

Sources/Socket/System/SocketOperations.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ extension SocketDescriptor {
179179
) -> Result<(), Errno> {
180180
nothingOrErrno(retryOnInterrupt: retryOnInterrupt) {
181181
option.withUnsafeBytes { bufferPointer in
182-
system_setsockopt(self.rawValue, Option.ID.optionLevel.rawValue, Option.id.rawValue, bufferPointer.baseAddress!, UInt32(bufferPointer.count))
182+
system_setsockopt(self.rawValue, Option.ID.optionLevel.rawValue, Option.id.rawValue, bufferPointer.baseAddress!, CInterop.SocketLength(bufferPointer.count))
183183
}
184184
}
185185
}
@@ -208,7 +208,7 @@ extension SocketDescriptor {
208208
) -> Result<Option, Errno> {
209209
do {
210210
let value = try Option.withUnsafeBytes { bufferPointer throws(Errno) -> () in
211-
var length = UInt32(bufferPointer.count)
211+
var length = CInterop.SocketLength(bufferPointer.count)
212212
guard system_getsockopt(self.rawValue, Option.ID.optionLevel.rawValue, Option.id.rawValue, bufferPointer.baseAddress!, &length) != -1 else {
213213
throw Errno.current
214214
}
@@ -498,7 +498,7 @@ extension SocketDescriptor {
498498
internal func _accept(
499499
retryOnInterrupt: Bool
500500
) -> Result<SocketDescriptor, Errno> {
501-
var length: UInt32 = 0
501+
var length: CInterop.SocketLength = 0
502502
return valueOrErrno(retryOnInterrupt: retryOnInterrupt) {
503503
system_accept(self.rawValue, nil, &length)
504504
}.map(SocketDescriptor.init(rawValue:))

0 commit comments

Comments
 (0)