Remove all uses of native cdecl except for those that yield

This commit is contained in:
Brian Anderson 2011-11-08 11:09:40 -08:00
parent a727bbaf70
commit 0f1af17a60
14 changed files with 58 additions and 27 deletions

View file

@ -77,7 +77,7 @@ fn writeclose(fd: int, s: option::t<str>) {
writer.write_str(option::get(s));
}
os::libc::close(fd);
os::close(fd);
}
fn readclose(fd: int) -> str {
@ -89,7 +89,7 @@ fn readclose(fd: int) -> str {
let bytes = reader.read_bytes(4096u);
buf += str::unsafe_from_bytes(bytes);
}
os::libc::fclose(file);
os::fclose(file);
ret buf;
}
@ -134,13 +134,13 @@ fn worker(p: port<request>) {
pipe_in.in, pipe_out.out, pipe_err.out);
let pid = maybe_with_lib_path(execparms.lib_path, spawnproc);
os::libc::close(pipe_in.in);
os::libc::close(pipe_out.out);
os::libc::close(pipe_err.out);
os::close(pipe_in.in);
os::close(pipe_out.out);
os::close(pipe_err.out);
if pid == -1 {
os::libc::close(pipe_in.out);
os::libc::close(pipe_out.in);
os::libc::close(pipe_err.in);
os::close(pipe_in.out);
os::close(pipe_out.in);
os::close(pipe_err.in);
fail;
}

View file

@ -6,7 +6,7 @@
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
// by https://github.com/graydon/rust/issues#issue/268
native "cdecl" mod libc = "" {
native "c-stack-cdecl" mod libc = "" {
fn read(fd: int, buf: *u8, count: uint) -> int;
fn write(fd: int, buf: *u8, count: uint) -> int;
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@ -72,6 +72,14 @@ fn fd_FILE(fd: int) -> libc::FILE {
ret str::as_buf("r", {|modebuf| libc::fdopen(fd, modebuf) });
}
fn close(fd: int) -> int {
libc::close(fd)
}
fn fclose(file: libc::FILE) {
libc::fclose(file)
}
fn waitpid(pid: int) -> int {
let status = 0;
assert (os::libc::waitpid(pid, status, 0) != -1);

View file

@ -1,5 +1,5 @@
native "cdecl" mod libc = "" {
native "c-stack-cdecl" mod libc = "" {
fn read(fd: int, buf: *u8, count: uint) -> int;
fn write(fd: int, buf: *u8, count: uint) -> int;
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@ -65,6 +65,14 @@ fn fd_FILE(fd: int) -> libc::FILE {
ret str::as_buf("r", {|modebuf| libc::fdopen(fd, modebuf) });
}
fn close(fd: int) -> int {
libc::close(fd)
}
fn fclose(file: libc::FILE) {
libc::fclose(file)
}
fn waitpid(pid: int) -> int {
let status = 0;
assert (os::libc::waitpid(pid, status, 0) != -1);

View file

@ -148,7 +148,7 @@ mod icu {
// FIXME: should be -1, change when compiler supports negative
// constants
native "cdecl" mod libicu = "icuuc" {
native "c-stack-cdecl" mod libicu = "icuuc" {
fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
}
}

View file

@ -1,5 +1,5 @@
native "cdecl" mod libc = "" {
native "c-stack-cdecl" mod libc = "" {
fn read(fd: int, buf: *u8, count: uint) -> int;
fn write(fd: int, buf: *u8, count: uint) -> int;
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@ -79,6 +79,14 @@ fn fd_FILE(fd: int) -> libc::FILE {
ret str::as_buf("r", {|modebuf| libc::_fdopen(fd, modebuf) });
}
fn close(fd: int) -> int {
libc::close(fd)
}
fn fclose(file: libc::FILE) {
libc::fclose(file)
}
native "c-stack-cdecl" mod rustrt {
fn rust_process_wait(handle: int) -> int;
fn rust_getcwd() -> str;

View file

@ -1,6 +1,6 @@
// -*- rust -*-
// error-pattern: safe function calls function marked unsafe
native "cdecl" mod test {
native "c-stack-cdecl" mod test {
unsafe fn free();
}

View file

@ -1,7 +1,7 @@
// -*- rust -*-
// error-pattern: unsafe functions can only be called
native "cdecl" mod test {
native "c-stack-cdecl" mod test {
unsafe fn free();
}

View file

@ -2,7 +2,7 @@
Can we bind native things?
*/
native "cdecl" mod rustrt {
native "c-stack-cdecl" mod rustrt {
fn task_yield();
}

View file

@ -117,15 +117,17 @@ fn h(i: int) { }
assert (h1 >= h2);
}
native "cdecl" mod native_mod = "" {
native "c-stack-cdecl" mod native_mod = "" {
fn do_gc();
fn unsupervise();
}
// FIXME: comparison of native fns
// FIXME (#1058): comparison of native fns
fn test_native_fn() {
/*
assert (native_mod::do_gc == native_mod::do_gc);
assert (native_mod::do_gc != native_mod::unsupervise);
*/
}
fn test_obj() {

View file

@ -20,7 +20,7 @@ mod b2 {
// | | |
mod a2 {
// | | |
native "cdecl" mod b1 = "" {
native "c-stack-cdecl" mod b1 = "" {
// | | |
import a1::b2::*;
// | <-/ -/

View file

@ -1,3 +1,8 @@
// xfail-test
// FIXME: This test is no longer testing what it was intended to. It should
// be testing spawning of a native function, but is actually testing
// spawning some other function, then executing a native function.
/*
A reduced test case for Issue #506, provided by Rob Arnold.
*/

View file

@ -1,6 +1,6 @@
native "cdecl" mod libc = "" {
native "c-stack-cdecl" mod libc = "" {
type file_handle;
}

View file

@ -6,12 +6,12 @@
native "c-stack-cdecl" mod bar = "" { }
native "cdecl" mod zed = "" { }
native "c-stack-cdecl" mod zed = "" { }
native "cdecl" mod libc = "" {
native "c-stack-cdecl" mod libc = "" {
fn write(fd: int, buf: *u8, count: uint) -> int;
}
native "cdecl" mod baz = "" { }
native "c-stack-cdecl" mod baz = "" { }
fn main(args: [str]) { }

View file

@ -22,9 +22,9 @@ fn test_pipes() unsafe {
let pid =
run::spawn_process("cat", [], pipe_in.in, pipe_out.out, pipe_err.out);
os::libc::close(pipe_in.in);
os::libc::close(pipe_out.out);
os::libc::close(pipe_err.out);
os::close(pipe_in.in);
os::close(pipe_out.out);
os::close(pipe_err.out);
if pid == -1 { fail; }
let expected = "test";
@ -41,7 +41,7 @@ fn writeclose(fd: int, s: str) unsafe {
let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
writer.write_str(s);
os::libc::close(fd);
os::close(fd);
}
fn readclose(fd: int) -> str unsafe {
@ -53,7 +53,7 @@ fn readclose(fd: int) -> str unsafe {
let bytes = reader.read_bytes(4096u);
buf += str::unsafe_from_bytes(bytes);
}
os::libc::fclose(file);
os::fclose(file);
ret buf;
}
}