Skip to content

Commit 88b093e

Browse files
authored
Merge pull request #30615 from apple/post-back-master-xcode-11.4
Update master to build with Xcode 11.4
2 parents f14e9a8 + 95dbb9b commit 88b093e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3163
-263
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,13 @@ static bool
827827
deploymentTargetHasRemoteMirrorZeroSizedTypeDescriptorBug(IRGenModule &IGM) {
828828
auto target = IGM.Context.LangOpts.Target;
829829

830-
if (target.isMacOSX() && target.isMacOSXVersionLT(10, 16, 0)) {
830+
if (target.isMacOSX() && target.isMacOSXVersionLT(10, 15, 4)) {
831831
return true;
832832
}
833-
if (target.isiOS() && target.isOSVersionLT(14)) { // includes tvOS
833+
if (target.isiOS() && target.isOSVersionLT(13, 4)) { // includes tvOS
834834
return true;
835835
}
836-
if (target.isWatchOS() && target.isOSVersionLT(7)) {
836+
if (target.isWatchOS() && target.isOSVersionLT(6, 2)) {
837837
return true;
838838
}
839839

stdlib/public/Darwin/Dispatch/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ add_swift_target_library(swiftDispatch ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES}
1111
Private.swift
1212
Queue.swift
1313
Source.swift
14+
Schedulers+DispatchQueue.swift
1415
Time.swift
1516

1617
"${SWIFT_SOURCE_DIR}/stdlib/linker-support/magic-symbols-for-install-name.c"
@@ -21,6 +22,7 @@ add_swift_target_library(swiftDispatch ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES}
2122
SWIFT_MODULE_DEPENDS_IOS Darwin ObjectiveC # auto-updated
2223
SWIFT_MODULE_DEPENDS_TVOS Darwin ObjectiveC # auto-updated
2324
SWIFT_MODULE_DEPENDS_WATCHOS Darwin ObjectiveC # auto-updated
25+
FRAMEWORK_DEPENDS_WEAK Combine
2426

2527
DEPLOYMENT_VERSION_OSX ${SWIFTLIB_DEPLOYMENT_VERSION_DISPATCH_OSX}
2628
DEPLOYMENT_VERSION_IOS ${SWIFTLIB_DEPLOYMENT_VERSION_DISPATCH_IOS}
Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Only support 64bit
14+
#if !(os(iOS) && (arch(i386) || arch(arm)))
15+
16+
import Combine
17+
18+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
19+
private func clampedIntProduct(_ m1: Int, _ m2: UInt64) -> Int {
20+
assert(m2 > 0, "multiplier must be positive")
21+
guard m1 < Int.max, m2 < Int.max else { return Int.max }
22+
let (result, overflow) = m1.multipliedReportingOverflow(by: Int(m2))
23+
if overflow {
24+
return m1 > 0 ? Int.max : Int.min
25+
}
26+
return result
27+
}
28+
29+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
30+
extension DispatchTimeInterval {
31+
fileprivate var nanoseconds: Int {
32+
switch self {
33+
case .seconds(let s): return clampedIntProduct(s, NSEC_PER_SEC)
34+
case .milliseconds(let ms): return clampedIntProduct(ms, NSEC_PER_MSEC)
35+
case .microseconds(let us): return clampedIntProduct(us, NSEC_PER_USEC)
36+
case .nanoseconds(let ns): return ns
37+
case .never: return Int.max
38+
}
39+
}
40+
}
41+
42+
// This is Strideable except: <rdar://problem/35158274>
43+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
44+
extension DispatchTime /* : Strideable */ {
45+
typealias Stride = DispatchTimeInterval
46+
47+
public func distance(to other: DispatchTime) -> DispatchTimeInterval {
48+
let lhs = other.rawValue
49+
let rhs = rawValue
50+
if lhs >= rhs {
51+
return DispatchTimeInterval.nanoseconds(Int(lhs - rhs))
52+
} else {
53+
return DispatchTimeInterval.nanoseconds(0 - Int(rhs - lhs))
54+
}
55+
}
56+
57+
public func advanced(by n: DispatchTimeInterval) -> DispatchTime {
58+
return self + n
59+
}
60+
}
61+
62+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
63+
extension DispatchQueue: Scheduler {
64+
/// The scheduler time type used by the dispatch queue.
65+
public struct SchedulerTimeType: Strideable, Codable, Hashable {
66+
/// The dispatch time represented by this type.
67+
public var dispatchTime: DispatchTime
68+
69+
/// Creates a dispatch queue time type instance.
70+
///
71+
/// - Parameter time: The dispatch time to represent.
72+
public init(_ time: DispatchTime) {
73+
dispatchTime = time
74+
}
75+
76+
public init(from decoder: Decoder) throws {
77+
let container = try decoder.singleValueContainer()
78+
let time = DispatchTime(uptimeNanoseconds: try container.decode(UInt64.self))
79+
self.init(time)
80+
}
81+
82+
public func encode(to encoder: Encoder) throws {
83+
var container = encoder.singleValueContainer()
84+
try container.encode(dispatchTime.uptimeNanoseconds)
85+
}
86+
87+
/// Returns the distance to another dispatch queue time.
88+
///
89+
/// - Parameter other: Another dispatch queue time.
90+
/// - Returns: The time interval between this time and the provided time.
91+
public func distance(to other: SchedulerTimeType) -> Stride {
92+
return Stride(self.dispatchTime.distance(to: other.dispatchTime))
93+
}
94+
95+
/// Returns a dispatch queue scheduler time calculated by advancing this instance’s time by the given interval.
96+
///
97+
/// - Parameter n: A time interval to advance.
98+
/// - Returns: A dispatch queue time advanced by the given interval from this instance’s time.
99+
public func advanced(by n: Stride) -> SchedulerTimeType {
100+
return SchedulerTimeType(self.dispatchTime.advanced(by: n.timeInterval))
101+
}
102+
103+
public func hash(into hasher: inout Hasher) {
104+
hasher.combine(dispatchTime.rawValue)
105+
}
106+
107+
public struct Stride: SchedulerTimeIntervalConvertible, Comparable, SignedNumeric, ExpressibleByFloatLiteral, Hashable, Codable {
108+
/// If created via floating point literal, the value is converted to nanoseconds via multiplication.
109+
public typealias FloatLiteralType = Double
110+
111+
/// Nanoseconds, same as DispatchTimeInterval.
112+
public typealias IntegerLiteralType = Int
113+
public typealias Magnitude = Int
114+
115+
/// The value of this time interval in nanoseconds.
116+
public var magnitude: Int
117+
118+
/// A `DispatchTimeInterval` created with the value of this type in nanoseconds.
119+
public var timeInterval: DispatchTimeInterval {
120+
return .nanoseconds(magnitude)
121+
}
122+
123+
/// Creates a dispatch queue time interval from the given dispatch time interval.
124+
///
125+
/// - Parameter timeInterval: A dispatch time interval.
126+
public init(_ timeInterval: DispatchTimeInterval) {
127+
magnitude = Int(timeInterval.nanoseconds)
128+
}
129+
130+
/// Creates a dispatch queue time interval from a floating-point seconds value.
131+
///
132+
/// - Parameter value: The number of seconds, as a `Double`.
133+
public init(floatLiteral value: Double) {
134+
magnitude = Int(value * 1_000_000_000)
135+
}
136+
137+
/// Creates a dispatch queue time interval from an integer seconds value.
138+
///
139+
/// - Parameter value: The number of seconds, as an `Int`.
140+
public init(integerLiteral value: Int) {
141+
magnitude = value * 1_000_000_000
142+
}
143+
144+
/// Creates a dispatch queue time interval from a binary integer type.
145+
///
146+
/// If `exactly` cannot convert to an `Int`, the resulting time interval is `nil`.
147+
/// - Parameter exactly: A binary integer representing a time interval.
148+
public init?<T>(exactly source: T) where T: BinaryInteger {
149+
if let v = Int(exactly: source) {
150+
magnitude = v
151+
} else {
152+
return nil
153+
}
154+
}
155+
156+
// ---
157+
158+
public static func < (lhs: Stride, rhs: Stride) -> Bool {
159+
return lhs.magnitude < rhs.magnitude
160+
}
161+
162+
// ---
163+
164+
public static func * (lhs: Stride, rhs: Stride) -> Stride {
165+
return Stride(.nanoseconds(lhs.magnitude * rhs.magnitude))
166+
}
167+
168+
public static func + (lhs: Stride, rhs: Stride) -> Stride {
169+
return Stride(.nanoseconds(lhs.magnitude + rhs.magnitude))
170+
}
171+
172+
public static func - (lhs: Stride, rhs: Stride) -> Stride {
173+
return Stride(.nanoseconds(lhs.magnitude - rhs.magnitude))
174+
}
175+
176+
// ---
177+
178+
public static func -= (lhs: inout Stride, rhs: Stride) {
179+
let result = lhs - rhs
180+
lhs = result
181+
}
182+
183+
public static func *= (lhs: inout Stride, rhs: Stride) {
184+
let result = lhs * rhs
185+
lhs = result
186+
}
187+
188+
public static func += (lhs: inout Stride, rhs: Stride) {
189+
let result = lhs + rhs
190+
lhs = result
191+
}
192+
193+
// ---
194+
195+
public static func seconds(_ s: Double) -> Stride {
196+
return Stride(.nanoseconds(Int(s * 1_000_000_000)))
197+
}
198+
199+
public static func seconds(_ s: Int) -> Stride {
200+
return Stride(.seconds(s))
201+
}
202+
203+
public static func milliseconds(_ ms: Int) -> Stride {
204+
return Stride(.milliseconds(ms))
205+
}
206+
207+
public static func microseconds(_ us: Int) -> Stride {
208+
return Stride(.microseconds(us))
209+
}
210+
211+
public static func nanoseconds(_ ns: Int) -> Stride {
212+
return Stride(.nanoseconds(ns))
213+
}
214+
}
215+
}
216+
217+
/// Options that affect the operation of the dispatch queue scheduler.
218+
public struct SchedulerOptions {
219+
/// The dispatch queue quality of service.
220+
public var qos: DispatchQoS
221+
222+
/// The dispatch queue work item flags.
223+
public var flags: DispatchWorkItemFlags
224+
225+
/// The dispatch group, if any, that should be used for performing actions.
226+
public var group: DispatchGroup?
227+
228+
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], group: DispatchGroup? = nil) {
229+
self.qos = qos
230+
self.flags = flags
231+
self.group = group
232+
}
233+
}
234+
235+
public var minimumTolerance: SchedulerTimeType.Stride {
236+
return SchedulerTimeType.Stride(DispatchTimeInterval.seconds(0))
237+
}
238+
239+
public var now: DispatchQueue.SchedulerTimeType {
240+
return SchedulerTimeType(DispatchTime.now())
241+
}
242+
243+
public func schedule(options: SchedulerOptions?, _ action: @escaping () -> Void) {
244+
let qos = options?.qos ?? .unspecified
245+
let flags = options?.flags ?? []
246+
247+
if let group = options?.group {
248+
// Distinguish on the group because it appears to not be a call-through like the others. This may need to be adjusted.
249+
self.async(group: group, qos: qos, flags: flags, execute: action)
250+
} else {
251+
self.async(qos: qos, flags: flags, execute: action)
252+
}
253+
}
254+
255+
public func schedule(after date: SchedulerTimeType,
256+
tolerance: SchedulerTimeType.Stride,
257+
options: SchedulerOptions?,
258+
_ action: @escaping () -> Void) {
259+
// TODO: Tolerance ignored
260+
let qos = options?.qos ?? .unspecified
261+
let flags = options?.flags ?? []
262+
263+
self.asyncAfter(deadline: date.dispatchTime, qos: qos, flags: flags, execute: action)
264+
}
265+
266+
public func schedule(after date: SchedulerTimeType,
267+
interval: SchedulerTimeType.Stride,
268+
tolerance: SchedulerTimeType.Stride,
269+
options: SchedulerOptions?,
270+
_ action: @escaping () -> Void) -> Cancellable {
271+
let source = DispatchSource.makeTimerSource(flags: DispatchSource.TimerFlags(), queue: self)
272+
273+
source.schedule(deadline: date.dispatchTime,
274+
repeating: interval.timeInterval,
275+
leeway: tolerance.timeInterval)
276+
source.setEventHandler(handler: action)
277+
source.resume()
278+
279+
return AnyCancellable(source.cancel)
280+
}
281+
}
282+
283+
#endif /* !(os(iOS) && (arch(i386) || arch(arm))) */

stdlib/public/Darwin/Foundation/CMakeLists.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ add_swift_target_library(swiftFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
77
BundleLookup.mm
88
Calendar.swift
99
CharacterSet.swift
10+
CheckClass.mm
1011
Codable.swift
1112
Collections+DataProtocol.swift
13+
CombineTypealiases.swift
1214
ContiguousBytes.swift
1315
Data.swift
1416
DataProtocol.swift
15-
DispatchData+DataProtocol.swift
16-
NSData+DataProtocol.swift
17-
Pointers+DataProtocol.swift
1817
DataThunks.m
1918
Date.swift
2019
DateComponents.swift
2120
DateInterval.swift
2221
Decimal.swift
22+
DispatchData+DataProtocol.swift
2323
FileManager.swift
2424
Foundation.swift
2525
IndexPath.swift
@@ -30,6 +30,7 @@ add_swift_target_library(swiftFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
3030
Notification.swift
3131
NSArray.swift
3232
NSCoder.swift
33+
NSData+DataProtocol.swift
3334
NSDate.swift
3435
NSDictionary.swift
3536
NSError.swift
@@ -53,15 +54,26 @@ add_swift_target_library(swiftFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
5354
NSURL.swift
5455
PersonNameComponents.swift
5556
PlistEncoder.swift
57+
Pointers+DataProtocol.swift
5658
Progress.swift
59+
Publishers+KeyValueObserving.swift
60+
Publishers+Locking.swift
61+
Publishers+NotificationCenter.swift
62+
Publishers+Timer.swift
63+
Publishers+URLSession.swift
5764
ReferenceConvertible.swift
65+
Scanner.swift
66+
Schedulers+Date.swift
67+
Schedulers+OperationQueue.swift
68+
Schedulers+RunLoop.swift
5869
String.swift
5970
TimeZone.swift
6071
URL.swift
72+
URLCache.swift
6173
URLComponents.swift
6274
URLRequest.swift
75+
URLSession.swift
6376
UUID.swift
64-
CheckClass.mm
6577

6678
"${SWIFT_SOURCE_DIR}/stdlib/linker-support/magic-symbols-for-install-name.c"
6779

@@ -80,6 +92,7 @@ add_swift_target_library(swiftFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
8092
SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch CoreFoundation ObjectiveC # auto-updated
8193
CoreGraphics # imported in Swift
8294
FRAMEWORK_DEPENDS Foundation
95+
FRAMEWORK_DEPENDS_WEAK Combine
8396

8497
DEPLOYMENT_VERSION_OSX ${SWIFTLIB_DEPLOYMENT_VERSION_FOUNDATION_OSX}
8598
DEPLOYMENT_VERSION_IOS ${SWIFTLIB_DEPLOYMENT_VERSION_FOUNDATION_IOS}

0 commit comments

Comments
 (0)