- DISPATCH_STRUCT_HEADER(dispatch_source_s, dispatch_source_vtable_s);
- DISPATCH_QUEUE_HEADER;
- // Instruments always copies DISPATCH_QUEUE_MIN_LABEL_SIZE, which is 64,
- // so the remainder of the structure must be big enough
- union {
- char _ds_pad[DISPATCH_QUEUE_MIN_LABEL_SIZE];
- struct {
- char dq_label[8];
- dispatch_kevent_t ds_dkev;
-
- dispatch_source_handler_function_t ds_handler_func;
- void *ds_handler_ctxt;
-
- void *ds_cancel_handler;
-
- unsigned int ds_is_level:1,
- ds_is_adder:1,
- ds_is_installed:1,
- ds_needs_rearm:1,
- ds_is_armed:1,
- ds_is_legacy:1,
- ds_cancel_is_block:1,
- ds_handler_is_block:1;
-
- unsigned int ds_atomic_flags;
-
- unsigned long ds_data;
- unsigned long ds_pending_data;
- unsigned long ds_pending_data_mask;
-
- TAILQ_ENTRY(dispatch_source_s) ds_list;
-
- unsigned long ds_ident_hack;
-
- struct dispatch_timer_source_s ds_timer;
- };
- };
-};
+ _DISPATCH_SOURCE_HEADER(source);
+ uint64_t ds_data DISPATCH_ATOMIC64_ALIGN;
+ uint64_t ds_pending_data DISPATCH_ATOMIC64_ALIGN;
+} DISPATCH_ATOMIC64_ALIGN;
+
+// Extracts source data from the ds_data field
+#define DISPATCH_SOURCE_GET_DATA(d) ((d) & 0xFFFFFFFF)
+
+// Extracts status from the ds_data field
+#define DISPATCH_SOURCE_GET_STATUS(d) ((d) >> 32)
+
+// Combine data and status for the ds_data field
+#define DISPATCH_SOURCE_COMBINE_DATA_AND_STATUS(data, status) \
+ ((((uint64_t)(status)) << 32) | (data))
+
+#endif // __cplusplus
+
+void _dispatch_source_refs_register(dispatch_source_t ds,
+ dispatch_wlh_t wlh, dispatch_priority_t bp);
+void _dispatch_source_refs_unregister(dispatch_source_t ds, uint32_t options);
+void _dispatch_source_xref_dispose(dispatch_source_t ds);
+void _dispatch_source_dispose(dispatch_source_t ds, bool *allow_free);
+void _dispatch_source_finalize_activation(dispatch_source_t ds,
+ bool *allow_resume);
+void _dispatch_source_invoke(dispatch_source_t ds,
+ dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
+void _dispatch_source_wakeup(dispatch_source_t ds, dispatch_qos_t qos,
+ dispatch_wakeup_flags_t flags);
+void _dispatch_source_merge_evt(dispatch_unote_t du, uint32_t flags,
+ uintptr_t data, uintptr_t status, pthread_priority_t pp);
+size_t _dispatch_source_debug(dispatch_source_t ds, char* buf, size_t bufsiz);