@@ -76,19 +76,19 @@ enum uv_handle_type {
76
76
UV_FS_EVENT
77
77
}
78
78
79
- type handle_type = ctypes :: enum ;
79
+ type handle_type = libc :: c_uint ;
80
80
81
81
type uv_handle_fields = {
82
- loop_handle : * ctypes :: void ,
82
+ loop_handle : * libc :: c_void ,
83
83
type_ : handle_type ,
84
84
close_cb : * u8 ,
85
- mutable data: * ctypes :: void ,
85
+ mutable data: * libc :: c_void ,
86
86
} ;
87
87
88
88
// unix size: 8
89
89
type uv_err_t = {
90
- code : ctypes :: c_int ,
91
- sys_errno_ : ctypes :: c_int
90
+ code : libc :: c_int ,
91
+ sys_errno_ : libc :: c_int
92
92
} ;
93
93
94
94
// don't create one of these directly. instead,
@@ -138,7 +138,7 @@ fn gen_stub_uv_tcp_t() -> uv_tcp_t {
138
138
139
139
#[ cfg( target_os = "win32" ) ]
140
140
type uv_tcp_t = {
141
- loop_handle : * ctypes :: void
141
+ loop_handle : * libc :: c_void
142
142
} ;
143
143
#[ cfg( target_os = "win32" ) ]
144
144
fn gen_stub_uv_tcp_t ( ) -> uv_tcp_t {
@@ -170,14 +170,14 @@ fn gen_stub_uv_connect_t() -> uv_connect_t {
170
170
#[ cfg( target_os = "freebsd" ) ]
171
171
type uv_buf_t = {
172
172
base : * u8 ,
173
- len : ctypes :: size_t
173
+ len : libc :: size_t
174
174
} ;
175
175
// no gen stub method.. should create
176
176
// it via uv::direct::buf_init()
177
177
178
178
#[ cfg( target_os = "win32" ) ]
179
179
type uv_connect_t = {
180
- loop_handle : * ctypes :: void
180
+ loop_handle : * libc :: c_void
181
181
} ;
182
182
#[ cfg( target_os = "win32" ) ]
183
183
fn gen_stub_uv_connect_t ( ) -> uv_connect_t {
@@ -210,7 +210,7 @@ fn gen_stub_uv_write_t() -> uv_write_t {
210
210
}
211
211
#[ cfg( target_os = "win32" ) ]
212
212
type uv_write_t = {
213
- loop_handle : * ctypes :: void
213
+ loop_handle : * libc :: c_void
214
214
} ;
215
215
#[ cfg( target_os = "win32" ) ]
216
216
fn gen_stub_uv_write_t ( ) -> uv_write_t {
@@ -268,77 +268,82 @@ native mod rustrt {
268
268
////////////
269
269
// NOT IN rustrt.def.in
270
270
////////////
271
- fn rust_uv_free ( ptr : * ctypes :: void ) ;
271
+ fn rust_uv_free ( ptr : * libc :: c_void ) ;
272
272
fn rust_uv_tcp_init (
273
- loop_handle : * ctypes :: void ,
274
- handle_ptr : * uv_tcp_t ) -> ctypes :: c_int ;
275
- fn rust_uv_buf_init ( base : * u8 , len : ctypes :: size_t )
276
- -> * ctypes :: void ;
277
- fn rust_uv_last_error ( loop_handle : * ctypes :: void ) -> uv_err_t ;
278
- fn rust_uv_ip4_addr ( ip : * u8 , port : ctypes :: c_int )
279
- -> * ctypes :: void ;
273
+ loop_handle : * libc :: c_void ,
274
+ handle_ptr : * uv_tcp_t ) -> libc :: c_int ;
275
+ fn rust_uv_buf_init ( base : * u8 , len : libc :: size_t )
276
+ -> * libc :: c_void ;
277
+ fn rust_uv_last_error ( loop_handle : * libc :: c_void ) -> uv_err_t ;
278
+ fn rust_uv_ip4_addr ( ip : * u8 , port : libc :: c_int )
279
+ -> * libc :: c_void ;
280
280
fn rust_uv_tcp_connect ( connect_ptr : * uv_connect_t ,
281
281
tcp_handle_ptr : * uv_tcp_t ,
282
- addr : * ctypes:: void ,
283
- after_cb : * u8 ) -> ctypes:: c_int ;
282
+ addr : * libc:: c_void ,
283
+ after_cb : * u8 ) -> libc:: c_int ;
284
+ fn rust_uv_write ( req : * libc:: c_void , stream : * libc:: c_void ,
285
+ buf_in : * uv_buf_t , buf_cnt : libc:: c_int ,
286
+ cb : * u8 ) -> libc:: c_int ;
284
287
285
288
// sizeof testing helpers
286
- fn rust_uv_helper_uv_tcp_t_size ( ) -> ctypes :: c_uint ;
287
- fn rust_uv_helper_uv_connect_t_size ( ) -> ctypes :: c_uint ;
288
- fn rust_uv_helper_uv_buf_t_size ( ) -> ctypes :: c_uint ;
289
- fn rust_uv_helper_uv_write_t_size ( ) -> ctypes :: c_uint ;
290
- fn rust_uv_helper_uv_err_t_size ( ) -> ctypes :: c_uint ;
291
- fn rust_uv_helper_sockaddr_in_size ( ) -> ctypes :: c_uint ;
289
+ fn rust_uv_helper_uv_tcp_t_size ( ) -> libc :: c_uint ;
290
+ fn rust_uv_helper_uv_connect_t_size ( ) -> libc :: c_uint ;
291
+ fn rust_uv_helper_uv_buf_t_size ( ) -> libc :: c_uint ;
292
+ fn rust_uv_helper_uv_write_t_size ( ) -> libc :: c_uint ;
293
+ fn rust_uv_helper_uv_err_t_size ( ) -> libc :: c_uint ;
294
+ fn rust_uv_helper_sockaddr_in_size ( ) -> libc :: c_uint ;
292
295
293
296
// data accessors for rust-mapped uv structs
294
297
fn rust_uv_get_stream_handle_for_connect ( connect : * uv_connect_t )
295
298
-> * uv_stream_t ;
296
- fn rust_uv_get_loop_for_uv_handle ( handle : * ctypes :: void )
297
- -> * ctypes :: void ;
298
- fn rust_uv_get_data_for_uv_handle ( handle : * ctypes :: void )
299
- -> * ctypes :: void ;
300
- fn rust_uv_set_data_for_uv_handle ( handle : * ctypes :: void ,
301
- data : * ctypes :: void ) ;
302
- fn rust_uv_get_data_for_req ( req : * ctypes :: void ) -> * ctypes :: void ;
303
- fn rust_uv_set_data_for_req ( req : * ctypes :: void ,
304
- data : * ctypes :: void ) ;
299
+ fn rust_uv_get_loop_for_uv_handle ( handle : * libc :: c_void )
300
+ -> * libc :: c_void ;
301
+ fn rust_uv_get_data_for_uv_handle ( handle : * libc :: c_void )
302
+ -> * libc :: c_void ;
303
+ fn rust_uv_set_data_for_uv_handle ( handle : * libc :: c_void ,
304
+ data : * libc :: c_void ) ;
305
+ fn rust_uv_get_data_for_req ( req : * libc :: c_void ) -> * libc :: c_void ;
306
+ fn rust_uv_set_data_for_req ( req : * libc :: c_void ,
307
+ data : * libc :: c_void ) ;
305
308
}
306
309
307
310
// this module is structured around functions that directly
308
311
// expose libuv functionality and data structures. for use
309
312
// in higher level mappings
310
313
mod direct {
311
- unsafe fn loop_new ( ) -> * ctypes :: void {
314
+ unsafe fn loop_new ( ) -> * libc :: c_void {
312
315
ret rustrt:: rust_uv_loop_new ( ) ;
313
316
}
314
317
315
- unsafe fn loop_delete ( loop_handle : * ctypes :: void ) {
318
+ unsafe fn loop_delete ( loop_handle : * libc :: c_void ) {
316
319
rustrt:: rust_uv_loop_delete ( loop_handle) ;
317
320
}
318
321
319
- unsafe fn run ( loop_handle : * ctypes :: void ) {
322
+ unsafe fn run ( loop_handle : * libc :: c_void ) {
320
323
rustrt:: rust_uv_run ( loop_handle) ;
321
324
}
322
325
323
- unsafe fn tcp_init ( loop_handle : * ctypes :: void , handle : * uv_tcp_t )
324
- -> ctypes :: c_int {
326
+ unsafe fn tcp_init ( loop_handle : * libc :: c_void , handle : * uv_tcp_t )
327
+ -> libc :: c_int {
325
328
ret rustrt:: rust_uv_tcp_init ( loop_handle, handle) ;
326
329
}
327
330
unsafe fn tcp_connect ( connect_ptr : * uv_connect_t ,
328
331
tcp_handle_ptr : * uv_tcp_t ,
329
- address : * ctypes :: void ,
332
+ address : * libc :: c_void ,
330
333
after_connect_cb : * u8 )
331
- -> ctypes :: c_int {
334
+ -> libc :: c_int {
332
335
ret rustrt:: rust_uv_tcp_connect ( connect_ptr, tcp_handle_ptr,
333
336
address, after_connect_cb) ;
334
337
}
335
338
336
- unsafe fn write ( req : * ctypes:: void , stream : * ctypes:: void ,
337
- buf : * [ uv_buf_t ] , cb : * u8 ) -> ctypes:: c_int {
338
- ret rustrt:: rust_uv_write(
339
+ unsafe fn write ( req : * libc:: c_void , stream : * libc:: c_void ,
340
+ buf_in : * [ uv_buf_t ] , cb : * u8 ) -> libc:: c_int {
341
+ let buf_ptr = vec:: unsafe:: to_ptr ( * buf_in) ;
342
+ let buf_cnt = vec:: len ( * buf_in) as i32 ;
343
+ ret rustrt:: rust_uv_write ( req, stream, buf_ptr, buf_cnt, cb) ;
339
344
}
340
345
341
- unsafe fn uv_last_error ( loop_handle : * ctypes :: void ) -> uv_err_t {
346
+ unsafe fn uv_last_error ( loop_handle : * libc :: c_void ) -> uv_err_t {
342
347
ret rustrt:: rust_uv_last_error ( loop_handle) ;
343
348
}
344
349
@@ -352,29 +357,29 @@ mod direct {
352
357
unsafe fn write_t ( ) -> uv_write_t {
353
358
ret gen_stub_uv_write_t ( ) ;
354
359
}
355
- unsafe fn get_loop_for_uv_handle ( handle : * ctypes :: void )
356
- -> * ctypes :: void {
360
+ unsafe fn get_loop_for_uv_handle ( handle : * libc :: c_void )
361
+ -> * libc :: c_void {
357
362
ret rustrt:: rust_uv_get_loop_for_uv_handle ( handle) ;
358
363
}
359
364
unsafe fn get_stream_handle_for_connect ( connect : * uv_connect_t )
360
365
-> * uv_stream_t {
361
366
ret rustrt:: rust_uv_get_stream_handle_for_connect ( connect) ;
362
367
}
363
368
364
- unsafe fn get_data_for_req ( req : * ctypes :: void ) -> * ctypes :: void {
369
+ unsafe fn get_data_for_req ( req : * libc :: c_void ) -> * libc :: c_void {
365
370
ret rustrt:: rust_uv_get_data_for_req ( req) ;
366
371
}
367
- unsafe fn set_data_for_req ( req : * ctypes :: void ,
368
- data : * ctypes :: void ) {
372
+ unsafe fn set_data_for_req ( req : * libc :: c_void ,
373
+ data : * libc :: c_void ) {
369
374
rustrt:: rust_uv_set_data_for_req ( req, data) ;
370
375
}
371
376
// FIXME: see github issue #1402
372
- unsafe fn buf_init ( input : * u8 , len : uint ) -> * ctypes :: void {
377
+ unsafe fn buf_init ( input : * u8 , len : uint ) -> * libc :: c_void {
373
378
ret rustrt:: rust_uv_buf_init ( input, len) ;
374
379
}
375
380
// FIXME: see github issue #1402
376
- unsafe fn ip4_addr ( ip : str , port : ctypes :: c_int )
377
- -> * ctypes :: void {
381
+ unsafe fn ip4_addr ( ip : str , port : libc :: c_int )
382
+ -> * libc :: c_void {
378
383
let addr_vec = str:: bytes ( ip) ;
379
384
addr_vec += [ 0u8 ] ; // add null terminator
380
385
let addr_vec_ptr = vec:: unsafe:: to_ptr ( addr_vec) ;
@@ -384,7 +389,7 @@ mod direct {
384
389
}
385
390
// this is lame.
386
391
// FIXME: see github issue #1402
387
- unsafe fn free_1402 ( ptr : * ctypes :: void ) {
392
+ unsafe fn free_1402 ( ptr : * libc :: c_void ) {
388
393
rustrt:: rust_uv_free ( ptr) ;
389
394
}
390
395
}
@@ -943,44 +948,46 @@ type request_wrapper = {
943
948
req_buf : * [ uv_buf_t ]
944
949
} ;
945
950
946
- crust fn on_alloc ( handle : * ctypes :: void ,
947
- suggested_size : ctypes :: size_t ) -> uv_buf_t
951
+ crust fn on_alloc ( handle : * libc :: c_void ,
952
+ suggested_size : libc :: size_t ) -> uv_buf_t
948
953
unsafe {
949
954
io:: println ( "beginning on_alloc..." ) ;
950
955
io:: println ( "ending on_alloc..." ) ;
951
956
let new_vec: @[ u8 ] = @[ ] ;
952
957
let ptr = vec:: unsafe:: to_ptr ( * new_vec) ;
953
- ret direct:: buf_init ( ptr, vec:: len ( * new_vec) ) ;
958
+ let buf = direct:: buf_init ( ptr, vec:: len ( * new_vec) ) ;
959
+ ret * ( buf as * uv_buf_t ) ;
960
+
954
961
}
955
962
956
963
crust fn on_write_complete_cb ( write_handle : * uv_write_t ,
957
- status : ctypes :: c_int ) unsafe {
964
+ status : libc :: c_int ) unsafe {
958
965
io:: println ( "beginning on_write_complete_cb" ) ;
959
966
io:: println ( "ending on_write_complete_cb" ) ;
960
967
}
961
968
962
969
crust fn on_connect_cb ( connect_handle_ptr : * uv_connect_t ,
963
- status : ctypes :: c_int ) unsafe {
970
+ status : libc :: c_int ) unsafe {
964
971
io:: println ( #fmt ( "beginning on_connect_cb .. status: %d" ,
965
972
status as int ) ) ;
966
973
let stream = direct:: get_stream_handle_for_connect ( connect_handle_ptr) ;
967
974
if ( status == 0i32 ) {
968
975
io:: println ( "on_connect_cb: in status=0 if.." ) ;
969
976
let data = direct:: get_data_for_req (
970
- connect_handle_ptr as * ctypes :: void )
977
+ connect_handle_ptr as * libc :: c_void )
971
978
as * request_wrapper ;
972
- let write_handle = ( * data) . write_req as * ctypes :: void ;
979
+ let write_handle = ( * data) . write_req as * libc :: c_void ;
973
980
io:: println ( #fmt ( "on_connect_cb: tcp stream: %d write_handle addr %d" ,
974
981
stream as int , write_handle as int ) ) ;
975
982
direct:: write ( write_handle,
976
- stream as * ctypes :: void ,
983
+ stream as * libc :: c_void ,
977
984
( * data) . req_buf ,
978
985
on_write_complete_cb) ;
979
986
io:: println ( "on_connect_cb: after direct::write()" ) ;
980
987
}
981
988
else {
982
989
let loop_handle = direct:: get_loop_for_uv_handle (
983
- stream as * ctypes :: void ) ;
990
+ stream as * libc :: c_void ) ;
984
991
let err = direct:: uv_last_error ( loop_handle) ;
985
992
}
986
993
io:: println ( "finishing on_connect_cb" ) ;
@@ -1016,7 +1023,7 @@ fn impl_uv_tcp_request() unsafe {
1016
1023
let addr = direct:: ip4_addr ( "173.194.33.40" , 80i32 ) ;
1017
1024
1018
1025
let tcp_init_result = direct:: tcp_init (
1019
- test_loop as * ctypes :: void , tcp_handle_ptr) ;
1026
+ test_loop as * libc :: c_void , tcp_handle_ptr) ;
1020
1027
if ( tcp_init_result == 0i32 ) {
1021
1028
io:: println ( "sucessful tcp_init_result" ) ;
1022
1029
// this should set up the connection request..
@@ -1026,8 +1033,8 @@ fn impl_uv_tcp_request() unsafe {
1026
1033
if ( tcp_connect_result == 0i32 ) {
1027
1034
// not set the data on the connect_req until its initialized
1028
1035
direct:: set_data_for_req (
1029
- connect_handle_ptr as * ctypes :: void ,
1030
- ptr:: addr_of ( req) as * ctypes :: void ) ;
1036
+ connect_handle_ptr as * libc :: c_void ,
1037
+ ptr:: addr_of ( req) as * libc :: c_void ) ;
1031
1038
io:: println ( "before run tcp req loop" ) ;
1032
1039
direct:: run ( test_loop) ;
1033
1040
io:: println ( "after run tcp req loop" ) ;
0 commit comments