Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7c0fed46
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c0fed46
编写于
4月 02, 2012
作者:
J
Jeff Olson
提交者:
Brian Anderson
4月 06, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename uv::direct:: to uv::ll:: and put into its own crate
上级
f18991d9
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
669 addition
and
597 deletion
+669
-597
src/libstd/std.rc
src/libstd/std.rc
+3
-0
src/libstd/uv.rs
src/libstd/uv.rs
+140
-597
src/libstd/uv_ll.rs
src/libstd/uv_ll.rs
+526
-0
未找到文件。
src/libstd/std.rc
浏览文件 @
7c0fed46
...
...
@@ -23,7 +23,10 @@ export test, tempfile, serialization;
// General io and system-services modules
mod net;
// libuv modules
mod uv;
mod uv_ll;
// Utility modules
...
...
src/libstd/uv.rs
浏览文件 @
7c0fed46
此差异已折叠。
点击以展开。
src/libstd/uv_ll.rs
0 → 100644
浏览文件 @
7c0fed46
// libuv struct mappings
type
uv_ip4_addr
=
{
ip
:
[
u8
],
port
:
int
};
type
uv_ip6_addr
=
uv_ip4_addr
;
enum
uv_handle_type
{
UNKNOWN_HANDLE
=
0
,
UV_TCP
,
UV_UDP
,
UV_NAMED_PIPE
,
UV_TTY
,
UV_FILE
,
UV_TIMER
,
UV_PREPARE
,
UV_CHECK
,
UV_IDLE
,
UV_ASYNC
,
UV_ARES_TASK
,
UV_ARES_EVENT
,
UV_PROCESS
,
UV_FS_EVENT
}
type
handle_type
=
libc
::
c_uint
;
type
uv_handle_fields
=
{
loop_handle
:
*
libc
::
c_void
,
type_
:
handle_type
,
close_cb
:
*
u8
,
mut
data
:
*
libc
::
c_void
,
};
// unix size: 8
type
uv_err_t
=
{
code
:
libc
::
c_int
,
sys_errno_
:
libc
::
c_int
};
// don't create one of these directly. instead,
// count on it appearing in libuv callbacks or embedded
// in other types as a pointer to be used in other
// operations (so mostly treat it as opaque, once you
// have it in this form..)
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
#[cfg(target_os
=
"win32"
)]
type
uv_stream_t
=
{
fields
:
uv_handle_fields
};
// unix size: 272
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
type
uv_tcp_t
=
{
fields
:
uv_handle_fields
,
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
,
a11
:
*
u8
,
a12
:
*
u8
,
a13
:
*
u8
,
a14
:
*
u8
,
a15
:
*
u8
,
a16
:
*
u8
,
a17
:
*
u8
,
a18
:
*
u8
,
a19
:
*
u8
,
a20
:
*
u8
,
a21
:
*
u8
,
a22
:
*
u8
,
a23
:
*
u8
,
a24
:
*
u8
,
a25
:
*
u8
,
a26
:
*
u8
,
a27
:
*
u8
,
a28
:
*
u8
,
a29
:
*
u8
};
// win32 size: 240 (120)
#[cfg(target_os
=
"win32"
)]
type
uv_tcp_t
=
{
fields
:
uv_handle_fields
,
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
,
a11
:
*
u8
,
a12
:
*
u8
,
a13
:
*
u8
,
a14
:
*
u8
,
a15
:
*
u8
,
a16
:
*
u8
,
a17
:
*
u8
,
a18
:
*
u8
,
a19
:
*
u8
,
a20
:
*
u8
,
a21
:
*
u8
,
a22
:
*
u8
,
a23
:
*
u8
,
a24
:
*
u8
,
a25
:
*
u8
};
// unix size: 48
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
type
uv_connect_t
=
{
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
};
// win32 size: 88 (44)
#[cfg(target_os
=
"win32"
)]
type
uv_connect_t
=
{
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
};
// unix size: 16
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
#[cfg(target_os
=
"win32"
)]
type
uv_buf_t
=
{
base
:
*
u8
,
len
:
libc
::
size_t
};
// no gen stub method.. should create
// it via uv::direct::buf_init()
// unix size: 144
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
type
uv_write_t
=
{
fields
:
uv_handle_fields
,
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
,
a11
:
*
u8
,
a12
:
*
u8
,
a13
:
*
u8
};
// win32 size: 136 (68)
#[cfg(target_os
=
"win32"
)]
type
uv_write_t
=
{
fields
:
uv_handle_fields
,
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
,
a11
:
*
u8
,
a12
:
*
u8
};
// unix size: 120
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
type
uv_async_t
=
{
fields
:
uv_handle_fields
,
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
};
// win32 size 132 (68)
#[cfg(target_os
=
"win32"
)]
type
uv_async_t
=
{
fields
:
uv_handle_fields
,
a00
:
*
u8
,
a01
:
*
u8
,
a02
:
*
u8
,
a03
:
*
u8
,
a04
:
*
u8
,
a05
:
*
u8
,
a06
:
*
u8
,
a07
:
*
u8
,
a08
:
*
u8
,
a09
:
*
u8
,
a10
:
*
u8
,
a11
:
*
u8
,
a12
:
*
u8
};
// unix size: 16
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
#[cfg(target_os
=
"win32"
)]
type
sockaddr_in
=
{
mut
sin_family
:
u16
,
mut
sin_port
:
u16
,
mut
sin_addr
:
u32
,
// in_addr: this is an opaque, per-platform struct
mut
sin_zero
:
(
u8
,
u8
,
u8
,
u8
,
u8
,
u8
,
u8
,
u8
)
};
// unix size: 28 .. make due w/ 32
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
#[cfg(target_os
=
"win32"
)]
type
sockaddr_in6
=
{
a0
:
*
u8
,
a1
:
*
u8
,
a2
:
*
u8
,
a3
:
*
u8
};
mod
uv_ll_struct_stubgen
{
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
fn
gen_stub_uv_tcp_t
()
->
uv_tcp_t
{
ret
{
fields
:
{
loop_handle
:
ptr
::
null
(),
type_
:
0u32
,
close_cb
:
ptr
::
null
(),
mut
data
:
ptr
::
null
()
},
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
,
a11
:
0
as
*
u8
,
a12
:
0
as
*
u8
,
a13
:
0
as
*
u8
,
a14
:
0
as
*
u8
,
a15
:
0
as
*
u8
,
a16
:
0
as
*
u8
,
a17
:
0
as
*
u8
,
a18
:
0
as
*
u8
,
a19
:
0
as
*
u8
,
a20
:
0
as
*
u8
,
a21
:
0
as
*
u8
,
a22
:
0
as
*
u8
,
a23
:
0
as
*
u8
,
a24
:
0
as
*
u8
,
a25
:
0
as
*
u8
,
a26
:
0
as
*
u8
,
a27
:
0
as
*
u8
,
a28
:
0
as
*
u8
,
a29
:
0
as
*
u8
};
}
#[cfg(target_os
=
"win32"
)]
fn
gen_stub_uv_tcp_t
()
->
uv_tcp_t
{
ret
{
fields
:
{
loop_handle
:
ptr
::
null
(),
type_
:
0u32
,
close_cb
:
ptr
::
null
(),
mut
data
:
ptr
::
null
()
},
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
,
a11
:
0
as
*
u8
,
a12
:
0
as
*
u8
,
a13
:
0
as
*
u8
,
a14
:
0
as
*
u8
,
a15
:
0
as
*
u8
,
a16
:
0
as
*
u8
,
a17
:
0
as
*
u8
,
a18
:
0
as
*
u8
,
a19
:
0
as
*
u8
,
a20
:
0
as
*
u8
,
a21
:
0
as
*
u8
,
a22
:
0
as
*
u8
,
a23
:
0
as
*
u8
,
a24
:
0
as
*
u8
,
a25
:
0
as
*
u8
};
}
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
fn
gen_stub_uv_connect_t
()
->
uv_connect_t
{
ret
{
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
};
}
#[cfg(target_os
=
"win32"
)]
fn
gen_stub_uv_connect_t
()
->
uv_connect_t
{
ret
{
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
};
}
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
fn
gen_stub_uv_async_t
()
->
uv_async_t
{
ret
{
fields
:
{
loop_handle
:
ptr
::
null
(),
type_
:
0u32
,
close_cb
:
ptr
::
null
(),
mut
data
:
ptr
::
null
()
},
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
};
}
#[cfg(target_os
=
"win32"
)]
fn
gen_stub_uv_async_t
()
->
uv_async_t
{
ret
{
fields
:
{
loop_handle
:
ptr
::
null
(),
type_
:
0u32
,
close_cb
:
ptr
::
null
(),
mut
data
:
ptr
::
null
()
},
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
,
a11
:
0
as
*
u8
,
a12
:
0
as
*
u8
};
}
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"freebsd"
)]
fn
gen_stub_uv_write_t
()
->
uv_write_t
{
ret
{
fields
:
{
loop_handle
:
ptr
::
null
(),
type_
:
0u32
,
close_cb
:
ptr
::
null
(),
mut
data
:
ptr
::
null
()
},
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
,
a11
:
0
as
*
u8
,
a12
:
0
as
*
u8
,
a13
:
0
as
*
u8
};
}
#[cfg(target_os
=
"win32"
)]
fn
gen_stub_uv_write_t
()
->
uv_write_t
{
ret
{
fields
:
{
loop_handle
:
ptr
::
null
(),
type_
:
0u32
,
close_cb
:
ptr
::
null
(),
mut
data
:
ptr
::
null
()
},
a00
:
0
as
*
u8
,
a01
:
0
as
*
u8
,
a02
:
0
as
*
u8
,
a03
:
0
as
*
u8
,
a04
:
0
as
*
u8
,
a05
:
0
as
*
u8
,
a06
:
0
as
*
u8
,
a07
:
0
as
*
u8
,
a08
:
0
as
*
u8
,
a09
:
0
as
*
u8
,
a10
:
0
as
*
u8
,
a11
:
0
as
*
u8
,
a12
:
0
as
*
u8
};
}
}
#[nolink]
native
mod
rustrt
{
fn
rust_uv_loop_new
()
->
*
libc
::
c_void
;
fn
rust_uv_loop_delete
(
lp
:
*
libc
::
c_void
);
fn
rust_uv_run
(
loop_handle
:
*
libc
::
c_void
);
fn
rust_uv_close
(
handle
:
*
libc
::
c_void
,
cb
:
*
u8
);
fn
rust_uv_async_send
(
handle
:
*
uv_async_t
);
fn
rust_uv_async_init
(
loop_handle
:
*
libc
::
c_void
,
async_handle
:
*
uv_async_t
,
cb
:
*
u8
)
->
libc
::
c_int
;
fn
rust_uv_tcp_init
(
loop_handle
:
*
libc
::
c_void
,
handle_ptr
:
*
uv_tcp_t
)
->
libc
::
c_int
;
fn
rust_uv_buf_init
(
base
:
*
u8
,
len
:
libc
::
size_t
)
->
uv_buf_t
;
fn
rust_uv_last_error
(
loop_handle
:
*
libc
::
c_void
)
->
uv_err_t
;
// FIXME ref #2064
fn
rust_uv_strerror
(
err
:
*
uv_err_t
)
->
*
libc
::
c_char
;
// FIXME ref #2064
fn
rust_uv_err_name
(
err
:
*
uv_err_t
)
->
*
libc
::
c_char
;
fn
rust_uv_ip4_addr
(
ip
:
*
u8
,
port
:
libc
::
c_int
)
->
sockaddr_in
;
// FIXME ref #2064
fn
rust_uv_tcp_connect
(
connect_ptr
:
*
uv_connect_t
,
tcp_handle_ptr
:
*
uv_tcp_t
,
++
after_cb
:
*
u8
,
++
addr
:
*
sockaddr_in
)
->
libc
::
c_int
;
// FIXME ref 2064
fn
rust_uv_tcp_bind
(
tcp_server
:
*
uv_tcp_t
,
++
addr
:
*
sockaddr_in
)
->
libc
::
c_int
;
fn
rust_uv_listen
(
stream
:
*
libc
::
c_void
,
backlog
:
libc
::
c_int
,
cb
:
*
u8
)
->
libc
::
c_int
;
fn
rust_uv_accept
(
server
:
*
libc
::
c_void
,
client
:
*
libc
::
c_void
)
->
libc
::
c_int
;
fn
rust_uv_write
(
req
:
*
libc
::
c_void
,
stream
:
*
libc
::
c_void
,
++
buf_in
:
*
uv_buf_t
,
buf_cnt
:
libc
::
c_int
,
cb
:
*
u8
)
->
libc
::
c_int
;
fn
rust_uv_read_start
(
stream
:
*
libc
::
c_void
,
on_alloc
:
*
u8
,
on_read
:
*
u8
)
->
libc
::
c_int
;
fn
rust_uv_read_stop
(
stream
:
*
libc
::
c_void
)
->
libc
::
c_int
;
fn
rust_uv_malloc_buf_base_of
(
sug_size
:
libc
::
size_t
)
->
*
u8
;
fn
rust_uv_free_base_of_buf
(
++
buf
:
uv_buf_t
);
// data accessors for rust-mapped uv structs
fn
rust_uv_get_stream_handle_from_connect_req
(
connect_req
:
*
uv_connect_t
)
->
*
uv_stream_t
;
fn
rust_uv_get_stream_handle_from_write_req
(
write_req
:
*
uv_write_t
)
->
*
uv_stream_t
;
fn
rust_uv_get_loop_for_uv_handle
(
handle
:
*
libc
::
c_void
)
->
*
libc
::
c_void
;
fn
rust_uv_get_data_for_uv_handle
(
handle
:
*
libc
::
c_void
)
->
*
libc
::
c_void
;
fn
rust_uv_set_data_for_uv_handle
(
handle
:
*
libc
::
c_void
,
data
:
*
libc
::
c_void
);
fn
rust_uv_get_data_for_req
(
req
:
*
libc
::
c_void
)
->
*
libc
::
c_void
;
fn
rust_uv_set_data_for_req
(
req
:
*
libc
::
c_void
,
data
:
*
libc
::
c_void
);
fn
rust_uv_get_base_from_buf
(
++
buf
:
uv_buf_t
)
->
*
u8
;
fn
rust_uv_get_len_from_buf
(
++
buf
:
uv_buf_t
)
->
libc
::
size_t
;
}
unsafe
fn
loop_new
()
->
*
libc
::
c_void
{
ret
rustrt
::
rust_uv_loop_new
();
}
unsafe
fn
loop_delete
(
loop_handle
:
*
libc
::
c_void
)
{
rustrt
::
rust_uv_loop_delete
(
loop_handle
);
}
unsafe
fn
run
(
loop_handle
:
*
libc
::
c_void
)
{
rustrt
::
rust_uv_run
(
loop_handle
);
}
unsafe
fn
close
(
handle
:
*
libc
::
c_void
,
cb
:
*
u8
)
{
rustrt
::
rust_uv_close
(
handle
,
cb
);
}
unsafe
fn
tcp_init
(
loop_handle
:
*
libc
::
c_void
,
handle
:
*
uv_tcp_t
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_tcp_init
(
loop_handle
,
handle
);
}
// FIXME ref #2064
unsafe
fn
tcp_connect
(
connect_ptr
:
*
uv_connect_t
,
tcp_handle_ptr
:
*
uv_tcp_t
,
addr_ptr
:
*
sockaddr_in
,
++
after_connect_cb
:
*
u8
)
->
libc
::
c_int
{
let
address
=
*
addr_ptr
;
io
::
println
(
#
fmt
(
"b4 native tcp_connect--addr port: %u cb: %u"
,
address
.sin_port
as
uint
,
after_connect_cb
as
uint
));
ret
rustrt
::
rust_uv_tcp_connect
(
connect_ptr
,
tcp_handle_ptr
,
after_connect_cb
,
addr_ptr
);
}
// FIXME ref #2064
unsafe
fn
tcp_bind
(
tcp_server_ptr
:
*
uv_tcp_t
,
addr_ptr
:
*
sockaddr_in
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_tcp_bind
(
tcp_server_ptr
,
addr_ptr
);
}
unsafe
fn
listen
(
stream
:
*
libc
::
c_void
,
backlog
:
libc
::
c_int
,
cb
:
*
u8
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_listen
(
stream
,
backlog
,
cb
);
}
unsafe
fn
accept
(
server
:
*
libc
::
c_void
,
client
:
*
libc
::
c_void
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_accept
(
server
,
client
);
}
unsafe
fn
write
(
req
:
*
libc
::
c_void
,
stream
:
*
libc
::
c_void
,
buf_in
:
*
[
uv_buf_t
],
cb
:
*
u8
)
->
libc
::
c_int
{
let
buf_ptr
=
vec
::
unsafe
::
to_ptr
(
*
buf_in
);
let
buf_cnt
=
vec
::
len
(
*
buf_in
)
as
i32
;
ret
rustrt
::
rust_uv_write
(
req
,
stream
,
buf_ptr
,
buf_cnt
,
cb
);
}
unsafe
fn
read_start
(
stream
:
*
uv_stream_t
,
on_alloc
:
*
u8
,
on_read
:
*
u8
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_read_start
(
stream
as
*
libc
::
c_void
,
on_alloc
,
on_read
);
}
unsafe
fn
read_stop
(
stream
:
*
uv_stream_t
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_read_stop
(
stream
as
*
libc
::
c_void
);
}
unsafe
fn
last_error
(
loop_handle
:
*
libc
::
c_void
)
->
uv_err_t
{
ret
rustrt
::
rust_uv_last_error
(
loop_handle
);
}
unsafe
fn
strerror
(
err
:
*
uv_err_t
)
->
*
libc
::
c_char
{
ret
rustrt
::
rust_uv_strerror
(
err
);
}
unsafe
fn
err_name
(
err
:
*
uv_err_t
)
->
*
libc
::
c_char
{
ret
rustrt
::
rust_uv_err_name
(
err
);
}
unsafe
fn
async_init
(
loop_handle
:
*
libc
::
c_void
,
async_handle
:
*
uv_async_t
,
cb
:
*
u8
)
->
libc
::
c_int
{
ret
rustrt
::
rust_uv_async_init
(
loop_handle
,
async_handle
,
cb
);
}
unsafe
fn
async_send
(
async_handle
:
*
uv_async_t
)
{
ret
rustrt
::
rust_uv_async_send
(
async_handle
);
}
// libuv struct initializers
unsafe
fn
tcp_t
()
->
uv_tcp_t
{
ret
uv_ll_struct_stubgen
::
gen_stub_uv_tcp_t
();
}
unsafe
fn
connect_t
()
->
uv_connect_t
{
ret
uv_ll_struct_stubgen
::
gen_stub_uv_connect_t
();
}
unsafe
fn
write_t
()
->
uv_write_t
{
ret
uv_ll_struct_stubgen
::
gen_stub_uv_write_t
();
}
unsafe
fn
async_t
()
->
uv_async_t
{
ret
uv_ll_struct_stubgen
::
gen_stub_uv_async_t
();
}
unsafe
fn
get_loop_for_uv_handle
(
handle
:
*
libc
::
c_void
)
->
*
libc
::
c_void
{
ret
rustrt
::
rust_uv_get_loop_for_uv_handle
(
handle
);
}
unsafe
fn
get_stream_handle_from_connect_req
(
connect
:
*
uv_connect_t
)
->
*
uv_stream_t
{
ret
rustrt
::
rust_uv_get_stream_handle_from_connect_req
(
connect
);
}
unsafe
fn
get_stream_handle_from_write_req
(
write_req
:
*
uv_write_t
)
->
*
uv_stream_t
{
ret
rustrt
::
rust_uv_get_stream_handle_from_write_req
(
write_req
);
}
unsafe
fn
get_data_for_uv_handle
(
handle
:
*
libc
::
c_void
)
->
*
libc
::
c_void
{
ret
rustrt
::
rust_uv_get_data_for_uv_handle
(
handle
);
}
unsafe
fn
set_data_for_uv_handle
(
handle
:
*
libc
::
c_void
,
data
:
*
libc
::
c_void
)
{
rustrt
::
rust_uv_set_data_for_uv_handle
(
handle
,
data
);
}
unsafe
fn
get_data_for_req
(
req
:
*
libc
::
c_void
)
->
*
libc
::
c_void
{
ret
rustrt
::
rust_uv_get_data_for_req
(
req
);
}
unsafe
fn
set_data_for_req
(
req
:
*
libc
::
c_void
,
data
:
*
libc
::
c_void
)
{
rustrt
::
rust_uv_set_data_for_req
(
req
,
data
);
}
unsafe
fn
get_base_from_buf
(
buf
:
uv_buf_t
)
->
*
u8
{
ret
rustrt
::
rust_uv_get_base_from_buf
(
buf
);
}
unsafe
fn
get_len_from_buf
(
buf
:
uv_buf_t
)
->
libc
::
size_t
{
ret
rustrt
::
rust_uv_get_len_from_buf
(
buf
);
}
unsafe
fn
buf_init
(
input
:
*
u8
,
len
:
uint
)
->
uv_buf_t
{
ret
rustrt
::
rust_uv_buf_init
(
input
,
len
);
}
unsafe
fn
ip4_addr
(
ip
:
str
,
port
:
int
)
->
sockaddr_in
{
let
mut
addr_vec
=
str
::
bytes
(
ip
);
addr_vec
+=
[
0u8
];
// add null terminator
let
addr_vec_ptr
=
vec
::
unsafe
::
to_ptr
(
addr_vec
);
let
ip_back
=
str
::
from_bytes
(
addr_vec
);
io
::
println
(
#
fmt
(
"vec val: '%s' length: %u"
,
ip_back
,
vec
::
len
(
addr_vec
)));
ret
rustrt
::
rust_uv_ip4_addr
(
addr_vec_ptr
,
port
as
libc
::
c_int
);
}
unsafe
fn
malloc_buf_base_of
(
suggested_size
:
libc
::
size_t
)
->
*
u8
{
ret
rustrt
::
rust_uv_malloc_buf_base_of
(
suggested_size
);
}
unsafe
fn
free_base_of_buf
(
buf
:
uv_buf_t
)
{
rustrt
::
rust_uv_free_base_of_buf
(
buf
);
}
unsafe
fn
get_last_err_info
(
uv_loop
:
*
libc
::
c_void
)
->
str
{
let
err
=
last_error
(
uv_loop
);
let
err_ptr
=
ptr
::
addr_of
(
err
);
let
err_name
=
str
::
unsafe
::
from_c_str
(
err_name
(
err_ptr
));
let
err_msg
=
str
::
unsafe
::
from_c_str
(
strerror
(
err_ptr
));
ret
#
fmt
(
"LIBUV ERROR: name: %s msg: %s"
,
err_name
,
err_msg
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录