Commit Graph

106 Commits

Author SHA1 Message Date
Kevin Ballard
2530957bc6 Use shims for all calls to Dispatch APIs that take blocks
This ensures that blocks that come from `DispatchWorkItem`s will
function correctly.

The only exception is __dispatch_barrier_sync() as the block passed to
that call is not `@convention(block)` so it doesn't matter.

Fixes SR-2246.
2016-08-01 17:08:14 -07:00
Kevin Ballard
6fe9b13f12 Add fast path for queue.async(flags: .barrier)
Fixes SR-2248.
2016-08-01 14:58:30 -07:00
Rintaro Ishizaki
58676616ea [Dispatch] .size to .stride 2016-07-30 18:24:06 +09:00
Doug Gregor
b9363fe6bd [SE-0111] Enable SE-0111 by default. 2016-07-29 17:28:24 -07:00
Dmitri Gribenko
99dffd7682 Merge pull request #3854 from rintaro/SE-0101-memorylayout
[SE-0101] Implement: Reconfiguring sizeof and related functions into a unified MemoryLayout struct - Part 1
2016-07-29 15:56:27 -07:00
Doug Gregor
8219d4f42b Merge pull request #3853 from milseman/noescape_by_default
SE-0103 Noescape by default
2016-07-29 15:27:52 -07:00
Dmitri Gribenko
621d3b7c66 Merge pull request #3827 from mwwa/libdispatch-data-leak
[libdispatch-data-leak] DisaptchData never calls destructor
2016-07-29 14:58:37 -07:00
Michael Ilseman
ccda8f33d1 [noescape by default] Proliferate @escaping
Adds an explicit @escaping throughout the standard library, validation
test suite, and tests. This will be necessary as soon as noescape is
the default for closure parameters.
2016-07-29 13:48:07 -07:00
Devin Coughlin
8cb358195d Merge pull request #3797 from devincoughlin/dispatch_deprecation
[libdispatch] Fix deprecation annotations for macOS, watchOS.
2016-07-29 11:42:06 -07:00
Rintaro Ishizaki
06603c10bc [SE-0101] .size to .stride 2016-07-30 03:11:46 +09:00
Rintaro Ishizaki
091506315b [SE-0101] Implement: Reconfiguring sizeof and related functions into MemoryLayout struct
As of now:

* old APIs are just marked as `deprecated` not `unavaiable`. To make it
  easier to co-operate with other toolchain repos.
* Value variant of API is implemented as public @private
  `_ofInstance(_:)`.
2016-07-30 03:09:28 +09:00
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Matt Wright
e32016ffd7 [libdispatch-time-signedness] Correct signedness handling of DispatchTimeInterval
* DispatchTimeInterval's internal interval computation should be
    done with signed integers to allow for negative intervals. This
    moves all the unsigned conversions out to the API calls that can
    only accept positive intervals (timer sources and IO interval) and
    allows intermediate TimeIntervals to have a negative value.
2016-07-28 15:00:44 -07:00
Matt Wright
a151db06cd [libdispatch-data-leak] DisaptchData never calls destructor
* _swift_dispatch_data_create should have been marked as returning a
    retained object, otherwise the object is never fully released and
    the destructor is never executed.

    Fixes: <rdar://problem/27577958>
2016-07-28 15:00:32 -07:00
Devin Coughlin
c459f34029 [libdispatch] Fix deprecation annotations for macOS, watchOS.
Several libdispatch APIs in Queue.swift are annotated as:

public enum GlobalQueuePriority {
  @available(OSX, deprecated: 10.10, message: "Use qos attributes instead")
  @available(*, deprecated: 8.0, message: "Use qos attributes instead")
  case high

This annotation means ".high is deprecated on all OSes in version 8.0 and
above", so the compiler had false positive deprecation warnings on macOS
when the minimum deployment target is 10.9 and false negatives on watchOS
when the deployment target is 2.0.

The fix is to explicitly enumerate the platforms the API is deprecated on. This
is not ideal (see SR-2155) but avoids the false positives and negatives.

This fixes https://bugs.swift.org/browse/SR-2153
2016-07-27 14:10:25 -07:00
Andrew Trick
a18d490d6a Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3773)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 14:21:15 -07:00
Andrew Trick
0ed9ee8dee Revert "Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)"
This reverts commit ece0951924.

