Skip to content

Further integration of Dispatch into Foundation #338

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 1 commit into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion CoreFoundation/Base.subproj/CFInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,12 @@ CF_EXPORT void _NS_pthread_setname_np(const char *name);
#define pthread_setname_np _NS_pthread_setname_np
#endif

#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if DEPLOYMENT_TARGET_LINUX
CF_EXPORT Boolean _CFIsMainThread(void);
#define pthread_main_np _CFIsMainThread
#endif

#if DEPLOYMENT_TARGET_WINDOWS
// replacement for DISPATCH_QUEUE_OVERCOMMIT until we get a bug fix in dispatch on Windows
// <rdar://problem/7923891> dispatch on Windows: Need queue_private.h
#define DISPATCH_QUEUE_OVERCOMMIT 2
Expand Down
5 changes: 5 additions & 0 deletions CoreFoundation/Base.subproj/CFPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ const char *_CFProcessPath(void) {

#if DEPLOYMENT_TARGET_LINUX
#include <unistd.h>
#include <syscall.h>

Boolean _CFIsMainThread(void) {
return syscall(SYS_gettid) == getpid();
}

const char *_CFProcessPath(void) {
if (__CFProcessPath) return __CFProcessPath;
Expand Down
4 changes: 2 additions & 2 deletions CoreFoundation/RunLoop.subproj/CFRunLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ DISPATCH_EXPORT void _dispatch_main_queue_callback_4CF(void);
#include <sys/eventfd.h>
#include <sys/timerfd.h>

#define _dispatch_get_main_queue_port_4CF dispatch_get_main_queue_eventfd_np
#define _dispatch_main_queue_callback_4CF(x) dispatch_main_queue_drain_np()
#define _dispatch_get_main_queue_port_4CF dispatch_get_main_queue_eventfd_4CF
#define _dispatch_main_queue_callback_4CF(x) dispatch_main_queue_drain_4CF()
#endif

#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_IPHONESIMULATOR || DEPLOYMENT_TARGET_LINUX
Expand Down
18 changes: 11 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@
'-I/usr/include/libxml2'
]

# Disable until changes are merged into dispatch.
# Configure use of Dispatch in CoreFoundation and Foundation if libdispatch is being built
#if "LIBDISPATCH_SOURCE_DIR" in Configuration.current.variables:
# foundation.CFLAGS += " "+" ".join([
# '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
# '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
# '-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests' # for include of dispatch/private.h in CF
# ])

# foundation.CFLAGS += " "+" ".join([
# '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
# '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
# '-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests' # for include of dispatch/private.h in CF
# ])
# swift_cflags += ([
# '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
# '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
# ])
# foundation.LDFLAGS += '-ldispatch -L'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/src/.libs '

foundation.SWIFTCFLAGS = " ".join(swift_cflags)

Expand Down