@@ -28,7 +28,41 @@ extern "C" void *_Block_copy(const void *);
2828extern " C" void _Block_release (const void *);
2929#endif
3030
31+ #if __has_include(<dispatch/dispatch.h>)
3132#include < dispatch/dispatch.h>
33+ #else
34+ // on Linux dispatch/dispatch.h is only available with unsafe Swift flags,
35+ // which preclude the use of this package as a versioned dependency
36+ struct dispatch_source_type_s {} __attribute__((aligned(sizeof (uintptr_t ))));
37+
38+ typedef struct dispatch_source_s *dispatch_source_t ;
39+ typedef struct dispatch_queue_s *dispatch_queue_t ;
40+ typedef const struct dispatch_source_type_s *dispatch_source_type_t ;
41+
42+ typedef void (^dispatch_block_t )(void );
43+
44+ extern " C" {
45+ extern const struct dispatch_source_type_s _dispatch_source_type_read;
46+
47+ void dispatch_release (void *object);
48+ void dispatch_resume (void *object);
49+
50+ void *dispatch_get_context (void *object);
51+ void dispatch_set_context (void *object, void *context);
52+
53+ void dispatch_source_cancel (void *object);
54+ void dispatch_source_set_event_handler (dispatch_source_t source, dispatch_block_t handler);
55+ void dispatch_source_set_cancel_handler (dispatch_source_t source, dispatch_block_t handler);
56+
57+ dispatch_queue_t dispatch_get_global_queue (intptr_t identifier, uintptr_t flags);
58+ dispatch_source_t dispatch_source_create (dispatch_source_type_t type, uintptr_t handle, uintptr_t mask, dispatch_queue_t queue);
59+ }
60+
61+ #define dispatch_cancel dispatch_source_cancel
62+ #define DISPATCH_QUEUE_PRIORITY_DEFAULT 0
63+ #define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read)
64+
65+ #endif
3266
3367#include " CIORingShims.h"
3468
0 commit comments