Skip to content

Commit 70185fd

Browse files
committed
rt: remove last_os_error and adjust tests.
1 parent 625fac3 commit 70185fd

File tree

10 files changed

+14
-59
lines changed

10 files changed

+14
-59
lines changed

src/libcore/os.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ extern mod rustrt {
6262
unsafe fn rust_path_exists(path: *libc::c_char) -> c_int;
6363
unsafe fn rust_list_files2(&&path: ~str) -> ~[~str];
6464
unsafe fn rust_process_wait(handle: c_int) -> c_int;
65-
unsafe fn last_os_error() -> ~str;
6665
unsafe fn rust_set_exit_status(code: libc::intptr_t);
6766
}
6867

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -52,50 +52,6 @@ timegm(struct tm *tm)
5252
}
5353
#endif
5454

55-
56-
extern "C" CDECL rust_str*
57-
last_os_error() {
58-
rust_task *task = rust_get_current_task();
59-
60-
LOG(task, task, "last_os_error()");
61-
62-
#if defined(__WIN32__)
63-
LPTSTR buf;
64-
DWORD err = GetLastError();
65-
DWORD res = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
66-
FORMAT_MESSAGE_FROM_SYSTEM |
67-
FORMAT_MESSAGE_IGNORE_INSERTS,
68-
NULL, err,
69-
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
70-
(LPTSTR) &buf, 0, NULL);
71-
if (!res) {
72-
task->fail();
73-
return NULL;
74-
}
75-
#elif defined(_GNU_SOURCE) && !defined(__ANDROID__)
76-
char cbuf[BUF_BYTES];
77-
char *buf = strerror_r(errno, cbuf, sizeof(cbuf));
78-
if (!buf) {
79-
task->fail();
80-
return NULL;
81-
}
82-
#else
83-
char buf[BUF_BYTES];
84-
int err = strerror_r(errno, buf, sizeof(buf));
85-
if (err) {
86-
task->fail();
87-
return NULL;
88-
}
89-
#endif
90-
91-
rust_str * st = make_str(task->kernel, buf, strlen(buf),
92-
"last_os_error");
93-
#ifdef __WIN32__
94-
LocalFree((HLOCAL)buf);
95-
#endif
96-
return st;
97-
}
98-
9955
extern "C" CDECL rust_str *
10056
rust_getcwd() {
10157
rust_task *task = rust_get_current_task();

src/test/auxiliary/anon-extern-mod-cross-crate-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515

1616
#[crate_type = "lib"];
1717
extern {
18-
fn last_os_error() -> ~str;
18+
fn rust_get_argc() -> libc::c_int;
1919
}

src/test/auxiliary/foreign_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
#[link(name="foreign_lib", vers="0.0")];
1212

1313
pub extern mod rustrt {
14-
pub fn last_os_error() -> ~str;
14+
pub fn rust_get_argc() -> libc::c_int;
1515
}

src/test/run-fail/morestack2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
extern mod std;
1919

2020
extern mod rustrt {
21-
pub fn last_os_error() -> ~str;
21+
pub fn rust_get_argc() -> libc::c_int;
2222
}
2323

2424
fn getbig_call_c_and_fail(i: int) {
2525
if i != 0 {
2626
getbig_call_c_and_fail(i - 1);
2727
} else {
2828
unsafe {
29-
rustrt::last_os_error();
29+
rustrt::rust_get_argc();
3030
die!();
3131
}
3232
}

src/test/run-pass/anon-extern-mod-cross-crate-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ extern mod anonexternmod;
1515
use anonexternmod::*;
1616

1717
pub fn main() {
18-
last_os_error();
18+
rust_get_argc();
1919
}

src/test/run-pass/anon-extern-mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
#[abi = "cdecl"]
1212
#[link_name = "rustrt"]
1313
extern {
14-
fn last_os_error() -> ~str;
14+
fn rust_get_argc() -> libc::c_int;
1515
}
1616

1717
pub fn main() {
1818
unsafe {
19-
let _ = last_os_error();
19+
let _ = rust_get_argc();
2020
}
2121
}

src/test/run-pass/foreign-dupe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
#[abi = "cdecl"]
1515
#[link_name = "rustrt"]
1616
extern mod rustrt1 {
17-
pub fn last_os_error() -> ~str;
17+
pub fn rust_get_argc() -> libc::c_int;
1818
}
1919

2020
#[abi = "cdecl"]
2121
#[link_name = "rustrt"]
2222
extern mod rustrt2 {
23-
pub fn last_os_error() -> ~str;
23+
pub fn rust_get_argc() -> libc::c_int;
2424
}
2525

2626
pub fn main() {
2727
unsafe {
28-
rustrt1::last_os_error();
29-
rustrt2::last_os_error();
28+
rustrt1::rust_get_argc();
29+
rustrt2::rust_get_argc();
3030
}
3131
}

src/test/run-pass/invoke-external-foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
extern mod foreign_lib;
1919

2020
pub fn main() {
21-
let foo = foreign_lib::rustrt::last_os_error();
21+
let foo = foreign_lib::rustrt::rust_get_argc();
2222
}

src/test/run-pass/morestack6.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ extern mod rustrt {
1515
pub fn debug_get_stk_seg() -> *u8;
1616

1717
pub fn rust_get_sched_id() -> libc::intptr_t;
18-
pub fn last_os_error() -> ~str;
18+
pub fn rust_get_argc() -> libc::c_int;
1919
pub fn rust_getcwd() -> ~str;
2020
pub fn get_task_id() -> libc::intptr_t;
2121
pub fn rust_sched_threads();
2222
pub fn rust_get_task();
2323
}
2424

2525
fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } }
26-
fn calllink02() { unsafe { rustrt::last_os_error(); } }
26+
fn calllink02() { unsafe { rustrt::rust_get_argc(); } }
2727
fn calllink03() { unsafe { rustrt::rust_getcwd(); } }
2828
fn calllink08() { unsafe { rustrt::get_task_id(); } }
2929
fn calllink09() { unsafe { rustrt::rust_sched_threads(); } }

0 commit comments

Comments
 (0)