Skip to content

Foundation: add missing and disambiguation imports #4711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@

#if DEPLOYMENT_RUNTIME_SWIFT

#if os(Windows)
@usableFromInline let calloc = ucrt.calloc
@usableFromInline let malloc = ucrt.malloc
@usableFromInline let free = ucrt.free
@usableFromInline let memset = ucrt.memset
@usableFromInline let memcpy = ucrt.memcpy
@usableFromInline let memcmp = ucrt.memcmp
#endif

#if canImport(Glibc)
@usableFromInline let calloc = Glibc.calloc
@usableFromInline let malloc = Glibc.malloc
Expand Down
6 changes: 2 additions & 4 deletions Sources/Foundation/FileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ fileprivate let _close = Glibc.close(_:)
#endif

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

extension NSError {
Expand Down
3 changes: 3 additions & 0 deletions Sources/Foundation/FileManager+Win32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
@_implementationOnly import CoreFoundation

#if os(Windows)
import let WinSDK.INVALID_FILE_ATTRIBUTES
import WinSDK

internal func joinPath(prefix: String, suffix: String) -> String {
var pszPath: PWSTR?

Expand Down
1 change: 1 addition & 0 deletions Sources/Foundation/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fileprivate let UF_HIDDEN: Int32 = 1
@_implementationOnly import CoreFoundation
#if os(Windows)
import CRT
import WinSDK
#endif

#if os(Windows)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Foundation/Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//

@_implementationOnly import CoreFoundation
#if os(Windows)
import WinSDK
#endif

#if os(Android)
// Android Glibc differs a little with respect to the Linux Glibc.
Expand Down
3 changes: 3 additions & 0 deletions Sources/Foundation/NSPathUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//

@_implementationOnly import CoreFoundation
#if os(Windows)
import WinSDK
#endif

#if os(Windows)
let validPathSeps: [Character] = ["\\", "/"]
Expand Down
3 changes: 3 additions & 0 deletions Sources/Foundation/NSURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@


@_implementationOnly import CoreFoundation
#if os(Windows)
import WinSDK
#endif

internal let kCFURLPOSIXPathStyle = CFURLPathStyle.cfurlposixPathStyle
internal let kCFURLWindowsPathStyle = CFURLPathStyle.cfurlWindowsPathStyle
Expand Down
13 changes: 6 additions & 7 deletions Sources/Foundation/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
//

@_implementationOnly import CoreFoundation
#if os(Windows)
import WinSDK
import let WinSDK.HANDLE_FLAG_INHERIT
import let WinSDK.STARTF_USESTDHANDLES
import struct WinSDK.HANDLE
#endif

#if canImport(Darwin)
import Darwin
#endif

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

extension Process {
public enum TerminationReason : Int {
case exit
Expand Down
3 changes: 3 additions & 0 deletions Sources/Foundation/ProcessInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//

@_implementationOnly import CoreFoundation
#if os(Windows)
import WinSDK
#endif

public struct OperatingSystemVersion {
public var majorVersion: Int
Expand Down
3 changes: 3 additions & 0 deletions Sources/Foundation/Thread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//

@_implementationOnly import CoreFoundation
#if os(Windows)
import WinSDK
#endif

#if canImport(Glibc)
import Glibc
Expand Down