1
1
#![ allow( missing_docs) ]
2
2
#![ allow( non_camel_case_types) ]
3
3
4
+ use libc:: uintptr_t;
4
5
use std:: os:: raw:: { c_char, c_long, c_ulong, c_void} ;
5
6
6
7
#[ repr( C ) ]
7
8
pub struct dispatch_object_s { _private : [ u8 ; 0 ] }
8
9
10
+ #[ repr( C ) ]
11
+ pub struct dispatch_source_type_s { _private : [ u8 ; 0 ] }
12
+
9
13
// dispatch_block_t
10
14
pub type dispatch_function_t = extern fn ( * mut c_void ) ;
11
15
pub type dispatch_semaphore_t = * mut dispatch_object_s ;
@@ -14,7 +18,8 @@ pub type dispatch_object_t = *mut dispatch_object_s;
14
18
pub type dispatch_once_t = c_long ;
15
19
pub type dispatch_queue_t = * mut dispatch_object_s ;
16
20
pub type dispatch_time_t = u64 ;
17
- // dispatch_source_type_t
21
+ pub type dispatch_source_t = * mut dispatch_object_s ;
22
+ pub type dispatch_source_type_t = * const dispatch_source_type_s ;
18
23
// dispatch_fd_t
19
24
// dispatch_data_t
20
25
// dispatch_data_applier_t
@@ -77,20 +82,32 @@ extern {
77
82
// void dispatch_barrier_sync ( dispatch_queue_t queue, dispatch_block_t block );
78
83
pub fn dispatch_barrier_sync_f ( queue : dispatch_queue_t , context : * mut c_void , work : dispatch_function_t ) ;
79
84
80
- // void dispatch_source_cancel ( dispatch_source_t source );
81
- // dispatch_source_t dispatch_source_create ( dispatch_source_type_t type, uintptr_t handle, unsigned long mask, dispatch_queue_t queue );
82
- // unsigned long dispatch_source_get_data ( dispatch_source_t source );
83
- // uintptr_t dispatch_source_get_handle ( dispatch_source_t source );
84
- // unsigned long dispatch_source_get_mask ( dispatch_source_t source );
85
- // void dispatch_source_merge_data ( dispatch_source_t source, unsigned long value );
85
+ static _dispatch_source_type_data_add: dispatch_source_type_s ;
86
+ static _dispatch_source_type_data_or: dispatch_source_type_s ;
87
+ static _dispatch_source_type_mach_send: dispatch_source_type_s ;
88
+ static _dispatch_source_type_mach_recv: dispatch_source_type_s ;
89
+ static _dispatch_source_type_memorypressure: dispatch_source_type_s ;
90
+ static _dispatch_source_type_proc: dispatch_source_type_s ;
91
+ static _dispatch_source_type_read: dispatch_source_type_s ;
92
+ static _dispatch_source_type_signal: dispatch_source_type_s ;
93
+ static _dispatch_source_type_timer: dispatch_source_type_s ;
94
+ static _dispatch_source_type_vnode: dispatch_source_type_s ;
95
+ static _dispatch_source_type_write: dispatch_source_type_s ;
96
+
97
+ pub fn dispatch_source_cancel ( source : dispatch_source_t ) ;
98
+ pub fn dispatch_source_create ( type_ : dispatch_source_type_t , handle : uintptr_t , mask : c_ulong , queue : dispatch_queue_t ) -> dispatch_source_t ;
99
+ pub fn dispatch_source_get_data ( source : dispatch_source_t ) -> c_ulong ;
100
+ pub fn dispatch_source_get_handle ( source : dispatch_source_t ) -> uintptr_t ;
101
+ pub fn dispatch_source_get_mask ( source : dispatch_source_t ) -> c_ulong ;
102
+ pub fn dispatch_source_merge_data ( source : dispatch_source_t , value : c_ulong ) ;
86
103
// void dispatch_source_set_registration_handler ( dispatch_source_t source, dispatch_block_t handler );
87
- // void dispatch_source_set_registration_handler_f ( dispatch_source_t source, dispatch_function_t handler );
104
+ pub fn dispatch_source_set_registration_handler_f ( source : dispatch_source_t , handler : dispatch_function_t ) ;
88
105
// void dispatch_source_set_cancel_handler ( dispatch_source_t source, dispatch_block_t handler );
89
- // void dispatch_source_set_cancel_handler_f ( dispatch_source_t source, dispatch_function_t handler );
106
+ pub fn dispatch_source_set_cancel_handler_f ( source : dispatch_source_t , handler : dispatch_function_t ) ;
90
107
// void dispatch_source_set_event_handler ( dispatch_source_t source, dispatch_block_t handler );
91
- // void dispatch_source_set_event_handler_f ( dispatch_source_t source, dispatch_function_t handler );
92
- // void dispatch_source_set_timer ( dispatch_source_t source, dispatch_time_t start, uint64_t interval, uint64_t leeway );
93
- // long dispatch_source_testcancel ( dispatch_source_t source ) ;
108
+ pub fn dispatch_source_set_event_handler_f ( source : dispatch_source_t , handler : dispatch_function_t ) ;
109
+ pub fn dispatch_source_set_timer ( source : dispatch_source_t , start : dispatch_time_t , interval : u64 , leeway : u64 ) ;
110
+ pub fn dispatch_source_testcancel ( source : dispatch_source_t ) -> c_long ;
94
111
95
112
// void dispatch_read ( dispatch_fd_t fd, size_t length, dispatch_queue_t queue, void (^handler)(dispatch_data_t data, int error) );
96
113
// void dispatch_write ( dispatch_fd_t fd, dispatch_data_t data, dispatch_queue_t queue, void (^handler)(dispatch_data_t data, int error) );
@@ -146,6 +163,49 @@ pub const DISPATCH_QUEUE_PRIORITY_BACKGROUND: c_long = -1 << 15;
146
163
pub const DISPATCH_TIME_NOW : dispatch_time_t = 0 ;
147
164
pub const DISPATCH_TIME_FOREVER : dispatch_time_t = !0 ;
148
165
166
+ pub type dispatch_source_mach_send_flags_t = c_ulong ;
167
+
168
+ pub const DISPATCH_MACH_SEND_DEAD : dispatch_source_mach_send_flags_t = 1 ;
169
+
170
+ pub type dispatch_source_memorypressure_flags_t = c_ulong ;
171
+
172
+ pub const DISPATCH_MEMORYPRESSURE_NORMAL : dispatch_source_memorypressure_flags_t = 0x1 ;
173
+ pub const DISPATCH_MEMORYPRESSURE_WARN : dispatch_source_memorypressure_flags_t = 0x2 ;
174
+ pub const DISPATCH_MEMORYPRESSURE_CRITICAL : dispatch_source_memorypressure_flags_t = 0x4 ;
175
+
176
+ pub type dispatch_source_proc_flags_t = c_ulong ;
177
+
178
+ pub const DISPATCH_PROC_EXIT : dispatch_source_proc_flags_t = 0x80000000 ;
179
+ pub const DISPATCH_PROC_FORK : dispatch_source_proc_flags_t = 0x40000000 ;
180
+ pub const DISPATCH_PROC_EXEC : dispatch_source_proc_flags_t = 0x20000000 ;
181
+ pub const DISPATCH_PROC_SIGNAL : dispatch_source_proc_flags_t = 0x08000000 ;
182
+
183
+ pub type dispatch_source_timer_flags_t = c_ulong ;
184
+
185
+ pub const DISPATCH_TIMER_STRICT : dispatch_source_timer_flags_t = 0x1 ;
186
+
187
+ pub type dispatch_source_vnode_flags_t = c_ulong ;
188
+
189
+ pub const DISPATCH_VNODE_DELETE : dispatch_source_vnode_flags_t = 0x1 ;
190
+ pub const DISPATCH_VNODE_WRITE : dispatch_source_vnode_flags_t = 0x2 ;
191
+ pub const DISPATCH_VNODE_EXTEND : dispatch_source_vnode_flags_t = 0x4 ;
192
+ pub const DISPATCH_VNODE_ATTRIB : dispatch_source_vnode_flags_t = 0x8 ;
193
+ pub const DISPATCH_VNODE_LINK : dispatch_source_vnode_flags_t = 0x10 ;
194
+ pub const DISPATCH_VNODE_RENAME : dispatch_source_vnode_flags_t = 0x20 ;
195
+ pub const DISPATCH_VNODE_REVOKE : dispatch_source_vnode_flags_t = 0x40 ;
196
+
197
+ pub static DISPATCH_SOURCE_TYPE_DATA_ADD : & ' static dispatch_source_type_s = & _dispatch_source_type_data_add;
198
+ pub static DISPATCH_SOURCE_TYPE_DATA_OR : & ' static dispatch_source_type_s = & _dispatch_source_type_data_or;
199
+ pub static DISPATCH_SOURCE_TYPE_MACH_SEND : & ' static dispatch_source_type_s = & _dispatch_source_type_mach_send;
200
+ pub static DISPATCH_SOURCE_TYPE_MACH_RECV : & ' static dispatch_source_type_s = & _dispatch_source_type_mach_recv;
201
+ pub static DISPATCH_SOURCE_TYPE_MEMORYPRESSURE : & ' static dispatch_source_type_s = & _dispatch_source_type_memorypressure;
202
+ pub static DISPATCH_SOURCE_TYPE_PROC : & ' static dispatch_source_type_s = & _dispatch_source_type_proc;
203
+ pub static DISPATCH_SOURCE_TYPE_READ : & ' static dispatch_source_type_s = & _dispatch_source_type_read;
204
+ pub static DISPATCH_SOURCE_TYPE_SIGNAL : & ' static dispatch_source_type_s = & _dispatch_source_type_signal;
205
+ pub static DISPATCH_SOURCE_TYPE_TIMER : & ' static dispatch_source_type_s = & _dispatch_source_type_timer;
206
+ pub static DISPATCH_SOURCE_TYPE_VNODE : & ' static dispatch_source_type_s = & _dispatch_source_type_vnode;
207
+ pub static DISPATCH_SOURCE_TYPE_WRITE : & ' static dispatch_source_type_s = & _dispatch_source_type_write;
208
+
149
209
#[ cfg( test) ]
150
210
mod tests {
151
211
use super :: * ;
0 commit comments