3131
3232use c_str:: ToCStr ;
3333use libc:: { size_t, c_int, c_uint, c_void, c_char, uintptr_t} ;
34+ #[ cfg( not( stage0) ) ]
35+ use libc:: ssize_t;
3436use libc:: { malloc, free} ;
3537use libc;
3638use prelude:: * ;
@@ -63,17 +65,78 @@ pub type uv_idle_t = c_void;
6365pub type uv_tcp_t = c_void ;
6466pub type uv_udp_t = c_void ;
6567pub type uv_connect_t = c_void ;
68+ pub type uv_connection_t = c_void ;
6669pub type uv_write_t = c_void ;
6770pub type uv_async_t = c_void ;
6871pub type uv_timer_t = c_void ;
6972pub type uv_stream_t = c_void ;
7073pub type uv_fs_t = c_void ;
7174pub type uv_udp_send_t = c_void ;
7275
76+ #[ cfg( stage0) ]
7377pub type uv_idle_cb = * u8 ;
78+ #[ cfg( stage0) ]
7479pub type uv_alloc_cb = * u8 ;
80+ #[ cfg( stage0) ]
81+ pub type uv_read_cb = * u8 ;
82+ #[ cfg( stage0) ]
7583pub type uv_udp_send_cb = * u8 ;
84+ #[ cfg( stage0) ]
7685pub type uv_udp_recv_cb = * u8 ;
86+ #[ cfg( stage0) ]
87+ pub type uv_close_cb = * u8 ;
88+ #[ cfg( stage0) ]
89+ pub type uv_walk_cb = * u8 ;
90+ #[ cfg( stage0) ]
91+ pub type uv_async_cb = * u8 ;
92+ #[ cfg( stage0) ]
93+ pub type uv_connect_cb = * u8 ;
94+ #[ cfg( stage0) ]
95+ pub type uv_connection_cb = * u8 ;
96+ #[ cfg( stage0) ]
97+ pub type uv_timer_cb = * u8 ;
98+ #[ cfg( stage0) ]
99+ pub type uv_write_cb = * u8 ;
100+
101+ #[ cfg( not( stage0) ) ]
102+ pub type uv_idle_cb = extern "C" fn ( handle : * uv_idle_t ,
103+ status : c_int ) ;
104+ #[ cfg( not( stage0) ) ]
105+ pub type uv_alloc_cb = extern "C" fn ( stream : * uv_stream_t ,
106+ suggested_size : size_t ) -> uv_buf_t ;
107+ #[ cfg( not( stage0) ) ]
108+ pub type uv_read_cb = extern "C" fn ( stream : * uv_stream_t ,
109+ nread : ssize_t ,
110+ buf : uv_buf_t ) ;
111+ #[ cfg( not( stage0) ) ]
112+ pub type uv_udp_send_cb = extern "C" fn ( req : * uv_udp_send_t ,
113+ status : c_int ) ;
114+ #[ cfg( not( stage0) ) ]
115+ pub type uv_udp_recv_cb = extern "C" fn ( handle : * uv_udp_t ,
116+ nread : ssize_t ,
117+ buf : uv_buf_t ,
118+ addr : * sockaddr ,
119+ flags : c_uint ) ;
120+ #[ cfg( not( stage0) ) ]
121+ pub type uv_close_cb = extern "C" fn ( handle : * uv_handle_t ) ;
122+ #[ cfg( not( stage0) ) ]
123+ pub type uv_walk_cb = extern "C" fn ( handle : * uv_handle_t ,
124+ arg : * c_void ) ;
125+ #[ cfg( not( stage0) ) ]
126+ pub type uv_async_cb = extern "C" fn ( handle : * uv_async_t ,
127+ status : c_int ) ;
128+ #[ cfg( not( stage0) ) ]
129+ pub type uv_connect_cb = extern "C" fn ( handle : * uv_connect_t ,
130+ status : c_int ) ;
131+ #[ cfg( not( stage0) ) ]
132+ pub type uv_connection_cb = extern "C" fn ( handle : * uv_connection_t ,
133+ status : c_int ) ;
134+ #[ cfg( not( stage0) ) ]
135+ pub type uv_timer_cb = extern "C" fn ( handle : * uv_timer_t ,
136+ status : c_int ) ;
137+ #[ cfg( not( stage0) ) ]
138+ pub type uv_write_cb = extern "C" fn ( handle : * uv_write_t ,
139+ status : c_int ) ;
77140
78141pub type sockaddr = c_void ;
79142pub type sockaddr_in = c_void ;
@@ -191,13 +254,13 @@ pub unsafe fn run(loop_handle: *c_void) {
191254 rust_uv_run ( loop_handle) ;
192255}
193256
194- pub unsafe fn close < T > ( handle : * T , cb : * u8 ) {
257+ pub unsafe fn close < T > ( handle : * T , cb : uv_close_cb ) {
195258 #[ fixed_stack_segment] ; #[ inline( never) ] ;
196259
197260 rust_uv_close ( handle as * c_void , cb) ;
198261}
199262
200- pub unsafe fn walk ( loop_handle : * c_void , cb : * u8 , arg : * c_void ) {
263+ pub unsafe fn walk ( loop_handle : * c_void , cb : uv_walk_cb , arg : * c_void ) {
201264 #[ fixed_stack_segment] ; #[ inline( never) ] ;
202265
203266 rust_uv_walk ( loop_handle, cb, arg) ;
@@ -332,14 +395,14 @@ pub unsafe fn tcp_init(loop_handle: *c_void, handle: *uv_tcp_t) -> c_int {
332395}
333396
334397pub unsafe fn tcp_connect ( connect_ptr : * uv_connect_t , tcp_handle_ptr : * uv_tcp_t ,
335- addr_ptr : * sockaddr_in , after_connect_cb : * u8 ) -> c_int {
398+ addr_ptr : * sockaddr_in , after_connect_cb : uv_connect_cb ) -> c_int {
336399 #[ fixed_stack_segment] ; #[ inline( never) ] ;
337400
338401 return rust_uv_tcp_connect ( connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr) ;
339402}
340403
341404pub unsafe fn tcp_connect6 ( connect_ptr : * uv_connect_t , tcp_handle_ptr : * uv_tcp_t ,
342- addr_ptr : * sockaddr_in6 , after_connect_cb : * u8 ) -> c_int {
405+ addr_ptr : * sockaddr_in6 , after_connect_cb : uv_connect_cb ) -> c_int {
343406 #[ fixed_stack_segment] ; #[ inline( never) ] ;
344407
345408 return rust_uv_tcp_connect6 ( connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr) ;
@@ -387,7 +450,8 @@ pub unsafe fn tcp_simultaneous_accepts(handle: *uv_tcp_t, enable: c_int) -> c_in
387450 return rust_uv_tcp_simultaneous_accepts ( handle, enable) ;
388451}
389452
390- pub unsafe fn listen < T > ( stream : * T , backlog : c_int , cb : * u8 ) -> c_int {
453+ pub unsafe fn listen < T > ( stream : * T , backlog : c_int ,
454+ cb : uv_connection_cb ) -> c_int {
391455 #[ fixed_stack_segment] ; #[ inline( never) ] ;
392456
393457 return rust_uv_listen ( stream as * c_void , backlog, cb) ;
@@ -399,14 +463,19 @@ pub unsafe fn accept(server: *c_void, client: *c_void) -> c_int {
399463 return rust_uv_accept ( server as * c_void , client as * c_void ) ;
400464}
401465
402- pub unsafe fn write < T > ( req : * uv_write_t , stream : * T , buf_in : & [ uv_buf_t ] , cb : * u8 ) -> c_int {
466+ pub unsafe fn write < T > ( req : * uv_write_t ,
467+ stream : * T ,
468+ buf_in : & [ uv_buf_t ] ,
469+ cb : uv_write_cb ) -> c_int {
403470 #[ fixed_stack_segment] ; #[ inline( never) ] ;
404471
405472 let buf_ptr = vec:: raw:: to_ptr ( buf_in) ;
406473 let buf_cnt = buf_in. len ( ) as i32 ;
407474 return rust_uv_write ( req as * c_void , stream as * c_void , buf_ptr, buf_cnt, cb) ;
408475}
409- pub unsafe fn read_start ( stream : * uv_stream_t , on_alloc : uv_alloc_cb , on_read : * u8 ) -> c_int {
476+ pub unsafe fn read_start ( stream : * uv_stream_t ,
477+ on_alloc : uv_alloc_cb ,
478+ on_read : uv_read_cb ) -> c_int {
410479 #[ fixed_stack_segment] ; #[ inline( never) ] ;
411480
412481 return rust_uv_read_start ( stream as * c_void , on_alloc, on_read) ;
@@ -435,7 +504,9 @@ pub unsafe fn err_name(err: *uv_err_t) -> *c_char {
435504 return rust_uv_err_name ( err) ;
436505}
437506
438- pub unsafe fn async_init ( loop_handle : * c_void , async_handle : * uv_async_t , cb : * u8 ) -> c_int {
507+ pub unsafe fn async_init ( loop_handle : * c_void ,
508+ async_handle : * uv_async_t ,
509+ cb : uv_async_cb ) -> c_int {
439510 #[ fixed_stack_segment] ; #[ inline( never) ] ;
440511
441512 return rust_uv_async_init ( loop_handle, async_handle, cb) ;
@@ -460,7 +531,8 @@ pub unsafe fn timer_init(loop_ptr: *c_void, timer_ptr: *uv_timer_t) -> c_int {
460531
461532 return rust_uv_timer_init ( loop_ptr, timer_ptr) ;
462533}
463- pub unsafe fn timer_start ( timer_ptr : * uv_timer_t , cb : * u8 , timeout : u64 ,
534+ pub unsafe fn timer_start ( timer_ptr : * uv_timer_t ,
535+ cb : uv_timer_cb , timeout : u64 ,
464536 repeat : u64 ) -> c_int {
465537 #[ fixed_stack_segment] ; #[ inline( never) ] ;
466538
@@ -634,8 +706,8 @@ extern {
634706 fn rust_uv_loop_new ( ) -> * c_void ;
635707 fn rust_uv_loop_delete ( lp : * c_void ) ;
636708 fn rust_uv_run ( loop_handle : * c_void ) ;
637- fn rust_uv_close ( handle : * c_void , cb : * u8 ) ;
638- fn rust_uv_walk ( loop_handle : * c_void , cb : * u8 , arg : * c_void ) ;
709+ fn rust_uv_close ( handle : * c_void , cb : uv_close_cb ) ;
710+ fn rust_uv_walk ( loop_handle : * c_void , cb : uv_walk_cb , arg : * c_void ) ;
639711
640712 fn rust_uv_idle_new ( ) -> * uv_idle_t ;
641713 fn rust_uv_idle_delete ( handle : * uv_idle_t ) ;
@@ -644,7 +716,9 @@ extern {
644716 fn rust_uv_idle_stop ( handle : * uv_idle_t ) -> c_int ;
645717
646718 fn rust_uv_async_send ( handle : * uv_async_t ) ;
647- fn rust_uv_async_init ( loop_handle : * c_void , async_handle : * uv_async_t , cb : * u8 ) -> c_int ;
719+ fn rust_uv_async_init ( loop_handle : * c_void ,
720+ async_handle : * uv_async_t ,
721+ cb : uv_async_cb ) -> c_int ;
648722 fn rust_uv_tcp_init ( loop_handle : * c_void , handle_ptr : * uv_tcp_t ) -> c_int ;
649723 fn rust_uv_buf_init ( out_buf : * uv_buf_t , base : * u8 , len : size_t ) ;
650724 fn rust_uv_last_error ( loop_handle : * c_void ) -> uv_err_t ;
@@ -658,10 +732,12 @@ extern {
658732 fn rust_uv_ip6_name ( src : * sockaddr_in6 , dst : * u8 , size : size_t ) -> c_int ;
659733 fn rust_uv_ip4_port ( src : * sockaddr_in ) -> c_uint ;
660734 fn rust_uv_ip6_port ( src : * sockaddr_in6 ) -> c_uint ;
661- fn rust_uv_tcp_connect ( req : * uv_connect_t , handle : * uv_tcp_t , cb : * u8 ,
735+ fn rust_uv_tcp_connect ( req : * uv_connect_t , handle : * uv_tcp_t ,
736+ cb : uv_connect_cb ,
662737 addr : * sockaddr_in ) -> c_int ;
663738 fn rust_uv_tcp_bind ( tcp_server : * uv_tcp_t , addr : * sockaddr_in ) -> c_int ;
664- fn rust_uv_tcp_connect6 ( req : * uv_connect_t , handle : * uv_tcp_t , cb : * u8 ,
739+ fn rust_uv_tcp_connect6 ( req : * uv_connect_t , handle : * uv_tcp_t ,
740+ cb : uv_connect_cb ,
665741 addr : * sockaddr_in6 ) -> c_int ;
666742 fn rust_uv_tcp_bind6 ( tcp_server : * uv_tcp_t , addr : * sockaddr_in6 ) -> c_int ;
667743 fn rust_uv_tcp_getpeername ( tcp_handle_ptr : * uv_tcp_t , name : * sockaddr_storage ) -> c_int ;
@@ -674,10 +750,12 @@ extern {
674750 fn rust_uv_udp_bind ( server : * uv_udp_t , addr : * sockaddr_in , flags : c_uint ) -> c_int ;
675751 fn rust_uv_udp_bind6 ( server : * uv_udp_t , addr : * sockaddr_in6 , flags : c_uint ) -> c_int ;
676752 fn rust_uv_udp_send ( req : * uv_udp_send_t , handle : * uv_udp_t , buf_in : * uv_buf_t ,
677- buf_cnt : c_int , addr : * sockaddr_in , cb : * u8 ) -> c_int ;
753+ buf_cnt : c_int , addr : * sockaddr_in , cb : uv_udp_send_cb ) -> c_int ;
678754 fn rust_uv_udp_send6 ( req : * uv_udp_send_t , handle : * uv_udp_t , buf_in : * uv_buf_t ,
679- buf_cnt : c_int , addr : * sockaddr_in6 , cb : * u8 ) -> c_int ;
680- fn rust_uv_udp_recv_start ( server : * uv_udp_t , on_alloc : * u8 , on_recv : * u8 ) -> c_int ;
755+ buf_cnt : c_int , addr : * sockaddr_in6 , cb : uv_udp_send_cb ) -> c_int ;
756+ fn rust_uv_udp_recv_start ( server : * uv_udp_t ,
757+ on_alloc : uv_alloc_cb ,
758+ on_recv : uv_udp_recv_cb ) -> c_int ;
681759 fn rust_uv_udp_recv_stop ( server : * uv_udp_t ) -> c_int ;
682760 fn rust_uv_get_udp_handle_from_send_req ( req : * uv_udp_send_t ) -> * uv_udp_t ;
683761 fn rust_uv_udp_getsockname ( handle : * uv_udp_t , name : * sockaddr_storage ) -> c_int ;
@@ -693,14 +771,17 @@ extern {
693771 fn rust_uv_malloc_sockaddr_storage ( ) -> * sockaddr_storage ;
694772 fn rust_uv_free_sockaddr_storage ( ss : * sockaddr_storage ) ;
695773
696- fn rust_uv_listen ( stream : * c_void , backlog : c_int , cb : * u8 ) -> c_int ;
774+ fn rust_uv_listen ( stream : * c_void , backlog : c_int ,
775+ cb : uv_connection_cb ) -> c_int ;
697776 fn rust_uv_accept ( server : * c_void , client : * c_void ) -> c_int ;
698777 fn rust_uv_write ( req : * c_void , stream : * c_void , buf_in : * uv_buf_t , buf_cnt : c_int ,
699- cb : * u8 ) -> c_int ;
700- fn rust_uv_read_start ( stream : * c_void , on_alloc : * u8 , on_read : * u8 ) -> c_int ;
778+ cb : uv_write_cb ) -> c_int ;
779+ fn rust_uv_read_start ( stream : * c_void ,
780+ on_alloc : uv_alloc_cb ,
781+ on_read : uv_read_cb ) -> c_int ;
701782 fn rust_uv_read_stop ( stream : * c_void ) -> c_int ;
702783 fn rust_uv_timer_init ( loop_handle : * c_void , timer_handle : * uv_timer_t ) -> c_int ;
703- fn rust_uv_timer_start ( timer_handle : * uv_timer_t , cb : * u8 , timeout : libc:: uint64_t ,
784+ fn rust_uv_timer_start ( timer_handle : * uv_timer_t , cb : uv_timer_cb , timeout : libc:: uint64_t ,
704785 repeat : libc:: uint64_t ) -> c_int ;
705786 fn rust_uv_timer_stop ( handle : * uv_timer_t ) -> c_int ;
706787
0 commit comments