Skip to content

Merge darwin/trunk, including libdispatch-703.1.4 Apple source drop, to master #142

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

Merged
merged 70 commits into from
Aug 15, 2016

Conversation

das
Copy link
Contributor

@das das commented Aug 11, 2016

Merge tag darwin/darwin-006 on darwin/trunk, which includes the latest Apple source drop libdispatch-703.1.4 as well as all the github PR’s that we’ve pulled back into our internal repository since the last darwin/trunk merge, along with any changes made to these during internal review and testing on Darwin.

dgrove-oss and others added 30 commits July 28, 2016 20:39
Minimal set of changes to get sources merged
from libdispatch-685 to compile and run on Linux.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Linux port of libdispatch-685 merge

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
validated by building on Darwin with -DHAVE_PTHREAD_WORKQUEUE_QOS=0
-DDISPATCH_USE_KEVENT_QOS=0 -DVOUCHER_USE_MACH_VOUCHER=0
-DOS_FIREHOSE_SPI=0

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Change name of generated header file to config_ac.h
and use __has_include to prefer the generated file if
it is present.  Avoids stomping on the config.h used by
XCode when building using autotools.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Avoid overwriting config.h with generated header

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Get rid of mach_error_string, mach_vm_deallocate, and mach_test_self
by adding missing #if HAVE_MACH in the last couple places it was missing.

Avoid needing pthread_mach_thread_np by replacing uses of the
_dispatch_thread_port() macro with _dispatch_tid_self()

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
eliminate mach_task_self from linux_stubs

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
TLS: Thread Local Storage

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
whitespace

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
…of github swift repo

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Import Swift 3 overlay from swift repo

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Define DISPATCH_UNAVAILABLE and DISPATCH_LINUX_UNAVAILABLE macros
and use them to mark dispatch_source API functions that are
not available on Linux.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Mark dispatch_source APIs that are not available on Linux as unavailable

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
…header annotation macros

switch guard for vm_deallocate to HAVE_MACH

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
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

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Initial Swift3 wrapping overlay for libdispatch

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Instead of using a special macro, check for __has_feature(modules) to
activate including stdio.h in dispatch.h on Linux.

Also, fix one place where OS_OBJECT_SWIFT_3 was used outside of an
OS_OBJECT_USE_OBJC block (to prepare for SWIFT_SDK_OVERLAY_DISPATCH_EPOCH
being defined by the clang importer on non-Darwin platforms).

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
…-on-linux

Use SWIFT_SDK_OVERLAY_DISPATCH_EPOCH to detect that an overlay is bei…

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
ARC support in wrapping overlay. Add deinit methods to wrapping
Swift classes that call dispatch_release on the wrapped C objects.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
release wrapped C objects when Swift object deinitialized

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
If the main thread calls pthread_exit on Linux, the process
becomes a zombie. Modify dispatch_main to avoid this by adding
a pthread_key destructor that calls dispatch_sig_thread
(effectively stalling pthread exit until the program really exits).

This patch relies on the TSD destructors being called in order of
creation, which is currently the case in glibc.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Linux: avoid zombie process when dispatch_main is called

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Update for SE-0112: ErrorProtocol has been renamed to Error

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
MadCoder and others added 22 commits July 28, 2016 20:42
update libkqueue version to include PR-14 (kevent64 timer resolution …

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
leverage of new kevent timer granularity functionality

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
[Data] fix crash when creating iterator of empty DispatchData

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Deallocation / reference counting support for DispatchData
in the wrapping overlay consisting of two main pieces.

First, since DispatchData is a struct and dispatch_data_t is
a COpaquePointer, we need an intermediate class __DispatchData
on which to perform the reference counting operations to enable
the backing _dispatch_data_t to be deallocated when they are no
longer reachable.  I overlooked the mapping of _dispatch_data_t
to OS_dispatch_data in Dispatch.apinotes in my initial pull request
for the wrapping overlay and as a result all the dispatch_data_t
instances were not being reference counted.

Second, enable the DispatchData.Deallocator portion of the API.
After some experimentation, found a way to have the desired API
without getting a reference to _TMBO in the generated code.
Left a FIXME because the current approach is sub-optimal in where
it converts from Swift blocks to @convention(block) blocks.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
deallocation support for DispatchData on Linux

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
dispatch_main is meant to be made available via
the global function dispatchMain().

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
add dispatchMain to wrapping overlay

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Should have used an ifdef instead of an if to guard this block
of code.  Fixes compilation on linux when using an older version
of libkqueue that doesn't include the nsec kevent support.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
fix compilation error when building against old libkqueue

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Update libpwq version to latest.  This picks up the code in
libpwq PR#14 which changes the default number of libpwq worker
threads from 2 to the number of cores in the system.
This avoids very slow initial rampups in high core count systems.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
refresh libpwq submodule to include libpwq PR#14

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Unsafe[Mutable]Pointer<Void> is replaced by Unsafe[Mutable]RawPointer.

Migrating often means simply removing casts to/from UnsafePointer<UInt8>
and working directly with UnsafeRawPointer instead.

Unfortunately some API's, like NSData still want UnsafePointer<UInt8>,
which requires "binding" memory to UInt8 before passing it to the API.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Update for SE-0107: Migrate Void->Raw.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Sync up recent Swift overlay changes into swift-corelibs-dispatch and
get them building for Linux.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
[overlay-syncup] sync overlay changes to Linux

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Add description for building libdispatch with Swift API
either as part of building a Swift toolchain from source
using utils/build-script or using a pre-built Swift toolchain.

Update Linux-specific instructions to try to avoid some
common problems people have been reporting.

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Update INSTALL instructions

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
@das
Copy link
Contributor Author

das commented Aug 11, 2016

@swift-ci Please test

@das
Copy link
Contributor Author

das commented Aug 15, 2016

@swift-ci Please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants