Skip to content

Commit bda3baf

Browse files
authored
Merge pull request swiftlang#170 from dgrove-oss/fix-small-deltas-from-darwin
Fix some small divergences from Darwin overlay
2 parents 3639fbe + 24f49a2 commit bda3baf

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/swift/Block.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ public struct DispatchWorkItemFlags : OptionSet, RawRepresentable {
3737
@available(OSX 10.10, iOS 8.0, *)
3838
public class DispatchWorkItem {
3939
internal var _block: _DispatchBlock
40-
internal var _group: DispatchGroup?
4140

4241
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) {
4342
_block = dispatch_block_create_with_qos_class(dispatch_block_flags_t(flags.rawValue),
4443
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
4544
}
4645

47-
// Used by DispatchQueue.synchronously<T> to provide a @noescape path through
46+
// Used by DispatchQueue.synchronously<T> to provide a path through
4847
// dispatch_block_t, as we know the lifetime of the block in question.
4948
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
5049
_block = _swift_dispatch_block_create_noescape(dispatch_block_flags_t(flags.rawValue), noescapeBlock)

src/swift/Data.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public struct DispatchData : RandomAccessCollection {
4949
/// Initialize a `Data` with copied memory content.
5050
///
5151
/// - parameter bytes: A pointer to the memory. It will be copied.
52-
/// - parameter count: The number of bytes to copy.
5352
public init(bytes buffer: UnsafeBufferPointer<UInt8>) {
5453
let d = dispatch_data_create(buffer.baseAddress!, buffer.count, nil, _dispatch_data_destructor_default())
5554
self.init(data: d)
@@ -88,7 +87,7 @@ public struct DispatchData : RandomAccessCollection {
8887
public func enumerateBytes(
8988
block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
9089
{
91-
_swift_dispatch_data_apply(__wrapped.__wrapped) { (data: dispatch_data_t, offset: Int, ptr: UnsafeRawPointer, size: Int) in
90+
_swift_dispatch_data_apply(__wrapped.__wrapped) { (_, offset: Int, ptr: UnsafeRawPointer, size: Int) in
9291
let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size)
9392
let bp = UnsafeBufferPointer(start: bytePtr, count: size)
9493
var stop = false
@@ -124,7 +123,7 @@ public struct DispatchData : RandomAccessCollection {
124123
}
125124
}
126125

127-
private func _copyBytesHelper(to pointer: UnsafeMutablePointer<UInt8>, from range: CountableRange<Index>) {
126+
private func _copyBytesHelper(to pointer: UnsafeMutableRawPointer, from range: CountableRange<Index>) {
128127
var copiedCount = 0
129128
_ = CDispatch.dispatch_data_apply(__wrapped.__wrapped) { (data: dispatch_data_t, offset: Int, ptr: UnsafeRawPointer, size: Int) in
130129
let limit = Swift.min((range.endIndex - range.startIndex) - copiedCount, size)
@@ -179,10 +178,7 @@ public struct DispatchData : RandomAccessCollection {
179178

180179
guard !copyRange.isEmpty else { return 0 }
181180

182-
let bufferCapacity = buffer.count * MemoryLayout<DestinationType>.stride
183-
buffer.baseAddress?.withMemoryRebound(to: UInt8.self, capacity: bufferCapacity) {
184-
_copyBytesHelper(to: $0, from: copyRange)
185-
}
181+
_copyBytesHelper(to: buffer.baseAddress!, from: copyRange)
186182
return copyRange.count
187183
}
188184

@@ -244,7 +240,7 @@ public struct DispatchData : RandomAccessCollection {
244240

245241
public struct DispatchDataIterator : IteratorProtocol, Sequence {
246242

247-
/// Create an iterator over the given DisaptchData
243+
/// Create an iterator over the given DispatchData
248244
public init(_data: DispatchData) {
249245
var ptr: UnsafeRawPointer?
250246
self._count = 0

src/swift/Wrapper.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class DispatchQueue : DispatchObject {
153153
_swift_dispatch_release(wrapped())
154154
}
155155

156-
public func sync(execute workItem: @noescape ()->()) {
156+
public func sync(execute workItem: ()->()) {
157157
dispatch_sync(self.__wrapped, workItem)
158158
}
159159
}

0 commit comments

Comments
 (0)