mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 04:23:37 +00:00
Remove all uses of native cdecl except for those that yield
This commit is contained in:
parent
a727bbaf70
commit
0f1af17a60
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Can we bind native things?
|
||||
*/
|
||||
|
||||
native "cdecl" mod rustrt {
|
||||
native "c-stack-cdecl" mod rustrt {
|
||||
fn task_yield();
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -20,7 +20,7 @@ mod b2 {
|
|||
// | | |
|
||||
mod a2 {
|
||||
// | | |
|
||||
native "cdecl" mod b1 = "" {
|
||||
native "c-stack-cdecl" mod b1 = "" {
|
||||
// | | |
|
||||
import a1::b2::*;
|
||||
// | <-/ -/
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
native "cdecl" mod libc = "" {
|
||||
native "c-stack-cdecl" mod libc = "" {
|
||||
type file_handle;
|
||||
}
|
||||
|
||||
|
|
|
@ -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]) { }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue