Revision: 98 http://trac.macosforge.org/projects/libdispatch/changeset/98 Author: robert@fledge.watson.org Date: 2009-11-03 06:35:21 -0800 (Tue, 03 Nov 2009) Log Message: ----------- Complete implementation of DISPATCH_NO_LEGACY so that legacy.h can be excluded from non-legacy builds. Submitted by: Daniel A. Steffen <dsteffen@apple.com> Modified Paths: -------------- trunk/src/internal.h trunk/src/legacy.c trunk/src/queue.c trunk/src/shims/mach.c trunk/src/source.c trunk/src/source_internal.h Modified: trunk/src/internal.h =================================================================== --- trunk/src/internal.h 2009-11-03 14:33:06 UTC (rev 97) +++ trunk/src/internal.h 2009-11-03 14:35:21 UTC (rev 98) @@ -52,7 +52,10 @@ #include "queue_private.h" #include "source_private.h" #include "private.h" + +#ifndef DISPATCH_NO_LEGACY #include "legacy.h" +#endif /* More #includes at EOF (dependent on the contents of internal.h) ... */ /* The "_debug" library build */ Modified: trunk/src/legacy.c =================================================================== --- trunk/src/legacy.c 2009-11-03 14:33:06 UTC (rev 97) +++ trunk/src/legacy.c 2009-11-03 14:35:21 UTC (rev 98) @@ -19,6 +19,8 @@ */ #include "internal.h" + +#ifndef DISPATCH_NO_LEGACY #include "legacy.h" /* @@ -83,8 +85,6 @@ } #endif /* __BLOCKS__ */ -#ifndef DISPATCH_NO_LEGACY - sigset_t dispatch_event_get_signals(dispatch_event_t de) { Modified: trunk/src/queue.c =================================================================== --- trunk/src/queue.c 2009-11-03 14:33:06 UTC (rev 97) +++ trunk/src/queue.c 2009-11-03 14:35:21 UTC (rev 98) @@ -130,6 +130,7 @@ struct dispatch_queue_attr_s { DISPATCH_STRUCT_HEADER(dispatch_queue_attr_s, dispatch_queue_attr_vtable_s); +#ifndef DISPATCH_NO_LEGACY // Public: int qa_priority; void* finalizer_ctxt; @@ -137,6 +138,7 @@ // Private: unsigned long qa_flags; +#endif }; static int _dispatch_pthread_sigmask(int how, sigset_t *set, sigset_t *oset); @@ -951,6 +953,7 @@ #endif } +#ifndef DISPATCH_NO_LEGACY dispatch_queue_t dispatch_get_concurrent_queue(long pri) { @@ -961,6 +964,7 @@ } return _dispatch_get_root_queue(pri, false); } +#endif static void _dispatch_queue_cleanup(void *ctxt) Modified: trunk/src/shims/mach.c =================================================================== --- trunk/src/shims/mach.c 2009-11-03 14:33:06 UTC (rev 97) +++ trunk/src/shims/mach.c 2009-11-03 14:35:21 UTC (rev 98) @@ -35,6 +35,7 @@ return context; } +#ifndef DISPATCH_NO_LEGACY /* * Raw Mach message support */ @@ -64,4 +65,5 @@ return TRUE; } +#endif #endif /* HAVE_MACH */ Modified: trunk/src/source.c =================================================================== --- trunk/src/source.c 2009-11-03 14:33:06 UTC (rev 97) +++ trunk/src/source.c 2009-11-03 14:35:21 UTC (rev 98) @@ -27,6 +27,22 @@ #include "kevent_internal.h" +#ifdef DISPATCH_NO_LEGACY +enum { + DISPATCH_TIMER_WALL_CLOCK = 0x4, +}; +enum { + DISPATCH_TIMER_INTERVAL = 0x0, + DISPATCH_TIMER_ONESHOT = 0x1, + DISPATCH_TIMER_ABSOLUTE = 0x3, +}; +enum { + DISPATCH_MACHPORT_DEAD = 0x1, + DISPATCH_MACHPORT_RECV = 0x2, + DISPATCH_MACHPORT_DELETED = 0x4, +}; +#endif + #define DISPATCH_EVFILT_TIMER (-EVFILT_SYSCOUNT - 1) #define DISPATCH_EVFILT_CUSTOM_ADD (-EVFILT_SYSCOUNT - 2) #define DISPATCH_EVFILT_CUSTOM_OR (-EVFILT_SYSCOUNT - 3) @@ -739,7 +755,11 @@ } if (dispatch_assume(prev)) { if (ds->ds_handler_func) { - ds->ds_handler_func(ds->ds_handler_ctxt, ds); +#ifndef DISPATCH_NO_LEGACY + ((dispatch_source_handler_function_t)ds->ds_handler_func)(ds->ds_handler_ctxt, ds); +#else + ds->ds_handler_func(ds->ds_handler_ctxt); +#endif } } } @@ -1275,7 +1295,7 @@ ds->ds_is_legacy = true; - ds->ds_handler_func = handler; + ds->ds_handler_func = (dispatch_function_t)handler; ds->ds_handler_ctxt = context; if (attr && attr != DISPATCH_SOURCE_CREATE_SUSPENDED) { @@ -1303,7 +1323,7 @@ } // all legacy sources get a cancellation event on the normal event handler. - dispatch_source_handler_function_t func = ds->ds_handler_func; + dispatch_function_t func = ds->ds_handler_func; dispatch_source_handler_t block = ds->ds_handler_ctxt; void *ctxt = ds->ds_handler_ctxt; bool handler_is_block = ds->ds_handler_is_block; @@ -1315,7 +1335,7 @@ }); } else { ds->ds_cancel_handler = _dispatch_Block_copy(^{ - func(ctxt, ds); + ((dispatch_source_handler_function_t)func)(ctxt, ds); }); } #endif Modified: trunk/src/source_internal.h =================================================================== --- trunk/src/source_internal.h 2009-11-03 14:33:06 UTC (rev 97) +++ trunk/src/source_internal.h 2009-11-03 14:35:21 UTC (rev 98) @@ -67,7 +67,7 @@ char dq_label[8]; dispatch_kevent_t ds_dkev; - dispatch_source_handler_function_t ds_handler_func; + dispatch_function_t ds_handler_func; void *ds_handler_ctxt; void *ds_cancel_handler;