Skip to content

Commit 0ca0348

Browse files
committed
Foundation: add missing and disambiguation imports
Add the missing imports for WinSDK and disambiguate the existing ones so resolve the issues identified when removing the SDK and using the `-vfsoverlay` flag to inject the overlay during the builds.
1 parent 6e3a6ac commit 0ca0348

10 files changed

+36
-11
lines changed

Sources/Foundation/Data.swift

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212

1313
#if DEPLOYMENT_RUNTIME_SWIFT
1414

15+
#if os(Windows)
16+
@usableFromInline let calloc = ucrt.calloc
17+
@usableFromInline let malloc = ucrt.malloc
18+
@usableFromInline let free = ucrt.free
19+
@usableFromInline let memset = ucrt.memset
20+
@usableFromInline let memcpy = ucrt.memcpy
21+
@usableFromInline let memcmp = ucrt.memcmp
22+
#endif
23+
1524
#if canImport(Glibc)
1625
@usableFromInline let calloc = Glibc.calloc
1726
@usableFromInline let malloc = Glibc.malloc

Sources/Foundation/FileHandle.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ fileprivate let _close = Glibc.close(_:)
2525
#endif
2626

2727
#if canImport(WinSDK)
28-
// We used to get the copy that was re-exported by CoreFoundation
29-
// but we want to explicitly depend on its types in this file,
30-
// so we need to make sure Swift doesn't think it's @_implementationOnly.
31-
import WinSDK
28+
import let WinSDK.INVALID_HANDLE_VALUE
29+
import struct WinSDK.HANDLE
3230
#endif
3331

3432
extension NSError {

Sources/Foundation/FileManager+Win32.swift

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
@_implementationOnly import CoreFoundation
1111

1212
#if os(Windows)
13+
import let WinSDK.INVALID_FILE_ATTRIBUTES
14+
import WinSDK
15+
1316
internal func joinPath(prefix: String, suffix: String) -> String {
1417
var pszPath: PWSTR?
1518

Sources/Foundation/FileManager.swift

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fileprivate let UF_HIDDEN: Int32 = 1
1818
@_implementationOnly import CoreFoundation
1919
#if os(Windows)
2020
import CRT
21+
import WinSDK
2122
#endif
2223

2324
#if os(Windows)

Sources/Foundation/Host.swift

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
//
99

1010
@_implementationOnly import CoreFoundation
11+
#if os(Windows)
12+
import WinSDK
13+
#endif
1114

1215
#if os(Android)
1316
// Android Glibc differs a little with respect to the Linux Glibc.

Sources/Foundation/NSPathUtilities.swift

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
//
99

1010
@_implementationOnly import CoreFoundation
11+
#if os(Windows)
12+
import WinSDK
13+
#endif
1114

1215
#if os(Windows)
1316
let validPathSeps: [Character] = ["\\", "/"]

Sources/Foundation/NSURL.swift

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010

1111
@_implementationOnly import CoreFoundation
12+
#if os(Windows)
13+
import WinSDK
14+
#endif
1215

1316
internal let kCFURLPOSIXPathStyle = CFURLPathStyle.cfurlposixPathStyle
1417
internal let kCFURLWindowsPathStyle = CFURLPathStyle.cfurlWindowsPathStyle

Sources/Foundation/Process.swift

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
//
99

1010
@_implementationOnly import CoreFoundation
11+
#if os(Windows)
12+
import WinSDK
13+
import let WinSDK.HANDLE_FLAG_INHERIT
14+
import let WinSDK.STARTF_USESTDHANDLES
15+
import struct WinSDK.HANDLE
16+
#endif
1117

1218
#if canImport(Darwin)
1319
import Darwin
1420
#endif
1521

16-
#if canImport(WinSDK)
17-
// We used to get the copy that was re-exported by CoreFoundation
18-
// but we want to explicitly depend on its types in this file,
19-
// so we need to make sure Swift doesn't think it's @_implementationOnly.
20-
import WinSDK
21-
#endif
22-
2322
extension Process {
2423
public enum TerminationReason : Int {
2524
case exit

Sources/Foundation/ProcessInfo.swift

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
//
99

1010
@_implementationOnly import CoreFoundation
11+
#if os(Windows)
12+
import WinSDK
13+
#endif
1114

1215
public struct OperatingSystemVersion {
1316
public var majorVersion: Int

Sources/Foundation/Thread.swift

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
//
99

1010
@_implementationOnly import CoreFoundation
11+
#if os(Windows)
12+
import WinSDK
13+
#endif
1114

1215
#if canImport(Glibc)
1316
import Glibc

0 commit comments

Comments
 (0)