stdlib: Make pipe and waitpid use interior vectors
This commit is contained in:
@@ -29,8 +29,8 @@ native "cdecl" mod libc = "" {
|
|||||||
fn getenv(sbuf n) -> sbuf;
|
fn getenv(sbuf n) -> sbuf;
|
||||||
fn setenv(sbuf n, sbuf v, int overwrite) -> int;
|
fn setenv(sbuf n, sbuf v, int overwrite) -> int;
|
||||||
fn unsetenv(sbuf n) -> int;
|
fn unsetenv(sbuf n) -> int;
|
||||||
fn pipe(vbuf buf) -> int;
|
fn pipe(*mutable int buf) -> int;
|
||||||
fn waitpid(int pid, vbuf status, int options) -> int;
|
fn waitpid(int pid, &mutable int status, int options) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
native "cdecl" mod libc_ivec = "" {
|
native "cdecl" mod libc_ivec = "" {
|
||||||
@@ -67,16 +67,16 @@ fn target_os() -> str { ret "linux"; }
|
|||||||
fn dylib_filename(str base) -> str { ret "lib" + base + ".so"; }
|
fn dylib_filename(str base) -> str { ret "lib" + base + ".so"; }
|
||||||
|
|
||||||
fn pipe() -> tup(int, int) {
|
fn pipe() -> tup(int, int) {
|
||||||
let vec[mutable int] fds = [mutable 0, 0];
|
auto fds = tup(mutable 0, 0);
|
||||||
assert (os::libc::pipe(vec::buf(fds)) == 0);
|
assert (os::libc::pipe(ptr::addr_of(fds._0)) == 0);
|
||||||
ret tup(fds.(0), fds.(1));
|
ret tup(fds._0, fds._1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fd_FILE(int fd) -> libc::FILE { ret libc::fdopen(fd, str::buf("r")); }
|
fn fd_FILE(int fd) -> libc::FILE { ret libc::fdopen(fd, str::buf("r")); }
|
||||||
|
|
||||||
fn waitpid(int pid) -> int {
|
fn waitpid(int pid) -> int {
|
||||||
let vec[mutable int] status = [mutable 0];
|
auto status = 0;
|
||||||
assert (os::libc::waitpid(pid, vec::buf(status), 0) != -1);
|
assert (os::libc::waitpid(pid, status, 0) != -1);
|
||||||
ret status.(0);
|
ret status.(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ native "cdecl" mod libc = "" {
|
|||||||
fn getenv(sbuf n) -> sbuf;
|
fn getenv(sbuf n) -> sbuf;
|
||||||
fn setenv(sbuf n, sbuf v, int overwrite) -> int;
|
fn setenv(sbuf n, sbuf v, int overwrite) -> int;
|
||||||
fn unsetenv(sbuf n) -> int;
|
fn unsetenv(sbuf n) -> int;
|
||||||
fn pipe(vbuf buf) -> int;
|
fn pipe(*mutable int buf) -> int;
|
||||||
fn waitpid(int pid, vbuf status, int options) -> int;
|
fn waitpid(int pid, &mutable int status, int options) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
native "cdecl" mod libc_ivec = "" {
|
native "cdecl" mod libc_ivec = "" {
|
||||||
@@ -64,17 +64,17 @@ fn target_os() -> str { ret "macos"; }
|
|||||||
fn dylib_filename(str base) -> str { ret "lib" + base + ".dylib"; }
|
fn dylib_filename(str base) -> str { ret "lib" + base + ".dylib"; }
|
||||||
|
|
||||||
fn pipe() -> tup(int, int) {
|
fn pipe() -> tup(int, int) {
|
||||||
let vec[mutable int] fds = [mutable 0, 0];
|
auto fds = tup(mutable 0, 0);
|
||||||
assert (os::libc::pipe(vec::buf(fds)) == 0);
|
assert (os::libc::pipe(ptr::addr_of(fds._0)) == 0);
|
||||||
ret tup(fds.(0), fds.(1));
|
ret tup(fds._0, fds._1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fd_FILE(int fd) -> libc::FILE { ret libc::fdopen(fd, str::buf("r")); }
|
fn fd_FILE(int fd) -> libc::FILE { ret libc::fdopen(fd, str::buf("r")); }
|
||||||
|
|
||||||
fn waitpid(int pid) -> int {
|
fn waitpid(int pid) -> int {
|
||||||
let vec[mutable int] status = [mutable 0];
|
auto status = 0;
|
||||||
assert (os::libc::waitpid(pid, vec::buf(status), 0) != -1);
|
assert (os::libc::waitpid(pid, status, 0) != -1);
|
||||||
ret status.(0);
|
ret status;
|
||||||
}
|
}
|
||||||
|
|
||||||
native "rust" mod rustrt {
|
native "rust" mod rustrt {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ native "cdecl" mod libc = "" {
|
|||||||
fn fseek(FILE f, int offset, int whence) -> int;
|
fn fseek(FILE f, int offset, int whence) -> int;
|
||||||
fn ftell(FILE f) -> int;
|
fn ftell(FILE f) -> int;
|
||||||
fn getenv(sbuf n) -> sbuf;
|
fn getenv(sbuf n) -> sbuf;
|
||||||
fn _pipe(vbuf fds, uint size, int mode) -> int;
|
fn _pipe(*mutable int fds, uint size, int mode) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
native "cdecl" mod libc_ivec = "" {
|
native "cdecl" mod libc_ivec = "" {
|
||||||
@@ -56,10 +56,10 @@ fn target_os() -> str { ret "win32"; }
|
|||||||
fn dylib_filename(str base) -> str { ret base + ".dll"; }
|
fn dylib_filename(str base) -> str { ret base + ".dll"; }
|
||||||
|
|
||||||
fn pipe() -> tup(int, int) {
|
fn pipe() -> tup(int, int) {
|
||||||
let vec[mutable int] fds = [mutable 0, 0];
|
auto fds = tup(mutable 0, 0);
|
||||||
assert (os::libc::_pipe(vec::buf(fds), 1024u, libc_constants::O_BINARY())
|
assert (os::libc::pipe(ptr::addr_of(fds._0), 1024u,
|
||||||
== 0);
|
libc_constants::O_BINARY()) == 0);
|
||||||
ret tup(fds.(0), fds.(1));
|
ret tup(fds._0, fds._1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fd_FILE(int fd) -> libc::FILE { ret libc::_fdopen(fd, str::buf("r")); }
|
fn fd_FILE(int fd) -> libc::FILE { ret libc::_fdopen(fd, str::buf("r")); }
|
||||||
|
|||||||
Reference in New Issue
Block a user