Skip to content

Commit 8b06e8f

Browse files
authored
Fix the missing socket options for 32-bit. (#1918)
Motivation: When pulling out the NIOBSDSocket later in #1907 we dropped some of the socket option fixes for 32 bit platforms, which broke them. Modifications: Restore the socket options. Result: 32-bit build should be working again.
1 parent 4c0c5e5 commit 8b06e8f

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import PackageDescription
1717

1818
var targets: [PackageDescription.Target] = [
1919
.target(name: "NIOCore",
20-
dependencies: ["NIOConcurrencyHelpers"]),
20+
dependencies: ["NIOConcurrencyHelpers", "CNIOLinux"]),
2121
.target(name: "NIO",
2222
dependencies: ["CNIOLinux",
2323
"CNIODarwin",

Sources/NIO/System.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ extension ipv6_mreq { // http://lkml.iu.edu/hypermail/linux/kernel/0106.1/0080.h
4848
}
4949
}
5050
#if arch(arm)
51-
let SO_RCVTIMEO = SO_RCVTIMEO_OLD
52-
let SO_TIMESTAMP = SO_TIMESTAMP_OLD
5351
let S_IFSOCK = UInt32(SwiftGlibc.S_IFSOCK)
5452
let S_IFMT = UInt32(SwiftGlibc.S_IFMT)
5553
let S_IFREG = UInt32(SwiftGlibc.S_IFREG)
@@ -59,12 +57,6 @@ let S_IFBLK = UInt32(SwiftGlibc.S_IFBLK)
5957
#endif
6058
#endif
6159

62-
// Work around SO_TIMESTAMP/SO_RCVTIMEO being awkwardly defined in glibc.
63-
#if os(Linux)
64-
let SO_TIMESTAMP = CNIOLinux_SO_TIMESTAMP
65-
let SO_RCVTIMEO = CNIOLinux_SO_RCVTIMEO
66-
#endif
67-
6860
// Declare aliases to share more code and not need to repeat #if #else blocks
6961
#if !os(Windows)
7062
private let sysClose = close

Sources/NIOCore/BSDSocketAPI.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import func WinSDK.inet_ntop
5656
import func WinSDK.inet_pton
5757
#elseif os(Linux) || os(Android)
5858
import Glibc
59+
import CNIOLinux
5960

6061
private let sysInet_ntop: @convention(c) (CInt, UnsafeRawPointer?, UnsafeMutablePointer<CChar>?, socklen_t) -> UnsafePointer<CChar>? = inet_ntop
6162
private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMutableRawPointer?) -> CInt = inet_pton
@@ -66,6 +67,15 @@ private let sysInet_ntop: @convention(c) (CInt, UnsafeRawPointer?, UnsafeMutable
6667
private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMutableRawPointer?) -> CInt = inet_pton
6768
#endif
6869

70+
// Work around SO_TIMESTAMP/SO_RCVTIMEO being awkwardly defined in glibc.
71+
#if os(Android) && arch(arm)
72+
let SO_RCVTIMEO = SO_RCVTIMEO_OLD
73+
let SO_TIMESTAMP = SO_TIMESTAMP_OLD
74+
#elseif os(Linux)
75+
let SO_TIMESTAMP = CNIOLinux_SO_TIMESTAMP
76+
let SO_RCVTIMEO = CNIOLinux_SO_RCVTIMEO
77+
#endif
78+
6979
public enum NIOBSDSocket {
7080
#if os(Windows)
7181
public typealias Handle = SOCKET

0 commit comments

Comments
 (0)