rt: remove last_os_error and adjust tests.
This commit is contained in:
parent
625fac3c7e
commit
70185fdcc2
@ -62,7 +62,6 @@ extern mod rustrt {
|
||||
unsafe fn rust_path_exists(path: *libc::c_char) -> c_int;
|
||||
unsafe fn rust_list_files2(&&path: ~str) -> ~[~str];
|
||||
unsafe fn rust_process_wait(handle: c_int) -> c_int;
|
||||
unsafe fn last_os_error() -> ~str;
|
||||
unsafe fn rust_set_exit_status(code: libc::intptr_t);
|
||||
}
|
||||
|
||||
|
@ -52,50 +52,6 @@ timegm(struct tm *tm)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" CDECL rust_str*
|
||||
last_os_error() {
|
||||
rust_task *task = rust_get_current_task();
|
||||
|
||||
LOG(task, task, "last_os_error()");
|
||||
|
||||
#if defined(__WIN32__)
|
||||
LPTSTR buf;
|
||||
DWORD err = GetLastError();
|
||||
DWORD res = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, err,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buf, 0, NULL);
|
||||
if (!res) {
|
||||
task->fail();
|
||||
return NULL;
|
||||
}
|
||||
#elif defined(_GNU_SOURCE) && !defined(__ANDROID__)
|
||||
char cbuf[BUF_BYTES];
|
||||
char *buf = strerror_r(errno, cbuf, sizeof(cbuf));
|
||||
if (!buf) {
|
||||
task->fail();
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
char buf[BUF_BYTES];
|
||||
int err = strerror_r(errno, buf, sizeof(buf));
|
||||
if (err) {
|
||||
task->fail();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
rust_str * st = make_str(task->kernel, buf, strlen(buf),
|
||||
"last_os_error");
|
||||
#ifdef __WIN32__
|
||||
LocalFree((HLOCAL)buf);
|
||||
#endif
|
||||
return st;
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_str *
|
||||
rust_getcwd() {
|
||||
rust_task *task = rust_get_current_task();
|
||||
|
@ -15,5 +15,5 @@
|
||||
|
||||
#[crate_type = "lib"];
|
||||
extern {
|
||||
fn last_os_error() -> ~str;
|
||||
fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
|
@ -11,5 +11,5 @@
|
||||
#[link(name="foreign_lib", vers="0.0")];
|
||||
|
||||
pub extern mod rustrt {
|
||||
pub fn last_os_error() -> ~str;
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
extern mod std;
|
||||
|
||||
extern mod rustrt {
|
||||
pub fn last_os_error() -> ~str;
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
|
||||
fn getbig_call_c_and_fail(i: int) {
|
||||
@ -26,7 +26,7 @@ fn getbig_call_c_and_fail(i: int) {
|
||||
getbig_call_c_and_fail(i - 1);
|
||||
} else {
|
||||
unsafe {
|
||||
rustrt::last_os_error();
|
||||
rustrt::rust_get_argc();
|
||||
die!();
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ extern mod anonexternmod;
|
||||
use anonexternmod::*;
|
||||
|
||||
pub fn main() {
|
||||
last_os_error();
|
||||
rust_get_argc();
|
||||
}
|
||||
|
@ -11,11 +11,11 @@
|
||||
#[abi = "cdecl"]
|
||||
#[link_name = "rustrt"]
|
||||
extern {
|
||||
fn last_os_error() -> ~str;
|
||||
fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let _ = last_os_error();
|
||||
let _ = rust_get_argc();
|
||||
}
|
||||
}
|
||||
|
@ -14,18 +14,18 @@
|
||||
#[abi = "cdecl"]
|
||||
#[link_name = "rustrt"]
|
||||
extern mod rustrt1 {
|
||||
pub fn last_os_error() -> ~str;
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[link_name = "rustrt"]
|
||||
extern mod rustrt2 {
|
||||
pub fn last_os_error() -> ~str;
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
rustrt1::last_os_error();
|
||||
rustrt2::last_os_error();
|
||||
rustrt1::rust_get_argc();
|
||||
rustrt2::rust_get_argc();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,5 @@
|
||||
extern mod foreign_lib;
|
||||
|
||||
pub fn main() {
|
||||
let foo = foreign_lib::rustrt::last_os_error();
|
||||
let foo = foreign_lib::rustrt::rust_get_argc();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ extern mod rustrt {
|
||||
pub fn debug_get_stk_seg() -> *u8;
|
||||
|
||||
pub fn rust_get_sched_id() -> libc::intptr_t;
|
||||
pub fn last_os_error() -> ~str;
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
pub fn rust_getcwd() -> ~str;
|
||||
pub fn get_task_id() -> libc::intptr_t;
|
||||
pub fn rust_sched_threads();
|
||||
@ -23,7 +23,7 @@ extern mod rustrt {
|
||||
}
|
||||
|
||||
fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } }
|
||||
fn calllink02() { unsafe { rustrt::last_os_error(); } }
|
||||
fn calllink02() { unsafe { rustrt::rust_get_argc(); } }
|
||||
fn calllink03() { unsafe { rustrt::rust_getcwd(); } }
|
||||
fn calllink08() { unsafe { rustrt::get_task_id(); } }
|
||||
fn calllink09() { unsafe { rustrt::rust_sched_threads(); } }
|
||||
|
Loading…
x
Reference in New Issue
Block a user