Merge pull request #224 from dgrove-oss/epoll_support_dispatch_test

SR-4026: dispatch_test_check_evfilt_read_for_fd for epoll
diff --git a/src/BlocksRuntime/data.c b/src/BlocksRuntime/data.c
index 0837176..dd36051 100644
--- a/src/BlocksRuntime/data.c
+++ b/src/BlocksRuntime/data.c
@@ -14,7 +14,7 @@
 
 We keep these in a separate file so that we can include the runtime code in test subprojects but not include the data so that compiled code that sees the data in libSystem doesn't get confused by a second copy.  Somehow these don't get unified in a common block.
 **********************/
-#define BLOCK_EXPORT extern __attribute__((visibility("default")))
+#define BLOCK_EXPORT __attribute__((visibility("default")))
 
 BLOCK_EXPORT void * _NSConcreteStackBlock[32] = { 0 };
 BLOCK_EXPORT void * _NSConcreteMallocBlock[32] = { 0 };
diff --git a/src/BlocksRuntime/runtime.c b/src/BlocksRuntime/runtime.c
index 164fe6e..8ec64cd 100644
--- a/src/BlocksRuntime/runtime.c
+++ b/src/BlocksRuntime/runtime.c
@@ -53,9 +53,11 @@
 Globals
 ************************/
 
+#if HAVE_OBJC
 static void *_Block_copy_class = _NSConcreteMallocBlock;
 static void *_Block_copy_finalizing_class = _NSConcreteMallocBlock;
 static int _Block_copy_flag = BLOCK_NEEDS_FREE;
+#endif
 static int _Byref_flag_initial_value = BLOCK_BYREF_NEEDS_FREE | 4;  // logical 2
 
 static bool isGC = false;
@@ -156,7 +158,9 @@
 static void _Block_setHasRefcount_default(const void *ptr, const bool hasRefcount) {
 }
 
+#if HAVE_OBJC
 static void _Block_do_nothing(const void *aBlock) { }
+#endif
 
 static void _Block_retain_object_default(const void *ptr) {
 }
@@ -176,6 +180,7 @@
     memmove(dst, src, (size_t)size);
 }
 
+#if HAVE_OBJC
 static void _Block_memmove_gc_broken(void *dest, void *src, unsigned long size) {
     void **destp = (void **)dest;
     void **srcp = (void **)src;
@@ -186,6 +191,7 @@
         size -= sizeof(void *);
     }
 }
+#endif
 
 static void _Block_destructInstance_default(const void *aBlock) {}
 
diff --git a/src/init.c b/src/init.c
index 29d8c4e..a04daeb 100644
--- a/src/init.c
+++ b/src/init.c
@@ -398,6 +398,7 @@
 	.do_kind = "global-queue",
 	.do_dispose = _dispatch_pthread_root_queue_dispose,
 	.do_push = _dispatch_root_queue_push,
+	.do_invoke = NULL,
 	.do_wakeup = _dispatch_root_queue_wakeup,
 	.do_debug = dispatch_queue_debug,
 );
@@ -406,8 +407,8 @@
 	.do_type = DISPATCH_QUEUE_SERIAL_TYPE,
 	.do_kind = "main-queue",
 	.do_dispose = _dispatch_queue_dispose,
-	.do_invoke = _dispatch_queue_invoke,
 	.do_push = _dispatch_queue_push,
+	.do_invoke = _dispatch_queue_invoke,
 	.do_wakeup = _dispatch_main_queue_wakeup,
 	.do_debug = dispatch_queue_debug,
 );
@@ -416,8 +417,8 @@
 	.do_type = DISPATCH_QUEUE_RUNLOOP_TYPE,
 	.do_kind = "runloop-queue",
 	.do_dispose = _dispatch_runloop_queue_dispose,
-	.do_invoke = _dispatch_queue_invoke,
 	.do_push = _dispatch_queue_push,
+	.do_invoke = _dispatch_queue_invoke,
 	.do_wakeup = _dispatch_runloop_queue_wakeup,
 	.do_debug = dispatch_queue_debug,
 );
@@ -425,8 +426,8 @@
 DISPATCH_VTABLE_SUBCLASS_INSTANCE(queue_mgr, queue,
 	.do_type = DISPATCH_QUEUE_MGR_TYPE,
 	.do_kind = "mgr-queue",
-	.do_invoke = _dispatch_mgr_thread,
 	.do_push = _dispatch_queue_push,
+	.do_invoke = _dispatch_mgr_thread,
 	.do_wakeup = _dispatch_mgr_queue_wakeup,
 	.do_debug = dispatch_queue_debug,
 );
@@ -435,6 +436,7 @@
 	.do_type = DISPATCH_QUEUE_SPECIFIC_TYPE,
 	.do_kind = "queue-context",
 	.do_dispose = _dispatch_queue_specific_queue_dispose,
+	.do_push = (void *)_dispatch_queue_push,
 	.do_invoke = (void *)_dispatch_queue_invoke,
 	.do_wakeup = (void *)_dispatch_queue_wakeup,
 	.do_debug = (void *)dispatch_queue_debug,
diff --git a/src/source.c b/src/source.c
index c202046..7c85c74 100644
--- a/src/source.c
+++ b/src/source.c
@@ -2515,7 +2515,7 @@
 			"mask = 0x%x, pending_data = 0x%llx, registered = %d, "
 			"armed = %d, deleted = %d%s, canceled = %d, ",
 			target && target->dq_label ? target->dq_label : "", target,
-			dr->du_ident, dr->du_fflags, ds->ds_pending_data,
+			dr->du_ident, dr->du_fflags, (unsigned long long)ds->ds_pending_data,
 			ds->ds_is_installed, (bool)(ds->dq_atomic_flags & DSF_ARMED),
 			(bool)(ds->dq_atomic_flags & DSF_DELETED),
 			(ds->dq_atomic_flags & DSF_DEFERRED_DELETE) ? " (pending)" : "",
diff --git a/tests/Makefile.am b/tests/Makefile.am
index da3f39d..a476130 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,7 +41,6 @@
 	dispatch_drift				\
 	dispatch_readsync			\
 	dispatch_cascade			\
-	dispatch_context_for_key	\
 	dispatch_io
 
 if EXTENDED_TEST_SUITE
@@ -60,6 +59,7 @@
 	dispatch_group				\
 	dispatch_overcommit			\
 	dispatch_plusplus			\
+	dispatch_context_for_key	\
 	dispatch_after				\
 	dispatch_timer				\
 	dispatch_timer_short		\
diff --git a/tests/dispatch_data.c b/tests/dispatch_data.c
index 8b6bd1c..d574768 100644
--- a/tests/dispatch_data.c
+++ b/tests/dispatch_data.c
@@ -79,13 +79,14 @@
 static void
 test_cleanup(void) // <rdar://problem/9843440>
 {
+	static char buffer4[16];
 	dispatch_group_enter(g);
 	dispatch_async(dispatch_get_main_queue(), ^{
 		void *buffer3 = malloc(1024);
 		dispatch_data_t data3 = dispatch_data_create(buffer3, 0,
 				dispatch_get_main_queue(), DISPATCH_DATA_DESTRUCTOR_FREE);
 		__block bool buffer4_destroyed = false;
-		dispatch_data_t data4 = dispatch_data_create(NULL, 1024,
+		dispatch_data_t data4 = dispatch_data_create(buffer4, 16,
 				dispatch_get_main_queue(), ^{
 			buffer4_destroyed = true;
 		});