This results in lldb failues on linux that I can't readily debug.
Backing out until they can be resolved.
2016-07-26 02:50:57 -07:00
Andrew Trick
ece0951924 Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 02:18:21 -07:00
Jordan Rose
0712ffcb07 Convert the Dispatch and Foundation overlays to 'fileprivate'. (#3753)
Similar to the work in apple/swift-corelibs-foundation#445.

Groundwork for SE-0025 ('private' and 'fileprivate').
No intended functionality change.
2016-07-25 20:58:06 -07:00
Joe Groff
32b50c624d stdlib: Remove _isBridgedToObjectiveC from _ObjectiveCBridgeable.
All generic bridgeable types can bridge for all their instantiations now. Removing this ferrets out some now-unnecessary traps that check for unbridgeable parameter types.
2016-07-25 06:01:21 -07:00
Doug Gregor
9575215f34 Merge pull request #3635 from mwwa/libdispatch-fixits
[libdispatch-fixits] Address stale or incorrect fixits
2016-07-20 22:24:45 -07:00
Doug Gregor
2d7847d7b7 Merge pull request #3648 from mwwa/libdispatch-data-fixes
[libdispatch] libdispatch data fixes
2016-07-20 22:22:02 -07:00
Matt Wright
56a579763f [libdispatch-data-fixes] Appending UnsafeBufferPointers to data is unsafe
* The buffer-pointer based init methods were passing the dispatch
    data default destructor in such a way that the
    @convention(block)-ness was lost. This leads to a thunk being passed
    to dispatch instead of NULL. Subsequently, dispatch would reference
    rather than copy the provided data.

    Fixes:
	SR-2050 (<rdar://problem/27293973>)
2016-07-20 16:46:31 -07:00
Matt Wright
bb40547123 [libdispatch-data-fixes] DispatchDataIterator crashes when iterating DispatchData.empty
*  DispatchDataIterator is unsafe when iterating the empty
    DispatchData object as it forcibly unwraps a nil pointer.
2016-07-20 14:57:39 -07:00
Matt Wright
25f7cda01c [libdispatch-fixits] Address stale or incorrect fixits
* Several fixits references stale or deprecated methods, or
    generated incorrect syntax when applied to actual code.

    Fixes:
	<rdar://problem/26681271>
	<rdar://problem/27088581>
	<rdar://problem/27181502>
2016-07-20 11:21:14 -07:00
Chris Lattner
bc09af33f1 Merge pull request #3592 from practicalswift/trailing-semicolon
[gardening] Remove trailing semicolons.
2016-07-19 22:58:35 -07:00
practicalswift
8287c5dfca [gardening] Remove trailing semicolons.
Inspiration: 425138c56e
2016-07-19 00:04:53 +02:00
Matt Wright
11a6dcd2b7 [libdispatch] Remove deprecated methods
* Removes methods introduces in Swift3 that were already marked
    deprecated based on pre-release review feedback.

    Fixes <rdar://problem/26479523>
2016-07-18 13:22:23 -07:00
Matt Wright
8ac413a0b5 [libdispatch] Post-beta API changes and bug fixes
* Fix DispatchSourceSignal initialisation such that it no longer
    registers for the wrong source type.

    * Remove (group:) option from DispatchWorkItem, introduce group
    options to `.async` methods that accept DispatchWorkItem.

    * Rename `DispatchSourceType` to `DispatchSourceProtocol`

    * Rework DispatchQueue attributes and flags into a less confusing
    approach.

    * Fixes:

	SR-1817, SR-1771, SR-1770, SR-1769

	<rdar://problem/26725156> <rdar://problem/26873917>
	<rdar://problem/26918843> <rdar://problem/26810149>
	<rdar://problem/27117023> <rdar://problem/27121422>
	<rdar://problem/27236887> <rdar://problem/27337555>
2016-07-18 13:22:23 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Chris Lattner
45f2cfaaa0 Implement SE-0099, but where the migration diagnostics are left as warnings
for now.  I'll upgrade them to errors in a week or two to give downstream
projects a chance to update.
2016-07-02 15:44:57 -07:00
Dave Abrahams
26e62ed917 Add missing instances of .self
Passing a type as a metatype directly is no longer supported
2016-06-20 17:11:48 -07:00
swift-ci
d68c6dcd6b Merge pull request #3069 from practicalswift/typo-fixes-20160619 2016-06-19 16:02:06 -07:00
practicalswift
4ae4e37b14 [gardening] Fix some spacing inconsistencies. 2016-06-19 21:38:59 +02:00
practicalswift
8d03ea1347 [gardening] Fix some recently introduced typos. 2016-06-19 21:28:36 +02:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
Dmitri Gribenko
d591f9cf7a stdlib: remove most uses of @warn_unused_result, which does nothing now
I kept the one on sorted(), because that one requires a less trivial
change.
2016-05-19 18:39:39 -07:00
Saleem Abdulrasool
81661fca61 stdlib: use the reserved attribute spellings
This is a purely mechanical change replacing the attributes with the reserved
spelling.  Compilers are to not error when they encounter a reserved spelling
for an attribute which they do not support.
2016-05-11 11:30:24 -07:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Dmitri Gribenko
f47f206ca0 Merge pull request #164 from jawwad/remove-trailing-semicolons-from-stdlib
Remove trailing semicolons from files in stdlib
2015-12-05 01:28:37 -08:00
ken0nek
2735dc32f7 Remove whitespaces 2015-12-05 00:07:27 +09:00
Jawwad Ahmad
8f6f5ab0dd [stdlib] Remove trailing semicolons from files in stdlib 2015-12-04 15:50:13 +05:00
Joe Groff
fbd2e4d872 Rename @asmname to @_silgen_name.
This reflects the fact that the attribute's only for compiler-internal use, and isn't really equivalent to C's asm attribute, since it doesn't change the calling convention to be C-compatible.
2015-11-17 14:13:48 -08:00
Slava Pestov
3e7d63085c Revert "Build the Dispatch overlay on Linux"
This broke the build with a dependency issue.

This reverts commit ac6de62b66.
2015-11-05 14:36:40 -08:00
Slava Pestov
ac6de62b66 Build the Dispatch overlay on Linux
This is an optional feature that is off by default, and is enabled by
passing -- -build-swift-dispatch-overlay=1 to utils/build-script.

The libdispatch build I was testing with was old and is missing some
symbols, so perhaps some of the stuff can move out of #if protection
later.

There isn't much here yet, and no tests either.
2015-11-05 14:18:19 -08:00
Jordan Rose
6e1bf0d10d Rename @exported to @_exported for now.
At some point I want to propose a revised model for exports, but for now
just mark that support for '@exported' is still experimental and subject
to change. (Thanks, Max.)
2015-11-05 11:59:00 -08:00
Jordan Rose
845513d359 [ClangImporter] Always treat dispatch_block_t as @convention(block).
Some GCD APIs rely on the pointer identity of blocks, so avoid bridging
when possible. The easiest way to do this was to use our existing rules
for special-casing typedefs.

The summary text for dispatch_block_t comes from the actual GCD headers.

rdar://problem/22432170

Swift SVN r31634
2015-09-02 18:31:51 +00:00