-
Notifications
You must be signed in to change notification settings - Fork 469
Initial Swift3 wrapping overlay for libdispatch #94
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
Conversation
d2152e1
to
759e8f8
Compare
public enum Deallocator { | ||
/// Use `free` | ||
case free | ||
|
||
#if HAVE_MACH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a mach specific thing from my understanding for dispatch: it probably could be just like the backing for Data;
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/Data.swift#L19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably right. I was mentally mapping this deallocator to DISPATCH_DATA_DESTRUCTOR_VM_DEALLOCATE which is guarded by HAVE_MACH in data.c. It probably makes sense to implement similar functionality via munmap on Linux.
Things look pretty good here, the |
65bf634
to
c1afdcb
Compare
Squashed & forced pushed to consolidate back to a single commit. Thanks for the feedback! |
In an attempt to see if this can resolve some of the other issues I was having I ran a build of this and it is failing from:
|
|
||
public protocol DispatchSourceType { | ||
#if false // crashes the swift compiler | ||
typealias DispatchSourceHandler = @convention(block) () -> Void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an associatedtype no?
Re the linker error, the workaround is to use the gold linker. As a hack, I just changed the /usr/bin/ld symlink on my system to point to /usr/bin/ld.gold. From the various email discussions about linking I'd expect a more principled fix for all of Swift to use the gold linker should be coming soon |
Adding |
Thanks for the pointer to the ld.gold change Chris; I picked it up for this changeset and confirm it works (undid the hack on my system of linking /usr/bin/ld to ld.gold). |
SOURCE(MACH_SEND) | ||
SOURCE(MACH_RECV) | ||
SOURCE(MEMORYPRESSURE) | ||
#endif | ||
SOURCE(PROC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proc should be ignored too
I've updated taking into account @MadCoder's comments on usage of HAVE_MACH and the vnode source. It wasn't clear to me if you had converged on the API for DataOr/DataAdd, so I didn't do anything there yet. |
a8bd36d
to
f81a0bd
Compare
A useful checkpoint along the way to a complete implementation of the Swift3 overlay for libdispatch on non-Objective C platforms. The overlay code builds successfully and simple example programs using queues and timers work as expected. The basic approach is to wrap the C libdispatch objects in Swift objects and make the C dispatch APIs available internally via the CDispatch module. A few pieces (marked with FIXME) are ifdefed out to avoid compilation problems (will get back to them in later commits) or still need to be implemented (release on deinit). Although the installed libdispatch can be used in Swift programs via 'import Dispatch', the swiftc command for the client program currently needs to pass additional command line flags (to be fixed later). For example: swiftc -Xcc -fblocks -Xcc -D__DISPATCH_BUILDING_SWIFT_MODULE__=1 Forever.swift
f81a0bd
to
a38736c
Compare
func setRegistrationHandler(qos: DispatchQoS, flags: DispatchWorkItemFlags, handler: DispatchSourceHandler?) | ||
|
||
func setRegistrationHandler(handler: DispatchWorkItem) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the eventHandler functions of the DispatchSourceType protocol to match the functions defined in the extension in Source.swift. This enables the code to compile successfully (ie without triggering an assertion failure in swiftc). Is this the right change from an API perspective?
rebased on top of #96 and squashed down to a single commit again. |
Additional changes needed, or is this ready to merge and I'll deal with the handful of FIXME's in a separate PR next week? |
Done! Thanks. |
Using my forked repositories: - swift-corelibs-libdispatch - Disable failing tests - swiftpm - Add workaround for swiftlang/swift-corelibs-libdispatch#94
Using my forked repositories: - swift-corelibs-libdispatch - Revert SE-0111 - Disable failing tests - swiftpm - Add workaround for swiftlang/swift-corelibs-libdispatch#94
Using my forked repositories: - swift - Run tests of SourceKit and disable failing tests - swift-corelibs-libdispatch - Disable failing tests - swiftpm - Add workaround for swiftlang/swift-corelibs-libdispatch#94
Using my forked repositories: - swift - Cherry picked some commits for building SourceKitInProc on Linux - Workarounds for link errors - swift-corelibs-libdispatch - Based on 3ce8734 - Disable failing tests - swiftpm - Add workaround for swiftlang/swift-corelibs-libdispatch#94
Initial Swift3 wrapping overlay for libdispatch Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
The Linux and Darwin module maps need to be kept separate as they have different linkage requirements. <rdar://problem/27366695> Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Using my forked repositories: - swift - Cherry picked some commits for building SourceKitInProc on Linux - Workarounds for link errors - swift-corelibs-libdispatch - Based on 3ce8734 - Disable failing tests - swiftpm - Add workaround for swiftlang/swift-corelibs-libdispatch#94
A useful checkpoint along the way to a complete implementation of
the Swift3 overlay for libdispatch on non-Objective C platforms.
The overlay code builds successfully and simple example programs
using queues and timers work as expected.
The basic approach is to wrap the C libdispatch objects in Swift
objects and make the C dispatch APIs available internally via the
CDispatch module.
A few pieces (marked with FIXME) are ifdefed out to avoid compilation
problems (will get back to them in later commits) or still need to
be implemented (release on deinit).
Although the installed libdispatch can be used in Swift programs via
'import Dispatch', the swiftc command for the client program currently
needs to pass additional command line flags (to be fixed later). For example:
swiftc -Xcc -fblocks -Xcc -D__DISPATCH_BUILDING_SWIFT_MODULE__=1 Forever.swift