From 13c44f99aebd0376f44430d4ebacdd17dd36563d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 12 Jul 2011 17:50:56 -0700 Subject: [PATCH] stdlib: Make pipe and waitpid use interior vectors --- src/lib/linux_os.rs | 14 +++++++------- src/lib/macos_os.rs | 16 ++++++++-------- src/lib/win32_os.rs | 10 +++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs index 353add3f7662..0a4c391de195 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_os.rs @@ -29,8 +29,8 @@ native "cdecl" mod libc = "" { fn getenv(sbuf n) -> sbuf; fn setenv(sbuf n, sbuf v, int overwrite) -> int; fn unsetenv(sbuf n) -> int; - fn pipe(vbuf buf) -> int; - fn waitpid(int pid, vbuf status, int options) -> int; + fn pipe(*mutable int buf) -> int; + fn waitpid(int pid, &mutable int status, int options) -> int; } 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 pipe() -> tup(int, int) { - let vec[mutable int] fds = [mutable 0, 0]; - assert (os::libc::pipe(vec::buf(fds)) == 0); - ret tup(fds.(0), fds.(1)); + auto fds = tup(mutable 0, 0); + assert (os::libc::pipe(ptr::addr_of(fds._0)) == 0); + ret tup(fds._0, fds._1); } fn fd_FILE(int fd) -> libc::FILE { ret libc::fdopen(fd, str::buf("r")); } fn waitpid(int pid) -> int { - let vec[mutable int] status = [mutable 0]; - assert (os::libc::waitpid(pid, vec::buf(status), 0) != -1); + auto status = 0; + assert (os::libc::waitpid(pid, status, 0) != -1); ret status.(0); } diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs index 95b601ffc17a..5b3e30f0398d 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_os.rs @@ -26,8 +26,8 @@ native "cdecl" mod libc = "" { fn getenv(sbuf n) -> sbuf; fn setenv(sbuf n, sbuf v, int overwrite) -> int; fn unsetenv(sbuf n) -> int; - fn pipe(vbuf buf) -> int; - fn waitpid(int pid, vbuf status, int options) -> int; + fn pipe(*mutable int buf) -> int; + fn waitpid(int pid, &mutable int status, int options) -> int; } 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 pipe() -> tup(int, int) { - let vec[mutable int] fds = [mutable 0, 0]; - assert (os::libc::pipe(vec::buf(fds)) == 0); - ret tup(fds.(0), fds.(1)); + auto fds = tup(mutable 0, 0); + assert (os::libc::pipe(ptr::addr_of(fds._0)) == 0); + ret tup(fds._0, fds._1); } fn fd_FILE(int fd) -> libc::FILE { ret libc::fdopen(fd, str::buf("r")); } fn waitpid(int pid) -> int { - let vec[mutable int] status = [mutable 0]; - assert (os::libc::waitpid(pid, vec::buf(status), 0) != -1); - ret status.(0); + auto status = 0; + assert (os::libc::waitpid(pid, status, 0) != -1); + ret status; } native "rust" mod rustrt { diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index da86cad3bafb..ecb18bed1306 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -19,7 +19,7 @@ native "cdecl" mod libc = "" { fn fseek(FILE f, int offset, int whence) -> int; fn ftell(FILE f) -> int; 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 = "" { @@ -56,10 +56,10 @@ fn target_os() -> str { ret "win32"; } fn dylib_filename(str base) -> str { ret base + ".dll"; } fn pipe() -> tup(int, int) { - let vec[mutable int] fds = [mutable 0, 0]; - assert (os::libc::_pipe(vec::buf(fds), 1024u, libc_constants::O_BINARY()) - == 0); - ret tup(fds.(0), fds.(1)); + auto fds = tup(mutable 0, 0); + assert (os::libc::pipe(ptr::addr_of(fds._0), 1024u, + libc_constants::O_BINARY()) == 0); + ret tup(fds._0, fds._1); } fn fd_FILE(int fd) -> libc::FILE { ret libc::_fdopen(fd, str::buf("r")); }