Skip to content

Commit 4a6ec51

Browse files
committed
Merge pull request swiftlang#74 from dgrove-oss/enable_dispatch_block_create_on_linux_master
Enable dispatch_block_create for Linux
2 parents 65330e0 + 189ed6c commit 4a6ec51

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/Makefile.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ DISPATCH_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \
6161
$(MARCH_FLAGS) $(KQUEUE_CFLAGS) $(BSD_OVERLAY_CFLAGS)
6262
AM_CFLAGS= $(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
6363
AM_OBJCFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
64-
AM_CXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
64+
AM_CXXFLAGS=$(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
6565
AM_OBJCXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
6666

6767
if BUILD_OWN_PTHREAD_WORKQUEUES
@@ -90,6 +90,9 @@ libdispatch_la_LDFLAGS+=-Wl,-upward-lobjc -Wl,-upward-lauto \
9090
-Wl,-order_file,$(top_srcdir)/xcodeconfig/libdispatch.order \
9191
-Wl,-alias_list,$(top_srcdir)/xcodeconfig/libdispatch_objc.aliases \
9292
-Wl,-unexported_symbols_list,$(top_srcdir)/xcodeconfig/libdispatch.unexport
93+
else
94+
libdispatch_la_SOURCES+=block.cpp
95+
libdispatch_la_CXXFLAGS=$(AM_CXXFLAGS) -std=gnu++11 -fno-exceptions
9396
endif
9497

9598
if USE_MIG

src/block.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ extern "C" {
103103
// The compiler hides the name of the function it generates, and changes it if
104104
// we try to reference it directly, but the linker still sees it.
105105
extern void DISPATCH_BLOCK_SPECIAL_INVOKE(void *)
106+
#ifdef __linux__
107+
asm("___dispatch_block_create_block_invoke");
108+
#else
106109
asm("____dispatch_block_create_block_invoke");
110+
#endif
107111
void (*_dispatch_block_special_invoke)(void*) = DISPATCH_BLOCK_SPECIAL_INVOKE;
108112
}
109113

src/shims/linux_stubs.c

-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@
3535
#undef LINUX_PORT_ERROR
3636
#define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); abort(); } while (0)
3737

38-
dispatch_block_t _dispatch_block_create(dispatch_block_flags_t flags,
39-
voucher_t voucher, pthread_priority_t priority,
40-
dispatch_block_t block) {
41-
LINUX_PORT_ERROR();
42-
}
43-
4438
unsigned long _dispatch_runloop_queue_probe(dispatch_queue_t dq) {
4539
LINUX_PORT_ERROR();
4640
}

0 commit comments

Comments
 (0)