Skip to content

Commit 291550f

Browse files
authored
Merge pull request #1842 from compnerd/msvcrt
Foundation: homogenise importing C, add MSVCRT
2 parents 3010b33 + 3aea7e8 commit 291550f

23 files changed

+4
-138
lines changed

Foundation/AffineTransform.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if os(macOS) || os(iOS)
11-
import Darwin
12-
#elseif os(Linux) || CYGWIN
13-
import Glibc
14-
#endif
15-
1610
private let ε: CGFloat = CGFloat(2.22045e-16)
1711

1812

Foundation/Data.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@
1212

1313
#if DEPLOYMENT_RUNTIME_SWIFT
1414

15-
#if os(macOS) || os(iOS)
16-
import Darwin
17-
#elseif os(Linux)
18-
import Glibc
19-
15+
#if os(Linux)
2016
@inlinable // This is @inlinable as trivially computable.
2117
internal func malloc_good_size(_ size: Int) -> Int {
2218
return size
2319
}
24-
2520
#endif
2621

2722
import CoreFoundation

Foundation/DataProtocol.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if os(macOS) || os(iOS)
14-
import Darwin
15-
#elseif os(Linux)
16-
import Glibc
17-
#endif
18-
1913
//===--- DataProtocol -----------------------------------------------------===//
2014

