Win32 warning police.

This commit is contained in:
Graydon Hoare 2012-02-02 11:35:07 -08:00
parent 6a7de641da
commit 6784b18303
3 changed files with 117 additions and 116 deletions

View File

@ -3,10 +3,6 @@ This is intended to be a low-level binding to libuv that very closely mimics
the C libuv API. Does very little right now pending scheduler improvements. the C libuv API. Does very little right now pending scheduler improvements.
*/ */
#[cfg(target_os = "linux")];
#[cfg(target_os = "macos")];
#[cfg(target_os = "freebsd")];
export sanity_check; export sanity_check;
export loop_t, idle_t; export loop_t, idle_t;
export loop_new, loop_delete, default_loop, run, unref; export loop_new, loop_delete, default_loop, run, unref;
@ -38,9 +34,6 @@ type handle_type = ctypes::enum;
type close_cb = opaque_cb; type close_cb = opaque_cb;
type idle_cb = opaque_cb; type idle_cb = opaque_cb;
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
type handle_private_fields = { type handle_private_fields = {
a00: ctypes::c_int, a00: ctypes::c_int,
a01: ctypes::c_int, a01: ctypes::c_int,
@ -121,9 +114,6 @@ fn sanity_check() {
sys::size_of::<idle_t>()); sys::size_of::<idle_t>());
} }
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
fn handle_fields_new() -> handle_fields { fn handle_fields_new() -> handle_fields {
{ {
loop: ptr::null(), loop: ptr::null(),
@ -154,46 +144,53 @@ fn idle_new() -> idle_t {
} }
} }
#[cfg(test)] #[cfg(target_os = "linux")]
mod tests { #[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
// FIXME: We're out of date on libuv and not testing
// it on windows presently. This needs to change.
mod os {
#[test] #[cfg(test)]
fn test_sanity_check() { mod tests {
sanity_check();
}
// From test-ref.c
mod test_ref {
#[test] #[test]
fn ref() { fn test_sanity_check() {
let loop = loop_new(); sanity_check();
run(loop);
loop_delete(loop);
} }
#[test] // From test-ref.c
fn idle_ref() { mod test_ref {
let loop = loop_new();
let h = idle_new();
idle_init(loop, ptr::addr_of(h));
idle_start(ptr::addr_of(h), ptr::null());
unref(loop);
run(loop);
loop_delete(loop);
}
#[test] #[test]
fn async_ref() { fn ref() {
/* let loop = loop_new();
let loop = loop_new(); run(loop);
let h = async_new(); loop_delete(loop);
async_init(loop, ptr::addr_of(h), ptr::null()); }
unref(loop);
run(loop); #[test]
loop_delete(loop); fn idle_ref() {
*/ let loop = loop_new();
let h = idle_new();
idle_init(loop, ptr::addr_of(h));
idle_start(ptr::addr_of(h), ptr::null());
unref(loop);
run(loop);
loop_delete(loop);
}
#[test]
fn async_ref() {
/*
let loop = loop_new();
let h = async_new();
async_init(loop, ptr::addr_of(h), ptr::null());
unref(loop);
run(loop);
loop_delete(loop);
*/
}
} }
} }
} }

View File

@ -1,10 +1,5 @@
// Some temporary libuv hacks for servo // Some temporary libuv hacks for servo
#[cfg(target_os = "linux")];
#[cfg(target_os = "macos")];
#[cfg(target_os = "freebsd")];
#[nolink] #[nolink]
native mod rustrt { native mod rustrt {
fn rust_uvtmp_create_thread() -> thread; fn rust_uvtmp_create_thread() -> thread;
@ -100,73 +95,82 @@ fn get_req_id(cd: connect_data) -> u32 {
ret rustrt::rust_uvtmp_get_req_id(cd); ret rustrt::rust_uvtmp_get_req_id(cd);
} }
#[test] #[cfg(target_os = "linux")]
fn test_start_stop() { #[cfg(target_os = "macos")]
let thread = create_thread(); #[cfg(target_os = "freebsd")]
start_thread(thread); // FIXME: We're out of date on libuv and not testing
join_thread(thread); // it on windows presently. This needs to change.
delete_thread(thread); mod os {
}
#[test] #[test]
#[ignore] fn test_start_stop() {
fn test_connect() { let thread = create_thread();
let thread = create_thread(); start_thread(thread);
start_thread(thread); join_thread(thread);
let port = comm::port(); delete_thread(thread);
let chan = comm::chan(port);
connect(thread, 0u32, "74.125.224.146", chan);
alt comm::recv(port) {
connected(cd) {
close_connection(thread, 0u32);
}
_ { fail "test_connect: port isn't connected"; }
} }
join_thread(thread);
delete_thread(thread);
}
#[test] #[test]
#[ignore] #[ignore]
fn test_http() { fn test_connect() {
let thread = create_thread(); let thread = create_thread();
start_thread(thread); start_thread(thread);
let port = comm::port(); let port = comm::port();
let chan = comm::chan(port); let chan = comm::chan(port);
connect(thread, 0u32, "74.125.224.146", chan); connect(thread, 0u32, "74.125.224.146", chan);
alt comm::recv(port) {
connected(cd) {
write(thread, 0u32, str::bytes("GET / HTTP/1.0\n\n"), chan);
alt comm::recv(port) { alt comm::recv(port) {
wrote(cd) { connected(cd) {
read_start(thread, 0u32, chan);
let keep_going = true;
while keep_going {
alt comm::recv(port) {
read(_, buf, -1) {
keep_going = false;
delete_buf(buf);
}
read(_, buf, len) {
unsafe {
log(error, len);
let buf = vec::unsafe::from_buf(buf, len as uint);
let str = str::from_bytes(buf);
#error("read something");
io::println(str);
}
delete_buf(buf);
}
_ { fail "test_http: protocol error"; }
}
}
close_connection(thread, 0u32); close_connection(thread, 0u32);
} }
_ { fail "test_http: expected `wrote`"; } _ { fail "test_connect: port isn't connected"; }
} }
} join_thread(thread);
_ { fail "test_http: port not connected"; } delete_thread(thread);
} }
join_thread(thread);
delete_thread(thread); #[test]
} #[ignore]
fn test_http() {
let thread = create_thread();
start_thread(thread);
let port = comm::port();
let chan = comm::chan(port);
connect(thread, 0u32, "74.125.224.146", chan);
alt comm::recv(port) {
connected(cd) {
write(thread, 0u32, str::bytes("GET / HTTP/1.0\n\n"), chan);
alt comm::recv(port) {
wrote(cd) {
read_start(thread, 0u32, chan);
let keep_going = true;
while keep_going {
alt comm::recv(port) {
read(_, buf, -1) {
keep_going = false;
delete_buf(buf);
}
read(_, buf, len) {
unsafe {
log(error, len);
let buf = vec::unsafe::from_buf(buf,
len as uint);
let str = str::from_bytes(buf);
#error("read something");
io::println(str);
}
delete_buf(buf);
}
_ { fail "test_http: protocol error"; }
}
}
close_connection(thread, 0u32);
}
_ { fail "test_http: expected `wrote`"; }
}
}
_ { fail "test_http: port not connected"; }
}
join_thread(thread);
delete_thread(thread);
}
}

View File

@ -44,7 +44,7 @@ mod libc_constants {
} }
type DWORD = u32; type DWORD = u32;
type HMODULE = uint; type HMODULE = c_uint;
type LPTSTR = str::sbuf; type LPTSTR = str::sbuf;
type LPCTSTR = str::sbuf; type LPCTSTR = str::sbuf;
@ -52,9 +52,9 @@ type LPSECURITY_ATTRIBUTES = *ctypes::void;
#[abi = "stdcall"] #[abi = "stdcall"]
native mod kernel32 { native mod kernel32 {
fn GetEnvironmentVariableA(n: str::sbuf, v: str::sbuf, nsize: uint) -> fn GetEnvironmentVariableA(n: str::sbuf, v: str::sbuf, nsize: c_uint) ->
uint; c_uint;
fn SetEnvironmentVariableA(n: str::sbuf, v: str::sbuf) -> int; fn SetEnvironmentVariableA(n: str::sbuf, v: str::sbuf) -> c_int;
fn GetModuleFileNameA(hModule: HMODULE, fn GetModuleFileNameA(hModule: HMODULE,
lpFilename: LPTSTR, lpFilename: LPTSTR,
nSize: DWORD) -> DWORD; nSize: DWORD) -> DWORD;
@ -99,7 +99,7 @@ fn fclose(file: FILE) {
libc::fclose(file) libc::fclose(file)
} }
fn fsync_fd(fd: fd_t, level: io::fsync::level) -> c_int { fn fsync_fd(_fd: fd_t, _level: io::fsync::level) -> c_int {
// FIXME (1253) // FIXME (1253)
fail; fail;
} }