Skip to content

Commit a7d7805

Browse files
committed
Further integration of Dispatch into Foundation
1 parent 660193d commit a7d7805

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CoreFoundation/Base.subproj/CFInternal.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,12 @@ CF_EXPORT void _NS_pthread_setname_np(const char *name);
805805
#define pthread_setname_np _NS_pthread_setname_np
806806
#endif
807807

808-
#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
808+
#if DEPLOYMENT_TARGET_LINUX
809+
CF_EXPORT Boolean _CFIsMainThread(void);
810+
#define pthread_main_np _CFIsMainThread
811+
#endif
812+
813+
#if DEPLOYMENT_TARGET_WINDOWS
809814
// replacement for DISPATCH_QUEUE_OVERCOMMIT until we get a bug fix in dispatch on Windows
810815
// <rdar://problem/7923891> dispatch on Windows: Need queue_private.h
811816
#define DISPATCH_QUEUE_OVERCOMMIT 2

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ const char *_CFProcessPath(void) {
157157

158158
#if DEPLOYMENT_TARGET_LINUX
159159
#include <unistd.h>
160+
#include <syscall.h>
161+
162+
Boolean _CFIsMainThread(void) {
163+
return syscall(SYS_gettid) == getpid();
164+
}
160165

161166
const char *_CFProcessPath(void) {
162167
if (__CFProcessPath) return __CFProcessPath;

CoreFoundation/RunLoop.subproj/CFRunLoop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ DISPATCH_EXPORT void _dispatch_main_queue_callback_4CF(void);
7878
#include <sys/eventfd.h>
7979
#include <sys/timerfd.h>
8080

81-
#define _dispatch_get_main_queue_port_4CF dispatch_get_main_queue_eventfd_np
82-
#define _dispatch_main_queue_callback_4CF(x) dispatch_main_queue_drain_np()
81+
#define _dispatch_get_main_queue_port_4CF dispatch_get_main_queue_eventfd_4CF
82+
#define _dispatch_main_queue_callback_4CF(x) dispatch_main_queue_drain_4CF()
8383
#endif
8484

8585
#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_IPHONESIMULATOR || DEPLOYMENT_TARGET_LINUX

build.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@
6464
'-I/usr/include/libxml2'
6565
]
6666

67-
# Disable until changes are merged into dispatch.
68-
#if "LIBDISPATCH_SOURCE_DIR" in Configuration.current.variables:
69-
# foundation.CFLAGS += " "+" ".join([
70-
# '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
71-
# '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
72-
# '-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests' # for include of dispatch/private.h in CF
73-
# ])
74-
67+
# Configure use of Dispatch in CoreFoundation and Foundation if libdispatch is being built
68+
if "LIBDISPATCH_SOURCE_DIR" in Configuration.current.variables:
69+
# foundation.CFLAGS += " "+" ".join([
70+
# '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
71+
# '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
72+
# '-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests' # for include of dispatch/private.h in CF
73+
# ])
74+
# swift_cflags += ([
75+
# '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
76+
# '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
77+
# ])
78+
# foundation.LDFLAGS += '-ldispatch -L'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/src/.libs '
7579

7680
foundation.SWIFTCFLAGS = " ".join(swift_cflags)
7781

0 commit comments

Comments
 (0)