2115
public protocol DataProtocol : RandomAccessCollection where Element == UInt8, SubSequence : DataProtocol {

Foundation/FileHandle.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import CoreFoundation
1111

12-
#if os(macOS) || os(iOS)
13-
import Darwin
14-
#elseif os(Linux) || CYGWIN
15-
import Glibc
16-
#endif
17-
1812
open class FileHandle : NSObject, NSSecureCoding {
1913
private var _fd: Int32
2014
private var _closeOnDealloc: Bool

Foundation/FileManager.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if canImport(Darwin)
11-
import Darwin
12-
#endif
13-
14-
#if canImport(Glibc)
15-
import Glibc
16-
#endif
17-
1810
#if os(Android) // struct stat.st_mode is UInt32
1911
internal func &(left: UInt32, right: mode_t) -> mode_t {
2012
return mode_t(left) & right

Foundation/FoundationErrors.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,6 @@ public var NSCoderReadCorruptError: Int { return CocoaError
164164

165165
public var NSCoderValueNotFoundError: Int { return CocoaError.Code.coderValueNotFound.rawValue }
166166

167-
#if os(macOS) || os(iOS)
168-
import Darwin
169-
#elseif os(Linux) || CYGWIN
170-
import Glibc
171-
#endif
172-
173167
internal func _NSErrorWithErrno(_ posixErrno : Int32, reading : Bool, path : String? = nil, url : URL? = nil, extraUserInfo : [String : Any]? = nil) -> NSError {
174168
var cocoaError : CocoaError.Code
175169
if reading {

Foundation/Host.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
11-
#if os(macOS) || os(iOS)
12-
import Darwin
13-
#elseif os(Linux) || CYGWIN
14-
import Glibc
15-
#endif
16-
1710
import CoreFoundation
1811

1912
open class Host: NSObject {

Foundation/JSONSerialization.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import CoreFoundation
1111

12-
#if os(macOS) || os(iOS)
13-
import Darwin
14-
#elseif os(Linux) || CYGWIN
15-
import Glibc
16-
#endif
17-
1812
extension JSONSerialization {
1913
public struct ReadingOptions : OptionSet {
2014
public let rawValue: UInt

Foundation/NSConcreteValue.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import CoreFoundation
1111

12-
#if os(macOS) || os(iOS)
13-
import Darwin
14-
#elseif os(Linux) || CYGWIN
15-
import Glibc
16-
#endif
17-
1812
internal class NSConcreteValue : NSValue {
1913

2014
struct TypeInfo : Equatable {

Foundation/NSData.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import CoreFoundation
1111

12-
#if os(macOS) || os(iOS)
13-
import Darwin
14-
#elseif os(Linux) || CYGWIN
15-
import Glibc
16-
#endif
17-
1812
#if DEPLOYMENT_ENABLE_LIBDISPATCH
1913
import Dispatch
2014
#endif

Foundation/NSDate.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import CoreFoundation
1111

12-
#if os(macOS) || os(iOS)
13-
import Darwin
14-
#elseif os(Linux) || CYGWIN
15-
import Glibc
16-
#endif
17-
1812
public typealias TimeInterval = Double
1913

2014
public var NSTimeIntervalSince1970: Double {

Foundation/NSGeometry.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if os(macOS) || os(iOS)
11-
import Darwin
12-
#elseif os(Linux) || CYGWIN
13-
import Glibc
14-
#endif
15-
1610
public struct CGPoint {
1711
public var x: CGFloat
1812
public var y: CGFloat

Foundation/NSLock.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
11-
#if os(macOS) || os(iOS)
12-
import Darwin
13-
#elseif os(Linux) || CYGWIN
14-
import Glibc
15-
#endif
16-
1710
import CoreFoundation
1811

1912
public protocol NSLocking {

Foundation/NSPathUtilities.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import CoreFoundation
1111

12-
#if os(macOS) || os(iOS)
13-
import Darwin
14-
#elseif os(Linux) || CYGWIN
15-
import Glibc
16-
#endif
17-
1812
public func NSTemporaryDirectory() -> String {
1913
#if os(macOS) || os(iOS)
2014
var buf = [Int8](repeating: 0, count: 100)

Foundation/NSPlatform.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if os(macOS) || os(iOS)
11-
import Darwin
12-
#elseif os(Linux)
13-
import Glibc
14-
#endif
15-
1610
#if os(macOS) || os(iOS)
1711
fileprivate let _NSPageSize = Int(vm_page_size)
1812
#elseif os(Linux) || os(Android)

Foundation/NSSwiftRuntime.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import CoreFoundation
1212

1313
// Re-export Darwin and Glibc by importing Foundation
1414
// This mimics the behavior of the swift sdk overlay on Darwin
15-
#if os(macOS) || os(iOS)
15+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
1616
@_exported import Darwin
1717
#elseif os(Linux) || os(Android) || CYGWIN
1818
@_exported import Glibc
19+
#elseif os(Windows)
20+
@_exported import MSVCRT
1921
#endif
2022

2123
@_exported import Dispatch

Foundation/NSURL.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
import CoreFoundation
1212

13-
#if os(macOS) || os(iOS)
14-
import Darwin
15-
#elseif os(Linux) || CYGWIN
16-
import Glibc
17-
#endif
18-
1913
#if os(macOS) || os(iOS)
2014
internal let kCFURLPOSIXPathStyle = CFURLPathStyle.cfurlposixPathStyle
2115
internal let kCFURLWindowsPathStyle = CFURLPathStyle.cfurlWindowsPathStyle

Foundation/NSUUID.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
import CoreFoundation
1212

13-
#if os(macOS) || os(iOS)
14-
import Darwin.uuid
15-
#elseif os(Linux) || CYGWIN
16-
import Glibc
17-
#endif
18-
1913
open class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
2014
internal var buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 16)
2115

Foundation/Process.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
#if !os(Android) // not available
1111
import CoreFoundation
1212

13-
#if os(macOS) || os(iOS)
14-
import Darwin
15-
#elseif os(Linux) || CYGWIN
16-
import Glibc
17-
#endif
18-
1913
extension Process {
2014
public enum TerminationReason : Int {
2115
case exit

Foundation/ProcessInfo.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
11-
#if os(macOS) || os(iOS)
12-
import Darwin
13-
#elseif os(Linux) || CYGWIN
14-
import Glibc
15-
#endif
16-
1710
import CoreFoundation
1811

1912
public struct OperatingSystemVersion {

Foundation/Progress.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if os(macOS) || os(iOS)
11-
import Darwin
12-
#elseif os(Linux)
13-
import Glibc
14-
#endif
15-
1610
import Dispatch
1711

1812
/**

Foundation/Thread.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
11-
#if os(macOS) || os(iOS)
12-
import Darwin
13-
#elseif os(Linux) || CYGWIN
14-
import Glibc
15-
#endif
1610
import CoreFoundation
1711

1812
internal class NSThreadSpecific<T: NSObject> {

Foundation/XMLParser.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if os(macOS) || os(iOS)
11-
import Darwin
12-
#elseif os(Linux) || CYGWIN
13-
import Glibc
14-
#endif
15-
1610
import CoreFoundation
1711

1812
extension XMLParser {

0 commit comments

Comments
 (0)