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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
4d5eff0
Linux port of libdispatch-685 merge
dgrove-oss Jun 15, 2016
847f62b
Merge pull request #81 from dgrove-oss/linux-porting
MadCoder Jun 15, 2016
7f2a683
tweaks to preprocessor checks in libdispatch-685 Linux port
das Jun 23, 2016
10c9991
Avoid overwriting config.h with generated header
dgrove-oss Jun 17, 2016
7518545
Merge pull request #84 from dgrove-oss/gitignore_config.h
MadCoder Jun 18, 2016
31f1d2b
Eliminate dummy mach-specific functions from linux_stubs
dgrove-oss Jun 16, 2016
b11112d
Merge pull request #86 from dgrove-oss/kill_mach_task_self_on_linux
MadCoder Jun 18, 2016
b8cce96
TLS thread local storage refresh
frankeh Jun 16, 2016
c4f4e68
Merge pull request #82 from frankeh/TLS
MadCoder Jun 21, 2016
3e6e4b7
remove mach-specific thread_port macro that should not be used on linux
das Jun 23, 2016
c1f5e46
import Dispatch overlay and apinotes from swift-3.0-preview-2-branch …
das Jun 22, 2016
aee1fe5
add new overlay sourcefiles to Makefile.am (does not build)
das Jun 22, 2016
4af7cad
Merge pull request #89 from apple/das-swift3-overlay
MadCoder Jun 22, 2016
0de9c3c
Mark dispatch_source APIs that are not available on Linux as unavailable
dgrove-oss Jun 30, 2016
0c41eab
Merge pull request #96 from dgrove-oss/hide_evfilt_proc
MadCoder Jun 30, 2016
63b00aa
move DISPATCH_LINUX_UNAVAILABLE to base.h and match it with existing …
das Jul 14, 2016
05255f9
Initial Swift3 wrapping overlay for libdispatch
dgrove-oss Jun 28, 2016
acea647
Merge pull request #94 from dgrove-oss/swift3-overlay-pr1
mwwa Jul 1, 2016
c40d554
need to guard definition of _dispatch_data_destructor_munmap
das Jul 14, 2016
17b7382
avoid requiring __DISPATCH_BUILDING_SWIFT_MODULE__ macro on Linux
dgrove-oss Jul 5, 2016
47369eb
Merge pull request #97 from dgrove-oss/define-dispatch-bridging-macro…
MadCoder Jul 6, 2016
13dd2ef
missing #ifdef __has_feature
das Jul 14, 2016
f3fc317
release wrapped C objects when Swift object deinitialized
dgrove-oss Jul 5, 2016
c9c0aac
Merge pull request #98 from dgrove-oss/release-in-deinit
mwwa Jul 6, 2016
2ab938a
whitespace
das Jul 14, 2016
d3bb7e5
Linux: avoid zombie process when dispatch_main is called
dgrove-oss Jul 6, 2016
fc3a731
Merge pull request #99 from dgrove-oss/dispatch-main-zombie
MadCoder Jul 6, 2016
f3c6254
Update for SE-0112: ErrorProtocol has been renamed to Error
DougGregor Jul 12, 2016
3830f55
Merge pull request #103 from apple/nserror-bridging
DougGregor Jul 12, 2016
3bbed1b
whitespace
das Jul 14, 2016
989c9dd
Enable CF runloop support for linux
dgrove-oss Jul 7, 2016
56eb6b5
Merge pull request #101 from dgrove-oss/cf-runloop-hooks
das Jul 12, 2016
627df61
workaround CF build failure, add resolvers for new symbol, whitespace
das Jul 14, 2016
eff2273
Revert modulemaps changes from PR #94
das Jul 15, 2016
f3bfb6f
Merge libdispatch-703.1.4
das Jul 28, 2016
fa5d032
define SWIFT_CC(swift) macro for DispatchStubs
dgrove-oss Jul 15, 2016
d871b97
Merge pull request #106 from dgrove-oss/dispatch-stubs-fixme
MadCoder Jul 15, 2016
c16870e
cleanup: remove LINUX_PORT_HDD remnants from initial porting work
dgrove-oss Jul 15, 2016
2cfc71e
Merge pull request #107 from dgrove-oss/cleanup-hdd-remnants
MadCoder Jul 15, 2016
9b63963
autoconf support for selecting build variant
dgrove-oss Jul 19, 2016
927f394
Merge pull request #110 from dgrove-oss/build-variants
MadCoder Jul 19, 2016
b1bdd35
Add libkqueue as a git submodule to pick up kqueue fixes
seabaylea Jul 20, 2016
9128fb2
Merge pull request #109 from seabaylea/kqueue
MadCoder Jul 20, 2016
3088ec5
update libkqueue version to include PR-14 (kevent64 timer resolution …
dgrove-oss Jul 20, 2016
34df163
Merge pull request #112 from dgrove-oss/refresh-kqueue
MadCoder Jul 20, 2016
196c268
leverage of new kevent timer granularity functionality
frankeh Jul 20, 2016
afbcf85
Merge pull request #113 from frankeh/kevent_nsecs
MadCoder Jul 20, 2016
191a607
[Data] fix crash when creating iterator of empty DispatchData
springsup Jul 20, 2016
9e7cb39
Merge pull request #111 from karwa/master
mwwa Jul 20, 2016
4fd8252
deallocation support for DispatchData on Linux
dgrove-oss Jul 15, 2016
b31c464
Merge pull request #108 from dgrove-oss/data-destructor
mwwa Jul 21, 2016
5c303da
add dispatchMain to wrapping overlay
dgrove-oss Jul 11, 2016
89c4fe1
Merge pull request #102 from dgrove-oss/missing-dispatchMain
mwwa Jul 21, 2016
12bdffa
fix compilation error when building against old libkqueue
dgrove-oss Jul 21, 2016
6a37681
Merge pull request #114 from dgrove-oss/kevent-nsec-tweak
mwwa Jul 21, 2016
3776c2e
refresh libpwq submodule to include libpwq PR#14
dgrove-oss Jul 21, 2016
6c617c2
Merge pull request #115 from dgrove-oss/refresh-libpwq
MadCoder Jul 21, 2016
e6f5827
Update for SE-0107: Migrate Void->Raw.
atrick Jul 26, 2016
0939cb0
Merge pull request #120 from atrick/rawptr-void
atrick Jul 26, 2016
632ade4
[overlay-syncup] sync overlay changes to Linux
mwwa Jul 21, 2016
8a16704
UnsafeRawPointer fixes.
mwwa Jul 27, 2016
1493f94
Merge pull request #116 from mwwa/overlay-syncup
mwwa Jul 28, 2016
2aed5c6
Update INSTALL instructions
dgrove-oss Jul 28, 2016
cf8aae4
Merge pull request #123 from dgrove-oss/update-build-instructions
parkera Jul 28, 2016
f932a06
merge darwin/darwin-006
das Jul 29, 2016
fb84c14
Merge branch master into das-darwin-006-merge-master
das Aug 11, 2016
adc5775
fixes for compilation/linking problems on linux
dgrove-oss Aug 12, 2016
2c9f19e
xcode / autoconf plumbing to select module.modulemap file
dgrove-oss Aug 12, 2016
a23ea8c
ensure root_queues are initialized before main thread exits
dgrove-oss Aug 13, 2016
40a9bfb
Merge pull request #144 from dgrove-oss/linux-compile-fixes
das Aug 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ config
configure
libtool
.dirstamp
/dispatch/module.modulemap
/private/module.modulemap
26 changes: 26 additions & 0 deletions PATCHES
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,29 @@ github commits starting with 29bdc2f from
[4a6ec51] APPLIED rdar://25159995
[bc16cc9] APPLIED rdar://25159995
[954ace4] APPLIED rdar://25159995
[5ea30b5] APPLIED rdar://26822213
[9f1e778] APPLIED rdar://26822213
[3339b81] APPLIED rdar://26822213
[4fa8d8d] APPLIED rdar://26822213
[e922531] APPLIED rdar://26822213
[195cbcf] APPLIED rdar://27303844
[5b893c8] APPLIED rdar://27303844
[92689ed] APPLIED rdar://27303844
[ecc14fa] APPLIED rdar://27303844
[2dbf83c] APPLIED rdar://27303844
[78b9e82] APPLIED rdar://27303844
[2c0e5ee] APPLIED rdar://27303844
[5ee237f] APPLIED rdar://27600964
[77299ec] APPLIED rdar://27600964
[57c5c28] APPLIED rdar://27600964
[f8423ec] APPLIED rdar://27600964
[325f73d] APPLIED rdar://27600964
[b84e87e] APPLIED rdar://27600964
[ae71a91] APPLIED rdar://27600964
[8669dea] APPLIED rdar://27600964
[a8d0327] APPLIED rdar://27600964
[2e4e6af] APPLIED rdar://27600964
[2457fb2] APPLIED rdar://27600964
[4d58038] APPLIED rdar://27600964
[98d0a05] APPLIED rdar://27600964
[8976101] APPLIED rdar://27600964
4 changes: 4 additions & 0 deletions config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
don't. */
#define HAVE_DECL_FD_COPY 1

/* Define to 1 if you have the declaration of `NOTE_LOWAT', and to 0 if you
don't. */
#define HAVE_DECL_NOTE_LOWAT 1

/* Define to 1 if you have the declaration of `NOTE_NONE', and to 0 if you
don't. */
#define HAVE_DECL_NOTE_NONE 1
Expand Down
18 changes: 16 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ AC_CHECK_FUNCS([mach_port_construct])
#
AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC], [], [],
[[#include <time.h>]])
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL], [], [],
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL, NOTE_LOWAT], [], [],
[[#include <sys/event.h>]])
AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
Expand Down Expand Up @@ -432,6 +432,20 @@ AS_IF([test "x$have_mach" = "xtrue"], [
])
AM_CONDITIONAL(HAVE_DARWIN_LD, [test "x$dispatch_cv_ld_darwin" == "xyes"])

#
# symlink platform-specific module.modulemap files
#
AS_CASE([$target_os],
[darwin*], [ dispatch_module_map_os=darwin ],
[ dispatch_module_map_os=generic ]
)
AC_CONFIG_COMMANDS([modulemaps], [
ln -fs $dispatch_module_map_os/module.modulemap $ac_top_srcdir/dispatch/module.modulemap
ln -fs $dispatch_module_map_os/module.modulemap $ac_top_srcdir/private/module.modulemap
],
[dispatch_module_map_os="$dispatch_module_map_os"]
)

#
# Temporary: some versions of clang do not mark __builtin_trap() as
# __attribute__((__noreturn__)). Detect and add if required.
Expand All @@ -449,6 +463,6 @@ AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Mak
#
# Generate testsuite links
#
AC_CONFIG_LINKS([tests/dispatch:$top_srcdir/private tests/leaks-wrapper:tests/leaks-wrapper.sh])
AC_CONFIG_LINKS([tests/dispatch:$ac_top_srcdir/private tests/leaks-wrapper:tests/leaks-wrapper.sh])

AC_OUTPUT
11 changes: 11 additions & 0 deletions dispatch/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#define DISPATCH_MALLOC __attribute__((__malloc__))
#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__))
#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg)))
#else
/*! @parseOnly */
#define DISPATCH_NORETURN
Expand Down Expand Up @@ -99,6 +100,16 @@
#define DISPATCH_ALWAYS_INLINE
/*! @parseOnly */
#define DISPATCH_UNAVAILABLE
/*! @parseOnly */
#define DISPATCH_UNAVAILABLE_MSG(msg)
#endif

#ifdef __linux__
#define DISPATCH_LINUX_UNAVAILABLE() \
DISPATCH_UNAVAILABLE_MSG( \
"This interface is unavailable on linux systems")
#else
#define DISPATCH_LINUX_UNAVAILABLE()
#endif

#ifndef DISPATCH_ALIAS_V2
Expand Down
10 changes: 10 additions & 0 deletions dispatch/darwin/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Dispatch [system] [extern_c] {
umbrella header "dispatch.h"
module * { export * }
export *
}

module DispatchIntrospection [system] [extern_c] {
header "introspection.h"
export *
}
67 changes: 16 additions & 51 deletions dispatch/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,71 +24,36 @@
#ifdef __APPLE__
#include <Availability.h>
#include <TargetConditionals.h>
#endif
#include <sys/cdefs.h>
#include <sys/types.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>

#ifdef __has_attribute
#if __has_attribute(unavailable)
#define __DISPATCH_UNAVAILABLE(msg) __attribute__((__unavailable__(msg)))
#endif
#endif
#ifndef __DISPATCH_UNAVAILABLE
#define __DISPATCH_UNAVAILABLE(msg)
#endif

#ifdef __linux__
#if __has_feature(modules)
#include <stdio.h> // for off_t (to match Glibc.modulemap)
#endif
#define DISPATCH_LINUX_UNAVAILABLE() \
__DISPATCH_UNAVAILABLE("This interface is unavailable on linux systems")
#else
#define DISPATCH_LINUX_UNAVAILABLE()
#endif

#ifndef __OSX_AVAILABLE_STARTING
#define __OSX_AVAILABLE_STARTING(x, y)
#endif
#ifndef __OSX_AVAILABLE_BUT_DEPRECATED
#define __OSX_AVAILABLE_BUT_DEPRECATED(...)
#endif
#ifndef __OSX_AVAILABLE_BUT_DEPRECATED_MSG
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(...)
#endif

#ifndef __OSX_AVAILABLE
#define __OSX_AVAILABLE(...)
#endif
#ifndef __IOS_AVAILABLE
#define __IOS_AVAILABLE(...)
#endif
#ifndef __TVOS_AVAILABLE
#define __TVOS_AVAILABLE(...)
#endif
#ifndef __WATCHOS_AVAILABLE
#define __WATCHOS_AVAILABLE(...)
#endif
#ifndef __OSX_DEPRECATED
#define __OSX_DEPRECATED(...)
#endif
#ifndef __IOS_DEPRECATED
#define __IOS_DEPRECATED(...)
#endif
#ifndef __TVOS_DEPRECATED
#define __TVOS_DEPRECATED(...)
#endif
#ifndef __WATCHOS_DEPRECATED
#define __WATCHOS_DEPRECATED(...)
#endif // __APPLE__

#include <sys/cdefs.h>
#include <sys/types.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>

#if defined(__linux__) && defined(__has_feature)
#if __has_feature(modules)
#include <stdio.h> // for off_t (to match Glibc.modulemap)
#endif
#endif

#define DISPATCH_API_VERSION 20160612
#define DISPATCH_API_VERSION 20160712

#ifndef __DISPATCH_BUILDING_DISPATCH__

Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions dispatch/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ dispatch_group_async_f(dispatch_group_t group,
* @discussion
* This function waits for the completion of the blocks associated with the
* given dispatch group, and returns after all blocks have completed or when
* the specified timeout has elapsed. When a timeout occurs, the group is
* restored to its original state.
* the specified timeout has elapsed.
*
* This function will return immediately if there are no blocks associated
* with the dispatch group (i.e. the group is empty).
Expand Down Expand Up @@ -262,7 +261,7 @@ dispatch_group_enter(dispatch_group_t group);
*
* @discussion
* Calling this function indicates block has completed and left the dispatch
* groupJ by a means other than dispatch_group_async().
* group by a means other than dispatch_group_async().
*
* @param group
* The dispatch group to update.
Expand Down
4 changes: 2 additions & 2 deletions libdispatch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@
C01866BD1C5973210040FC07 /* libdispatch.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libdispatch.a; sourceTree = BUILT_PRODUCTS_DIR; };
C01866BE1C59735B0040FC07 /* libdispatch-mp-static.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "libdispatch-mp-static.xcconfig"; sourceTree = "<group>"; };
C01866BF1C5976C90040FC07 /* run-on-install.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "run-on-install.sh"; sourceTree = "<group>"; };
C901445E1C73A7FE002638FC /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
C90144641C73A845002638FC /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
C901445E1C73A7FE002638FC /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = darwin/module.modulemap; sourceTree = "<group>"; };
C90144641C73A845002638FC /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = darwin/module.modulemap; sourceTree = "<group>"; };
C913AC0E143BD34800B78976 /* data_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = data_private.h; sourceTree = "<group>"; tabWidth = 8; };
C927F35F10FD7F1000C5AB8B /* ddt.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ddt.xcodeproj; path = tools/ddt/ddt.xcodeproj; sourceTree = "<group>"; };
C96CE17A1CEB851600F4B8E6 /* dispatch_objc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = dispatch_objc.m; sourceTree = "<group>"; };
Expand Down
11 changes: 6 additions & 5 deletions man/dispatch_source_create.3
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ Sources of this type allow applications to manually trigger the source's event
handler via a call to
.Fn dispatch_source_merge_data .
The data will be merged with the source's pending data via an atomic add or
logic OR (based on the source's type), and the event handler block will be
submitted to the source's target queue. The
atomic bitwise OR (based on the source's type), and the event handler block will
be submitted to the source's target queue. The
.Fa data
is application defined. These sources have no
.Fa handle
Expand All @@ -297,7 +297,8 @@ The data returned by
.Fn dispatch_source_get_data
indicates which of the events in the
.Fa mask
were observed. Note that because this source type will request notifications on the provided port, it should not be mixed with the use of
were observed. Note that because this source type will request notifications on
the provided port, it should not be mixed with the use of
.Fn mach_port_request_notification
on the same port.
.Pp
Expand All @@ -314,8 +315,8 @@ on the mach port is waiting to be received.
.Pp
.Vt DISPATCH_SOURCE_TYPE_MEMORYPRESSURE
.Pp
Sources of this type monitor the system memory pressure condition for state changes.
The
Sources of this type monitor the system memory pressure condition for state
changes. The
.Fa handle
is unused and should be zero. The
.Fa mask
Expand Down
2 changes: 1 addition & 1 deletion os/firehose_buffer_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ typedef struct firehose_buffer_chunk_s {
uint8_t fbc_data[FIREHOSE_BUFFER_CHUNK_SIZE
- sizeof(firehose_buffer_pos_u)
- sizeof(uint64_t)];
} *firehose_buffer_chunk_t;
} __attribute__((aligned(8))) *firehose_buffer_chunk_t;

typedef struct firehose_buffer_range_s {
uint16_t fbr_offset; // offset from the start of the buffer
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions private/generic/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module DispatchPrivate [system] [extern_c] {
umbrella header "private.h"
exclude header "mach_private.h"
module * { export * }
export *
}

module DispatchIntrospectionPrivate [system] [extern_c] {
header "introspection_private.h"
export *
}
9 changes: 8 additions & 1 deletion private/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#endif /* !__DISPATCH_BUILDING_DISPATCH__ */

// <rdar://problem/9627726> Check that public and private dispatch headers match
#if DISPATCH_API_VERSION != 20160612 // Keep in sync with <dispatch/dispatch.h>
#if DISPATCH_API_VERSION != 20160712 // Keep in sync with <dispatch/dispatch.h>
#error "Dispatch header mismatch between /usr/include and /usr/local/include"
#endif

Expand Down Expand Up @@ -199,10 +199,17 @@ DISPATCH_EXPORT DISPATCH_NOTHROW
dispatch_runloop_handle_t
_dispatch_get_main_queue_handle_4CF(void);

#if TARGET_OS_MAC
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_NOTHROW
void
_dispatch_main_queue_callback_4CF(mach_msg_header_t *_Null_unspecified msg);
#else
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_NOTHROW
void
_dispatch_main_queue_callback_4CF(void *_Null_unspecified msg);
#endif

__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
Expand Down
17 changes: 17 additions & 0 deletions private/queue_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,23 @@ dispatch_pthread_root_queue_flags_pool_size(uint8_t pool_size)

#endif /* __BLOCKS__ */

/*!
* @function dispatch_pthread_root_queue_copy_current
*
* @abstract
* Returns a reference to the pthread root queue object that has created the
* currently executing thread, or NULL if the current thread is not associated
* to a pthread root queue.
*
* @result
* A new reference to a pthread root queue object or NULL.
*/
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_queue_t _Nullable
dispatch_pthread_root_queue_copy_current(void);

/*!
* @constant DISPATCH_APPLY_CURRENT_ROOT_QUEUE
* @discussion Constant to pass to the dispatch_apply() and dispatch_apply_f()
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ if BUILD_OWN_BLOCKS_RUNTIME
libdispatch_la_SOURCES+= BlocksRuntime/data.c BlocksRuntime/runtime.c
CBLOCKS_FLAGS+= -I$(top_srcdir)/src/BlocksRuntime
CXXBLOCKS_FLAGS+= -I$(top_srcdir)/src/BlocksRuntime
BLOCKS_RUNTIME_LIBS=-ldl
endif

libdispatch_la_LDFLAGS=-avoid-version
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS)
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS) $(BLOCKS_RUNTIME_LIBS)

if HAVE_DARWIN_LD
libdispatch_la_LDFLAGS+=-Wl,-compatibility_version,1 \
Expand Down
11 changes: 11 additions & 0 deletions src/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ _dispatch_apply_invoke2(void *ctxt, long invoke_flags)
_dispatch_thread_event_destroy(&da->da_event);
}
if (os_atomic_dec2o(da, da_thr_cnt, release) == 0) {
#if DISPATCH_INTROSPECTION
_dispatch_continuation_free(da->da_dc);
#endif
_dispatch_continuation_free((dispatch_continuation_t)da);
}
}
Expand Down Expand Up @@ -145,6 +148,9 @@ _dispatch_apply_serial(void *ctxt)
});
} while (++idx < iter);

#if DISPATCH_INTROSPECTION
_dispatch_continuation_free(da->da_dc);
#endif
_dispatch_continuation_free((dispatch_continuation_t)da);
}

Expand Down Expand Up @@ -262,7 +268,12 @@ dispatch_apply_f(size_t iterations, dispatch_queue_t dq, void *ctxt,
da->da_iterations = iterations;
da->da_nested = nested;
da->da_thr_cnt = thr_cnt;
#if DISPATCH_INTROSPECTION
da->da_dc = _dispatch_continuation_alloc();
*da->da_dc = dc;
#else
da->da_dc = &dc;
#endif
da->da_flags = 0;

if (slowpath(dq->dq_width == 1) || slowpath(thr_cnt <= 1)) {
Expand Down
Loading